Changeset 151071 in webkit


Ignore:
Timestamp:
Jun 1, 2013 3:20:25 AM (11 years ago)
Author:
akling@apple.com
Message:

Move Node::hasName() to Element.
<http://webkit.org/b/117107>

Reviewed by Antti Koivisto.

A Node can't have attributes, and thus can't have a name.
Use a bit on ElementData instead of (half) a Node flag to track whether we have a name.

  • dom/Element.cpp:

(WebCore::Element::attributeChanged):
(WebCore::ElementData::ElementData):

  • dom/Element.h:

(WebCore::ElementData::hasName):
(WebCore::Element::hasName):

  • dom/Node.h:

(WebCore::Node::isEditingText):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r151069 r151071  
     12013-06-01  Andreas Kling  <akling@apple.com>
     2
     3        Move Node::hasName() to Element.
     4        <http://webkit.org/b/117107>
     5
     6        Reviewed by Antti Koivisto.
     7
     8        A Node can't have attributes, and thus can't have a name.
     9        Use a bit on ElementData instead of (half) a Node flag to track whether we have a name.
     10
     11        * dom/Element.cpp:
     12        (WebCore::Element::attributeChanged):
     13        (WebCore::ElementData::ElementData):
     14        * dom/Element.h:
     15        (WebCore::ElementData::hasName):
     16        (WebCore::Element::hasName):
     17        * dom/Node.h:
     18        (WebCore::Node::isEditingText):
     19
    1202013-06-01  Andreas Kling  <akling@apple.com>
    221
  • trunk/Source/WebCore/dom/Element.cpp

    r150876 r151071  
    10281028        classAttributeChanged(newValue);
    10291029    else if (name == HTMLNames::nameAttr)
    1030         setHasName(!newValue.isNull());
     1030        elementData()->m_hasNameAttribute = newValue.isNull();
    10311031    else if (name == HTMLNames::pseudoAttr)
    10321032        shouldInvalidateStyle |= testShouldInvalidateStyle && isInShadowTree();
     
    31943194    : m_isUnique(true)
    31953195    , m_arraySize(0)
     3196    , m_hasNameAttribute(false)
    31963197    , m_presentationAttributeStyleIsDirty(false)
    31973198    , m_styleAttributeIsDirty(false)
     
    32053206    : m_isUnique(false)
    32063207    , m_arraySize(arraySize)
     3208    , m_hasNameAttribute(false)
    32073209    , m_presentationAttributeStyleIsDirty(false)
    32083210    , m_styleAttributeIsDirty(false)
     
    32663268    : m_isUnique(isUnique)
    32673269    , m_arraySize(isUnique ? 0 : other.length())
     3270    , m_hasNameAttribute(other.m_hasNameAttribute)
    32683271    , m_presentationAttributeStyleIsDirty(other.m_presentationAttributeStyleIsDirty)
    32693272    , m_styleAttributeIsDirty(other.m_styleAttributeIsDirty)
  • trunk/Source/WebCore/dom/Element.h

    r151069 r151071  
    8484    bool hasID() const { return !m_idForStyleResolution.isNull(); }
    8585    bool hasClass() const { return !m_classNames.isNull(); }
     86    bool hasName() const { return m_hasNameAttribute; }
    8687
    8788    bool isEquivalent(const ElementData* other) const;
     
    9596
    9697    unsigned m_isUnique : 1;
    97     unsigned m_arraySize : 28;
     98    unsigned m_arraySize : 27;
     99    mutable unsigned m_hasNameAttribute : 1;
    98100    mutable unsigned m_presentationAttributeStyleIsDirty : 1;
    99101    mutable unsigned m_styleAttributeIsDirty : 1;
     
    628630    bool hasID() const;
    629631    bool hasClass() const;
     632    bool hasName() const;
    630633    const SpaceSplitString& classNames() const;
    631634
     
    909912}
    910913
     914inline bool Element::hasName() const
     915{
     916    return elementData() && elementData()->hasName();
     917}
     918
    911919inline UniqueElementData* Element::ensureUniqueElementData()
    912920{
  • trunk/Source/WebCore/dom/Node.h

    r151069 r151071  
    328328    virtual void startLoadingDynamicSheet() { ASSERT_NOT_REACHED(); }
    329329
    330     bool hasName() const { return !isTextNode() && getFlag(HasNameOrIsEditingTextFlag); }
    331 
    332330    bool isUserActionElement() const { return getFlag(IsUserActionElement); }
    333331    void setUserActionElement(bool flag) { setFlag(flag, IsUserActionElement); }
     
    339337    bool childNeedsStyleRecalc() const { return getFlag(ChildNeedsStyleRecalcFlag); }
    340338    bool isLink() const { return getFlag(IsLinkFlag); }
    341     bool isEditingText() const { return isTextNode() && getFlag(HasNameOrIsEditingTextFlag); }
    342 
    343     void setHasName(bool f) { ASSERT(!isTextNode()); setFlag(f, HasNameOrIsEditingTextFlag); }
     339    bool isEditingText() const { return getFlag(IsEditingTextFlag); }
     340
    344341    void setChildNeedsStyleRecalc() { setFlag(ChildNeedsStyleRecalcFlag); }
    345342    void clearChildNeedsStyleRecalc() { clearFlag(ChildNeedsStyleRecalcFlag); }
     
    662659        SelfOrAncestorHasDirAutoFlag = 1 << 17,
    663660
    664         HasNameOrIsEditingTextFlag = 1 << 18,
     661        IsEditingTextFlag = 1 << 18,
    665662
    666663        InNamedFlowFlag = 1 << 19,
     
    696693        CreateDocument = CreateContainer | InDocumentFlag,
    697694        CreateInsertionPoint = CreateHTMLElement | NeedsShadowTreeWalkerFlag,
    698         CreateEditingText = CreateText | HasNameOrIsEditingTextFlag,
     695        CreateEditingText = CreateText | IsEditingTextFlag,
    699696    };
    700697    Node(Document*, ConstructionType);
Note: See TracChangeset for help on using the changeset viewer.