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

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: Post lgtm review 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
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..9dce05438d3d369adcb0ed898ba39b2b781883c8 100644
--- a/third_party/WebKit/Source/core/dom/Node.cpp
+++ b/third_party/WebKit/Source/core/dom/Node.cpp
@@ -298,6 +298,8 @@ Node::~Node() {
// With Oilpan, the rare data finalizer also asserts for
// this condition (we cannot directly access it here.)
CHECK(HasRareData() || !GetLayoutObject());
esprehn 2017/04/13 22:02:49 You can remove this CHECK and the comment now, the
nainar 2017/04/13 22:28:16 Done.
+ if (!HasRareData() && !data_.node_layout_data_->IsSharedEmptyData())
+ delete data_.node_layout_data_;
InstanceCounters::DecrementNodeCounter();
}
@@ -311,9 +313,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 +591,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.
esprehn 2017/04/13 22:02:49 extra //
nainar 2017/04/13 22:28:16 I can't even. git cl format broke this I guess. Do
+ 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 //
esprehn 2017/04/13 22:02:49 extra //
nainar 2017/04/13 22:28:16 Done.
+ // 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()

Powered by Google App Engine
This is Rietveld 408576698