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

Unified Diff: third_party/WebKit/Source/core/dom/Node.cpp

Issue 2814603002: Move LayoutObject to satellite NodeLayoutData that hangs from a Node. (Closed)
Patch Set: esprehn comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/dom/Node.h ('k') | third_party/WebKit/Source/core/dom/NodeRareData.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/Node.cpp
diff --git a/third_party/WebKit/Source/core/dom/Node.cpp b/third_party/WebKit/Source/core/dom/Node.cpp
index e7d6f098551ae1870c005465e4180553085f1d3f..a61464b7c7b714a55b57fa53ef6c8f894772ec11 100644
--- a/third_party/WebKit/Source/core/dom/Node.cpp
+++ b/third_party/WebKit/Source/core/dom/Node.cpp
@@ -295,9 +295,8 @@ Node::Node(TreeScope* tree_scope, ConstructionType type)
}
Node::~Node() {
- // With Oilpan, the rare data finalizer also asserts for
- // this condition (we cannot directly access it here.)
- CHECK(HasRareData() || !GetLayoutObject());
+ if (!HasRareData() && !data_.node_layout_data_->IsSharedEmptyData())
+ delete data_.node_layout_data_;
InstanceCounters::DecrementNodeCounter();
}
@@ -311,9 +310,9 @@ NodeRareData& Node::EnsureRareData() {
return *RareData();
if (IsElementNode())
- data_.rare_data_ = ElementRareData::Create(data_.layout_object_);
+ data_.rare_data_ = ElementRareData::Create(data_.node_layout_data_);
else
- data_.rare_data_ = NodeRareData::Create(data_.layout_object_);
+ data_.rare_data_ = NodeRareData::Create(data_.node_layout_data_);
DCHECK(data_.rare_data_);
SetFlag(kHasRareDataFlag);
@@ -589,6 +588,30 @@ LayoutBox* Node::GetLayoutBox() const {
: nullptr;
}
+void Node::SetLayoutObject(LayoutObject* layout_object) {
+ NodeLayoutData* node_layout_data = HasRareData()
+ ? data_.rare_data_->GetNodeLayoutData()
+ : data_.node_layout_data_;
+
+ // Already pointing to a non empty NodeLayoutData so just set the pointer to
+ // the new LayoutObject.
+ if (!node_layout_data->IsSharedEmptyData()) {
+ node_layout_data->SetLayoutObject(layout_object);
+ return;
+ }
+
+ if (!layout_object)
+ return;
+
+ // Swap the NodeLayoutData to point to a new NodeLayoutData instead of the
+ // static SharedEmptyData instance.
+ node_layout_data = new NodeLayoutData(layout_object);
+ if (HasRareData())
+ data_.rare_data_->SetNodeLayoutData(node_layout_data);
+ else
+ data_.node_layout_data_ = node_layout_data;
+}
+
LayoutBoxModelObject* Node::GetLayoutBoxModelObject() const {
LayoutObject* layout_object = this->GetLayoutObject();
return layout_object && layout_object->IsBoxModelObject()
« no previous file with comments | « third_party/WebKit/Source/core/dom/Node.h ('k') | third_party/WebKit/Source/core/dom/NodeRareData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698