Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: third_party/WebKit/Source/core/dom/Node.h

Issue 2814603002: Move LayoutObject to satellite NodeLayoutData that hangs from a Node. (Closed)
Patch Set: Question Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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) : layout_object_(layout_o bject) {}
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 LayoutObject* layout_object_;
109 : layout_object_(layout_object) {} 110 };
110 111
111 protected: 112 class NodeRareDataBase {
112 // LayoutObjects are fully owned by their DOM node. See LayoutObject's
113 // LIFETIME documentation section.
114 LayoutObject* layout_object_;
115 }; 113 };
116 114
117 class Node; 115 class Node;
118 WILL_NOT_BE_EAGERLY_TRACED_CLASS(Node); 116 WILL_NOT_BE_EAGERLY_TRACED_CLASS(Node);
119 117
120 // This class represents a DOM node in the DOM tree. 118 // This class represents a DOM node in the DOM tree.
121 // https://dom.spec.whatwg.org/#interface-node 119 // https://dom.spec.whatwg.org/#interface-node
122 class CORE_EXPORT Node : public EventTarget { 120 class CORE_EXPORT Node : public EventTarget {
123 DEFINE_WRAPPERTYPEINFO(); 121 DEFINE_WRAPPERTYPEINFO();
124 friend class TreeScope; 122 friend class TreeScope;
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 virtual bool CanStartSelection() const; 554 virtual bool CanStartSelection() const;
557 555
558 // --------------------------------------------------------------------------- -- 556 // --------------------------------------------------------------------------- --
559 // Integration with layout tree 557 // Integration with layout tree
560 558
561 // As layoutObject() includes a branch you should avoid calling it repeatedly 559 // As layoutObject() includes a branch you should avoid calling it repeatedly
562 // in hot code paths. 560 // in hot code paths.
563 // Note that if a Node has a layoutObject, it's parentNode is guaranteed to 561 // Note that if a Node has a layoutObject, it's parentNode is guaranteed to
564 // have one as well. 562 // have one as well.
565 LayoutObject* GetLayoutObject() const { 563 LayoutObject* GetLayoutObject() const {
566 return HasRareData() ? data_.rare_data_->GetLayoutObject() 564 return data_.node_layout_data_ ? data_.node_layout_data_->GetLayoutObject() : nullptr;
567 : data_.layout_object_;
568 } 565 }
569 void SetLayoutObject(LayoutObject* layout_object) { 566 void SetLayoutObject(LayoutObject* layout_object) {
570 if (HasRareData()) 567 data_.node_layout_data_->SetLayoutObject(layout_object);
571 data_.rare_data_->SetLayoutObject(layout_object);
572 else
573 data_.layout_object_ = layout_object;
574 } 568 }
575 569
576 // Use these two methods with caution. 570 // Use these two methods with caution.
577 LayoutBox* GetLayoutBox() const; 571 LayoutBox* GetLayoutBox() const;
578 LayoutBoxModelObject* GetLayoutBoxModelObject() const; 572 LayoutBoxModelObject* GetLayoutBoxModelObject() const;
579 573
580 struct AttachContext { 574 struct AttachContext {
581 STACK_ALLOCATED(); 575 STACK_ALLOCATED();
582 ComputedStyle* resolved_style = nullptr; 576 ComputedStyle* resolved_style = nullptr;
583 bool performing_reattach = false; 577 bool performing_reattach = false;
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 const HeapHashSet<TraceWrapperMember<MutationObserverRegistration>>* 912 const HeapHashSet<TraceWrapperMember<MutationObserverRegistration>>*
919 TransientMutationObserverRegistry(); 913 TransientMutationObserverRegistry();
920 914
921 uint32_t node_flags_; 915 uint32_t node_flags_;
922 Member<ContainerNode> parent_or_shadow_host_node_; 916 Member<ContainerNode> parent_or_shadow_host_node_;
923 Member<TreeScope> tree_scope_; 917 Member<TreeScope> tree_scope_;
924 Member<Node> previous_; 918 Member<Node> previous_;
925 Member<Node> next_; 919 Member<Node> next_;
926 // When a node has rare data we move the layoutObject into the rare data. 920 // When a node has rare data we move the layoutObject into the rare data.
927 union DataUnion { 921 union DataUnion {
928 DataUnion() : layout_object_(nullptr) {} 922 DataUnion() : node_layout_data_(nullptr) {}
929 // LayoutObjects are fully owned by their DOM node. See LayoutObject's 923 // LayoutObjects are fully owned by their DOM node. See LayoutObject's
930 // LIFETIME documentation section. 924 // LIFETIME documentation section.
931 LayoutObject* layout_object_; 925 NodeLayoutData* node_layout_data_;
nainar 2017/04/11 06:03:59 If the DataUnion is a NodeLayoutData we then have
932 NodeRareDataBase* rare_data_; 926 NodeRareDataBase* rare_data_;
nainar 2017/04/11 06:03:59 However, if we have a NodeRareDataBase we don't ha
933 } data_; 927 } data_;
934 }; 928 };
935 929
936 inline void Node::SetParentOrShadowHostNode(ContainerNode* parent) { 930 inline void Node::SetParentOrShadowHostNode(ContainerNode* parent) {
937 DCHECK(IsMainThread()); 931 DCHECK(IsMainThread());
938 parent_or_shadow_host_node_ = parent; 932 parent_or_shadow_host_node_ = parent;
939 ScriptWrappableVisitor::WriteBarrier( 933 ScriptWrappableVisitor::WriteBarrier(
940 this, reinterpret_cast<Node*>(parent_or_shadow_host_node_.Get())); 934 this, reinterpret_cast<Node*>(parent_or_shadow_host_node_.Get()));
941 } 935 }
942 936
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 } // namespace blink 988 } // namespace blink
995 989
996 #ifndef NDEBUG 990 #ifndef NDEBUG
997 // Outside the WebCore namespace for ease of invocation from gdb. 991 // Outside the WebCore namespace for ease of invocation from gdb.
998 void showNode(const blink::Node*); 992 void showNode(const blink::Node*);
999 void showTree(const blink::Node*); 993 void showTree(const blink::Node*);
1000 void showNodePath(const blink::Node*); 994 void showNodePath(const blink::Node*);
1001 #endif 995 #endif
1002 996
1003 #endif // Node_h 997 #endif // Node_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/ElementRareData.h ('k') | third_party/WebKit/Source/core/dom/Node.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698