22#include "wtf/Platform.h"
31#include "cssstyleselector.h"
39#include "SVGRenderStyle.h"
42#include <wtf/Assertions.h>
50using namespace SVGNames;
53static HashSet<const SVGStyledElement*>* gElementsWithInstanceUpdatesBlocked = 0;
56 : SVGElement(tagName, doc)
60SVGStyledElement::~SVGStyledElement()
65ANIMATED_PROPERTY_DEFINITIONS(SVGStyledElement, String, String,
string, ClassName, className, HTMLNames::classAttr, m_className)
67bool SVGStyledElement::rendererIsNeeded(RenderStyle* style)
74 if (!parentNode() || parentNode()->isSVGElement())
75 return StyledElement::rendererIsNeeded(style);
80static void mapAttributeToCSSProperty(HashMap<DOMStringImpl*, int>* propertyNameToIdMap,
const QualifiedName& attrName)
84 int propertyId = DOM::getPropertyID(propName.toLatin1(), propName.length());
85 ASSERT(propertyId > 0);
89int SVGStyledElement::cssPropertyIdForSVGAttributeName(
const QualifiedName& attrName)
95 static HashMap<DOMStringImpl*, int>* propertyNameToIdMap = 0;
96 if (!propertyNameToIdMap) {
97 propertyNameToIdMap =
new HashMap<DOMStringImpl*, int>;
99 mapAttributeToCSSProperty(propertyNameToIdMap, alignment_baselineAttr);
100 mapAttributeToCSSProperty(propertyNameToIdMap, baseline_shiftAttr);
101 mapAttributeToCSSProperty(propertyNameToIdMap, clipAttr);
102 mapAttributeToCSSProperty(propertyNameToIdMap, clip_pathAttr);
103 mapAttributeToCSSProperty(propertyNameToIdMap, clip_ruleAttr);
104 mapAttributeToCSSProperty(propertyNameToIdMap, colorAttr);
105 mapAttributeToCSSProperty(propertyNameToIdMap, color_interpolationAttr);
106 mapAttributeToCSSProperty(propertyNameToIdMap, color_interpolation_filtersAttr);
107 mapAttributeToCSSProperty(propertyNameToIdMap, color_profileAttr);
108 mapAttributeToCSSProperty(propertyNameToIdMap, color_renderingAttr);
109 mapAttributeToCSSProperty(propertyNameToIdMap, cursorAttr);
110 mapAttributeToCSSProperty(propertyNameToIdMap, directionAttr);
111 mapAttributeToCSSProperty(propertyNameToIdMap, displayAttr);
112 mapAttributeToCSSProperty(propertyNameToIdMap, dominant_baselineAttr);
113 mapAttributeToCSSProperty(propertyNameToIdMap, enable_backgroundAttr);
114 mapAttributeToCSSProperty(propertyNameToIdMap, fillAttr);
115 mapAttributeToCSSProperty(propertyNameToIdMap, fill_opacityAttr);
116 mapAttributeToCSSProperty(propertyNameToIdMap, fill_ruleAttr);
117 mapAttributeToCSSProperty(propertyNameToIdMap, filterAttr);
118 mapAttributeToCSSProperty(propertyNameToIdMap, flood_colorAttr);
119 mapAttributeToCSSProperty(propertyNameToIdMap, flood_opacityAttr);
120 mapAttributeToCSSProperty(propertyNameToIdMap, font_familyAttr);
121 mapAttributeToCSSProperty(propertyNameToIdMap, font_sizeAttr);
122 mapAttributeToCSSProperty(propertyNameToIdMap, font_stretchAttr);
123 mapAttributeToCSSProperty(propertyNameToIdMap, font_styleAttr);
124 mapAttributeToCSSProperty(propertyNameToIdMap, font_variantAttr);
125 mapAttributeToCSSProperty(propertyNameToIdMap, font_weightAttr);
126 mapAttributeToCSSProperty(propertyNameToIdMap, glyph_orientation_horizontalAttr);
127 mapAttributeToCSSProperty(propertyNameToIdMap, glyph_orientation_verticalAttr);
128 mapAttributeToCSSProperty(propertyNameToIdMap, image_renderingAttr);
129 mapAttributeToCSSProperty(propertyNameToIdMap, kerningAttr);
130 mapAttributeToCSSProperty(propertyNameToIdMap, letter_spacingAttr);
131 mapAttributeToCSSProperty(propertyNameToIdMap, lighting_colorAttr);
132 mapAttributeToCSSProperty(propertyNameToIdMap, marker_endAttr);
133 mapAttributeToCSSProperty(propertyNameToIdMap, marker_midAttr);
134 mapAttributeToCSSProperty(propertyNameToIdMap, marker_startAttr);
135 mapAttributeToCSSProperty(propertyNameToIdMap, maskAttr);
136 mapAttributeToCSSProperty(propertyNameToIdMap, opacityAttr);
137 mapAttributeToCSSProperty(propertyNameToIdMap, overflowAttr);
138 mapAttributeToCSSProperty(propertyNameToIdMap, pointer_eventsAttr);
139 mapAttributeToCSSProperty(propertyNameToIdMap, shape_renderingAttr);
140 mapAttributeToCSSProperty(propertyNameToIdMap, stop_colorAttr);
141 mapAttributeToCSSProperty(propertyNameToIdMap, stop_opacityAttr);
142 mapAttributeToCSSProperty(propertyNameToIdMap, strokeAttr);
143 mapAttributeToCSSProperty(propertyNameToIdMap, stroke_dasharrayAttr);
144 mapAttributeToCSSProperty(propertyNameToIdMap, stroke_dashoffsetAttr);
145 mapAttributeToCSSProperty(propertyNameToIdMap, stroke_linecapAttr);
146 mapAttributeToCSSProperty(propertyNameToIdMap, stroke_linejoinAttr);
147 mapAttributeToCSSProperty(propertyNameToIdMap, stroke_miterlimitAttr);
148 mapAttributeToCSSProperty(propertyNameToIdMap, stroke_opacityAttr);
149 mapAttributeToCSSProperty(propertyNameToIdMap, stroke_widthAttr);
150 mapAttributeToCSSProperty(propertyNameToIdMap, text_anchorAttr);
151 mapAttributeToCSSProperty(propertyNameToIdMap, text_decorationAttr);
152 mapAttributeToCSSProperty(propertyNameToIdMap, text_renderingAttr);
153 mapAttributeToCSSProperty(propertyNameToIdMap, unicode_bidiAttr);
154 mapAttributeToCSSProperty(propertyNameToIdMap, visibilityAttr);
155 mapAttributeToCSSProperty(propertyNameToIdMap, word_spacingAttr);
156 mapAttributeToCSSProperty(propertyNameToIdMap, writing_modeAttr);
170void SVGStyledElement::parseMappedAttribute(MappedAttribute* attr)
175 if (
id == ATTR_STYLE) {
176 if (inlineStyleDecls()) {
177 inlineStyleDecls()->clear();
181 inlineStyleDecls()->setProperty(attr->value());
185 int propId = SVGStyledElement::cssPropertyIdForSVGAttributeName(attr->name());
187 addCSSProperty(attr, propId, attr->value());
193 SVGElement::parseMappedAttribute(attr);
196bool SVGStyledElement::isKnownAttribute(
const QualifiedName& attrName)
199 int propId = SVGStyledElement::cssPropertyIdForSVGAttributeName(attrName);
202 return (attrName.
id() == ATTR_ID || attrName.
id() == ATTR_STYLE);
206void SVGStyledElement::svgAttributeChanged(
const QualifiedName& attrName)
208 SVGElement::svgAttributeChanged(attrName);
211 invalidateResourcesInAncestorChain();
213 SVGDocumentExtensions* extensions = document()->accessSVGExtensions();
222 updateElementInstance(extensions);
225void SVGStyledElement::invalidateResourcesInAncestorChain()
const
227 Node* node = parentNode();
229 if (!node->isSVGElement())
232 SVGElement* element =
static_cast<SVGElement*
>(node);
233 if (SVGStyledElement* styledElement =
static_cast<SVGStyledElement*
>(element->isStyled() ? element : 0)) {
242void SVGStyledElement::childrenChanged(
bool changedByParser,
Node* beforeChange,
Node* afterChange,
int childCountDelta)
244 Q_UNUSED(changedByParser);
245 Q_UNUSED(beforeChange);
246 Q_UNUSED(afterChange);
247 Q_UNUSED(childCountDelta);
248 SVGElement::childrenChanged();
265void SVGStyledElement::updateElementInstance(SVGDocumentExtensions* extensions)
const
267 Q_UNUSED(extensions);
295RenderStyle* SVGStyledElement::resolveStyle(RenderStyle* parentStyle)
297 Q_UNUSED(parentStyle);
299 RenderStyle* renderStyle = renderer()->style();
304 return document()->styleSelector()->styleForElement(
this);
307PassRefPtr<DOM::CSSValueImpl> SVGStyledElement::getPresentationAttribute(
const String& name)
315 return new CSSPrimitiveValueImpl(0);
318void SVGStyledElement::detach()
321 SVGElement::detach();
324void SVGStyledElement::setInstanceUpdatesBlocked(
bool blockUpdates)
327 if (!gElementsWithInstanceUpdatesBlocked)
328 gElementsWithInstanceUpdatesBlocked =
new HashSet<const SVGStyledElement*>;
329 gElementsWithInstanceUpdatesBlocked->add(
this);
331 ASSERT(gElementsWithInstanceUpdatesBlocked);
332 ASSERT(gElementsWithInstanceUpdatesBlocked->contains(
this));
333 gElementsWithInstanceUpdatesBlocked->remove(
this);
DOMStringImpl * implementation() const
The Document interface represents the entire HTML or XML document.
The Node interface is the primary datatype for the entire Document Object Model.
Node parentNode() const
The parent of this node.
DOMString namespaceURI() const
DOMString localName() const
This library provides a full-featured HTML parser and widget.