Changeset 135816 in webkit


Ignore:
Timestamp:
Nov 26, 2012 9:13:40 PM (11 years ago)
Author:
akling@apple.com
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):

Location:
trunk/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r135815 r135816  
     12012-11-26  Andreas Kling  <akling@apple.com>
     2
     3        Node: Move AreSVGAttributesValidFlag to ElementAttributeData.
     4        <http://webkit.org/b/103349>
     5
     6        Reviewed by Anders Carlsson.
     7
     8        Moved AreSVGAttributesValidFlag to ElementAttributeData and change it to use "dirty" semantics.
     9        This frees up a bit on Node, and we will always have ElementAttributeData if the animated
     10        attributes are dirty anyway.
     11
     12        * dom/Element.cpp:
     13        (WebCore::Element::getAttribute):
     14        * dom/Element.h:
     15        (WebCore::Element::updateInvalidAttributes):
     16        * dom/ElementAttributeData.cpp:
     17        (WebCore::ElementAttributeData::ElementAttributeData):
     18        * dom/ElementAttributeData.h:
     19        (WebCore::ElementAttributeData::ElementAttributeData):
     20        (ElementAttributeData):
     21        * dom/Node.h:
     22        (Node):
     23        * svg/SVGElement.cpp:
     24        (WebCore::SVGElement::updateAnimatedSVGAttribute):
     25        * svg/SVGElement.h:
     26        (WebCore::SVGElement::invalidateSVGAttributes):
     27
    1282012-11-26  Sheriff Bot  <webkit.review.bot@gmail.com>
    229
  • trunk/Source/WebCore/dom/Element.cpp

    r135693 r135816  
    306306const AtomicString& Element::getAttribute(const QualifiedName& name) const
    307307{
    308     if (UNLIKELY(name == styleAttr) && attributeData() && attributeData()->m_styleAttributeIsDirty)
     308    if (!attributeData())
     309        return nullAtom;
     310
     311    if (UNLIKELY(name == styleAttr && attributeData()->m_styleAttributeIsDirty))
    309312        updateStyleAttribute();
    310313
    311314#if ENABLE(SVG)
    312     if (UNLIKELY(!areSVGAttributesValid()))
     315    if (UNLIKELY(attributeData()->m_animatedSVGAttributesAreDirty))
    313316        updateAnimatedSVGAttribute(name);
    314317#endif
    315318
    316     if (attributeData()) {
    317         if (const Attribute* attribute = getAttributeItem(name))
    318             return attribute->value();
    319     }
     319    if (const Attribute* attribute = getAttributeItem(name))
     320        return attribute->value();
    320321    return nullAtom;
    321322}
     
    661662const AtomicString& Element::getAttribute(const AtomicString& name) const
    662663{
     664    if (!attributeData())
     665        return nullAtom;
     666
    663667    bool ignoreCase = shouldIgnoreAttributeCase(this);
    664668
    665669    // Update the 'style' attribute if it's invalid and being requested:
    666     if (attributeData() && attributeData()->m_styleAttributeIsDirty && equalPossiblyIgnoringCase(name, styleAttr.localName(), ignoreCase))
     670    if (attributeData()->m_styleAttributeIsDirty && equalPossiblyIgnoringCase(name, styleAttr.localName(), ignoreCase))
    667671        updateStyleAttribute();
    668672
    669673#if ENABLE(SVG)
    670     if (!areSVGAttributesValid()) {
     674    if (attributeData()->m_animatedSVGAttributesAreDirty) {
    671675        // We're not passing a namespace argument on purpose. SVGNames::*Attr are defined w/o namespaces as well.
    672676        updateAnimatedSVGAttribute(QualifiedName(nullAtom, name, nullAtom));
     
    674678#endif
    675679
    676     if (attributeData()) {
    677         if (const Attribute* attribute = attributeData()->getAttributeItem(name, ignoreCase))
    678             return attribute->value();
    679     }
    680 
     680    if (const Attribute* attribute = attributeData()->getAttributeItem(name, ignoreCase))
     681        return attribute->value();
    681682    return nullAtom;
    682683}
  • trunk/Source/WebCore/dom/Element.h

    r135693 r135816  
    744744inline void Element::updateInvalidAttributes() const
    745745{
    746     if (attributeData() && attributeData()->m_styleAttributeIsDirty)
     746    if (!attributeData())
     747        return;
     748
     749    if (attributeData()->m_styleAttributeIsDirty)
    747750        updateStyleAttribute();
    748751
    749752#if ENABLE(SVG)
    750     if (!areSVGAttributesValid())
     753    if (attributeData()->m_animatedSVGAttributesAreDirty)
    751754        updateAnimatedSVGAttribute(anyQName());
    752755#endif
  • trunk/Source/WebCore/dom/ElementAttributeData.cpp

    r135428 r135816  
    8787    , m_presentationAttributeStyleIsDirty(other.m_presentationAttributeStyleIsDirty)
    8888    , m_styleAttributeIsDirty(other.m_styleAttributeIsDirty)
     89#if ENABLE(SVG)
     90    , m_animatedSVGAttributesAreDirty(other.m_animatedSVGAttributesAreDirty)
     91#endif
    8992    , m_classNames(other.m_classNames)
    9093    , m_idForStyleResolution(other.m_idForStyleResolution)
  • trunk/Source/WebCore/dom/ElementAttributeData.h

    r135421 r135816  
    9191        , m_presentationAttributeStyleIsDirty(false)
    9292        , m_styleAttributeIsDirty(false)
     93#if ENABLE(SVG)
     94        , m_animatedSVGAttributesAreDirty(false)
     95#endif
    9396    { }
    9497
     
    98101        , m_presentationAttributeStyleIsDirty(false)
    99102        , m_styleAttributeIsDirty(false)
     103#if ENABLE(SVG)
     104        , m_animatedSVGAttributesAreDirty(false)
     105#endif
    100106    { }
    101107
     
    103109
    104110    unsigned m_isMutable : 1;
    105     unsigned m_arraySize : 29;
     111    unsigned m_arraySize : 28;
    106112    mutable unsigned m_presentationAttributeStyleIsDirty : 1;
    107113    mutable unsigned m_styleAttributeIsDirty : 1;
     114#if ENABLE(SVG)
     115    mutable unsigned m_animatedSVGAttributesAreDirty : 1;
     116#endif
    108117
    109118    mutable RefPtr<StylePropertySet> m_inlineStyle;
     
    116125    friend class ImmutableElementAttributeData;
    117126    friend class MutableElementAttributeData;
     127#if ENABLE(SVG)
     128    friend class SVGElement;
     129#endif
    118130
    119131    Attribute* getAttributeItem(const AtomicString& name, bool shouldIgnoreAttributeCase);
  • trunk/Source/WebCore/dom/Node.h

    r135793 r135816  
    9999typedef int ExceptionCode;
    100100
    101 const int nodeStyleChangeShift = 18;
     101const int nodeStyleChangeShift = 17;
    102102
    103103// SyntheticStyleChange means that we need to go through the entire style change logic even though
     
    706706        IsParsingChildrenFinishedFlag = 1 << 15, // Element
    707707#if ENABLE(SVG)
    708         AreSVGAttributesValidFlag = 1 << 16, // Element
    709         HasSVGRareDataFlag = 1 << 17, // SVGElement
     708        HasSVGRareDataFlag = 1 << 16, // SVGElement
    710709#endif
    711710
    712711        StyleChangeMask = 1 << nodeStyleChangeShift | 1 << (nodeStyleChangeShift + 1),
    713712
    714         SelfOrAncestorHasDirAutoFlag = 1 << 20,
    715 
    716         HasNameOrIsEditingTextFlag = 1 << 21,
    717 
    718         InNamedFlowFlag = 1 << 22,
    719         HasSyntheticAttrChildNodesFlag = 1 << 23,
    720         HasCustomCallbacksFlag = 1 << 24,
    721         HasScopedHTMLStyleChildFlag = 1 << 25,
    722         HasEventTargetDataFlag = 1 << 26,
    723         V8CollectableDuringMinorGCFlag = 1 << 27,
    724         IsInsertionPointFlag = 1 << 28,
    725 
    726 #if ENABLE(SVG)
    727         DefaultNodeFlags = IsParsingChildrenFinishedFlag | AreSVGAttributesValidFlag,
    728 #else
    729         DefaultNodeFlags = IsParsingChildrenFinishedFlag,
    730 #endif
     713        SelfOrAncestorHasDirAutoFlag = 1 << 19,
     714
     715        HasNameOrIsEditingTextFlag = 1 << 20,
     716
     717        InNamedFlowFlag = 1 << 21,
     718        HasSyntheticAttrChildNodesFlag = 1 << 22,
     719        HasCustomCallbacksFlag = 1 << 23,
     720        HasScopedHTMLStyleChildFlag = 1 << 24,
     721        HasEventTargetDataFlag = 1 << 25,
     722        V8CollectableDuringMinorGCFlag = 1 << 26,
     723        IsInsertionPointFlag = 1 << 27,
     724
     725        DefaultNodeFlags = IsParsingChildrenFinishedFlag
    731726    };
    732727
    733     // 3 bits remaining
     728    // 4 bits remaining
    734729
    735730    bool getFlag(NodeFlags mask) const { return m_nodeFlags & mask; }
     
    840835
    841836#if ENABLE(SVG)
    842     bool areSVGAttributesValid() const { return getFlag(AreSVGAttributesValidFlag); }
    843     void setAreSVGAttributesValid() const { setFlag(AreSVGAttributesValidFlag); }
    844     void clearAreSVGAttributesValid() { clearFlag(AreSVGAttributesValidFlag); }
    845837    bool hasSVGRareData() const { return getFlag(HasSVGRareDataFlag); }
    846838    void setHasSVGRareData() { setFlag(HasSVGRareDataFlag); }
  • trunk/Source/WebCore/svg/SVGElement.cpp

    r135793 r135816  
    567567void SVGElement::updateAnimatedSVGAttribute(const QualifiedName& name) const
    568568{
    569     if (areSVGAttributesValid())
     569    if (!attributeData() || !attributeData()->m_animatedSVGAttributesAreDirty)
    570570        return;
    571571
     
    573573    if (name == anyQName()) {
    574574        nonConstThis->localAttributeToPropertyMap().synchronizeProperties(nonConstThis);
    575         setAreSVGAttributesValid();
     575        attributeData()->m_animatedSVGAttributesAreDirty = false;
    576576    } else
    577577        nonConstThis->localAttributeToPropertyMap().synchronizeProperty(nonConstThis, name);
  • trunk/Source/WebCore/svg/SVGElement.h

    r135069 r135816  
    8585    virtual AffineTransform* supplementalTransform() { return 0; }
    8686
    87     void invalidateSVGAttributes() { clearAreSVGAttributesValid(); }
     87    void invalidateSVGAttributes() { ensureAttributeData()->m_animatedSVGAttributesAreDirty = true; }
    8888
    8989    const HashSet<SVGElementInstance*>& instancesForElement() const;
Note: See TracChangeset for help on using the changeset viewer.