diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/core/dom/node.h')
-rw-r--r-- | chromium/third_party/blink/renderer/core/dom/node.h | 170 |
1 files changed, 91 insertions, 79 deletions
diff --git a/chromium/third_party/blink/renderer/core/dom/node.h b/chromium/third_party/blink/renderer/core/dom/node.h index 261c41a49e2..a3a9a7b3905 100644 --- a/chromium/third_party/blink/renderer/core/dom/node.h +++ b/chromium/third_party/blink/renderer/core/dom/node.h @@ -36,6 +36,9 @@ #include "third_party/blink/renderer/core/dom/tree_scope.h" #include "third_party/blink/renderer/core/scroll/scroll_customization.h" #include "third_party/blink/renderer/core/style/computed_style_constants.h" +#include "third_party/blink/renderer/platform/heap/custom_spaces.h" +#include "third_party/blink/renderer/platform/text/text_direction.h" +#include "third_party/blink/renderer/platform/wtf/buildflags.h" // This needs to be here because element.cc also depends on it. #define DUMP_NODE_STATISTICS 0 @@ -83,8 +86,8 @@ struct PhysicalRect; const int kDOMNodeTypeShift = 2; const int kElementNamespaceTypeShift = 4; -const int kNodeStyleChangeShift = 17; -const int kNodeCustomElementShift = 19; +const int kNodeStyleChangeShift = 15; +const int kNodeCustomElementShift = 17; // Values for kChildNeedsStyleRecalcFlag, controlling whether a node gets its // style recalculated. @@ -166,6 +169,7 @@ class CORE_EXPORT Node : public EventTarget { kDocumentPositionImplementationSpecific = 0x20, }; +#if !BUILDFLAG(USE_V8_OILPAN) template <typename T> static void* AllocateObject(size_t size) { ThreadState* state = @@ -175,6 +179,7 @@ class CORE_EXPORT Node : public EventTarget { state, size, BlinkGC::kNodeArenaIndex, GCInfoTrait<GCInfoFoldedType<T>>::Index(), type_name); } +#endif // !BUILDFLAG(USE_V8_OILPAN) static void DumpStatistics(); @@ -321,19 +326,6 @@ class CORE_EXPORT Node : public EventTarget { return GetCustomElementState() != CustomElementState::kUncustomized; } void SetCustomElementState(CustomElementState); - bool IsV0CustomElement() const { return GetFlag(kV0CustomElementFlag); } - enum V0CustomElementState { - kV0NotCustomElement = 0, - kV0WaitingForUpgrade = 1 << 0, - kV0Upgraded = 1 << 1 - }; - V0CustomElementState GetV0CustomElementState() const { - return IsV0CustomElement() - ? (GetFlag(kV0CustomElementUpgradedFlag) ? kV0Upgraded - : kV0WaitingForUpgrade) - : kV0NotCustomElement; - } - void SetV0CustomElementState(V0CustomElementState new_state); virtual bool IsMediaControlElement() const { return false; } virtual bool IsMediaControls() const { return false; } @@ -355,14 +347,10 @@ class CORE_EXPORT Node : public EventTarget { bool IsDocumentNode() const; bool IsTreeScope() const; bool IsShadowRoot() const { return IsDocumentFragment() && IsTreeScope(); } - bool IsV0InsertionPoint() const { return GetFlag(kIsV0InsertionPointFlag); } bool CanParticipateInFlatTree() const; - bool IsActiveSlotOrActiveV0InsertionPoint() const; - // A re-distribution across v0 and v1 shadow trees is not supported. - bool IsSlotable() const { - return IsTextNode() || (IsElementNode() && !IsV0InsertionPoint()); - } + bool IsActiveSlot() const; + bool IsSlotable() const { return IsTextNode() || IsElementNode(); } AtomicString SlotName() const; bool HasCustomStyleCallbacks() const { @@ -530,19 +518,6 @@ class CORE_EXPORT Node : public EventTarget { return NeedsStyleRecalc() || GetForceReattachLayoutTree(); } - bool NeedsDistributionRecalc() const; - - bool ChildNeedsDistributionRecalc() const { - return GetFlag(kChildNeedsDistributionRecalcFlag); - } - void SetChildNeedsDistributionRecalc() { - SetFlag(kChildNeedsDistributionRecalcFlag); - } - void ClearChildNeedsDistributionRecalc() { - ClearFlag(kChildNeedsDistributionRecalcFlag); - } - void MarkAncestorsWithChildNeedsDistributionRecalc(); - // True if the style invalidation process should traverse this node's children // when looking for pending invalidations. bool ChildNeedsStyleInvalidation() const { @@ -565,20 +540,6 @@ class CORE_EXPORT Node : public EventTarget { // MarkAncestorsWithChildNeedsStyleInvalidation void SetNeedsStyleInvalidation(); - // This needs to be called before using FlatTreeTraversal. - // Once Shadow DOM v0 is removed, this function can be removed. - void UpdateDistributionForFlatTreeTraversal() { - UpdateDistributionInternal(); - } - - // This is not what you might want to call in most cases. - // You should call UpdateDistributionForFlatTreeTraversal, instead. - // Only the implementation of v0 shadow trees uses this. - void UpdateDistributionForLegacyDistributedNodes() { - // The implementation is same to UpdateDistributionForFlatTreeTraversal. - UpdateDistributionInternal(); - } - // Please don't use this function. // Background: When we investigated the usage of (old) UpdateDistribution, // some caller's intents were unclear. Thus, we had to introduce this function @@ -587,8 +548,6 @@ class CORE_EXPORT Node : public EventTarget { // just RecalcSlotAssignments()) on a case-by-case basis. void UpdateDistributionForUnknownReasons(); - bool MayContainLegacyNodeTreeWhereDistributionShouldBeSupported() const; - void SetIsLink(bool f); bool HasEventTargetData() const { return GetFlag(kHasEventTargetDataFlag); } @@ -657,11 +616,8 @@ class CORE_EXPORT Node : public EventTarget { } ShadowRoot* ParentElementShadowRoot() const; - bool IsInV1ShadowTree() const; - bool IsInV0ShadowTree() const; - bool IsChildOfV1ShadowHost() const; - bool IsChildOfV0ShadowHost() const; - ShadowRoot* V1ShadowRootOfParent() const; + bool IsChildOfShadowHost() const; + ShadowRoot* ShadowRootOfParent() const; Element* FlatTreeParentForChildDirty() const; Element* GetStyleRecalcParent() const { return FlatTreeParentForChildDirty(); @@ -871,7 +827,6 @@ class CORE_EXPORT Node : public EventTarget { Event& underlying_event); void DispatchSimulatedClick(const Event* underlying_event, - SimulatedClickMouseEventOptions = kSendNoEvents, SimulatedClickCreationScope = SimulatedClickCreationScope::kFromUserAgent); @@ -904,6 +859,7 @@ class CORE_EXPORT Node : public EventTarget { StaticNodeList* getDestinationInsertionPoints(); HTMLSlotElement* AssignedSlot() const; HTMLSlotElement* assignedSlotForBinding(); + HTMLSlotElement* AssignedSlotWithoutRecalc() const; bool IsFinishedParsingChildren() const { return GetFlag(kIsFinishedParsingChildrenFlag); @@ -936,6 +892,44 @@ class CORE_EXPORT Node : public EventTarget { void RegisterScrollTimeline(ScrollTimeline*); void UnregisterScrollTimeline(ScrollTimeline*); + // For Element. + void SetHasDisplayLockContext() { SetFlag(kHasDisplayLockContext); } + bool HasDisplayLockContext() const { return GetFlag(kHasDisplayLockContext); } + + bool SelfOrAncestorHasDirAutoAttribute() const { + return GetFlag(kSelfOrAncestorHasDirAutoAttribute); + } + void SetSelfOrAncestorHasDirAutoAttribute() { + SetFlag(kSelfOrAncestorHasDirAutoAttribute); + } + void ClearSelfOrAncestorHasDirAutoAttribute() { + ClearFlag(kSelfOrAncestorHasDirAutoAttribute); + } + TextDirection CachedDirectionality() const { + return (node_flags_ & kCachedDirectionalityIsRtl) ? TextDirection::kRtl + : TextDirection::kLtr; + } + void SetCachedDirectionality(TextDirection direction) { + switch (direction) { + case TextDirection::kRtl: + SetFlag(kCachedDirectionalityIsRtl); + break; + case TextDirection::kLtr: + ClearFlag(kCachedDirectionalityIsRtl); + break; + } + ClearFlag(kNeedsInheritDirectionalityFromParent); + } + bool NeedsInheritDirectionalityFromParent() const { + return GetFlag(kNeedsInheritDirectionalityFromParent); + } + void SetNeedsInheritDirectionalityFromParent() { + SetFlag(kNeedsInheritDirectionalityFromParent); + } + void ClearNeedsInheritDirectionalityFromParent() { + ClearFlag(kNeedsInheritDirectionalityFromParent); + } + void Trace(Visitor*) const override; private: @@ -946,45 +940,46 @@ class CORE_EXPORT Node : public EventTarget { kIsContainerFlag = 1 << 1, kDOMNodeTypeMask = 0x3 << kDOMNodeTypeShift, kElementNamespaceTypeMask = 0x3 << kElementNamespaceTypeShift, - kIsV0InsertionPointFlag = 1 << 6, // Changes based on if the element should be treated like a link, // ex. When setting the href attribute on an <a>. - kIsLinkFlag = 1 << 7, + kIsLinkFlag = 1 << 6, // Changes based on :hover, :active and :focus state. - kIsUserActionElementFlag = 1 << 8, + kIsUserActionElementFlag = 1 << 7, // Tree state flags. These change when the element is added/removed // from a DOM tree. - kIsConnectedFlag = 1 << 9, - kIsInShadowTreeFlag = 1 << 10, + kIsConnectedFlag = 1 << 8, + kIsInShadowTreeFlag = 1 << 9, // Set by the parser when the children are done parsing. - kIsFinishedParsingChildrenFlag = 1 << 11, + kIsFinishedParsingChildrenFlag = 1 << 10, // Flags related to recalcStyle. - kHasCustomStyleCallbacksFlag = 1 << 12, - kChildNeedsStyleInvalidationFlag = 1 << 13, - kNeedsStyleInvalidationFlag = 1 << 14, - kChildNeedsDistributionRecalcFlag = 1 << 15, - kChildNeedsStyleRecalcFlag = 1 << 16, + kHasCustomStyleCallbacksFlag = 1 << 11, + kChildNeedsStyleInvalidationFlag = 1 << 12, + kNeedsStyleInvalidationFlag = 1 << 13, + kChildNeedsStyleRecalcFlag = 1 << 14, kStyleChangeMask = 0x3 << kNodeStyleChangeShift, kCustomElementStateMask = 0x7 << kNodeCustomElementShift, - kHasNameOrIsEditingTextFlag = 1 << 22, - kHasEventTargetDataFlag = 1 << 23, + kHasNameOrIsEditingTextFlag = 1 << 20, + kHasEventTargetDataFlag = 1 << 21, + + kNeedsReattachLayoutTree = 1 << 22, + kChildNeedsReattachLayoutTree = 1 << 23, - kV0CustomElementFlag = 1 << 24, - kV0CustomElementUpgradedFlag = 1 << 25, + kHasDuplicateAttributes = 1 << 24, - kNeedsReattachLayoutTree = 1 << 26, - kChildNeedsReattachLayoutTree = 1 << 27, + kForceReattachLayoutTree = 1 << 25, - kHasDuplicateAttributes = 1 << 28, + kHasDisplayLockContext = 1 << 26, - kForceReattachLayoutTree = 1 << 29, + kSelfOrAncestorHasDirAutoAttribute = 1 << 27, + kCachedDirectionalityIsRtl = 1 << 28, + kNeedsInheritDirectionalityFromParent = 1 << 29, kDefaultNodeFlags = kIsFinishedParsingChildrenFlag, @@ -1051,7 +1046,6 @@ class CORE_EXPORT Node : public EventTarget { static_cast<NodeFlags>(DOMNodeType::kElement) | static_cast<NodeFlags>(ElementNamespaceType::kSVG), kCreateDocument = kCreateContainer | kIsConnectedFlag, - kCreateV0InsertionPoint = kCreateHTMLElement | kIsV0InsertionPointFlag, kCreateEditingText = kCreateText | kHasNameOrIsEditingTextFlag, }; @@ -1107,9 +1101,6 @@ class CORE_EXPORT Node : public EventTarget { bool IsUserActionElementFocused() const; bool IsUserActionElementHasFocusWithin() const; - void UpdateDistributionInternal(); - void RecalcDistribution(); - void SetStyleChange(StyleChangeType change_type) { node_flags_ = (node_flags_ & ~kStyleChangeMask) | change_type; } @@ -1134,6 +1125,7 @@ class CORE_EXPORT Node : public EventTarget { DCHECK(!HasRareData()); return reinterpret_cast<NodeRenderingData*>(data_.Get()); } + ShadowRoot* GetSlotAssignmentRoot() const; uint32_t node_flags_; Member<Node> parent_or_shadow_host_node_; @@ -1169,4 +1161,24 @@ void showTree(const blink::Node*); void showNodePath(const blink::Node*); #endif +#if BUILDFLAG(USE_V8_OILPAN) +namespace cppgc { +// Assign Node to be allocated on custom NodeSpace. +template <typename T> +struct SpaceTrait<T, std::enable_if_t<std::is_base_of<blink::Node, T>::value>> { + using Space = blink::NodeSpace; +}; +} // namespace cppgc + +namespace blink { +template <typename T> +struct ThreadingTrait< + T, + std::enable_if_t<std::is_base_of<blink::Node, T>::value>> { + static constexpr ThreadAffinity kAffinity = kMainThreadOnly; +}; +} // namespace blink + +#endif // USE_V8_OILPAN + #endif // THIRD_PARTY_BLINK_RENDERER_CORE_DOM_NODE_H_ |