Node::document() should return a reference.
[WebKit-https.git] / Source / WebCore / svg / SVGClipPathElement.cpp
index 6afd6ad..b09b9a0 100644 (file)
 #include "SVGClipPathElement.h"
 
 #include "Attribute.h"
-#include "CSSStyleSelector.h"
 #include "Document.h"
 #include "RenderSVGResourceClipper.h"
+#include "SVGElementInstance.h"
 #include "SVGNames.h"
 #include "SVGTransformList.h"
+#include "StyleResolver.h"
 
 namespace WebCore {
 
@@ -37,11 +38,18 @@ namespace WebCore {
 DEFINE_ANIMATED_ENUMERATION(SVGClipPathElement, SVGNames::clipPathUnitsAttr, ClipPathUnits, clipPathUnits, SVGUnitTypes::SVGUnitType)
 DEFINE_ANIMATED_BOOLEAN(SVGClipPathElement, SVGNames::externalResourcesRequiredAttr, ExternalResourcesRequired, externalResourcesRequired)
 
+BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGClipPathElement)
+    REGISTER_LOCAL_ANIMATED_PROPERTY(clipPathUnits)
+    REGISTER_LOCAL_ANIMATED_PROPERTY(externalResourcesRequired)
+    REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement)
+END_REGISTER_ANIMATED_PROPERTIES
+
 inline SVGClipPathElement::SVGClipPathElement(const QualifiedName& tagName, Document* document)
-    : SVGStyledTransformableElement(tagName, document)
+    : SVGGraphicsElement(tagName, document)
     , m_clipPathUnits(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE)
 {
     ASSERT(hasTagName(SVGNames::clipPathTag));
+    registerAnimatedPropertiesForSVGClipPathElement();
 }
 
 PassRefPtr<SVGClipPathElement> SVGClipPathElement::create(const QualifiedName& tagName, Document* document)
@@ -49,75 +57,55 @@ PassRefPtr<SVGClipPathElement> SVGClipPathElement::create(const QualifiedName& t
     return adoptRef(new SVGClipPathElement(tagName, document));
 }
 
-void SVGClipPathElement::parseMappedAttribute(Attribute* attr)
+bool SVGClipPathElement::isSupportedAttribute(const QualifiedName& attrName)
 {
-    if (attr->name() == SVGNames::clipPathUnitsAttr) {
-        SVGUnitTypes::SVGUnitType propertyValue = SVGPropertyTraits<SVGUnitTypes::SVGUnitType>::fromString(attr->value());
-        if (propertyValue > 0)
-            setClipPathUnitsBaseValue(propertyValue);
-    } else {
-        if (SVGTests::parseMappedAttribute(attr))
-            return;
-        if (SVGLangSpace::parseMappedAttribute(attr))
-            return;
-        if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
-            return;
-        SVGStyledTransformableElement::parseMappedAttribute(attr);
+    DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
+    if (supportedAttributes.isEmpty()) {
+        SVGLangSpace::addSupportedAttributes(supportedAttributes);
+        SVGExternalResourcesRequired::addSupportedAttributes(supportedAttributes);
+        supportedAttributes.add(SVGNames::clipPathUnitsAttr);
     }
+    return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
 }
 
-void SVGClipPathElement::svgAttributeChanged(const QualifiedName& attrName)
+void SVGClipPathElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
 {
-    SVGStyledTransformableElement::svgAttributeChanged(attrName);
-
-    RenderObject* object = renderer();
-    if (!object)
+    if (!isSupportedAttribute(name)) {
+        SVGGraphicsElement::parseAttribute(name, value);
         return;
+    }
 
-    if (attrName == SVGNames::clipPathUnitsAttr
-        || SVGTests::isKnownAttribute(attrName)
-        || SVGLangSpace::isKnownAttribute(attrName)
-        || SVGExternalResourcesRequired::isKnownAttribute(attrName)
-        || SVGStyledTransformableElement::isKnownAttribute(attrName))
-        object->setNeedsLayout(true);
-}
-
-void SVGClipPathElement::synchronizeProperty(const QualifiedName& attrName)
-{
-    SVGStyledTransformableElement::synchronizeProperty(attrName);
-
-    if (attrName == anyQName()) {
-        synchronizeClipPathUnits();
-        synchronizeExternalResourcesRequired();
-        SVGTests::synchronizeProperties(this, attrName);
+    if (name == SVGNames::clipPathUnitsAttr) {
+        SVGUnitTypes::SVGUnitType propertyValue = SVGPropertyTraits<SVGUnitTypes::SVGUnitType>::fromString(value);
+        if (propertyValue > 0)
+            setClipPathUnitsBaseValue(propertyValue);
         return;
     }
 
-    if (attrName == SVGNames::clipPathUnitsAttr)
-        synchronizeClipPathUnits();
-    else if (SVGExternalResourcesRequired::isKnownAttribute(attrName))
-        synchronizeExternalResourcesRequired();
-    else if (SVGTests::isKnownAttribute(attrName))
-        SVGTests::synchronizeProperties(this, attrName);
-}
+    if (SVGLangSpace::parseAttribute(name, value))
+        return;
+    if (SVGExternalResourcesRequired::parseAttribute(name, value))
+        return;
 
-AttributeToPropertyTypeMap& SVGClipPathElement::attributeToPropertyTypeMap()
-{
-    DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_attributeToPropertyTypeMap, ());
-    return s_attributeToPropertyTypeMap;
+    ASSERT_NOT_REACHED();
 }
 
-void SVGClipPathElement::fillAttributeToPropertyTypeMap()
+void SVGClipPathElement::svgAttributeChanged(const QualifiedName& attrName)
 {
-    AttributeToPropertyTypeMap& attributeToPropertyTypeMap = this->attributeToPropertyTypeMap();
+    if (!isSupportedAttribute(attrName)) {
+        SVGGraphicsElement::svgAttributeChanged(attrName);
+        return;
+    }
+
+    SVGElementInstance::InvalidationGuard invalidationGuard(this);
 
-    SVGStyledTransformableElement::fillPassedAttributeToPropertyTypeMap(attributeToPropertyTypeMap);
-    attributeToPropertyTypeMap.set(SVGNames::clipPathUnitsAttr, AnimatedEnumeration);
+    if (RenderObject* object = renderer())
+        object->setNeedsLayout(true);
 }
 
 void SVGClipPathElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
 {
-    SVGStyledTransformableElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
+    SVGGraphicsElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
 
     if (changedByParser)
         return;