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

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: Revert back to rune@'s lgtmed patch 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..efda35024a8367079e0a91bec69f0b13a9146bae 100644
--- a/third_party/WebKit/Source/core/dom/Node.cpp
+++ b/third_party/WebKit/Source/core/dom/Node.cpp
@@ -606,7 +606,33 @@ 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_;
+
+ // Already pointing to a non empty NodeLayoutData so just set the pointer to
+ // the new LayoutObject.
+ if (!node_layout_data->IsSharedEmptyData()) {
+ node_layout_data->SetNonAttachedStyle(non_attached_style);
+ 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