Element: Remove unnecessary attributeChanged() argument.
authorkling@webkit.org <kling@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 4 Feb 2012 22:56:28 +0000 (22:56 +0000)
committerkling@webkit.org <kling@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 4 Feb 2012 22:56:28 +0000 (22:56 +0000)
<http://webkit.org/b/77814>

Reviewed by Ryosuke Niwa.

Remove the 'preserveDecls' argument to Element::attributeChanged() as that is no
longer needed after the removal of per-attribute style declarations.
Decorated subclass overrides with OVERRIDE since we're touching the lines.

Also removed an old inaccurate comment in NamedNodeMap::setAttributes() - calling
attributeChanged() is absolutely necessary to initialize element-specific state.

* dom/Element.cpp:
(WebCore::Element::attributeChanged):
* dom/Element.h:
(Element):
* dom/NamedNodeMap.cpp:
(WebCore::NamedNodeMap::setAttributes):
* dom/StyledElement.cpp:
(WebCore::StyledElement::attributeChanged):
* dom/StyledElement.h:
(StyledElement):
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::updateType):
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::attributeChanged):
* html/HTMLMediaElement.h:
(HTMLMediaElement):
* html/HTMLScriptElement.cpp:
(WebCore::HTMLScriptElement::attributeChanged):
* html/HTMLScriptElement.h:
(HTMLScriptElement):
* html/HTMLTrackElement.cpp:
(WebCore::HTMLTrackElement::attributeChanged):
* html/HTMLTrackElement.h:
(HTMLTrackElement):
* svg/SVGAnimationElement.cpp:
(WebCore::SVGAnimationElement::attributeChanged):
* svg/SVGAnimationElement.h:
* svg/SVGElement.cpp:
(WebCore::SVGElement::attributeChanged):
* svg/SVGElement.h:
(SVGElement):
* svg/animation/SVGSMILElement.cpp:
(WebCore::SVGSMILElement::attributeChanged):
* svg/animation/SVGSMILElement.h:
(SVGSMILElement):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@106746 268f45cc-cd09-0410-ab3c-d52691b4dbfc

19 files changed:
Source/WebCore/ChangeLog
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Element.h
Source/WebCore/dom/NamedNodeMap.cpp
Source/WebCore/dom/StyledElement.cpp
Source/WebCore/dom/StyledElement.h
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/html/HTMLScriptElement.cpp
Source/WebCore/html/HTMLScriptElement.h
Source/WebCore/html/HTMLTrackElement.cpp
Source/WebCore/html/HTMLTrackElement.h
Source/WebCore/svg/SVGAnimationElement.cpp
Source/WebCore/svg/SVGAnimationElement.h
Source/WebCore/svg/SVGElement.cpp
Source/WebCore/svg/SVGElement.h
Source/WebCore/svg/animation/SVGSMILElement.cpp
Source/WebCore/svg/animation/SVGSMILElement.h

index b84c1fe..a205c96 100644 (file)
@@ -1,3 +1,53 @@
+2012-02-04  Andreas Kling  <awesomekling@apple.com>
+
+        Element: Remove unnecessary attributeChanged() argument.
+        <http://webkit.org/b/77814>
+
+        Reviewed by Ryosuke Niwa.
+
+        Remove the 'preserveDecls' argument to Element::attributeChanged() as that is no
+        longer needed after the removal of per-attribute style declarations.
+        Decorated subclass overrides with OVERRIDE since we're touching the lines.
+
+        Also removed an old inaccurate comment in NamedNodeMap::setAttributes() - calling
+        attributeChanged() is absolutely necessary to initialize element-specific state.
+
+        * dom/Element.cpp:
+        (WebCore::Element::attributeChanged):
+        * dom/Element.h:
+        (Element):
+        * dom/NamedNodeMap.cpp:
+        (WebCore::NamedNodeMap::setAttributes):
+        * dom/StyledElement.cpp:
+        (WebCore::StyledElement::attributeChanged):
+        * dom/StyledElement.h:
+        (StyledElement):
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::updateType):
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::attributeChanged):
+        * html/HTMLMediaElement.h:
+        (HTMLMediaElement):
+        * html/HTMLScriptElement.cpp:
+        (WebCore::HTMLScriptElement::attributeChanged):
+        * html/HTMLScriptElement.h:
+        (HTMLScriptElement):
+        * html/HTMLTrackElement.cpp:
+        (WebCore::HTMLTrackElement::attributeChanged):
+        * html/HTMLTrackElement.h:
+        (HTMLTrackElement):
+        * svg/SVGAnimationElement.cpp:
+        (WebCore::SVGAnimationElement::attributeChanged):
+        * svg/SVGAnimationElement.h:
+        * svg/SVGElement.cpp:
+        (WebCore::SVGElement::attributeChanged):
+        * svg/SVGElement.h:
+        (SVGElement):
+        * svg/animation/SVGSMILElement.cpp:
+        (WebCore::SVGSMILElement::attributeChanged):
+        * svg/animation/SVGSMILElement.h:
+        (SVGSMILElement):
+
 2012-02-04  Ken Buchanan  <kenrb@chromium.org>
 
         Crash when reparenting children of flexible boxes
index 57caa4a..99a6d82 100644 (file)
@@ -655,7 +655,7 @@ PassRefPtr<Attribute> Element::createAttribute(const QualifiedName& name, const
     return Attribute::create(name, value);
 }
 
-void Element::attributeChanged(Attribute* attr, bool)
+void Element::attributeChanged(Attribute* attr)
 {
     if (isIdAttributeName(attr->name()))
         idAttributeChanged(attr);
index 60daf98..977949f 100644 (file)
@@ -221,8 +221,7 @@ public:
     NamedNodeMap* updatedAttributes() const;
 
     // This method is called whenever an attribute is added, changed or removed.
-    // FIXME: Remove the preserveDecls argument.
-    virtual void attributeChanged(Attribute*, bool preserveDecls = false);
+    virtual void attributeChanged(Attribute*);
 
     // Only called by the parser immediately after element construction.
     void parserSetAttributeMap(PassOwnPtr<NamedNodeMap>, FragmentScriptingPermission);
index fb7d1b0..7d37521 100644 (file)
@@ -239,15 +239,12 @@ void NamedNodeMap::setAttributes(const NamedNodeMap& other)
     clearAttributes();
     unsigned newLength = other.length();
     m_attributes.resize(newLength);
+
+    // FIXME: These loops can probably be combined.
     for (unsigned i = 0; i < newLength; i++)
         m_attributes[i] = other.m_attributes[i]->clone();
-
-    // FIXME: This is wasteful.  The class list could be preserved on a copy, and we
-    // wouldn't have to waste time reparsing the attribute.
-    // The derived class, HTMLNamedNodeMap, which manages a parsed class list for the CLASS attribute,
-    // will update its member variable when parse attribute is called.
     for (unsigned i = 0; i < newLength; i++)
-        m_element->attributeChanged(m_attributes[i].get(), true);
+        m_element->attributeChanged(m_attributes[i].get());
 }
 
 void NamedNodeMap::addAttribute(PassRefPtr<Attribute> prpAttribute)
index 63a554f..3e65da8 100644 (file)
@@ -64,13 +64,13 @@ PassRefPtr<Attribute> StyledElement::createAttribute(const QualifiedName& name,
     return Attribute::createMapped(name, value);
 }
 
-void StyledElement::attributeChanged(Attribute* attr, bool preserveDecls)
+void StyledElement::attributeChanged(Attribute* attr)
 {
     if (attr->name() == HTMLNames::nameAttr)
         setHasName(!attr->isNull());
 
     if (!attr->isMappedAttribute()) {
-        Element::attributeChanged(attr, preserveDecls);
+        Element::attributeChanged(attr);
         return;
     }
 
index 2b8da28..5da8655 100644 (file)
@@ -68,7 +68,7 @@ protected:
     {
     }
 
-    virtual void attributeChanged(Attribute*, bool preserveDecls = false);
+    virtual void attributeChanged(Attribute*) OVERRIDE;
     virtual void parseMappedAttribute(Attribute*);
     virtual void copyNonAttributeProperties(const Element*);
 
index b64c0e0..832ba52 100644 (file)
@@ -548,11 +548,11 @@ void HTMLInputElement::updateType()
         NamedNodeMap* map = attributeMap();
         ASSERT(map);
         if (Attribute* height = map->getAttributeItem(heightAttr))
-            attributeChanged(height, false);
+            attributeChanged(height);
         if (Attribute* width = map->getAttributeItem(widthAttr))
-            attributeChanged(width, false);
+            attributeChanged(width);
         if (Attribute* align = map->getAttributeItem(alignAttr))
-            attributeChanged(align, false);
+            attributeChanged(align);
     }
 
     if (wasAttached) {
index e8bb788..5e83942 100644 (file)
@@ -315,9 +315,9 @@ bool HTMLMediaElement::supportsFocus() const
     return controls() ||  HTMLElement::supportsFocus();
 }
 
-void HTMLMediaElement::attributeChanged(Attribute* attr, bool preserveDecls)
+void HTMLMediaElement::attributeChanged(Attribute* attr)
 {
-    HTMLElement::attributeChanged(attr, preserveDecls);
+    HTMLElement::attributeChanged(attr);
 
     const QualifiedName& attrName = attr->name();
     if (attrName == srcAttr) {
index 98fdf5a..ede5a1d 100644 (file)
@@ -336,7 +336,7 @@ private:
     void createMediaPlayer();
 
     virtual bool supportsFocus() const;
-    virtual void attributeChanged(Attribute*, bool preserveDecls);
+    virtual void attributeChanged(Attribute*) OVERRIDE;
     virtual bool rendererIsNeeded(const NodeRenderingContext&);
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
     virtual void insertedIntoDocument();
index a4c5586..a0b9254 100644 (file)
@@ -58,11 +58,11 @@ void HTMLScriptElement::childrenChanged(bool changedByParser, Node* beforeChange
     HTMLElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
 }
 
-void HTMLScriptElement::attributeChanged(Attribute* attr, bool preserveDecls)
+void HTMLScriptElement::attributeChanged(Attribute* attr)
 {
     if (attr->name() == asyncAttr)
         handleAsyncAttribute();
-    HTMLElement::attributeChanged(attr, preserveDecls);
+    HTMLElement::attributeChanged(attr);
 }
 
 void HTMLScriptElement::parseMappedAttribute(Attribute* attr)
index a5fe048..d50bcb8 100644 (file)
@@ -47,7 +47,7 @@ private:
     virtual void parseMappedAttribute(Attribute*);
     virtual void insertedIntoDocument();
     virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
-    virtual void attributeChanged(Attribute*, bool preserveDecls = false);
+    virtual void attributeChanged(Attribute*) OVERRIDE;
 
     virtual bool isURLAttribute(Attribute*) const;
 
index e723c5d..fc1ff3c 100644 (file)
@@ -100,9 +100,9 @@ void HTMLTrackElement::parseMappedAttribute(Attribute* attribute)
         HTMLElement::parseMappedAttribute(attribute);
 }
 
-void HTMLTrackElement::attributeChanged(Attribute* attr, bool preserveDecls)
+void HTMLTrackElement::attributeChanged(Attribute* attr)
 {
-    HTMLElement::attributeChanged(attr, preserveDecls);
+    HTMLElement::attributeChanged(attr);
 
     if (!RuntimeEnabledFeatures::webkitVideoTrackEnabled())
         return;
index 965e396..62ccd57 100644 (file)
@@ -76,7 +76,7 @@ private:
     virtual ~HTMLTrackElement();
 
     virtual void parseMappedAttribute(Attribute*);
-    virtual void attributeChanged(Attribute*, bool preserveDecls);
+    virtual void attributeChanged(Attribute*) OVERRIDE;
 
     virtual void insertedIntoDocument() OVERRIDE;
     virtual void removedFromDocument() OVERRIDE;
index 97fbad7..37ac4e2 100644 (file)
@@ -201,12 +201,12 @@ void SVGAnimationElement::parseMappedAttribute(Attribute* attr)
     ASSERT_NOT_REACHED();
 }
 
-void SVGAnimationElement::attributeChanged(Attribute* attr, bool preserveDecls)
+void SVGAnimationElement::attributeChanged(Attribute* attr)
 {
     // Assumptions may not hold after an attribute change.
     m_animationValid = false;
     setInactive();
-    SVGSMILElement::attributeChanged(attr, preserveDecls);
+    SVGSMILElement::attributeChanged(attr);
 }
 
 float SVGAnimationElement::getStartTime() const
index 2e109f0..33be081 100644 (file)
@@ -107,7 +107,7 @@ protected:
     virtual void endedActiveInterval();
 
 private:
-    virtual void attributeChanged(Attribute*, bool preserveDecls);
+    virtual void attributeChanged(Attribute*) OVERRIDE;
 
     virtual bool calculateFromAndToValues(const String& fromString, const String& toString) = 0;
     virtual bool calculateFromAndByValues(const String& fromString, const String& byString) = 0;
index 6e160f0..1f3a406 100644 (file)
@@ -359,13 +359,13 @@ bool SVGElement::childShouldCreateRenderer(Node* child) const
     return false;
 }
 
-void SVGElement::attributeChanged(Attribute* attr, bool preserveDecls)
+void SVGElement::attributeChanged(Attribute* attr)
 {
     ASSERT(attr);
     if (!attr)
         return;
 
-    StyledElement::attributeChanged(attr, preserveDecls);
+    StyledElement::attributeChanged(attr);
 
     // When an animated SVG property changes through SVG DOM, svgAttributeChanged() is called, not attributeChanged().
     // Next time someone tries to access the XML attributes, the synchronization code starts. During that synchronization
index e4872d8..00a97d2 100644 (file)
@@ -111,7 +111,7 @@ protected:
     virtual void parseMappedAttribute(Attribute*);
 
     virtual void finishParsingChildren();
-    virtual void attributeChanged(Attribute*, bool preserveDecls = false);
+    virtual void attributeChanged(Attribute*) OVERRIDE;
     virtual bool childShouldCreateRenderer(Node*) const;
     
     virtual void removedFromDocument();
index 977d80c..d9dd376 100644 (file)
@@ -406,10 +406,10 @@ void SVGSMILElement::parseMappedAttribute(Attribute* attr)
         SVGElement::parseMappedAttribute(attr);
 }
 
-void SVGSMILElement::attributeChanged(Attribute* attr, bool preserveDecls)
+void SVGSMILElement::attributeChanged(Attribute* attr)
 {
-    SVGElement::attributeChanged(attr, preserveDecls);
-    
+    SVGElement::attributeChanged(attr);
+
     const QualifiedName& attrName = attr->name();
     if (attrName == SVGNames::durAttr)
         m_cachedDur = invalidCachedTime;
index ee57460..fb8a6ae 100644 (file)
@@ -45,7 +45,7 @@ public:
     static bool isSMILElement(Node*);
 
     virtual void parseMappedAttribute(Attribute*);
-    virtual void attributeChanged(Attribute*, bool preserveDecls);
+    virtual void attributeChanged(Attribute*) OVERRIDE;
     virtual void insertedIntoDocument();
     virtual void removedFromDocument();