Title: [127126] trunk/Source/WebCore
Revision
127126
Author
[email protected]
Date
2012-08-30 04:43:14 -0700 (Thu, 30 Aug 2012)

Log Message

Element: Share code between setAttributeNode() and other attribute setters.
<http://webkit.org/b/95328>

Reviewed by Antti Koivisto.

Removed the specialized ElementAttributeData::replaceAttribute() that was only used for
replacing an existing Attr node on an Element. Instead, just use Element::setAttributeInternal()
like all the other attribute setters.

* dom/Element.cpp:
(WebCore::Element::setAttributeNode):
* dom/ElementAttributeData.cpp:
* dom/ElementAttributeData.h:
(ElementAttributeData):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (127125 => 127126)


--- trunk/Source/WebCore/ChangeLog	2012-08-30 11:33:26 UTC (rev 127125)
+++ trunk/Source/WebCore/ChangeLog	2012-08-30 11:43:14 UTC (rev 127126)
@@ -1,3 +1,20 @@
+2012-08-30  Andreas Kling  <[email protected]>
+
+        Element: Share code between setAttributeNode() and other attribute setters.
+        <http://webkit.org/b/95328>
+
+        Reviewed by Antti Koivisto.
+
+        Removed the specialized ElementAttributeData::replaceAttribute() that was only used for
+        replacing an existing Attr node on an Element. Instead, just use Element::setAttributeInternal()
+        like all the other attribute setters.
+
+        * dom/Element.cpp:
+        (WebCore::Element::setAttributeNode):
+        * dom/ElementAttributeData.cpp:
+        * dom/ElementAttributeData.h:
+        (ElementAttributeData):
+
 2012-08-30  Xan Lopez  <[email protected]>
 
         1.9.90 drops symbols, breaking compatibility

Modified: trunk/Source/WebCore/dom/Element.cpp (127125 => 127126)


--- trunk/Source/WebCore/dom/Element.cpp	2012-08-30 11:33:26 UTC (rev 127125)
+++ trunk/Source/WebCore/dom/Element.cpp	2012-08-30 11:43:14 UTC (rev 127126)
@@ -1439,20 +1439,14 @@
     ElementAttributeData* attributeData = mutableAttributeData();
 
     size_t index = attributeData->getAttributeItemIndex(attr->qualifiedName());
-    Attribute* oldAttribute = index != notFound ? attributeData->attributeItem(index) : 0;
-
-    if (!oldAttribute) {
-        attributeData->addAttribute(Attribute(attr->qualifiedName(), attr->value()), this);
-        attributeData->setAttr(this, attr->qualifiedName(), attr);
-        return 0;
+    if (index != notFound) {
+        if (oldAttr)
+            oldAttr->detachFromElementWithValue(attributeData->attributeItem(index)->value());
+        else
+            oldAttr = Attr::create(document(), attr->qualifiedName(), attributeData->attributeItem(index)->value());
     }
 
-    if (oldAttr)
-        oldAttr->detachFromElementWithValue(oldAttribute->value());
-    else
-        oldAttr = Attr::create(document(), oldAttribute->name(), oldAttribute->value());
-
-    attributeData->replaceAttribute(index, Attribute(attr->name(), attr->value()), this);
+    setAttributeInternal(index, attr->qualifiedName(), attr->value(), NotInSynchronizationOfLazyAttribute);
     attributeData->setAttr(this, attr->qualifiedName(), attr);
     return oldAttr.release();
 }

Modified: trunk/Source/WebCore/dom/ElementAttributeData.cpp (127125 => 127126)


--- trunk/Source/WebCore/dom/ElementAttributeData.cpp	2012-08-30 11:33:26 UTC (rev 127125)
+++ trunk/Source/WebCore/dom/ElementAttributeData.cpp	2012-08-30 11:43:14 UTC (rev 127126)
@@ -379,17 +379,6 @@
     m_mutableAttributeVector->clear();
 }
 
-void ElementAttributeData::replaceAttribute(size_t index, const Attribute& attribute, Element* element)
-{
-    ASSERT(isMutable());
-    ASSERT(element);
-    ASSERT(index < length());
-
-    element->willModifyAttribute(attribute.name(), m_mutableAttributeVector->at(index).value(), attribute.value());
-    (*m_mutableAttributeVector)[index] = attribute;
-    element->didModifyAttribute(attribute);
-}
-
 PassRefPtr<Attr> ElementAttributeData::getAttributeNode(const String& name, bool shouldIgnoreAttributeCase, Element* element) const
 {
     ASSERT(element);

Modified: trunk/Source/WebCore/dom/ElementAttributeData.h (127125 => 127126)


--- trunk/Source/WebCore/dom/ElementAttributeData.h	2012-08-30 11:33:26 UTC (rev 127125)
+++ trunk/Source/WebCore/dom/ElementAttributeData.h	2012-08-30 11:43:14 UTC (rev 127126)
@@ -108,7 +108,6 @@
     size_t getAttributeItemIndexSlowCase(const AtomicString& name, bool shouldIgnoreAttributeCase) const;
     void cloneDataFrom(const ElementAttributeData& sourceData, const Element& sourceElement, Element& targetElement);
     void clearAttributes(Element*);
-    void replaceAttribute(size_t index, const Attribute&, Element*);
 
     bool isMutable() const { return m_isMutable; }
     PassOwnPtr<ElementAttributeData> makeMutable() const { return adoptPtr(new ElementAttributeData(*this)); }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to