Title: [109285] trunk/Source/WebCore
Revision
109285
Author
[email protected]
Date
2012-02-29 17:03:41 -0800 (Wed, 29 Feb 2012)

Log Message

IsSynchronizingStyleAttributeFlag could be purged.
<http://webkit.org/b/79313>

Reviewed by Anders Carlsson.

We were using IsSynchronizingStyleAttributeFlag to prevent various things from
happening below setAttribute() when serializing the "style" attribute based on
an element's inline style.

Simplify the whole thing by adding a way to set an attribute without triggering
any callbacks (a 'notifyChanged' argument to Element::setAttribute().)
This removes the need for IsSynchronizingStyleAttributeFlag in the first place
and makes StyledElement::updateStyleAttribute() a bit cheaper to boot.

* dom/Element.cpp:
(WebCore::Element::setAttribute):
(WebCore::Element::setAttributeInternal):
(WebCore::Element::willModifyAttribute):
(WebCore::Element::didModifyAttribute):
(WebCore::Element::didRemoveAttribute):
* dom/Element.h:
* dom/Node.h:
* dom/StyledElement.cpp:
(WebCore::StyledElement::updateStyleAttribute):
(WebCore::StyledElement::attributeChanged):
* html/HTMLElement.cpp:
(WebCore::StyledElement::copyNonAttributeProperties):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (109284 => 109285)


--- trunk/Source/WebCore/ChangeLog	2012-03-01 00:33:56 UTC (rev 109284)
+++ trunk/Source/WebCore/ChangeLog	2012-03-01 01:03:41 UTC (rev 109285)
@@ -1,3 +1,33 @@
+2012-02-29  Andreas Kling  <[email protected]>
+
+        IsSynchronizingStyleAttributeFlag could be purged.
+        <http://webkit.org/b/79313>
+
+        Reviewed by Anders Carlsson.
+
+        We were using IsSynchronizingStyleAttributeFlag to prevent various things from
+        happening below setAttribute() when serializing the "style" attribute based on
+        an element's inline style.
+
+        Simplify the whole thing by adding a way to set an attribute without triggering
+        any callbacks (a 'notifyChanged' argument to Element::setAttribute().)
+        This removes the need for IsSynchronizingStyleAttributeFlag in the first place
+        and makes StyledElement::updateStyleAttribute() a bit cheaper to boot.
+
+        * dom/Element.cpp:
+        (WebCore::Element::setAttribute):
+        (WebCore::Element::setAttributeInternal):
+        (WebCore::Element::willModifyAttribute):
+        (WebCore::Element::didModifyAttribute):
+        (WebCore::Element::didRemoveAttribute):
+        * dom/Element.h:
+        * dom/Node.h:
+        * dom/StyledElement.cpp:
+        (WebCore::StyledElement::updateStyleAttribute):
+        (WebCore::StyledElement::attributeChanged):
+        * html/HTMLElement.cpp:
+        (WebCore::StyledElement::copyNonAttributeProperties):
+
 2012-02-29  Daniel Cheng  <[email protected]>
 
         [chromium] REGRESSION: Cannot drag a file out

Modified: trunk/Source/WebCore/dom/Element.cpp (109284 => 109285)


--- trunk/Source/WebCore/dom/Element.cpp	2012-03-01 00:33:56 UTC (rev 109284)
+++ trunk/Source/WebCore/dom/Element.cpp	2012-03-01 01:03:41 UTC (rev 109285)
@@ -624,12 +624,12 @@
     setAttributeInternal(index, qName, value);
 }
 
-void Element::setAttribute(const QualifiedName& name, const AtomicString& value)
+void Element::setAttribute(const QualifiedName& name, const AtomicString& value, bool notifyChanged)
 {
-    setAttributeInternal(ensureUpdatedAttributeData()->getAttributeItemIndex(name), name, value);
+    setAttributeInternal(ensureUpdatedAttributeData()->getAttributeItemIndex(name), name, value, notifyChanged);
 }
 
-inline void Element::setAttributeInternal(size_t index, const QualifiedName& name, const AtomicString& value)
+inline void Element::setAttributeInternal(size_t index, const QualifiedName& name, const AtomicString& value, bool notifyChanged)
 {
     ElementAttributeData* attributeData = &m_attributeMap->m_attributeData;
     Attribute* old = index != notFound ? attributeData->attributeItem(index) : 0;
@@ -644,14 +644,16 @@
         return;
     }
 
-    willModifyAttribute(name, old ? old->value() : nullAtom, value);
+    if (notifyChanged)
+        willModifyAttribute(name, old ? old->value() : nullAtom, value);
 
     if (Attr* attrNode = old->attr())
         attrNode->setValue(value);
     else
         old->setValue(value);
 
-    didModifyAttribute(old);
+    if (notifyChanged)
+        didModifyAttribute(old);
 }
 
 void Element::attributeChanged(Attribute* attr)
@@ -1939,15 +1941,12 @@
         updateName(oldValue, newValue);
 
 #if ENABLE(MUTATION_OBSERVERS)
-    if (!isSynchronizingStyleAttribute()) {
-        if (OwnPtr<MutationObserverInterestGroup> recipients = MutationObserverInterestGroup::createForAttributesMutation(this, name))
-            recipients->enqueueMutationRecord(MutationRecord::createAttributes(this, name, oldValue));
-    }
+    if (OwnPtr<MutationObserverInterestGroup> recipients = MutationObserverInterestGroup::createForAttributesMutation(this, name))
+        recipients->enqueueMutationRecord(MutationRecord::createAttributes(this, name, oldValue));
 #endif
 
 #if ENABLE(INSPECTOR)
-    if (!isSynchronizingStyleAttribute())
-        InspectorInstrumentation::willModifyDOMAttr(document(), this, oldValue, newValue);
+    InspectorInstrumentation::willModifyDOMAttr(document(), this, oldValue, newValue);
 #endif
 }
 
@@ -1955,10 +1954,8 @@
 {
     attributeChanged(attr);
 
-    if (!isSynchronizingStyleAttribute()) {
-        InspectorInstrumentation::didModifyDOMAttr(document(), this, attr->name().localName(), attr->value());
-        dispatchSubtreeModifiedEvent();
-    }
+    InspectorInstrumentation::didModifyDOMAttr(document(), this, attr->name().localName(), attr->value());
+    dispatchSubtreeModifiedEvent();
 }
 
 void Element::didRemoveAttribute(Attribute* attr)
@@ -1971,10 +1968,8 @@
     attributeChanged(attr);
     attr->setValue(savedValue);
 
-    if (!isSynchronizingStyleAttribute()) {
-        InspectorInstrumentation::didRemoveDOMAttr(document(), this, attr->name().localName());
-        dispatchSubtreeModifiedEvent();
-    }
+    InspectorInstrumentation::didRemoveDOMAttr(document(), this, attr->name().localName());
+    dispatchSubtreeModifiedEvent();
 }
 
 

Modified: trunk/Source/WebCore/dom/Element.h (109284 => 109285)


--- trunk/Source/WebCore/dom/Element.h	2012-03-01 00:33:56 UTC (rev 109284)
+++ trunk/Source/WebCore/dom/Element.h	2012-03-01 01:03:41 UTC (rev 109285)
@@ -113,7 +113,7 @@
 
     bool hasAttribute(const QualifiedName&) const;
     const AtomicString& getAttribute(const QualifiedName&) const;
-    void setAttribute(const QualifiedName&, const AtomicString& value);
+    void setAttribute(const QualifiedName&, const AtomicString& value, bool notifyChanged = true);
     void removeAttribute(const QualifiedName&);
 
     // Typed getters and setters for language bindings.
@@ -429,7 +429,7 @@
     virtual NodeType nodeType() const;
     virtual bool childTypeAllowed(NodeType) const;
 
-    void setAttributeInternal(size_t index, const QualifiedName&, const AtomicString& value);
+    void setAttributeInternal(size_t index, const QualifiedName&, const AtomicString& value, bool notifyChanged = true);
 
 #ifndef NDEBUG
     virtual void formatForDebugger(char* buffer, unsigned length) const;

Modified: trunk/Source/WebCore/dom/Node.h (109284 => 109285)


--- trunk/Source/WebCore/dom/Node.h	2012-03-01 00:33:56 UTC (rev 109284)
+++ trunk/Source/WebCore/dom/Node.h	2012-03-01 01:03:41 UTC (rev 109285)
@@ -88,7 +88,7 @@
 
 typedef int ExceptionCode;
 
-const int nodeStyleChangeShift = 23;
+const int nodeStyleChangeShift = 22;
 
 // SyntheticStyleChange means that we need to go through the entire style change logic even though
 // no style property has actually changed. It is used to restructure the tree when, for instance,
@@ -654,22 +654,21 @@
         // be stored in the same memory word as the Node bits above.
         IsParsingChildrenFinishedFlag = 1 << 17, // Element
         IsStyleAttributeValidFlag = 1 << 18, // StyledElement
-        IsSynchronizingStyleAttributeFlag = 1 << 19, // StyledElement
 #if ENABLE(SVG)
-        AreSVGAttributesValidFlag = 1 << 20, // Element
-        IsSynchronizingSVGAttributesFlag = 1 << 21, // SVGElement
-        HasSVGRareDataFlag = 1 << 22, // SVGElement
+        AreSVGAttributesValidFlag = 1 << 19, // Element
+        IsSynchronizingSVGAttributesFlag = 1 << 20, // SVGElement
+        HasSVGRareDataFlag = 1 << 21, // SVGElement
 #endif
 
         StyleChangeMask = 1 << nodeStyleChangeShift | 1 << (nodeStyleChangeShift + 1),
 
-        SelfOrAncestorHasDirAutoFlag = 1 << 25,
-        HasCustomWillOrDidRecalcStyleFlag = 1 << 26,
-        HasCustomStyleForRendererFlag = 1 << 27,
+        SelfOrAncestorHasDirAutoFlag = 1 << 24,
+        HasCustomWillOrDidRecalcStyleFlag = 1 << 25,
+        HasCustomStyleForRendererFlag = 1 << 26,
 
-        HasNameFlag = 1 << 28,
+        HasNameFlag = 1 << 27,
 
-        AttributeStyleDirtyFlag = 1 << 31,
+        AttributeStyleDirtyFlag = 1 << 28,
 
 #if ENABLE(SVG)
         DefaultNodeFlags = IsParsingChildrenFinishedFlag | IsStyleAttributeValidFlag | AreSVGAttributesValidFlag
@@ -775,10 +774,6 @@
     void setIsStyleAttributeValid(bool f) { setFlag(f, IsStyleAttributeValidFlag); }
     void setIsStyleAttributeValid() const { setFlag(IsStyleAttributeValidFlag); }
     void clearIsStyleAttributeValid() { clearFlag(IsStyleAttributeValidFlag); }
-    bool isSynchronizingStyleAttribute() const { return getFlag(IsSynchronizingStyleAttributeFlag); }
-    void setIsSynchronizingStyleAttribute(bool f) { setFlag(f, IsSynchronizingStyleAttributeFlag); }
-    void setIsSynchronizingStyleAttribute() const { setFlag(IsSynchronizingStyleAttributeFlag); }
-    void clearIsSynchronizingStyleAttribute() const { clearFlag(IsSynchronizingStyleAttributeFlag); }
 
 #if ENABLE(SVG)
     bool areSVGAttributesValid() const { return getFlag(AreSVGAttributesValidFlag); }

Modified: trunk/Source/WebCore/dom/StyledElement.cpp (109284 => 109285)


--- trunk/Source/WebCore/dom/StyledElement.cpp	2012-03-01 00:33:56 UTC (rev 109284)
+++ trunk/Source/WebCore/dom/StyledElement.cpp	2012-03-01 01:03:41 UTC (rev 109285)
@@ -50,10 +50,8 @@
 {
     ASSERT(!isStyleAttributeValid());
     setIsStyleAttributeValid();
-    setIsSynchronizingStyleAttribute();
     if (StylePropertySet* inlineStyle = inlineStyleDecl())
-        const_cast<StyledElement*>(this)->setAttribute(styleAttr, inlineStyle->asText());
-    clearIsSynchronizingStyleAttribute();
+        const_cast<StyledElement*>(this)->setAttribute(styleAttr, inlineStyle->asText(), /*notifyChanged*/ false);
 }
 
 StyledElement::~StyledElement()
@@ -63,8 +61,7 @@
 
 void StyledElement::attributeChanged(Attribute* attr)
 {
-    if (!(attr->name() == styleAttr && isSynchronizingStyleAttribute()))
-        parseAttribute(attr);
+    parseAttribute(attr);
 
     if (isPresentationAttribute(attr->name())) {
         setAttributeStyleDirty();

Modified: trunk/Source/WebCore/html/HTMLElement.cpp (109284 => 109285)


--- trunk/Source/WebCore/html/HTMLElement.cpp	2012-03-01 00:33:56 UTC (rev 109284)
+++ trunk/Source/WebCore/html/HTMLElement.cpp	2012-03-01 01:03:41 UTC (rev 109285)
@@ -1114,8 +1114,7 @@
     inlineStyle->setStrictParsing(source->inlineStyleDecl()->useStrictParsing());
 
     setIsStyleAttributeValid(source->isStyleAttributeValid());
-    setIsSynchronizingStyleAttribute(source->isSynchronizingStyleAttribute());
-    
+
     Element::copyNonAttributeProperties(sourceElement);
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to