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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 class Event; | 50 class Event; |
| 51 class ExceptionState; | 51 class ExceptionState; |
| 52 class GetRootNodeOptions; | 52 class GetRootNodeOptions; |
| 53 class HTMLQualifiedName; | 53 class HTMLQualifiedName; |
| 54 class HTMLSlotElement; | 54 class HTMLSlotElement; |
| 55 class IntRect; | 55 class IntRect; |
| 56 class EventDispatchHandlingState; | 56 class EventDispatchHandlingState; |
| 57 class NodeList; | 57 class NodeList; |
| 58 class NodeListsNodeData; | 58 class NodeListsNodeData; |
| 59 class NodeOrString; | 59 class NodeOrString; |
| 60 class NodeLayoutData; | |
| 60 class NodeRareData; | 61 class NodeRareData; |
| 61 class QualifiedName; | 62 class QualifiedName; |
| 62 class RegisteredEventListener; | 63 class RegisteredEventListener; |
| 63 class LayoutBox; | 64 class LayoutBox; |
| 64 class LayoutBoxModelObject; | 65 class LayoutBoxModelObject; |
| 65 class LayoutObject; | 66 class LayoutObject; |
| 66 class ComputedStyle; | 67 class ComputedStyle; |
| 67 class SVGQualifiedName; | 68 class SVGQualifiedName; |
| 68 class ShadowRoot; | 69 class ShadowRoot; |
| 69 template <typename NodeType> | 70 template <typename NodeType> |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 91 kFailed = 3 << kNodeCustomElementShift, | 92 kFailed = 3 << kNodeCustomElementShift, |
| 92 | 93 |
| 93 kNotDefinedFlag = 2 << kNodeCustomElementShift, | 94 kNotDefinedFlag = 2 << kNodeCustomElementShift, |
| 94 }; | 95 }; |
| 95 | 96 |
| 96 enum class SlotChangeType { | 97 enum class SlotChangeType { |
| 97 kInitial, | 98 kInitial, |
| 98 kChained, | 99 kChained, |
| 99 }; | 100 }; |
| 100 | 101 |
| 102 class NodeLayoutData { | |
| 103 public: | |
| 104 explicit NodeLayoutData(LayoutObject* layout_object) | |
| 105 : layout_object_(layout_object) {} | |
| 106 LayoutObject* GetLayoutObject() const { return layout_object_; } | |
| 107 void SetLayoutObject(LayoutObject* layout_object) { | |
| 108 layout_object_ = layout_object; | |
|
esprehn
2017/04/13 00:30:47
DCHECK_NE(&SharedEmptyData(), this);
nainar
2017/04/13 15:02:02
Done.
| |
| 109 } | |
| 110 static NodeLayoutData& SharedEmptyData() { | |
| 111 static NodeLayoutData shared_empty_data_(nullptr); | |
| 112 return shared_empty_data_; | |
| 113 } | |
| 114 | |
| 115 private: | |
| 116 LayoutObject* layout_object_; | |
| 117 }; | |
| 118 | |
| 101 class NodeRareDataBase { | 119 class NodeRareDataBase { |
| 102 public: | 120 public: |
| 103 LayoutObject* GetLayoutObject() const { return layout_object_; } | 121 NodeLayoutData* GetNodeLayoutData() const { |
| 104 void SetLayoutObject(LayoutObject* layout_object) { | 122 return node_layout_data_ ? node_layout_data_ |
|
esprehn
2017/04/13 00:30:47
The point of the SharedEmptyData() is that we don'
nainar
2017/04/13 15:02:02
Changed to
return node_layout_data_;
| |
| 105 layout_object_ = layout_object; | 123 : &NodeLayoutData::SharedEmptyData(); |
| 124 } | |
| 125 void SetNodeLayoutData(NodeLayoutData* node_layout_data) { | |
|
esprehn
2017/04/13 00:30:47
DCHECK(node_layout_data)
nainar
2017/04/13 15:02:02
Done.
| |
| 126 node_layout_data_ = node_layout_data; | |
| 106 } | 127 } |
| 107 | 128 |
| 108 protected: | 129 protected: |
| 109 NodeRareDataBase(LayoutObject* layout_object) | 130 NodeRareDataBase(NodeLayoutData* node_layout_data) |
| 110 : layout_object_(layout_object) {} | 131 : node_layout_data_(node_layout_data) {} |
| 111 | 132 |
| 112 protected: | 133 protected: |
| 113 // LayoutObjects are fully owned by their DOM node. See LayoutObject's | 134 NodeLayoutData* node_layout_data_; |
|
esprehn
2017/04/13 00:30:47
you need a destructor for NodeRareDataBase and ins
nainar
2017/04/13 15:02:02
Done.
| |
| 114 // LIFETIME documentation section. | |
| 115 LayoutObject* layout_object_; | |
| 116 }; | 135 }; |
| 117 | 136 |
| 118 class Node; | 137 class Node; |
| 119 WILL_NOT_BE_EAGERLY_TRACED_CLASS(Node); | 138 WILL_NOT_BE_EAGERLY_TRACED_CLASS(Node); |
| 120 | 139 |
| 121 // This class represents a DOM node in the DOM tree. | 140 // This class represents a DOM node in the DOM tree. |
| 122 // https://dom.spec.whatwg.org/#interface-node | 141 // https://dom.spec.whatwg.org/#interface-node |
| 123 class CORE_EXPORT Node : public EventTarget { | 142 class CORE_EXPORT Node : public EventTarget { |
| 124 DEFINE_WRAPPERTYPEINFO(); | 143 DEFINE_WRAPPERTYPEINFO(); |
| 125 friend class TreeScope; | 144 friend class TreeScope; |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 561 virtual bool CanStartSelection() const; | 580 virtual bool CanStartSelection() const; |
| 562 | 581 |
| 563 // --------------------------------------------------------------------------- -- | 582 // --------------------------------------------------------------------------- -- |
| 564 // Integration with layout tree | 583 // Integration with layout tree |
| 565 | 584 |
| 566 // As layoutObject() includes a branch you should avoid calling it repeatedly | 585 // As layoutObject() includes a branch you should avoid calling it repeatedly |
| 567 // in hot code paths. | 586 // in hot code paths. |
| 568 // Note that if a Node has a layoutObject, it's parentNode is guaranteed to | 587 // Note that if a Node has a layoutObject, it's parentNode is guaranteed to |
| 569 // have one as well. | 588 // have one as well. |
| 570 LayoutObject* GetLayoutObject() const { | 589 LayoutObject* GetLayoutObject() const { |
| 571 return HasRareData() ? data_.rare_data_->GetLayoutObject() | 590 return HasRareData() |
| 572 : data_.layout_object_; | 591 ? data_.rare_data_->GetNodeLayoutData()->GetLayoutObject() |
| 592 : data_.node_layout_data_->GetLayoutObject(); | |
| 573 } | 593 } |
| 574 void SetLayoutObject(LayoutObject* layout_object) { | 594 void SetLayoutObject(LayoutObject* layout_object) { |
|
esprehn
2017/04/13 00:30:47
This function has become so big, I'd suggest movin
nainar
2017/04/13 15:02:02
Done.
| |
| 575 if (HasRareData()) | 595 if (HasRareData()) { |
|
nainar
2017/04/13 00:10:22
Can make this less complicated by adding a EnsureL
| |
| 576 data_.rare_data_->SetLayoutObject(layout_object); | 596 data_.rare_data_->GetNodeLayoutData() == |
|
esprehn
2017/04/13 00:30:47
we should put this in a method on NodeLayoutData l
nainar
2017/04/13 15:02:02
Done.
| |
| 577 else | 597 &NodeLayoutData::SharedEmptyData() |
| 578 data_.layout_object_ = layout_object; | 598 ? data_.rare_data_->SetNodeLayoutData( |
| 599 new NodeLayoutData(layout_object)) | |
| 600 : data_.rare_data_->GetNodeLayoutData()->SetLayoutObject( | |
| 601 layout_object); | |
| 602 } else { | |
| 603 if (data_.node_layout_data_ == &NodeLayoutData::SharedEmptyData()) | |
|
esprehn
2017/04/13 00:30:47
if (data_.node_layout_data_->IsShared())
nainar
2017/04/13 15:02:02
Done.
| |
| 604 data_.node_layout_data_ = new NodeLayoutData(layout_object); | |
| 605 else | |
| 606 data_.node_layout_data_->SetLayoutObject(layout_object); | |
| 607 } | |
| 579 } | 608 } |
| 580 | 609 |
| 581 // Use these two methods with caution. | 610 // Use these two methods with caution. |
| 582 LayoutBox* GetLayoutBox() const; | 611 LayoutBox* GetLayoutBox() const; |
| 583 LayoutBoxModelObject* GetLayoutBoxModelObject() const; | 612 LayoutBoxModelObject* GetLayoutBoxModelObject() const; |
| 584 | 613 |
| 585 struct AttachContext { | 614 struct AttachContext { |
| 586 STACK_ALLOCATED(); | 615 STACK_ALLOCATED(); |
| 587 ComputedStyle* resolved_style = nullptr; | 616 ComputedStyle* resolved_style = nullptr; |
| 588 bool performing_reattach = false; | 617 bool performing_reattach = false; |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 923 const HeapHashSet<TraceWrapperMember<MutationObserverRegistration>>* | 952 const HeapHashSet<TraceWrapperMember<MutationObserverRegistration>>* |
| 924 TransientMutationObserverRegistry(); | 953 TransientMutationObserverRegistry(); |
| 925 | 954 |
| 926 uint32_t node_flags_; | 955 uint32_t node_flags_; |
| 927 Member<ContainerNode> parent_or_shadow_host_node_; | 956 Member<ContainerNode> parent_or_shadow_host_node_; |
| 928 Member<TreeScope> tree_scope_; | 957 Member<TreeScope> tree_scope_; |
| 929 Member<Node> previous_; | 958 Member<Node> previous_; |
| 930 Member<Node> next_; | 959 Member<Node> next_; |
| 931 // When a node has rare data we move the layoutObject into the rare data. | 960 // When a node has rare data we move the layoutObject into the rare data. |
| 932 union DataUnion { | 961 union DataUnion { |
| 933 DataUnion() : layout_object_(nullptr) {} | 962 DataUnion() : node_layout_data_(&NodeLayoutData::SharedEmptyData()) {} |
| 934 // LayoutObjects are fully owned by their DOM node. See LayoutObject's | 963 // LayoutObjects are fully owned by their DOM node. See LayoutObject's |
| 935 // LIFETIME documentation section. | 964 // LIFETIME documentation section. |
| 936 LayoutObject* layout_object_; | 965 NodeLayoutData* node_layout_data_; |
| 937 NodeRareDataBase* rare_data_; | 966 NodeRareDataBase* rare_data_; |
| 938 } data_; | 967 } data_; |
| 939 }; | 968 }; |
| 940 | 969 |
| 941 inline void Node::SetParentOrShadowHostNode(ContainerNode* parent) { | 970 inline void Node::SetParentOrShadowHostNode(ContainerNode* parent) { |
| 942 DCHECK(IsMainThread()); | 971 DCHECK(IsMainThread()); |
| 943 parent_or_shadow_host_node_ = parent; | 972 parent_or_shadow_host_node_ = parent; |
| 944 ScriptWrappableVisitor::WriteBarrier( | 973 ScriptWrappableVisitor::WriteBarrier( |
| 945 this, reinterpret_cast<Node*>(parent_or_shadow_host_node_.Get())); | 974 this, reinterpret_cast<Node*>(parent_or_shadow_host_node_.Get())); |
| 946 } | 975 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 999 } // namespace blink | 1028 } // namespace blink |
| 1000 | 1029 |
| 1001 #ifndef NDEBUG | 1030 #ifndef NDEBUG |
| 1002 // Outside the WebCore namespace for ease of invocation from gdb. | 1031 // Outside the WebCore namespace for ease of invocation from gdb. |
| 1003 void showNode(const blink::Node*); | 1032 void showNode(const blink::Node*); |
| 1004 void showTree(const blink::Node*); | 1033 void showTree(const blink::Node*); |
| 1005 void showNodePath(const blink::Node*); | 1034 void showNodePath(const blink::Node*); |
| 1006 #endif | 1035 #endif |
| 1007 | 1036 |
| 1008 #endif // Node_h | 1037 #endif // Node_h |
| OLD | NEW |