Skip to content

Commit

Permalink
Move more Node and EventTarget flags to ElementStateFlag
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=271683

Reviewed by Tim Nguyen.

Move some flags from Node::StateFlag and EventTarget::EventTargetFlag
to newly introduced Node::ElementStateFlag.

* Source/WebCore/dom/Element.cpp:
(WebCore::Element::invalidateForQueryContainerSizeChange):
(WebCore::Element::needsUpdateQueryContainerDependentStyle const):
(WebCore::Element::clearNeedsUpdateQueryContainerDependentStyle):
(WebCore::Element::setFullscreenFlag):
* Source/WebCore/dom/Element.h:
(WebCore::Element::hasFullscreenFlag const):
(WebCore::Element::capturedInViewTransition const):
(WebCore::Element::setCapturedInViewTransition):
(WebCore::Element::hasEverHadSmoothScroll const):
(WebCore::Element::setHasEverHadSmoothScroll):
* Source/WebCore/dom/EventTarget.h:
* Source/WebCore/dom/Node.h:
(WebCore::Node::needsSVGRendererUpdate const):
(WebCore::Node::setNeedsSVGRendererUpdate):
(WebCore::Node::isInCustomElementReactionQueue const):
(WebCore::Node::setIsInCustomElementReactionQueue):
(WebCore::Node::clearIsInCustomElementReactionQueue):
(WebCore::Node::isUserActionElement const):
(WebCore::Node::setUserActionElement):

Canonical link: https://commits.webkit.org/276707@main
  • Loading branch information
rniwa committed Mar 26, 2024
1 parent 098ae9d commit fac82a3
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 36 deletions.
10 changes: 5 additions & 5 deletions Source/WebCore/dom/Element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2458,7 +2458,7 @@ void Element::invalidateForQueryContainerSizeChange()
{
// FIXME: Ideally we would just recompute things that are actually affected by containers queries within the subtree.
Node::invalidateStyle(Style::Validity::SubtreeInvalid);
setStateFlag(StateFlag::NeedsUpdateQueryContainerDependentStyle);
setElementStateFlag(ElementStateFlag::NeedsUpdateQueryContainerDependentStyle);
}

void Element::invalidateForResumingQueryContainerResolution()
Expand All @@ -2468,12 +2468,12 @@ void Element::invalidateForResumingQueryContainerResolution()

bool Element::needsUpdateQueryContainerDependentStyle() const
{
return hasStateFlag(StateFlag::NeedsUpdateQueryContainerDependentStyle);
return hasElementStateFlag(ElementStateFlag::NeedsUpdateQueryContainerDependentStyle);
}

void Element::clearNeedsUpdateQueryContainerDependentStyle()
{
clearStateFlag(StateFlag::NeedsUpdateQueryContainerDependentStyle);
clearElementStateFlag(ElementStateFlag::NeedsUpdateQueryContainerDependentStyle);
}

void Element::invalidateEventListenerRegions()
Expand Down Expand Up @@ -4470,9 +4470,9 @@ void Element::setFullscreenFlag(bool flag)
{
Style::PseudoClassChangeInvalidation styleInvalidation(*this, { { CSSSelector::PseudoClass::Fullscreen, flag }, { CSSSelector::PseudoClass::Modal, flag } });
if (flag)
setStateFlag(StateFlag::IsFullscreen);
setElementStateFlag(ElementStateFlag::IsFullscreen);
else
clearStateFlag(StateFlag::IsFullscreen);
clearElementStateFlag(ElementStateFlag::IsFullscreen);
}

#endif
Expand Down
10 changes: 5 additions & 5 deletions Source/WebCore/dom/Element.h
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ class Element : public ContainerNode {
void removeFromTopLayer();

#if ENABLE(FULLSCREEN_API)
bool hasFullscreenFlag() const { return hasStateFlag(StateFlag::IsFullscreen); }
bool hasFullscreenFlag() const { return hasElementStateFlag(ElementStateFlag::IsFullscreen); }
void setFullscreenFlag(bool);
WEBCORE_EXPORT void webkitRequestFullscreen();
virtual void requestFullscreen(FullscreenOptions&&, RefPtr<DeferredPromise>&&);
Expand Down Expand Up @@ -779,8 +779,8 @@ class Element : public ContainerNode {
bool hasCustomState(const AtomString& state) const;
CustomStateSet& ensureCustomStateSet();

bool capturedInViewTransition() const { return hasEventTargetFlag(EventTargetFlag::CapturedInViewTransition); }
void setCapturedInViewTransition(bool captured) { setEventTargetFlag(EventTargetFlag::CapturedInViewTransition, captured); }
bool capturedInViewTransition() const { return hasElementStateFlag(ElementStateFlag::CapturedInViewTransition); }
void setCapturedInViewTransition(bool captured) { setElementStateFlag(ElementStateFlag::CapturedInViewTransition, captured); }

protected:
Element(const QualifiedName&, Document&, OptionSet<TypeFlag>);
Expand Down Expand Up @@ -926,8 +926,8 @@ class Element : public ContainerNode {
bool hasLanguageAttribute() const { return hasLangAttr() || hasXMLLangAttr(); }
bool hasLangAttrKnownToMatchDocumentElement() const { return hasLanguageAttribute() && effectiveLangKnownToMatchDocumentElement(); }

bool hasEverHadSmoothScroll() const { return hasStateFlag(StateFlag::EverHadSmoothScroll); }
void setHasEverHadSmoothScroll(bool value) { return setStateFlag(StateFlag::EverHadSmoothScroll, value); }
bool hasEverHadSmoothScroll() const { return hasElementStateFlag(ElementStateFlag::EverHadSmoothScroll); }
void setHasEverHadSmoothScroll(bool value) { return setElementStateFlag(ElementStateFlag::EverHadSmoothScroll, value); }

void parentOrShadowHostNode() const = delete; // Call parentNode() instead.

Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/dom/EventTarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class EventTarget : public ScriptWrappable, public CanMakeWeakPtrWithBitField<Ev
HasFormAssociatedCustomElementInterface = 1 << 11,
HasShadowRootContainingSlots = 1 << 12,
IsInTopLayer = 1 << 13,
CapturedInViewTransition = 1 << 14,
// 1-bit free
// SVGElement bits
HasPendingResources = 1 << 15,
};
Expand Down
52 changes: 27 additions & 25 deletions Source/WebCore/dom/Node.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ class Node : public EventTarget {
bool hasShadowRootContainingSlots() const { return hasEventTargetFlag(EventTargetFlag::HasShadowRootContainingSlots); }
void setHasShadowRootContainingSlots(bool flag) { setEventTargetFlag(EventTargetFlag::HasShadowRootContainingSlots, flag); }

bool needsSVGRendererUpdate() const { return hasStateFlag(StateFlag::NeedsSVGRendererUpdate); }
void setNeedsSVGRendererUpdate(bool flag) { setStateFlag(StateFlag::NeedsSVGRendererUpdate, flag); }
bool needsSVGRendererUpdate() const { return hasElementStateFlag(ElementStateFlag::NeedsSVGRendererUpdate); }
void setNeedsSVGRendererUpdate(bool flag) { setElementStateFlag(ElementStateFlag::NeedsSVGRendererUpdate, flag); }

// If this node is in a shadow tree, returns its shadow host. Otherwise, returns null.
WEBCORE_EXPORT Element* shadowHost() const;
Expand All @@ -290,9 +290,9 @@ class Node : public EventTarget {
bool isPrecustomizedCustomElement() const { return customElementState() == CustomElementState::FailedOrPrecustomized && !isUnknownElement(); }
bool isPrecustomizedOrDefinedCustomElement() const { return isPrecustomizedCustomElement() || isDefinedCustomElement(); }

bool isInCustomElementReactionQueue() const { return hasStateFlag(StateFlag::IsInCustomElementReactionQueue); }
void setIsInCustomElementReactionQueue() { setStateFlag(StateFlag::IsInCustomElementReactionQueue); }
void clearIsInCustomElementReactionQueue() { clearStateFlag(StateFlag::IsInCustomElementReactionQueue); }
bool isInCustomElementReactionQueue() const { return hasElementStateFlag(ElementStateFlag::IsInCustomElementReactionQueue); }
void setIsInCustomElementReactionQueue() { setElementStateFlag(ElementStateFlag::IsInCustomElementReactionQueue); }
void clearIsInCustomElementReactionQueue() { clearElementStateFlag(ElementStateFlag::IsInCustomElementReactionQueue); }

// Returns null, a child of ShadowRoot, or a legacy shadow root.
Node* nonBoundaryShadowTreeRootNode();
Expand Down Expand Up @@ -350,8 +350,8 @@ class Node : public EventTarget {
virtual void notifyLoadedSheetAndAllCriticalSubresources(bool /* error loading subresource */) { }
virtual void startLoadingDynamicSheet() { ASSERT_NOT_REACHED(); }

bool isUserActionElement() const { return hasStateFlag(StateFlag::IsUserActionElement); }
void setUserActionElement(bool flag) { setStateFlag(StateFlag::IsUserActionElement, flag); }
bool isUserActionElement() const { return hasElementStateFlag(ElementStateFlag::IsUserActionElement); }
void setUserActionElement(bool flag) { setElementStateFlag(ElementStateFlag::IsUserActionElement, flag); }

bool inRenderedDocument() const;
bool needsStyleRecalc() const { return styleValidity() != Style::Validity::Valid || hasInvalidRenderer(); }
Expand Down Expand Up @@ -627,28 +627,30 @@ class Node : public EventTarget {

enum class StateFlag : uint16_t {
IsLink = 1 << 0,
IsUserActionElement = 1 << 1,
IsParsingChildren = 1 << 2,
EverHadSmoothScroll = 1 << 3,
SelfOrPrecedingNodesAffectDirAuto = 1 << 4,
EffectiveLangKnownToMatchDocumentElement = 1 << 5,
IsComputedStyleInvalidFlag = 1 << 6,
NeedsSVGRendererUpdate = 1 << 7,
NeedsUpdateQueryContainerDependentStyle = 1 << 8,
#if ENABLE(FULLSCREEN_API)
IsFullscreen = 1 << 9,
#endif
HasInvalidRenderer = 1 << 10,
ContainsOnlyASCIIWhitespace = 1 << 11, // Only used on CharacterData.
ContainsOnlyASCIIWhitespaceIsValid = 1 << 12, // Only used on CharacterData.
HasHeldBackChildrenChanged = 1 << 13,
HasStartedDeletion = 1 << 14,
IsInCustomElementReactionQueue = 1 << 15,
IsParsingChildren = 1 << 1,
SelfOrPrecedingNodesAffectDirAuto = 1 << 2,
EffectiveLangKnownToMatchDocumentElement = 1 << 3,
IsComputedStyleInvalidFlag = 1 << 4,
HasInvalidRenderer = 1 << 5,
ContainsOnlyASCIIWhitespace = 1 << 6, // Only used on CharacterData.
ContainsOnlyASCIIWhitespaceIsValid = 1 << 7, // Only used on CharacterData.
HasHeldBackChildrenChanged = 1 << 8,
HasStartedDeletion = 1 << 9,
// 6-bits free.
};

enum class ElementStateFlag : uint16_t {
HasElementIdentifier = 1 << 0,
// 15-bits free.
IsUserActionElement = 1 << 1,
IsInCustomElementReactionQueue = 1 << 2,
NeedsSVGRendererUpdate = 1 << 3,
NeedsUpdateQueryContainerDependentStyle = 1 << 4,
EverHadSmoothScroll = 1 << 5,
CapturedInViewTransition = 1 << 6,
#if ENABLE(FULLSCREEN_API)
IsFullscreen = 1 << 7,
#endif
// 8-bits free.
};

enum class TabIndexState : uint8_t {
Expand Down

0 comments on commit fac82a3

Please sign in to comment.