OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2004-2011, 2014 Apple Inc. All rights reserved. | 5 * Copyright (C) 2004-2011, 2014 Apple Inc. All rights reserved. |
6 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 6 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
7 * (http://www.torchmobile.com/) | 7 * (http://www.torchmobile.com/) |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 class Event; | 51 class Event; |
52 class ExceptionState; | 52 class ExceptionState; |
53 class GetRootNodeOptions; | 53 class GetRootNodeOptions; |
54 class HTMLQualifiedName; | 54 class HTMLQualifiedName; |
55 class HTMLSlotElement; | 55 class HTMLSlotElement; |
56 class IntRect; | 56 class IntRect; |
57 class EventDispatchHandlingState; | 57 class EventDispatchHandlingState; |
58 class NodeList; | 58 class NodeList; |
59 class NodeListsNodeData; | 59 class NodeListsNodeData; |
60 class NodeOrString; | 60 class NodeOrString; |
61 class NodeLayoutData; | 61 class NodeRenderingData; |
62 class NodeRareData; | 62 class NodeRareData; |
63 class QualifiedName; | 63 class QualifiedName; |
64 class RegisteredEventListener; | 64 class RegisteredEventListener; |
65 class LayoutBox; | 65 class LayoutBox; |
66 class LayoutBoxModelObject; | 66 class LayoutBoxModelObject; |
67 class LayoutObject; | 67 class LayoutObject; |
68 class ComputedStyle; | 68 class ComputedStyle; |
69 class SVGQualifiedName; | 69 class SVGQualifiedName; |
70 class ShadowRoot; | 70 class ShadowRoot; |
71 template <typename NodeType> | 71 template <typename NodeType> |
(...skipping 21 matching lines...) Expand all Loading... |
93 kFailed = 3 << kNodeCustomElementShift, | 93 kFailed = 3 << kNodeCustomElementShift, |
94 | 94 |
95 kNotDefinedFlag = 2 << kNodeCustomElementShift, | 95 kNotDefinedFlag = 2 << kNodeCustomElementShift, |
96 }; | 96 }; |
97 | 97 |
98 enum class SlotChangeType { | 98 enum class SlotChangeType { |
99 kInitial, | 99 kInitial, |
100 kChained, | 100 kChained, |
101 }; | 101 }; |
102 | 102 |
103 class NodeLayoutData { | 103 class NodeRenderingData { |
104 WTF_MAKE_NONCOPYABLE(NodeLayoutData); | 104 WTF_MAKE_NONCOPYABLE(NodeRenderingData); |
105 | 105 |
106 public: | 106 public: |
107 explicit NodeLayoutData(LayoutObject* layout_object, | 107 explicit NodeRenderingData(LayoutObject* layout_object, |
108 RefPtr<ComputedStyle> non_attached_style) | 108 RefPtr<ComputedStyle> non_attached_style) |
109 : layout_object_(layout_object), | 109 : layout_object_(layout_object), |
110 non_attached_style_(non_attached_style) {} | 110 non_attached_style_(non_attached_style) {} |
111 ~NodeLayoutData() { CHECK(!layout_object_); } | 111 ~NodeRenderingData() { CHECK(!layout_object_); } |
112 | 112 |
113 LayoutObject* GetLayoutObject() const { return layout_object_; } | 113 LayoutObject* GetLayoutObject() const { return layout_object_; } |
114 void SetLayoutObject(LayoutObject* layout_object) { | 114 void SetLayoutObject(LayoutObject* layout_object) { |
115 DCHECK_NE(&SharedEmptyData(), this); | 115 DCHECK_NE(&SharedEmptyData(), this); |
116 layout_object_ = layout_object; | 116 layout_object_ = layout_object; |
117 } | 117 } |
118 | 118 |
119 ComputedStyle* GetNonAttachedStyle() const { | 119 ComputedStyle* GetNonAttachedStyle() const { |
120 return non_attached_style_.Get(); | 120 return non_attached_style_.Get(); |
121 } | 121 } |
122 void SetNonAttachedStyle(RefPtr<ComputedStyle> non_attached_style) { | 122 void SetNonAttachedStyle(RefPtr<ComputedStyle> non_attached_style) { |
123 DCHECK_NE(&SharedEmptyData(), this); | 123 DCHECK_NE(&SharedEmptyData(), this); |
124 non_attached_style_ = non_attached_style; | 124 non_attached_style_ = non_attached_style; |
125 } | 125 } |
126 | 126 |
127 static NodeLayoutData& SharedEmptyData() { | 127 static NodeRenderingData& SharedEmptyData() { |
128 DEFINE_STATIC_LOCAL(NodeLayoutData, shared_empty_data, (nullptr, nullptr)); | 128 DEFINE_STATIC_LOCAL(NodeRenderingData, shared_empty_data, |
| 129 (nullptr, nullptr)); |
129 return shared_empty_data; | 130 return shared_empty_data; |
130 } | 131 } |
131 bool IsSharedEmptyData() { return this == &SharedEmptyData(); } | 132 bool IsSharedEmptyData() { return this == &SharedEmptyData(); } |
132 | 133 |
133 private: | 134 private: |
134 LayoutObject* layout_object_; | 135 LayoutObject* layout_object_; |
135 RefPtr<ComputedStyle> non_attached_style_; | 136 RefPtr<ComputedStyle> non_attached_style_; |
136 }; | 137 }; |
137 | 138 |
138 class NodeRareDataBase { | 139 class NodeRareDataBase { |
139 public: | 140 public: |
140 NodeLayoutData* GetNodeLayoutData() const { return node_layout_data_; } | 141 NodeRenderingData* GetNodeRenderingData() const { return node_layout_data_; } |
141 void SetNodeLayoutData(NodeLayoutData* node_layout_data) { | 142 void SetNodeRenderingData(NodeRenderingData* node_layout_data) { |
142 DCHECK(node_layout_data); | 143 DCHECK(node_layout_data); |
143 node_layout_data_ = node_layout_data; | 144 node_layout_data_ = node_layout_data; |
144 } | 145 } |
145 | 146 |
146 protected: | 147 protected: |
147 NodeRareDataBase(NodeLayoutData* node_layout_data) | 148 NodeRareDataBase(NodeRenderingData* node_layout_data) |
148 : node_layout_data_(node_layout_data) {} | 149 : node_layout_data_(node_layout_data) {} |
149 ~NodeRareDataBase() { | 150 ~NodeRareDataBase() { |
150 if (node_layout_data_ && !node_layout_data_->IsSharedEmptyData()) | 151 if (node_layout_data_ && !node_layout_data_->IsSharedEmptyData()) |
151 delete node_layout_data_; | 152 delete node_layout_data_; |
152 } | 153 } |
153 | 154 |
154 protected: | 155 protected: |
155 NodeLayoutData* node_layout_data_; | 156 NodeRenderingData* node_layout_data_; |
156 }; | 157 }; |
157 | 158 |
158 class Node; | 159 class Node; |
159 WILL_NOT_BE_EAGERLY_TRACED_CLASS(Node); | 160 WILL_NOT_BE_EAGERLY_TRACED_CLASS(Node); |
160 | 161 |
161 // This class represents a DOM node in the DOM tree. | 162 // This class represents a DOM node in the DOM tree. |
162 // https://dom.spec.whatwg.org/#interface-node | 163 // https://dom.spec.whatwg.org/#interface-node |
163 class CORE_EXPORT Node : public EventTarget { | 164 class CORE_EXPORT Node : public EventTarget { |
164 DEFINE_WRAPPERTYPEINFO(); | 165 DEFINE_WRAPPERTYPEINFO(); |
165 friend class TreeScope; | 166 friend class TreeScope; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 | 277 |
277 String textContent(bool convert_brs_to_newlines = false) const; | 278 String textContent(bool convert_brs_to_newlines = false) const; |
278 void setTextContent(const String&); | 279 void setTextContent(const String&); |
279 | 280 |
280 bool SupportsAltText(); | 281 bool SupportsAltText(); |
281 | 282 |
282 void SetNonAttachedStyle(RefPtr<ComputedStyle> non_attached_style); | 283 void SetNonAttachedStyle(RefPtr<ComputedStyle> non_attached_style); |
283 | 284 |
284 ComputedStyle* GetNonAttachedStyle() const { | 285 ComputedStyle* GetNonAttachedStyle() const { |
285 return HasRareData() | 286 return HasRareData() |
286 ? data_.rare_data_->GetNodeLayoutData()->GetNonAttachedStyle() | 287 ? data_.rare_data_->GetNodeRenderingData()->GetNonAttachedStyle() |
287 : data_.node_layout_data_->GetNonAttachedStyle(); | 288 : data_.node_layout_data_->GetNonAttachedStyle(); |
288 } | 289 } |
289 | 290 |
290 // Other methods (not part of DOM) | 291 // Other methods (not part of DOM) |
291 | 292 |
292 bool IsElementNode() const { return GetFlag(kIsElementFlag); } | 293 bool IsElementNode() const { return GetFlag(kIsElementFlag); } |
293 bool IsContainerNode() const { return GetFlag(kIsContainerFlag); } | 294 bool IsContainerNode() const { return GetFlag(kIsContainerFlag); } |
294 bool IsTextNode() const { return GetFlag(kIsTextFlag); } | 295 bool IsTextNode() const { return GetFlag(kIsTextFlag); } |
295 bool IsHTMLElement() const { return GetFlag(kIsHTMLFlag); } | 296 bool IsHTMLElement() const { return GetFlag(kIsHTMLFlag); } |
296 bool IsSVGElement() const { return GetFlag(kIsSVGFlag); } | 297 bool IsSVGElement() const { return GetFlag(kIsSVGFlag); } |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 | 612 |
612 // ---------------------------------------------------------------------------
-- | 613 // ---------------------------------------------------------------------------
-- |
613 // Integration with layout tree | 614 // Integration with layout tree |
614 | 615 |
615 // As layoutObject() includes a branch you should avoid calling it repeatedly | 616 // As layoutObject() includes a branch you should avoid calling it repeatedly |
616 // in hot code paths. | 617 // in hot code paths. |
617 // Note that if a Node has a layoutObject, it's parentNode is guaranteed to | 618 // Note that if a Node has a layoutObject, it's parentNode is guaranteed to |
618 // have one as well. | 619 // have one as well. |
619 LayoutObject* GetLayoutObject() const { | 620 LayoutObject* GetLayoutObject() const { |
620 return HasRareData() | 621 return HasRareData() |
621 ? data_.rare_data_->GetNodeLayoutData()->GetLayoutObject() | 622 ? data_.rare_data_->GetNodeRenderingData()->GetLayoutObject() |
622 : data_.node_layout_data_->GetLayoutObject(); | 623 : data_.node_layout_data_->GetLayoutObject(); |
623 } | 624 } |
624 void SetLayoutObject(LayoutObject*); | 625 void SetLayoutObject(LayoutObject*); |
625 // Use these two methods with caution. | 626 // Use these two methods with caution. |
626 LayoutBox* GetLayoutBox() const; | 627 LayoutBox* GetLayoutBox() const; |
627 LayoutBoxModelObject* GetLayoutBoxModelObject() const; | 628 LayoutBoxModelObject* GetLayoutBoxModelObject() const; |
628 | 629 |
629 struct AttachContext { | 630 struct AttachContext { |
630 STACK_ALLOCATED(); | 631 STACK_ALLOCATED(); |
631 ComputedStyle* resolved_style = nullptr; | 632 ComputedStyle* resolved_style = nullptr; |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 const HeapHashSet<TraceWrapperMember<MutationObserverRegistration>>* | 968 const HeapHashSet<TraceWrapperMember<MutationObserverRegistration>>* |
968 TransientMutationObserverRegistry(); | 969 TransientMutationObserverRegistry(); |
969 | 970 |
970 uint32_t node_flags_; | 971 uint32_t node_flags_; |
971 Member<ContainerNode> parent_or_shadow_host_node_; | 972 Member<ContainerNode> parent_or_shadow_host_node_; |
972 Member<TreeScope> tree_scope_; | 973 Member<TreeScope> tree_scope_; |
973 Member<Node> previous_; | 974 Member<Node> previous_; |
974 Member<Node> next_; | 975 Member<Node> next_; |
975 // When a node has rare data we move the layoutObject into the rare data. | 976 // When a node has rare data we move the layoutObject into the rare data. |
976 union DataUnion { | 977 union DataUnion { |
977 DataUnion() : node_layout_data_(&NodeLayoutData::SharedEmptyData()) {} | 978 DataUnion() : node_layout_data_(&NodeRenderingData::SharedEmptyData()) {} |
978 // LayoutObjects are fully owned by their DOM node. See LayoutObject's | 979 // LayoutObjects are fully owned by their DOM node. See LayoutObject's |
979 // LIFETIME documentation section. | 980 // LIFETIME documentation section. |
980 NodeLayoutData* node_layout_data_; | 981 NodeRenderingData* node_layout_data_; |
981 NodeRareDataBase* rare_data_; | 982 NodeRareDataBase* rare_data_; |
982 } data_; | 983 } data_; |
983 }; | 984 }; |
984 | 985 |
985 inline void Node::SetParentOrShadowHostNode(ContainerNode* parent) { | 986 inline void Node::SetParentOrShadowHostNode(ContainerNode* parent) { |
986 DCHECK(IsMainThread()); | 987 DCHECK(IsMainThread()); |
987 parent_or_shadow_host_node_ = parent; | 988 parent_or_shadow_host_node_ = parent; |
988 ScriptWrappableVisitor::WriteBarrier( | 989 ScriptWrappableVisitor::WriteBarrier( |
989 this, reinterpret_cast<Node*>(parent_or_shadow_host_node_.Get())); | 990 this, reinterpret_cast<Node*>(parent_or_shadow_host_node_.Get())); |
990 } | 991 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1037 } // namespace blink | 1038 } // namespace blink |
1038 | 1039 |
1039 #ifndef NDEBUG | 1040 #ifndef NDEBUG |
1040 // Outside the WebCore namespace for ease of invocation from gdb. | 1041 // Outside the WebCore namespace for ease of invocation from gdb. |
1041 void showNode(const blink::Node*); | 1042 void showNode(const blink::Node*); |
1042 void showTree(const blink::Node*); | 1043 void showTree(const blink::Node*); |
1043 void showNodePath(const blink::Node*); | 1044 void showNodePath(const blink::Node*); |
1044 #endif | 1045 #endif |
1045 | 1046 |
1046 #endif // Node_h | 1047 #endif // Node_h |
OLD | NEW |