Title: [135816] trunk/Source/WebCore
Revision
135816
Author
akl...@apple.com
Date
2012-11-26 21:13:40 -0800 (Mon, 26 Nov 2012)

Log Message

Node: Move AreSVGAttributesValidFlag to ElementAttributeData.
<http://webkit.org/b/103349>

Reviewed by Anders Carlsson.

Moved AreSVGAttributesValidFlag to ElementAttributeData and change it to use "dirty" semantics.
This frees up a bit on Node, and we will always have ElementAttributeData if the animated
attributes are dirty anyway.

* dom/Element.cpp:
(WebCore::Element::getAttribute):
* dom/Element.h:
(WebCore::Element::updateInvalidAttributes):
* dom/ElementAttributeData.cpp:
(WebCore::ElementAttributeData::ElementAttributeData):
* dom/ElementAttributeData.h:
(WebCore::ElementAttributeData::ElementAttributeData):
(ElementAttributeData):
* dom/Node.h:
(Node):
* svg/SVGElement.cpp:
(WebCore::SVGElement::updateAnimatedSVGAttribute):
* svg/SVGElement.h:
(WebCore::SVGElement::invalidateSVGAttributes):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (135815 => 135816)


--- trunk/Source/WebCore/ChangeLog	2012-11-27 05:06:53 UTC (rev 135815)
+++ trunk/Source/WebCore/ChangeLog	2012-11-27 05:13:40 UTC (rev 135816)
@@ -1,3 +1,30 @@
+2012-11-26  Andreas Kling  <akl...@apple.com>
+
+        Node: Move AreSVGAttributesValidFlag to ElementAttributeData.
+        <http://webkit.org/b/103349>
+
+        Reviewed by Anders Carlsson.
+
+        Moved AreSVGAttributesValidFlag to ElementAttributeData and change it to use "dirty" semantics.
+        This frees up a bit on Node, and we will always have ElementAttributeData if the animated
+        attributes are dirty anyway.
+
+        * dom/Element.cpp:
+        (WebCore::Element::getAttribute):
+        * dom/Element.h:
+        (WebCore::Element::updateInvalidAttributes):
+        * dom/ElementAttributeData.cpp:
+        (WebCore::ElementAttributeData::ElementAttributeData):
+        * dom/ElementAttributeData.h:
+        (WebCore::ElementAttributeData::ElementAttributeData):
+        (ElementAttributeData):
+        * dom/Node.h:
+        (Node):
+        * svg/SVGElement.cpp:
+        (WebCore::SVGElement::updateAnimatedSVGAttribute):
+        * svg/SVGElement.h:
+        (WebCore::SVGElement::invalidateSVGAttributes):
+
 2012-11-26  Sheriff Bot  <webkit.review....@gmail.com>
 
         Unreviewed, rolling out r135798.

Modified: trunk/Source/WebCore/dom/Element.cpp (135815 => 135816)


--- trunk/Source/WebCore/dom/Element.cpp	2012-11-27 05:06:53 UTC (rev 135815)
+++ trunk/Source/WebCore/dom/Element.cpp	2012-11-27 05:13:40 UTC (rev 135816)
@@ -305,18 +305,19 @@
 
 const AtomicString& Element::getAttribute(const QualifiedName& name) const
 {
-    if (UNLIKELY(name == styleAttr) && attributeData() && attributeData()->m_styleAttributeIsDirty)
+    if (!attributeData())
+        return nullAtom;
+
+    if (UNLIKELY(name == styleAttr && attributeData()->m_styleAttributeIsDirty))
         updateStyleAttribute();
 
 #if ENABLE(SVG)
-    if (UNLIKELY(!areSVGAttributesValid()))
+    if (UNLIKELY(attributeData()->m_animatedSVGAttributesAreDirty))
         updateAnimatedSVGAttribute(name);
 #endif
 
-    if (attributeData()) {
-        if (const Attribute* attribute = getAttributeItem(name))
-            return attribute->value();
-    }
+    if (const Attribute* attribute = getAttributeItem(name))
+        return attribute->value();
     return nullAtom;
 }
 
@@ -660,24 +661,24 @@
 
 const AtomicString& Element::getAttribute(const AtomicString& name) const
 {
+    if (!attributeData())
+        return nullAtom;
+
     bool ignoreCase = shouldIgnoreAttributeCase(this);
 
     // Update the 'style' attribute if it's invalid and being requested:
-    if (attributeData() && attributeData()->m_styleAttributeIsDirty && equalPossiblyIgnoringCase(name, styleAttr.localName(), ignoreCase))
+    if (attributeData()->m_styleAttributeIsDirty && equalPossiblyIgnoringCase(name, styleAttr.localName(), ignoreCase))
         updateStyleAttribute();
 
 #if ENABLE(SVG)
-    if (!areSVGAttributesValid()) {
+    if (attributeData()->m_animatedSVGAttributesAreDirty) {
         // We're not passing a namespace argument on purpose. SVGNames::*Attr are defined w/o namespaces as well.
         updateAnimatedSVGAttribute(QualifiedName(nullAtom, name, nullAtom));
     }
 #endif
 
-    if (attributeData()) {
-        if (const Attribute* attribute = attributeData()->getAttributeItem(name, ignoreCase))
-            return attribute->value();
-    }
-
+    if (const Attribute* attribute = attributeData()->getAttributeItem(name, ignoreCase))
+        return attribute->value();
     return nullAtom;
 }
 

Modified: trunk/Source/WebCore/dom/Element.h (135815 => 135816)


--- trunk/Source/WebCore/dom/Element.h	2012-11-27 05:06:53 UTC (rev 135815)
+++ trunk/Source/WebCore/dom/Element.h	2012-11-27 05:13:40 UTC (rev 135816)
@@ -743,11 +743,14 @@
 
 inline void Element::updateInvalidAttributes() const
 {
-    if (attributeData() && attributeData()->m_styleAttributeIsDirty)
+    if (!attributeData())
+        return;
+
+    if (attributeData()->m_styleAttributeIsDirty)
         updateStyleAttribute();
 
 #if ENABLE(SVG)
-    if (!areSVGAttributesValid())
+    if (attributeData()->m_animatedSVGAttributesAreDirty)
         updateAnimatedSVGAttribute(anyQName());
 #endif
 }

Modified: trunk/Source/WebCore/dom/ElementAttributeData.cpp (135815 => 135816)


--- trunk/Source/WebCore/dom/ElementAttributeData.cpp	2012-11-27 05:06:53 UTC (rev 135815)
+++ trunk/Source/WebCore/dom/ElementAttributeData.cpp	2012-11-27 05:13:40 UTC (rev 135816)
@@ -86,6 +86,9 @@
     , m_arraySize(isMutable ? 0 : other.length())
     , m_presentationAttributeStyleIsDirty(other.m_presentationAttributeStyleIsDirty)
     , m_styleAttributeIsDirty(other.m_styleAttributeIsDirty)
+#if ENABLE(SVG)
+    , m_animatedSVGAttributesAreDirty(other.m_animatedSVGAttributesAreDirty)
+#endif
     , m_classNames(other.m_classNames)
     , m_idForStyleResolution(other.m_idForStyleResolution)
 {

Modified: trunk/Source/WebCore/dom/ElementAttributeData.h (135815 => 135816)


--- trunk/Source/WebCore/dom/ElementAttributeData.h	2012-11-27 05:06:53 UTC (rev 135815)
+++ trunk/Source/WebCore/dom/ElementAttributeData.h	2012-11-27 05:13:40 UTC (rev 135816)
@@ -90,6 +90,9 @@
         , m_arraySize(0)
         , m_presentationAttributeStyleIsDirty(false)
         , m_styleAttributeIsDirty(false)
+#if ENABLE(SVG)
+        , m_animatedSVGAttributesAreDirty(false)
+#endif
     { }
 
     ElementAttributeData(unsigned arraySize)
@@ -97,14 +100,20 @@
         , m_arraySize(arraySize)
         , m_presentationAttributeStyleIsDirty(false)
         , m_styleAttributeIsDirty(false)
+#if ENABLE(SVG)
+        , m_animatedSVGAttributesAreDirty(false)
+#endif
     { }
 
     ElementAttributeData(const ElementAttributeData&, bool isMutable);
 
     unsigned m_isMutable : 1;
-    unsigned m_arraySize : 29;
+    unsigned m_arraySize : 28;
     mutable unsigned m_presentationAttributeStyleIsDirty : 1;
     mutable unsigned m_styleAttributeIsDirty : 1;
+#if ENABLE(SVG)
+    mutable unsigned m_animatedSVGAttributesAreDirty : 1;
+#endif
 
     mutable RefPtr<StylePropertySet> m_inlineStyle;
     mutable SpaceSplitString m_classNames;
@@ -115,6 +124,9 @@
     friend class StyledElement;
     friend class ImmutableElementAttributeData;
     friend class MutableElementAttributeData;
+#if ENABLE(SVG)
+    friend class SVGElement;
+#endif
 
     Attribute* getAttributeItem(const AtomicString& name, bool shouldIgnoreAttributeCase);
     const Attribute* getAttributeItem(const AtomicString& name, bool shouldIgnoreAttributeCase) const;

Modified: trunk/Source/WebCore/dom/Node.h (135815 => 135816)


--- trunk/Source/WebCore/dom/Node.h	2012-11-27 05:06:53 UTC (rev 135815)
+++ trunk/Source/WebCore/dom/Node.h	2012-11-27 05:13:40 UTC (rev 135816)
@@ -98,7 +98,7 @@
 
 typedef int ExceptionCode;
 
-const int nodeStyleChangeShift = 18;
+const int nodeStyleChangeShift = 17;
 
 // 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,
@@ -705,32 +705,27 @@
         // be stored in the same memory word as the Node bits above.
         IsParsingChildrenFinishedFlag = 1 << 15, // Element
 #if ENABLE(SVG)
-        AreSVGAttributesValidFlag = 1 << 16, // Element
-        HasSVGRareDataFlag = 1 << 17, // SVGElement
+        HasSVGRareDataFlag = 1 << 16, // SVGElement
 #endif
 
         StyleChangeMask = 1 << nodeStyleChangeShift | 1 << (nodeStyleChangeShift + 1),
 
-        SelfOrAncestorHasDirAutoFlag = 1 << 20,
+        SelfOrAncestorHasDirAutoFlag = 1 << 19,
 
-        HasNameOrIsEditingTextFlag = 1 << 21,
+        HasNameOrIsEditingTextFlag = 1 << 20,
 
-        InNamedFlowFlag = 1 << 22,
-        HasSyntheticAttrChildNodesFlag = 1 << 23,
-        HasCustomCallbacksFlag = 1 << 24,
-        HasScopedHTMLStyleChildFlag = 1 << 25,
-        HasEventTargetDataFlag = 1 << 26,
-        V8CollectableDuringMinorGCFlag = 1 << 27,
-        IsInsertionPointFlag = 1 << 28,
+        InNamedFlowFlag = 1 << 21,
+        HasSyntheticAttrChildNodesFlag = 1 << 22,
+        HasCustomCallbacksFlag = 1 << 23,
+        HasScopedHTMLStyleChildFlag = 1 << 24,
+        HasEventTargetDataFlag = 1 << 25,
+        V8CollectableDuringMinorGCFlag = 1 << 26,
+        IsInsertionPointFlag = 1 << 27,
 
-#if ENABLE(SVG)
-        DefaultNodeFlags = IsParsingChildrenFinishedFlag | AreSVGAttributesValidFlag,
-#else
-        DefaultNodeFlags = IsParsingChildrenFinishedFlag,
-#endif
+        DefaultNodeFlags = IsParsingChildrenFinishedFlag
     };
 
-    // 3 bits remaining
+    // 4 bits remaining
 
     bool getFlag(NodeFlags mask) const { return m_nodeFlags & mask; }
     void setFlag(bool f, NodeFlags mask) const { m_nodeFlags = (m_nodeFlags & ~mask) | (-(int32_t)f & mask); } 
@@ -839,9 +834,6 @@
     void clearIsParsingChildrenFinished() { clearFlag(IsParsingChildrenFinishedFlag); }
 
 #if ENABLE(SVG)
-    bool areSVGAttributesValid() const { return getFlag(AreSVGAttributesValidFlag); }
-    void setAreSVGAttributesValid() const { setFlag(AreSVGAttributesValidFlag); }
-    void clearAreSVGAttributesValid() { clearFlag(AreSVGAttributesValidFlag); }
     bool hasSVGRareData() const { return getFlag(HasSVGRareDataFlag); }
     void setHasSVGRareData() { setFlag(HasSVGRareDataFlag); }
     void clearHasSVGRareData() { clearFlag(HasSVGRareDataFlag); }

Modified: trunk/Source/WebCore/svg/SVGElement.cpp (135815 => 135816)


--- trunk/Source/WebCore/svg/SVGElement.cpp	2012-11-27 05:06:53 UTC (rev 135815)
+++ trunk/Source/WebCore/svg/SVGElement.cpp	2012-11-27 05:13:40 UTC (rev 135816)
@@ -566,13 +566,13 @@
 
 void SVGElement::updateAnimatedSVGAttribute(const QualifiedName& name) const
 {
-    if (areSVGAttributesValid())
+    if (!attributeData() || !attributeData()->m_animatedSVGAttributesAreDirty)
         return;
 
     SVGElement* nonConstThis = const_cast<SVGElement*>(this);
     if (name == anyQName()) {
         nonConstThis->localAttributeToPropertyMap().synchronizeProperties(nonConstThis);
-        setAreSVGAttributesValid();
+        attributeData()->m_animatedSVGAttributesAreDirty = false;
     } else
         nonConstThis->localAttributeToPropertyMap().synchronizeProperty(nonConstThis, name);
 }

Modified: trunk/Source/WebCore/svg/SVGElement.h (135815 => 135816)


--- trunk/Source/WebCore/svg/SVGElement.h	2012-11-27 05:06:53 UTC (rev 135815)
+++ trunk/Source/WebCore/svg/SVGElement.h	2012-11-27 05:13:40 UTC (rev 135816)
@@ -84,7 +84,7 @@
 
     virtual AffineTransform* supplementalTransform() { return 0; }
 
-    void invalidateSVGAttributes() { clearAreSVGAttributesValid(); }
+    void invalidateSVGAttributes() { ensureAttributeData()->m_animatedSVGAttributesAreDirty = true; }
 
     const HashSet<SVGElementInstance*>& instancesForElement() const;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to