Chromium Code Reviews| 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 LayoutData { |
|
esprehn
2017/04/10 22:20:12
NodeLayoutData maybe? LayoutData is pretty generic
nainar
2017/04/13 00:10:22
Done.
| |
| 101 public: | 101 public: |
| 102 LayoutData(LayoutObject* layout_object) : layout_object_(layout_object) {} | |
|
esprehn
2017/04/10 22:20:12
explicit on all single arg constructors unless you
nainar
2017/04/13 00:10:22
Done.
| |
| 102 LayoutObject* GetLayoutObject() const { return layout_object_; } | 103 LayoutObject* GetLayoutObject() const { return layout_object_; } |
| 103 void SetLayoutObject(LayoutObject* layout_object) { | 104 void SetLayoutObject(LayoutObject* layout_object) { |
| 104 layout_object_ = layout_object; | 105 layout_object_ = layout_object; |
| 105 } | 106 } |
| 106 | 107 |
| 107 protected: | 108 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_; | 109 LayoutObject* layout_object_; |
| 115 }; | 110 }; |
| 116 | 111 |
| 112 class NodeRareDataBase { | |
| 113 public: | |
| 114 LayoutData* GetLayoutData() const { return layout_data_; } | |
| 115 void SetLayoutData(LayoutData* layout_data) { layout_data_ = layout_data; } | |
| 116 | |
| 117 protected: | |
| 118 NodeRareDataBase(LayoutObject* layout_object) { | |
| 119 layout_data_ = new LayoutData(layout_object); | |
| 120 } | |
| 121 | |
| 122 protected: | |
| 123 LayoutData* layout_data_; | |
| 124 }; | |
| 125 | |
| 117 class Node; | 126 class Node; |
| 118 WILL_NOT_BE_EAGERLY_TRACED_CLASS(Node); | 127 WILL_NOT_BE_EAGERLY_TRACED_CLASS(Node); |
| 119 | 128 |
| 120 // This class represents a DOM node in the DOM tree. | 129 // This class represents a DOM node in the DOM tree. |
| 121 // https://dom.spec.whatwg.org/#interface-node | 130 // https://dom.spec.whatwg.org/#interface-node |
| 122 class CORE_EXPORT Node : public EventTarget { | 131 class CORE_EXPORT Node : public EventTarget { |
| 123 DEFINE_WRAPPERTYPEINFO(); | 132 DEFINE_WRAPPERTYPEINFO(); |
| 124 friend class TreeScope; | 133 friend class TreeScope; |
| 125 friend class TreeScopeAdopter; | 134 friend class TreeScopeAdopter; |
| 126 | 135 |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 556 virtual bool CanStartSelection() const; | 565 virtual bool CanStartSelection() const; |
| 557 | 566 |
| 558 // --------------------------------------------------------------------------- -- | 567 // --------------------------------------------------------------------------- -- |
| 559 // Integration with layout tree | 568 // Integration with layout tree |
| 560 | 569 |
| 561 // As layoutObject() includes a branch you should avoid calling it repeatedly | 570 // As layoutObject() includes a branch you should avoid calling it repeatedly |
| 562 // in hot code paths. | 571 // in hot code paths. |
| 563 // Note that if a Node has a layoutObject, it's parentNode is guaranteed to | 572 // Note that if a Node has a layoutObject, it's parentNode is guaranteed to |
| 564 // have one as well. | 573 // have one as well. |
| 565 LayoutObject* GetLayoutObject() const { | 574 LayoutObject* GetLayoutObject() const { |
| 566 return HasRareData() ? data_.rare_data_->GetLayoutObject() | 575 return HasRareData() ? data_.rare_data_->GetLayoutData()->GetLayoutObject() |
| 567 : data_.layout_object_; | 576 : data_.layout_data_->GetLayoutObject(); |
| 568 } | 577 } |
| 569 void SetLayoutObject(LayoutObject* layout_object) { | 578 void SetLayoutObject(LayoutObject* layout_object) { |
| 570 if (HasRareData()) | 579 if (HasRareData()) |
| 571 data_.rare_data_->SetLayoutObject(layout_object); | 580 data_.rare_data_->GetLayoutData()->SetLayoutObject(layout_object); |
| 572 else | 581 else |
| 573 data_.layout_object_ = layout_object; | 582 data_.layout_data_->SetLayoutObject(layout_object); |
| 574 } | 583 } |
| 575 | 584 |
| 576 // Use these two methods with caution. | 585 // Use these two methods with caution. |
| 577 LayoutBox* GetLayoutBox() const; | 586 LayoutBox* GetLayoutBox() const; |
| 578 LayoutBoxModelObject* GetLayoutBoxModelObject() const; | 587 LayoutBoxModelObject* GetLayoutBoxModelObject() const; |
| 579 | 588 |
| 580 struct AttachContext { | 589 struct AttachContext { |
| 581 STACK_ALLOCATED(); | 590 STACK_ALLOCATED(); |
| 582 ComputedStyle* resolved_style = nullptr; | 591 ComputedStyle* resolved_style = nullptr; |
| 583 bool performing_reattach = false; | 592 bool performing_reattach = false; |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 918 const HeapHashSet<TraceWrapperMember<MutationObserverRegistration>>* | 927 const HeapHashSet<TraceWrapperMember<MutationObserverRegistration>>* |
| 919 TransientMutationObserverRegistry(); | 928 TransientMutationObserverRegistry(); |
| 920 | 929 |
| 921 uint32_t node_flags_; | 930 uint32_t node_flags_; |
| 922 Member<ContainerNode> parent_or_shadow_host_node_; | 931 Member<ContainerNode> parent_or_shadow_host_node_; |
| 923 Member<TreeScope> tree_scope_; | 932 Member<TreeScope> tree_scope_; |
| 924 Member<Node> previous_; | 933 Member<Node> previous_; |
| 925 Member<Node> next_; | 934 Member<Node> next_; |
| 926 // When a node has rare data we move the layoutObject into the rare data. | 935 // When a node has rare data we move the layoutObject into the rare data. |
| 927 union DataUnion { | 936 union DataUnion { |
| 928 DataUnion() : layout_object_(nullptr) {} | 937 DataUnion() : layout_data_(nullptr) {} |
| 929 // LayoutObjects are fully owned by their DOM node. See LayoutObject's | 938 // LayoutObjects are fully owned by their DOM node. See LayoutObject's |
| 930 // LIFETIME documentation section. | 939 // LIFETIME documentation section. |
| 931 LayoutObject* layout_object_; | 940 LayoutData* layout_data_; |
| 932 NodeRareDataBase* rare_data_; | 941 NodeRareDataBase* rare_data_; |
| 933 } data_; | 942 } data_; |
| 934 }; | 943 }; |
| 935 | 944 |
| 936 inline void Node::SetParentOrShadowHostNode(ContainerNode* parent) { | 945 inline void Node::SetParentOrShadowHostNode(ContainerNode* parent) { |
| 937 DCHECK(IsMainThread()); | 946 DCHECK(IsMainThread()); |
| 938 parent_or_shadow_host_node_ = parent; | 947 parent_or_shadow_host_node_ = parent; |
| 939 ScriptWrappableVisitor::WriteBarrier( | 948 ScriptWrappableVisitor::WriteBarrier( |
| 940 this, reinterpret_cast<Node*>(parent_or_shadow_host_node_.Get())); | 949 this, reinterpret_cast<Node*>(parent_or_shadow_host_node_.Get())); |
| 941 } | 950 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 994 } // namespace blink | 1003 } // namespace blink |
| 995 | 1004 |
| 996 #ifndef NDEBUG | 1005 #ifndef NDEBUG |
| 997 // Outside the WebCore namespace for ease of invocation from gdb. | 1006 // Outside the WebCore namespace for ease of invocation from gdb. |
| 998 void showNode(const blink::Node*); | 1007 void showNode(const blink::Node*); |
| 999 void showTree(const blink::Node*); | 1008 void showTree(const blink::Node*); |
| 1000 void showNodePath(const blink::Node*); | 1009 void showNodePath(const blink::Node*); |
| 1001 #endif | 1010 #endif |
| 1002 | 1011 |
| 1003 #endif // Node_h | 1012 #endif // Node_h |
| OLD | NEW |