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

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

Issue 2821193003: Store nonAttachedStyle on NodeLayoutData instead of on HashMap in Document. (Closed)
Patch Set: Clear NonAttachedStyle in (Attach/Detach)LayoutTree 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') | no next file » | 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 d5e59f90244c194809224a45f0f64f44e4fc4c27..b0406d907daf3ac8d3ad678a87cd8c8d1fa6b63a 100644
--- a/third_party/WebKit/Source/core/dom/Node.cpp
+++ b/third_party/WebKit/Source/core/dom/Node.cpp
@@ -606,7 +606,44 @@ void Node::SetLayoutObject(LayoutObject* layout_object) {
// Swap the NodeLayoutData to point to a new NodeLayoutData instead of the
// static SharedEmptyData instance.
- node_layout_data = new NodeLayoutData(layout_object);
+ DCHECK(!node_layout_data->GetNonAttachedStyle());
+ node_layout_data = new NodeLayoutData(layout_object, nullptr);
+ if (HasRareData())
+ data_.rare_data_->SetNodeLayoutData(node_layout_data);
+ else
+ data_.node_layout_data_ = node_layout_data;
+}
+
+void Node::SetNonAttachedStyle(RefPtr<ComputedStyle> non_attached_style) {
+ NodeLayoutData* node_layout_data = HasRareData()
+ ? data_.rare_data_->GetNodeLayoutData()
+ : data_.node_layout_data_;
+
+ if (!node_layout_data->IsSharedEmptyData()) {
+ if (non_attached_style) {
+ node_layout_data->SetNonAttachedStyle(non_attached_style);
+ } else {
+ if (node_layout_data->GetLayoutObject()) {
+ node_layout_data->SetNonAttachedStyle(nullptr);
+ } else {
+ if (HasRareData()) {
+ data_.rare_data_->SetNodeLayoutData(
+ &NodeLayoutData::SharedEmptyData());
+ } else {
+ data_.node_layout_data_ = &NodeLayoutData::SharedEmptyData();
rune 2017/04/26 08:47:28 Won't this leak the previously set node_layout_dat
nainar 2017/04/27 01:50:06 Yup, I see what you mean. I have reverted the CL b
+ }
+ }
+ }
+ return;
+ }
+
+ if (!non_attached_style)
+ return;
+
+ // Swap the NodeLayoutData to point to a new NodeLayoutData instead of the
+ // static SharedEmptyData instance.
+ DCHECK(!node_layout_data->GetLayoutObject());
+ node_layout_data = new NodeLayoutData(nullptr, non_attached_style);
if (HasRareData())
data_.rare_data_->SetNodeLayoutData(node_layout_data);
else
« no previous file with comments | « third_party/WebKit/Source/core/dom/Node.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698