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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 kFailed = 3 << kNodeCustomElementShift, | 90 kFailed = 3 << kNodeCustomElementShift, |
91 | 91 |
92 kNotDefinedFlag = 2 << kNodeCustomElementShift, | 92 kNotDefinedFlag = 2 << kNodeCustomElementShift, |
93 }; | 93 }; |
94 | 94 |
95 enum class SlotChangeType { | 95 enum class SlotChangeType { |
96 kInitial, | 96 kInitial, |
97 kChained, | 97 kChained, |
98 }; | 98 }; |
99 | 99 |
100 class NodeRareDataBase { | 100 class NodeLayoutData { |
101 public: | 101 public: |
| 102 explicit NodeLayoutData(LayoutObject* layout_object) |
| 103 : layout_object_(layout_object) {} |
| 104 |
102 LayoutObject* GetLayoutObject() const { return layout_object_; } | 105 LayoutObject* GetLayoutObject() const { return layout_object_; } |
103 void SetLayoutObject(LayoutObject* layout_object) { | 106 void SetLayoutObject(LayoutObject* layout_object) { |
104 layout_object_ = layout_object; | 107 layout_object_ = layout_object; |
105 } | 108 } |
106 | 109 |
107 protected: | 110 private: |
108 NodeRareDataBase(LayoutObject* layout_object) | |
109 : layout_object_(layout_object) {} | |
110 | |
111 protected: | |
112 // LayoutObjects are fully owned by their DOM node. See LayoutObject's | |
113 // LIFETIME documentation section. | |
114 LayoutObject* layout_object_; | 111 LayoutObject* layout_object_; |
115 }; | 112 }; |
116 | 113 |
| 114 class NodeRareDataBase { |
| 115 public: |
| 116 LayoutObject* GetLayoutObject() const { |
| 117 return layout_data_->GetLayoutObject(); |
| 118 } |
| 119 void SetLayoutObject(LayoutObject* layout_object) { |
| 120 layout_data_->SetLayoutObject(layout_object); |
| 121 } |
| 122 |
| 123 protected: |
| 124 NodeRareDataBase(LayoutObject* layout_object) { |
| 125 layout_data_ = new NodeLayoutData(layout_object); |
| 126 } |
| 127 |
| 128 protected: |
| 129 NodeLayoutData* layout_data_; |
| 130 }; |
| 131 |
117 class Node; | 132 class Node; |
118 WILL_NOT_BE_EAGERLY_TRACED_CLASS(Node); | 133 WILL_NOT_BE_EAGERLY_TRACED_CLASS(Node); |
119 | 134 |
120 // This class represents a DOM node in the DOM tree. | 135 // This class represents a DOM node in the DOM tree. |
121 // https://dom.spec.whatwg.org/#interface-node | 136 // https://dom.spec.whatwg.org/#interface-node |
122 class CORE_EXPORT Node : public EventTarget { | 137 class CORE_EXPORT Node : public EventTarget { |
123 DEFINE_WRAPPERTYPEINFO(); | 138 DEFINE_WRAPPERTYPEINFO(); |
124 friend class TreeScope; | 139 friend class TreeScope; |
125 friend class TreeScopeAdopter; | 140 friend class TreeScopeAdopter; |
126 | 141 |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 | 572 |
558 // ---------------------------------------------------------------------------
-- | 573 // ---------------------------------------------------------------------------
-- |
559 // Integration with layout tree | 574 // Integration with layout tree |
560 | 575 |
561 // As layoutObject() includes a branch you should avoid calling it repeatedly | 576 // As layoutObject() includes a branch you should avoid calling it repeatedly |
562 // in hot code paths. | 577 // in hot code paths. |
563 // Note that if a Node has a layoutObject, it's parentNode is guaranteed to | 578 // Note that if a Node has a layoutObject, it's parentNode is guaranteed to |
564 // have one as well. | 579 // have one as well. |
565 LayoutObject* GetLayoutObject() const { | 580 LayoutObject* GetLayoutObject() const { |
566 return HasRareData() ? data_.rare_data_->GetLayoutObject() | 581 return HasRareData() ? data_.rare_data_->GetLayoutObject() |
567 : data_.layout_object_; | 582 : data_.layout_data_->GetLayoutObject(); |
568 } | 583 } |
569 void SetLayoutObject(LayoutObject* layout_object) { | 584 void SetLayoutObject(LayoutObject* layout_object) { |
570 if (HasRareData()) | 585 if (HasRareData()) |
571 data_.rare_data_->SetLayoutObject(layout_object); | 586 data_.rare_data_->SetLayoutObject(layout_object); |
572 else | 587 else |
573 data_.layout_object_ = layout_object; | 588 data_.layout_data_->SetLayoutObject(layout_object); |
574 } | 589 } |
575 | 590 |
576 // Use these two methods with caution. | 591 // Use these two methods with caution. |
577 LayoutBox* GetLayoutBox() const; | 592 LayoutBox* GetLayoutBox() const; |
578 LayoutBoxModelObject* GetLayoutBoxModelObject() const; | 593 LayoutBoxModelObject* GetLayoutBoxModelObject() const; |
579 | 594 |
580 struct AttachContext { | 595 struct AttachContext { |
581 STACK_ALLOCATED(); | 596 STACK_ALLOCATED(); |
582 ComputedStyle* resolved_style = nullptr; | 597 ComputedStyle* resolved_style = nullptr; |
583 bool performing_reattach = false; | 598 bool performing_reattach = false; |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 const HeapHashSet<TraceWrapperMember<MutationObserverRegistration>>* | 933 const HeapHashSet<TraceWrapperMember<MutationObserverRegistration>>* |
919 TransientMutationObserverRegistry(); | 934 TransientMutationObserverRegistry(); |
920 | 935 |
921 uint32_t node_flags_; | 936 uint32_t node_flags_; |
922 Member<ContainerNode> parent_or_shadow_host_node_; | 937 Member<ContainerNode> parent_or_shadow_host_node_; |
923 Member<TreeScope> tree_scope_; | 938 Member<TreeScope> tree_scope_; |
924 Member<Node> previous_; | 939 Member<Node> previous_; |
925 Member<Node> next_; | 940 Member<Node> next_; |
926 // When a node has rare data we move the layoutObject into the rare data. | 941 // When a node has rare data we move the layoutObject into the rare data. |
927 union DataUnion { | 942 union DataUnion { |
928 DataUnion() : layout_object_(nullptr) {} | 943 DataUnion() { layout_data_ = new NodeLayoutData(nullptr); } |
929 // LayoutObjects are fully owned by their DOM node. See LayoutObject's | 944 // LayoutObjects are fully owned by their DOM node. See LayoutObject's |
930 // LIFETIME documentation section. | 945 // LIFETIME documentation section. |
931 LayoutObject* layout_object_; | 946 NodeLayoutData* layout_data_; |
932 NodeRareDataBase* rare_data_; | 947 NodeRareDataBase* rare_data_; |
933 } data_; | 948 } data_; |
934 }; | 949 }; |
935 | 950 |
936 inline void Node::SetParentOrShadowHostNode(ContainerNode* parent) { | 951 inline void Node::SetParentOrShadowHostNode(ContainerNode* parent) { |
937 DCHECK(IsMainThread()); | 952 DCHECK(IsMainThread()); |
938 parent_or_shadow_host_node_ = parent; | 953 parent_or_shadow_host_node_ = parent; |
939 ScriptWrappableVisitor::WriteBarrier( | 954 ScriptWrappableVisitor::WriteBarrier( |
940 this, reinterpret_cast<Node*>(parent_or_shadow_host_node_.Get())); | 955 this, reinterpret_cast<Node*>(parent_or_shadow_host_node_.Get())); |
941 } | 956 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
994 } // namespace blink | 1009 } // namespace blink |
995 | 1010 |
996 #ifndef NDEBUG | 1011 #ifndef NDEBUG |
997 // Outside the WebCore namespace for ease of invocation from gdb. | 1012 // Outside the WebCore namespace for ease of invocation from gdb. |
998 void showNode(const blink::Node*); | 1013 void showNode(const blink::Node*); |
999 void showTree(const blink::Node*); | 1014 void showTree(const blink::Node*); |
1000 void showNodePath(const blink::Node*); | 1015 void showNodePath(const blink::Node*); |
1001 #endif | 1016 #endif |
1002 | 1017 |
1003 #endif // Node_h | 1018 #endif // Node_h |
OLD | NEW |