| 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()
|
|
|