Changeset 266776 in webkit


Ignore:
Timestamp:
Sep 9, 2020, 2:03:48 AM (5 years ago)
Author:
rniwa@webkit.org
Message:

Node flags should be an OptionSet
https://bugs.webkit.org/show_bug.cgi?id=216305

Reviewed by Antti Koivisto.

Source/WebCore:

This patch renames NodeFlags to NodeFlag and turns into an enum class and changes the type of
m_nodeFlags from uint32_t to OptionSet<NodeFlag> as there is no state stored there after r266769.

This patch also introduces two new NodeFlag for identifying CharacterData and DocumentFragment
to simplify the type check conditions for these nodes now that we have plenty of free bits.

No new tests since there should be no behavioral change.

  • dom/CharacterData.h:

(WebCore::CharacterData::CharacterData): Sets NodeFlag::IsContainerNode via CreateCharacterData.
(WebCore::CharacterData::virtualIsCharacterData): Deleted.

  • dom/Comment.cpp:

(WebCore::Comment::Comment): Ditto.

  • dom/Element.cpp:

(WebCore::Element::setHasFocusWithin):
(WebCore::Element::removedFromAncestor):
(WebCore::Element::setContainsFullScreenElement):
(WebCore::Element::createElementIdentifier):

  • dom/Element.h:

(WebCore::Element::hasFocusWithin const):
(WebCore::Element::hasPendingResources const):
(WebCore::Element::setHasPendingResources):
(WebCore::Element::clearHasPendingResources):
(WebCore::Element::hasCSSAnimation const):
(WebCore::Element::setHasCSSAnimation):
(WebCore::Element::clearHasCSSAnimation):
(WebCore::Element::containsFullScreenElement const):

  • dom/Node.cpp:

(WebCore::Node::insertedIntoAncestor):
(WebCore::Node::removedFromAncestor):

  • dom/Node.h:

(WebCore::Node::isElementNode const):
(WebCore::Node::isContainerNode const):
(WebCore::Node::isTextNode const):
(WebCore::Node::isHTMLElement const):
(WebCore::Node::isSVGElement const):
(WebCore::Node::isMathMLElement const):
(WebCore::Node::isStyledElement const):
(WebCore::Node::isCharacterDataNode const): Check the newly added NodeFlag::IsContainerNode.
(WebCore::Node::isDocumentNode const):
(WebCore::Node::isTreeScope const):
(WebCore::Node::isDocumentFragment const):: Check the newly added NodeFlag::IsDocumentFragment.
(WebCore::Node::isShadowRoot const):
(WebCore::Node::hasCustomStyleResolveCallbacks const):
(WebCore::Node::hasSyntheticAttrChildNodes const):
(WebCore::Node::setHasSyntheticAttrChildNodes):
(WebCore::Node::selfOrAncestorHasDirAutoAttribute const):
(WebCore::Node::setSelfOrAncestorHasDirAutoAttribute):
(WebCore::Node::isUserActionElement const):
(WebCore::Node::setUserActionElement):
(WebCore::Node::isEditingText const): Removed the check for IsTextFlag since this is no longer needed
after r266769 as no longer share the bit for IsEditingText with an unknown custom element.
(WebCore::Node::isLink const):
(WebCore::Node::setIsLink):
(WebCore::Node::hasEventTargetData const):
(WebCore::Node::setHasEventTargetData):
(WebCore::Node::isConnected const):
(WebCore::Node::isInShadowTree const):
(WebCore::Node::isInTreeScope const):
(WebCore::Node::flagIsText):
(WebCore::Node::flagIsContainer):
(WebCore::Node::flagIsElement):
(WebCore::Node::flagIsShadowRoot):
(WebCore::Node::flagIsHTML):
(WebCore::Node::flagIsLink):
(WebCore::Node::flagHasFocusWithin):
(WebCore::Node::flagIsParsingChildrenFinished):
(WebCore::Node::NodeFlag): Renamed from NodeFlags and made it an enum class, and introduced IsCharacterData
and IsDocumentFragment and removed "Flag" suffix from various flags.
(WebCore::Node::hasNodeFlag const): Renamed from getFlag for clarity.
(WebCore::Node::setNodeFlag const): Ditto from setFlag. Also merge the two versions of setFlag one of which
took a boolean arugment as the first argument by making this a second optional argument.
(WebCore::Node::clearNodeFlag const): Ditto.
(WebCore::Node::isParsingChildrenFinished const):
(WebCore::Node::setIsParsingChildrenFinished):
(WebCore::Node::clearIsParsingChildrenFinished):
(WebCore::Node::ConstructionType): This is now an alias to OptionSet<NodeFlag> instead of a separate enum.
(WebCore::Node::setHasCustomStyleResolveCallbacks):
(WebCore::Node::virtualIsCharacterData const): Deleted.

  • dom/ProcessingInstruction.cpp:

(WebCore::ProcessingInstruction::ProcessingInstruction): Sets NodeFlag::IsContainerNode via CharacterData's
constructor's default argument value.

Source/WTF:

  • wtf/OptionSet.h:

(WTF::OptionSet::set): Added.

Location:
trunk/Source
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r266713 r266776  
     12020-09-08  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Node flags should be an OptionSet
     4        https://bugs.webkit.org/show_bug.cgi?id=216305
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * wtf/OptionSet.h:
     9        (WTF::OptionSet::set): Added.
     10
    1112020-09-06  Ryosuke Niwa  <rniwa@webkit.org>
    212
  • trunk/Source/WTF/wtf/OptionSet.h

    r264277 r266776  
    194194    }
    195195
     196    constexpr void set(OptionSet optionSet, bool value)
     197    {
     198        m_storage = (m_storage & ~optionSet.m_storage) | (-static_cast<StorageType>(value) & optionSet.m_storage);
     199    }
     200
    196201    constexpr bool hasExactlyOneBitSet() const
    197202    {
  • trunk/Source/WebCore/ChangeLog

    r266769 r266776  
     12020-09-08  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Node flags should be an OptionSet
     4        https://bugs.webkit.org/show_bug.cgi?id=216305
     5
     6        Reviewed by Antti Koivisto.
     7
     8        This patch renames NodeFlags to NodeFlag and turns into an enum class and changes the type of
     9        m_nodeFlags from uint32_t to OptionSet<NodeFlag> as there is no state stored there after r266769.
     10
     11        This patch also introduces two new NodeFlag for identifying CharacterData and DocumentFragment
     12        to simplify the type check conditions for these nodes now that we have plenty of free bits.
     13
     14        No new tests since there should be no behavioral change.
     15
     16        * dom/CharacterData.h:
     17        (WebCore::CharacterData::CharacterData): Sets NodeFlag::IsContainerNode via CreateCharacterData.
     18        (WebCore::CharacterData::virtualIsCharacterData): Deleted.
     19        * dom/Comment.cpp:
     20        (WebCore::Comment::Comment): Ditto.
     21        * dom/Element.cpp:
     22        (WebCore::Element::setHasFocusWithin):
     23        (WebCore::Element::removedFromAncestor):
     24        (WebCore::Element::setContainsFullScreenElement):
     25        (WebCore::Element::createElementIdentifier):
     26        * dom/Element.h:
     27        (WebCore::Element::hasFocusWithin const):
     28        (WebCore::Element::hasPendingResources const):
     29        (WebCore::Element::setHasPendingResources):
     30        (WebCore::Element::clearHasPendingResources):
     31        (WebCore::Element::hasCSSAnimation const):
     32        (WebCore::Element::setHasCSSAnimation):
     33        (WebCore::Element::clearHasCSSAnimation):
     34        (WebCore::Element::containsFullScreenElement const):
     35        * dom/Node.cpp:
     36        (WebCore::Node::insertedIntoAncestor):
     37        (WebCore::Node::removedFromAncestor):
     38        * dom/Node.h:
     39        (WebCore::Node::isElementNode const):
     40        (WebCore::Node::isContainerNode const):
     41        (WebCore::Node::isTextNode const):
     42        (WebCore::Node::isHTMLElement const):
     43        (WebCore::Node::isSVGElement const):
     44        (WebCore::Node::isMathMLElement const):
     45        (WebCore::Node::isStyledElement const):
     46        (WebCore::Node::isCharacterDataNode const): Check the newly added NodeFlag::IsContainerNode.
     47        (WebCore::Node::isDocumentNode const):
     48        (WebCore::Node::isTreeScope const):
     49        (WebCore::Node::isDocumentFragment const):: Check the newly added NodeFlag::IsDocumentFragment.
     50        (WebCore::Node::isShadowRoot const):
     51        (WebCore::Node::hasCustomStyleResolveCallbacks const):
     52        (WebCore::Node::hasSyntheticAttrChildNodes const):
     53        (WebCore::Node::setHasSyntheticAttrChildNodes):
     54        (WebCore::Node::selfOrAncestorHasDirAutoAttribute const):
     55        (WebCore::Node::setSelfOrAncestorHasDirAutoAttribute):
     56        (WebCore::Node::isUserActionElement const):
     57        (WebCore::Node::setUserActionElement):
     58        (WebCore::Node::isEditingText const): Removed the check for IsTextFlag since this is no longer needed
     59        after r266769 as no longer share the bit for IsEditingText with an unknown custom element.
     60        (WebCore::Node::isLink const):
     61        (WebCore::Node::setIsLink):
     62        (WebCore::Node::hasEventTargetData const):
     63        (WebCore::Node::setHasEventTargetData):
     64        (WebCore::Node::isConnected const):
     65        (WebCore::Node::isInShadowTree const):
     66        (WebCore::Node::isInTreeScope const):
     67        (WebCore::Node::flagIsText):
     68        (WebCore::Node::flagIsContainer):
     69        (WebCore::Node::flagIsElement):
     70        (WebCore::Node::flagIsShadowRoot):
     71        (WebCore::Node::flagIsHTML):
     72        (WebCore::Node::flagIsLink):
     73        (WebCore::Node::flagHasFocusWithin):
     74        (WebCore::Node::flagIsParsingChildrenFinished):
     75        (WebCore::Node::NodeFlag): Renamed from NodeFlags and made it an enum class, and introduced IsCharacterData
     76        and IsDocumentFragment and removed "Flag" suffix from various flags.
     77        (WebCore::Node::hasNodeFlag const): Renamed from getFlag for clarity.
     78        (WebCore::Node::setNodeFlag const): Ditto from setFlag. Also merge the two versions of setFlag one of which
     79        took a boolean arugment as the first argument by making this a second optional argument.
     80        (WebCore::Node::clearNodeFlag const): Ditto.
     81        (WebCore::Node::isParsingChildrenFinished const):
     82        (WebCore::Node::setIsParsingChildrenFinished):
     83        (WebCore::Node::clearIsParsingChildrenFinished):
     84        (WebCore::Node::ConstructionType): This is now an alias to OptionSet<NodeFlag> instead of a separate enum.
     85        (WebCore::Node::setHasCustomStyleResolveCallbacks):
     86        (WebCore::Node::virtualIsCharacterData const): Deleted.
     87        * dom/ProcessingInstruction.cpp:
     88        (WebCore::ProcessingInstruction::ProcessingInstruction): Sets NodeFlag::IsContainerNode via CharacterData's
     89        constructor's default argument value.
     90
    1912020-09-08  Ryosuke Niwa  <rniwa@webkit.org>
    292
  • trunk/Source/WebCore/dom/CharacterData.h

    r264305 r266776  
    4747
    4848protected:
    49     CharacterData(Document& document, const String& text, ConstructionType type)
     49    CharacterData(Document& document, const String& text, ConstructionType type = CreateCharacterData)
    5050        : Node(document, type)
    5151        , m_data(!text.isNull() ? text : emptyString())
    5252    {
    53         ASSERT(type == CreateOther || type == CreateText || type == CreateEditingText);
     53        ASSERT(type == CreateCharacterData || type == CreateText || type == CreateEditingText);
    5454    }
    5555
     
    6464    String nodeValue() const final;
    6565    ExceptionOr<void> setNodeValue(const String&) final;
    66     bool virtualIsCharacterData() const final { return true; }
    6766    void notifyParentAfterChange(ContainerNode::ChildChangeSource);
    6867
  • trunk/Source/WebCore/dom/Comment.cpp

    r233122 r266776  
    3131
    3232inline Comment::Comment(Document& document, const String& text)
    33     : CharacterData(document, text, CreateOther)
     33    : CharacterData(document, text)
    3434{
    3535}
  • trunk/Source/WebCore/dom/Element.cpp

    r266769 r266776  
    742742    {
    743743        Style::PseudoClassChangeInvalidation styleInvalidation(*this, CSSSelector::PseudoClassFocusWithin);
    744         setFlag(flag, HasFocusWithin);
     744        setNodeFlag(NodeFlag::HasFocusWithin, flag);
    745745    }
    746746}
     
    22922292#endif
    22932293
    2294     if (getFlag(HasElementIdentifierFlag)) {
     2294    if (hasNodeFlag(NodeFlag::HasElementIdentifier)) {
    22952295        document().identifiedElementWasRemovedFromDocument(*this);
    2296         clearFlag(HasElementIdentifierFlag);
     2296        clearNodeFlag(NodeFlag::HasElementIdentifier);
    22972297    }
    22982298}
     
    37503750{
    37513751    if (flag)
    3752         setFlag(ContainsFullScreenElementFlag);
     3752        setNodeFlag(NodeFlag::ContainsFullScreenElement);
    37533753    else
    3754         clearFlag(ContainsFullScreenElementFlag);
     3754        clearNodeFlag(NodeFlag::ContainsFullScreenElement);
    37553755    invalidateStyleAndLayerComposition();
    37563756}
     
    46064606ElementIdentifier Element::createElementIdentifier()
    46074607{
    4608     ASSERT(!getFlag(HasElementIdentifierFlag));
    4609     setFlag(HasElementIdentifierFlag);
     4608    ASSERT(!hasNodeFlag(NodeFlag::HasElementIdentifier));
     4609    setNodeFlag(NodeFlag::HasElementIdentifier);
    46104610    return ElementIdentifier::generate();
    46114611}
  • trunk/Source/WebCore/dom/Element.h

    r266714 r266776  
    321321    bool focused() const { return isUserActionElement() && isUserActionElementFocused(); }
    322322    bool isBeingDragged() const { return isUserActionElement() && isUserActionElementDragged(); }
    323     bool hasFocusWithin() const { return getFlag(HasFocusWithin); };
     323    bool hasFocusWithin() const { return hasNodeFlag(NodeFlag::HasFocusWithin); };
    324324
    325325    virtual void setActive(bool = true, bool pause = false);
     
    482482    virtual bool childShouldCreateRenderer(const Node&) const;
    483483
    484     bool hasPendingResources() const { return getFlag(HasPendingResourcesFlag); }
    485     void setHasPendingResources() { setFlag(HasPendingResourcesFlag); }
    486     void clearHasPendingResources() { clearFlag(HasPendingResourcesFlag); }
     484    bool hasPendingResources() const { return hasNodeFlag(NodeFlag::HasPendingResources); }
     485    void setHasPendingResources() { setNodeFlag(NodeFlag::HasPendingResources); }
     486    void clearHasPendingResources() { clearNodeFlag(NodeFlag::HasPendingResources); }
    487487    virtual void buildPendingResource() { };
    488488
    489     bool hasCSSAnimation() const { return getFlag(HasCSSAnimationFlag); }
    490     void setHasCSSAnimation() { setFlag(HasCSSAnimationFlag); }
    491     void clearHasCSSAnimation() { clearFlag(HasCSSAnimationFlag); }
     489    bool hasCSSAnimation() const { return hasNodeFlag(NodeFlag::HasCSSAnimation); }
     490    void setHasCSSAnimation() { setNodeFlag(NodeFlag::HasCSSAnimation); }
     491    void clearHasCSSAnimation() { clearNodeFlag(NodeFlag::HasCSSAnimation); }
    492492
    493493    KeyframeEffectStack* keyframeEffectStack() const;
     
    514514
    515515#if ENABLE(FULLSCREEN_API)
    516     bool containsFullScreenElement() const { return getFlag(ContainsFullScreenElementFlag); }
     516    bool containsFullScreenElement() const { return hasNodeFlag(NodeFlag::ContainsFullScreenElement); }
    517517    void setContainsFullScreenElement(bool);
    518518    void setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(bool);
  • trunk/Source/WebCore/dom/Node.cpp

    r266769 r266776  
    12991299{
    13001300    if (insertionType.connectedToDocument)
    1301         setFlag(IsConnectedFlag);
     1301        setNodeFlag(NodeFlag::IsConnected);
    13021302    if (parentOfInsertedTree.isInShadowTree())
    1303         setFlag(IsInShadowTreeFlag);
     1303        setNodeFlag(NodeFlag::IsInShadowTree);
    13041304
    13051305    invalidateStyle(Style::Validity::SubtreeAndRenderersInvalid);
     
    13111311{
    13121312    if (removalType.disconnectedFromDocument)
    1313         clearFlag(IsConnectedFlag);
     1313        clearNodeFlag(NodeFlag::IsConnected);
    13141314    if (isInShadowTree() && !treeScope().rootNode().isShadowRoot())
    1315         clearFlag(IsInShadowTreeFlag);
     1315        clearNodeFlag(NodeFlag::IsInShadowTree);
    13161316    if (removalType.disconnectedFromDocument) {
    13171317        if (auto* cache = oldParentOfRemovedTree.document().existingAXObjectCache())
  • trunk/Source/WebCore/dom/Node.h

    r266769 r266776  
    187187    // Other methods (not part of DOM)
    188188
    189     bool isElementNode() const { return getFlag(IsElementFlag); }
    190     bool isContainerNode() const { return getFlag(IsContainerFlag); }
    191     bool isTextNode() const { return getFlag(IsTextFlag); }
    192     bool isHTMLElement() const { return getFlag(IsHTMLFlag); }
    193     bool isSVGElement() const { return getFlag(IsSVGFlag); }
    194     bool isMathMLElement() const { return getFlag(IsMathMLFlag); }
     189    bool isElementNode() const { return hasNodeFlag(NodeFlag::IsElement); }
     190    bool isContainerNode() const { return hasNodeFlag(NodeFlag::IsContainerNode); }
     191    bool isTextNode() const { return hasNodeFlag(NodeFlag::IsText); }
     192    bool isHTMLElement() const { return hasNodeFlag(NodeFlag::IsHTMLElement); }
     193    bool isSVGElement() const { return hasNodeFlag(NodeFlag::IsSVGElement); }
     194    bool isMathMLElement() const { return hasNodeFlag(NodeFlag::IsMathMLElement); }
    195195
    196196    bool isPseudoElement() const { return pseudoId() != PseudoId::None; }
     
    202202    virtual bool isWebVTTElement() const { return false; }
    203203#endif
    204     bool isStyledElement() const { return getFlag(IsHTMLFlag) || getFlag(IsSVGFlag) || getFlag(IsMathMLFlag); }
     204    bool isStyledElement() const { return hasNodeFlag(NodeFlag::IsHTMLElement) || hasNodeFlag(NodeFlag::IsSVGElement) || hasNodeFlag(NodeFlag::IsMathMLElement); }
    205205    virtual bool isAttributeNode() const { return false; }
    206     bool isCharacterDataNode() const { return !isContainerNode() && (isTextNode() || virtualIsCharacterData()); }
     206    bool isCharacterDataNode() const { return hasNodeFlag(NodeFlag::IsCharacterData); }
    207207    virtual bool isFrameOwnerElement() const { return false; }
    208208    virtual bool isPluginElement() const { return false; }
     
    212212#endif
    213213
    214     bool isDocumentNode() const { return getFlag(IsDocumentNodeFlag); }
    215     bool isTreeScope() const { return getFlag(IsDocumentNodeFlag) || getFlag(IsShadowRootFlag); }
    216     bool isDocumentFragment() const { return getFlag(IsContainerFlag) && !(getFlag(IsElementFlag) || getFlag(IsDocumentNodeFlag)); }
    217     bool isShadowRoot() const { return getFlag(IsShadowRootFlag); }
    218 
    219     bool hasCustomStyleResolveCallbacks() const { return getFlag(HasCustomStyleResolveCallbacksFlag); }
    220 
    221     bool hasSyntheticAttrChildNodes() const { return getFlag(HasSyntheticAttrChildNodesFlag); }
    222     void setHasSyntheticAttrChildNodes(bool flag) { setFlag(flag, HasSyntheticAttrChildNodesFlag); }
     214    bool isDocumentNode() const { return hasNodeFlag(NodeFlag::IsDocumentNode); }
     215    bool isTreeScope() const { return hasNodeFlag(NodeFlag::IsDocumentNode) || hasNodeFlag(NodeFlag::IsShadowRoot); }
     216    bool isDocumentFragment() const { return hasNodeFlag(NodeFlag::IsDocumentFragment); }
     217    bool isShadowRoot() const { return hasNodeFlag(NodeFlag::IsShadowRoot); }
     218
     219    bool hasCustomStyleResolveCallbacks() const { return hasNodeFlag(NodeFlag::HasCustomStyleResolveCallbacks); }
     220
     221    bool hasSyntheticAttrChildNodes() const { return hasNodeFlag(NodeFlag::HasSyntheticAttrChildNodes); }
     222    void setHasSyntheticAttrChildNodes(bool flag) { setNodeFlag(NodeFlag::HasSyntheticAttrChildNodes, flag); }
    223223
    224224    // If this node is in a shadow tree, returns its shadow host. Otherwise, returns null.
     
    261261    ContainerNode* nonShadowBoundaryParentNode() const;
    262262
    263     bool selfOrAncestorHasDirAutoAttribute() const { return getFlag(SelfOrAncestorHasDirAutoFlag); }
    264     void setSelfOrAncestorHasDirAutoAttribute(bool flag) { setFlag(flag, SelfOrAncestorHasDirAutoFlag); }
     263    bool selfOrAncestorHasDirAutoAttribute() const { return hasNodeFlag(NodeFlag::SelfOrAncestorHasDirAuto); }
     264    void setSelfOrAncestorHasDirAutoAttribute(bool flag) { setNodeFlag(NodeFlag::SelfOrAncestorHasDirAuto, flag); }
    265265
    266266    // Returns the enclosing event parent Element (or self) that, when clicked, would trigger a navigation.
     
    290290    virtual void startLoadingDynamicSheet() { ASSERT_NOT_REACHED(); }
    291291
    292     bool isUserActionElement() const { return getFlag(IsUserActionElement); }
    293     void setUserActionElement(bool flag) { setFlag(flag, IsUserActionElement); }
     292    bool isUserActionElement() const { return hasNodeFlag(NodeFlag::IsUserActionElement); }
     293    void setUserActionElement(bool flag) { setNodeFlag(NodeFlag::IsUserActionElement, flag); }
    294294
    295295    bool inRenderedDocument() const;
     
    298298    bool styleResolutionShouldRecompositeLayer() const { return hasStyleFlag(NodeStyleFlag::StyleResolutionShouldRecompositeLayer); }
    299299    bool childNeedsStyleRecalc() const { return hasStyleFlag(NodeStyleFlag::DescendantNeedsStyleResolution); }
    300     bool isEditingText() const { return getFlag(IsTextFlag) && getFlag(IsEditingText); }
     300    bool isEditingText() const { return hasNodeFlag(NodeFlag::IsEditingText); }
    301301
    302302    void setChildNeedsStyleRecalc() { setStyleFlag(NodeStyleFlag::DescendantNeedsStyleResolution); }
     
    305305    void setHasValidStyle();
    306306
    307     bool isLink() const { return getFlag(IsLinkFlag); }
    308     void setIsLink(bool flag) { setFlag(flag, IsLinkFlag); }
    309 
    310     bool hasEventTargetData() const { return getFlag(HasEventTargetDataFlag); }
    311     void setHasEventTargetData(bool flag) { setFlag(flag, HasEventTargetDataFlag); }
     307    bool isLink() const { return hasNodeFlag(NodeFlag::IsLink); }
     308    void setIsLink(bool flag) { setNodeFlag(NodeFlag::IsLink, flag); }
     309
     310    bool hasEventTargetData() const { return hasNodeFlag(NodeFlag::HasEventTargetData); }
     311    void setHasEventTargetData(bool flag) { setNodeFlag(NodeFlag::HasEventTargetData, flag); }
    312312
    313313    WEBCORE_EXPORT bool isContentEditable();
     
    357357    // Returns true if this node is associated with a document and is in its associated document's
    358358    // node tree, false otherwise (https://dom.spec.whatwg.org/#connected).
    359     bool isConnected() const { return getFlag(IsConnectedFlag); }
     359    bool isConnected() const { return hasNodeFlag(NodeFlag::IsConnected); }
    360360    bool isInUserAgentShadowTree() const;
    361     bool isInShadowTree() const { return getFlag(IsInShadowTreeFlag); }
    362     bool isInTreeScope() const { return getFlag(static_cast<NodeFlags>(IsConnectedFlag | IsInShadowTreeFlag)); }
     361    bool isInShadowTree() const { return hasNodeFlag(NodeFlag::IsInShadowTree); }
     362    bool isInTreeScope() const { return hasNodeFlag(NodeFlag::IsConnected) || hasNodeFlag(NodeFlag::IsInShadowTree); }
    363363
    364364    bool isDocumentTypeNode() const { return nodeType() == DOCUMENT_TYPE_NODE; }
     
    507507    static uint32_t rareDataPointerMask() { return -1; }
    508508#endif
    509     static int32_t flagIsText() { return IsTextFlag; }
    510     static int32_t flagIsContainer() { return IsContainerFlag; }
    511     static int32_t flagIsElement() { return IsElementFlag; }
    512     static int32_t flagIsShadowRoot() { return IsShadowRootFlag; }
    513     static int32_t flagIsHTML() { return IsHTMLFlag; }
    514     static int32_t flagIsLink() { return IsLinkFlag; }
    515     static int32_t flagHasFocusWithin() { return HasFocusWithin; }
    516     static int32_t flagIsParsingChildrenFinished() { return IsParsingChildrenFinishedFlag; }
     509    static int32_t flagIsText() { return static_cast<int32_t>(NodeFlag::IsText); }
     510    static int32_t flagIsContainer() { return static_cast<int32_t>(NodeFlag::IsContainerNode); }
     511    static int32_t flagIsElement() { return static_cast<int32_t>(NodeFlag::IsElement); }
     512    static int32_t flagIsShadowRoot() { return static_cast<int32_t>(NodeFlag::IsShadowRoot); }
     513    static int32_t flagIsHTML() { return static_cast<int32_t>(NodeFlag::IsHTMLElement); }
     514    static int32_t flagIsLink() { return static_cast<int32_t>(NodeFlag::IsLink); }
     515    static int32_t flagHasFocusWithin() { return static_cast<int32_t>(NodeFlag::HasFocusWithin); }
     516    static int32_t flagIsParsingChildrenFinished() { return static_cast<int32_t>(NodeFlag::IsParsingChildrenFinished); }
    517517#endif // ENABLE(JIT)
    518518
    519519protected:
    520     enum NodeFlags {
    521         IsTextFlag = 1,
    522         IsContainerFlag = 1 << 1,
    523         IsElementFlag = 1 << 2,
    524         IsHTMLFlag = 1 << 3,
    525         IsSVGFlag = 1 << 4,
    526         IsMathMLFlag = 1 << 5,
    527         IsDocumentNodeFlag = 1 << 6,
    528         IsShadowRootFlag = 1 << 7,
    529         IsConnectedFlag = 1 << 8,
    530         IsInShadowTreeFlag = 1 << 9,
    531         // UnusedFlag = 1 << 10,
    532         HasEventTargetDataFlag = 1 << 11,
    533         // UnusedFlag = 1 << 12,
     520    enum class NodeFlag : uint32_t {
     521        IsCharacterData = 1 << 0,
     522        IsText = 1 << 1,
     523        IsContainerNode = 1 << 2,
     524        IsElement = 1 << 3,
     525        IsHTMLElement = 1 << 4,
     526        IsSVGElement = 1 << 5,
     527        IsMathMLElement = 1 << 6,
     528        IsDocumentNode = 1 << 7,
     529        IsDocumentFragment = 1 << 8,
     530        IsShadowRoot = 1 << 9,
     531        IsConnected = 1 << 10,
     532        IsInShadowTree = 1 << 11,
     533        HasEventTargetData = 1 << 12,
    534534        // UnusedFlag = 1 << 13,
    535535        // UnusedFlag = 1 << 14,
     
    539539        IsEditingText = 1 << 15, // Text
    540540        HasFocusWithin = 1 << 16, // Element
    541         IsLinkFlag = 1 << 17,
     541        IsLink = 1 << 17,
    542542        IsUserActionElement = 1 << 18,
    543         IsParsingChildrenFinishedFlag = 1 << 19,
    544         HasSyntheticAttrChildNodesFlag = 1 << 20,
    545         SelfOrAncestorHasDirAutoFlag = 1 << 21,
    546 
    547         HasCustomStyleResolveCallbacksFlag = 1 << 22,
    548 
    549         HasPendingResourcesFlag = 1 << 23,
    550         HasCSSAnimationFlag = 1 << 24,
    551         HasElementIdentifierFlag = 1 << 25,
     543        IsParsingChildrenFinished = 1 << 19,
     544        HasSyntheticAttrChildNodes = 1 << 20,
     545        SelfOrAncestorHasDirAuto = 1 << 21,
     546
     547        HasCustomStyleResolveCallbacks = 1 << 22,
     548
     549        HasPendingResources = 1 << 23,
     550        HasCSSAnimation = 1 << 24,
     551        HasElementIdentifier = 1 << 25,
    552552#if ENABLE(FULLSCREEN_API)
    553         ContainsFullScreenElementFlag = 1 << 26,
     553        ContainsFullScreenElement = 1 << 26,
    554554#endif
    555555
    556556        // Bits 27-31 are free.
    557 
    558         DefaultNodeFlags = IsParsingChildrenFinishedFlag
    559557    };
    560558
     
    579577    };
    580578
    581     bool getFlag(NodeFlags mask) const { return m_nodeFlags & mask; }
    582     void setFlag(bool f, NodeFlags mask) const { m_nodeFlags = (m_nodeFlags & ~mask) | (-(int32_t)f & mask); }
    583     void setFlag(NodeFlags mask) const { m_nodeFlags |= mask; }
    584     void clearFlag(NodeFlags mask) const { m_nodeFlags &= ~mask; }
     579    bool hasNodeFlag(NodeFlag flag) const { return m_nodeFlags.contains(flag); }
     580    void setNodeFlag(NodeFlag flag, bool value = true) const { m_nodeFlags.set(flag, value); }
     581    void clearNodeFlag(NodeFlag flag) const { m_nodeFlags.remove(flag); }
    585582
    586583    RareDataBitFields rareDataBitfields() const { return bitwise_cast<RareDataBitFields>(m_rareDataWithBitfields.type()); }
     
    593590    void setCustomElementState(CustomElementState);
    594591
    595     bool isParsingChildrenFinished() const { return getFlag(IsParsingChildrenFinishedFlag); }
    596     void setIsParsingChildrenFinished() { setFlag(IsParsingChildrenFinishedFlag); }
    597     void clearIsParsingChildrenFinished() { clearFlag(IsParsingChildrenFinishedFlag); }
    598 
    599     enum ConstructionType {
    600         CreateOther = DefaultNodeFlags,
    601         CreateText = DefaultNodeFlags | IsTextFlag,
    602         CreateContainer = DefaultNodeFlags | IsContainerFlag,
    603         CreateElement = CreateContainer | IsElementFlag,
    604         CreatePseudoElement =  CreateElement | IsConnectedFlag,
    605         CreateShadowRoot = CreateContainer | IsShadowRootFlag | IsInShadowTreeFlag,
    606         CreateDocumentFragment = CreateContainer,
    607         CreateHTMLElement = CreateElement | IsHTMLFlag,
    608         CreateSVGElement = CreateElement | IsSVGFlag | HasCustomStyleResolveCallbacksFlag,
    609         CreateMathMLElement = CreateElement | IsMathMLFlag,
    610         CreateDocument = CreateContainer | IsDocumentNodeFlag | IsConnectedFlag,
    611         CreateEditingText = CreateText | IsEditingText,
    612     };
     592    bool isParsingChildrenFinished() const { return hasNodeFlag(NodeFlag::IsParsingChildrenFinished); }
     593    void setIsParsingChildrenFinished() { setNodeFlag(NodeFlag::IsParsingChildrenFinished); }
     594    void clearIsParsingChildrenFinished() { clearNodeFlag(NodeFlag::IsParsingChildrenFinished); }
     595
     596    constexpr static auto DefaultNodeFlags = OptionSet<NodeFlag>(NodeFlag::IsParsingChildrenFinished);
     597    constexpr static auto CreateOther = DefaultNodeFlags;
     598    constexpr static auto CreateCharacterData = DefaultNodeFlags | NodeFlag::IsCharacterData;
     599    constexpr static auto CreateText = CreateCharacterData | NodeFlag::IsText;
     600    constexpr static auto CreateContainer = DefaultNodeFlags | NodeFlag::IsContainerNode;
     601    constexpr static auto CreateElement = CreateContainer | NodeFlag::IsElement;
     602    constexpr static auto CreatePseudoElement = CreateElement | NodeFlag::IsConnected;
     603    constexpr static auto CreateDocumentFragment = CreateContainer | NodeFlag::IsDocumentFragment;
     604    constexpr static auto CreateShadowRoot = CreateDocumentFragment | NodeFlag::IsShadowRoot | NodeFlag::IsInShadowTree;
     605    constexpr static auto CreateHTMLElement = CreateElement | NodeFlag::IsHTMLElement;
     606    constexpr static auto CreateSVGElement = CreateElement | NodeFlag::IsSVGElement | NodeFlag::HasCustomStyleResolveCallbacks;
     607    constexpr static auto CreateMathMLElement = CreateElement | NodeFlag::IsMathMLElement;
     608    constexpr static auto CreateDocument = CreateContainer | NodeFlag::IsDocumentNode | NodeFlag::IsConnected;
     609    constexpr static auto CreateEditingText = CreateText | NodeFlag::IsEditingText;
     610    using ConstructionType = OptionSet<NodeFlag>;
    613611    Node(Document&, ConstructionType);
    614612
     
    678676    void clearEventTargetData();
    679677
    680     void setHasCustomStyleResolveCallbacks() { setFlag(true, HasCustomStyleResolveCallbacksFlag); }
     678    void setHasCustomStyleResolveCallbacks() { setNodeFlag(NodeFlag::HasCustomStyleResolveCallbacks); }
    681679
    682680    void setTreeScope(TreeScope& scope) { m_treeScope = &scope; }
     
    694692    }
    695693
    696     virtual bool virtualIsCharacterData() const { return false; }
    697 
    698694    WEBCORE_EXPORT void removedLastRef();
    699695
     
    721717
    722718    mutable uint32_t m_refCountAndParentBit { s_refCountIncrement };
    723     mutable uint32_t m_nodeFlags;
     719    mutable OptionSet<NodeFlag> m_nodeFlags;
    724720
    725721    ContainerNode* m_parentNode { nullptr };
  • trunk/Source/WebCore/dom/ProcessingInstruction.cpp

    r239427 r266776  
    4545
    4646inline ProcessingInstruction::ProcessingInstruction(Document& document, const String& target, const String& data)
    47     : CharacterData(document, data, CreateOther)
     47    : CharacterData(document, data)
    4848    , m_target(target)
    4949{
Note: See TracChangeset for help on using the changeset viewer.