Changeset 235780 in webkit


Ignore:
Timestamp:
Sep 6, 2018 10:55:15 PM (6 years ago)
Author:
rniwa@webkit.org
Message:

ShadowRoot should have its own node flag
https://bugs.webkit.org/show_bug.cgi?id=189392

Reviewed by Antti Koivisto.

Added IsShadowRootFlag and IsDocumentNodeFlag, and removed IsDocumentFragmentFlag and IsStyledElementFlag.
Also re-ordered flags to group flags used by subclasses below ones directly used by Node in
accordinate with the comment.

No new tests since there should be no behavioral change.

  • dom/ContainerNode.h:

(WebCore::Node::isTreeScope const): Deleted.

  • dom/Node.h:

(WebCore::Node::isStyledElement const): Check if this is a HTML, SVG, or MathML element instead.
(WebCore::Node::isDocumentNode const): Simply check IsDocumentNodeFlag.
(WebCore::Node::isTreeScope const): Check if this is a document or a shadow root Instead of comparing
the tree scope to this.
(WebCore::Node::isDocumentFragment const): Check if this is a container node which is neither document,
element, nor shadow root.
(WebCore::Node::isShadowRoot const): Simply check IsShadowRootFlag. This is the change needed to fix
the blockign bug 166748.
(WebCore::Node::flagIsShadowRoot): Added. Will be used in the bug 166748.

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r235777 r235780  
     12018-09-06  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        ShadowRoot should have its own node flag
     4        https://bugs.webkit.org/show_bug.cgi?id=189392
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Added IsShadowRootFlag and IsDocumentNodeFlag, and removed IsDocumentFragmentFlag and IsStyledElementFlag.
     9        Also re-ordered flags to group flags used by subclasses below ones directly used by Node in
     10        accordinate with the comment.
     11
     12        No new tests since there should be no behavioral change.
     13
     14        * dom/ContainerNode.h:
     15        (WebCore::Node::isTreeScope const): Deleted.
     16        * dom/Node.h:
     17        (WebCore::Node::isStyledElement const): Check if this is a HTML, SVG, or MathML element instead.
     18        (WebCore::Node::isDocumentNode const): Simply check IsDocumentNodeFlag.
     19        (WebCore::Node::isTreeScope const): Check if this is a document or a shadow root Instead of comparing
     20        the tree scope to this.
     21        (WebCore::Node::isDocumentFragment const): Check if this is a container node which is neither document,
     22        element, nor shadow root.
     23        (WebCore::Node::isShadowRoot const): Simply check IsShadowRootFlag. This is the change needed to fix
     24        the blockign bug 166748.
     25        (WebCore::Node::flagIsShadowRoot): Added. Will be used in the bug 166748.
     26
    1272018-09-06  Zalan Bujtas  <zalan@apple.com>
    228
  • trunk/Source/WebCore/dom/ContainerNode.h

    r229694 r235780  
    193193}
    194194
    195 inline bool Node::isTreeScope() const
    196 {
    197     return &treeScope().rootNode() == this;
    198 }
    199 
    200195inline Node& Node::rootNode() const
    201196{
  • trunk/Source/WebCore/dom/Node.h

    r232178 r235780  
    213213    virtual bool isWebVTTElement() const { return false; }
    214214#endif
    215     bool isStyledElement() const { return getFlag(IsStyledElementFlag); }
     215    bool isStyledElement() const { return getFlag(IsHTMLFlag) || getFlag(IsSVGFlag) || getFlag(IsMathMLFlag); }
    216216    virtual bool isAttributeNode() const { return false; }
    217217    virtual bool isCharacterDataNode() const { return false; }
     
    223223#endif
    224224
    225     bool isDocumentNode() const { return getFlag(IsContainerFlag) && !getFlag(IsElementFlag) && !getFlag(IsDocumentFragmentFlag); }
    226     bool isTreeScope() const;
    227     bool isDocumentFragment() const { return getFlag(IsDocumentFragmentFlag); }
    228     bool isShadowRoot() const { return isDocumentFragment() && isTreeScope(); }
     225    bool isDocumentNode() const { return getFlag(IsDocumentNodeFlag); }
     226    bool isTreeScope() const { return getFlag(IsDocumentNodeFlag) || getFlag(IsShadowRootFlag); }
     227    bool isDocumentFragment() const { return getFlag(IsContainerFlag) && !(getFlag(IsElementFlag) || getFlag(IsDocumentNodeFlag)); }
     228    bool isShadowRoot() const { return getFlag(IsShadowRootFlag); }
    229229
    230230    bool hasCustomStyleResolveCallbacks() const { return getFlag(HasCustomStyleResolveCallbacksFlag); }
     
    539539    static int32_t flagIsContainer() { return IsContainerFlag; }
    540540    static int32_t flagIsElement() { return IsElementFlag; }
     541    static int32_t flagIsShadowRoot() { return IsShadowRootFlag; }
    541542    static int32_t flagIsHTML() { return IsHTMLFlag; }
    542543    static int32_t flagIsLink() { return IsLinkFlag; }
     
    556557        IsContainerFlag = 1 << 1,
    557558        IsElementFlag = 1 << 2,
    558         IsStyledElementFlag = 1 << 3,
    559         IsHTMLFlag = 1 << 4,
    560         IsSVGFlag = 1 << 5,
    561         DescendantsAffectedByPreviousSiblingFlag = 1 << 6,
    562         ChildNeedsStyleRecalcFlag = 1 << 7,
    563         IsConnectedFlag = 1 << 8,
    564         IsLinkFlag = 1 << 9,
    565         IsUserActionElement = 1 << 10,
    566         HasRareDataFlag = 1 << 11,
    567         IsDocumentFragmentFlag = 1 << 12,
     559        IsHTMLFlag = 1 << 3,
     560        IsSVGFlag = 1 << 4,
     561        IsMathMLFlag = 1 << 5,
     562        IsConnectedFlag = 1 << 6,
     563        IsInShadowTreeFlag = 1 << 7,
     564        IsDocumentNodeFlag = 1 << 8,
     565        IsShadowRootFlag = 1 << 9,
     566        HasRareDataFlag = 1 << 10,
     567        HasEventTargetDataFlag = 1 << 11,
    568568
    569569        // These bits are used by derived classes, pulled up here so they can
    570570        // be stored in the same memory word as the Node bits above.
     571        ChildNeedsStyleRecalcFlag = 1 << 12, // ContainerNode
     572
    571573        IsParsingChildrenFinishedFlag = 1 << 13, // Element
    572574        StyleValidityShift = 14,
     
    577579        HasSyntheticAttrChildNodesFlag = 1 << 19,
    578580        HasCustomStyleResolveCallbacksFlag = 1 << 20,
    579         HasEventTargetDataFlag = 1 << 21,
     581        DescendantsAffectedByPreviousSiblingFlag = 1 << 21,
    580582        IsCustomElement = 1 << 22,
    581         IsInShadowTreeFlag = 1 << 23,
    582         IsMathMLFlag = 1 << 24,
     583        IsLinkFlag = 1 << 23,
     584        IsUserActionElement = 1 << 24,
    583585
    584586        ChildrenAffectedByFirstChildRulesFlag = 1 << 25,
     
    610612        CreateElement = CreateContainer | IsElementFlag,
    611613        CreatePseudoElement =  CreateElement | IsConnectedFlag,
    612         CreateShadowRoot = CreateContainer | IsDocumentFragmentFlag | IsInShadowTreeFlag,
    613         CreateDocumentFragment = CreateContainer | IsDocumentFragmentFlag,
    614         CreateStyledElement = CreateElement | IsStyledElementFlag,
    615         CreateHTMLElement = CreateStyledElement | IsHTMLFlag,
    616         CreateSVGElement = CreateStyledElement | IsSVGFlag | HasCustomStyleResolveCallbacksFlag,
    617         CreateDocument = CreateContainer | IsConnectedFlag,
     614        CreateShadowRoot = CreateContainer | IsShadowRootFlag | IsInShadowTreeFlag,
     615        CreateDocumentFragment = CreateContainer,
     616        CreateHTMLElement = CreateElement | IsHTMLFlag,
     617        CreateSVGElement = CreateElement | IsSVGFlag | HasCustomStyleResolveCallbacksFlag,
     618        CreateMathMLElement = CreateElement | IsMathMLFlag,
     619        CreateDocument = CreateContainer | IsDocumentNodeFlag | IsConnectedFlag,
    618620        CreateEditingText = CreateText | IsEditingTextOrUndefinedCustomElementFlag,
    619         CreateMathMLElement = CreateStyledElement | IsMathMLFlag
    620621    };
    621622    Node(Document&, ConstructionType);
Note: See TracChangeset for help on using the changeset viewer.