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

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

Issue 2821193003: Store nonAttachedStyle on NodeLayoutData instead of on HashMap in Document. (Closed)
Patch Set: 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.h
diff --git a/third_party/WebKit/Source/core/dom/Node.h b/third_party/WebKit/Source/core/dom/Node.h
index 369b8c5263bd8626f16ba3293971f3d4813db904..81c6b94f7c6594595ca6b7839082d546ce5f792b 100644
--- a/third_party/WebKit/Source/core/dom/Node.h
+++ b/third_party/WebKit/Source/core/dom/Node.h
@@ -34,6 +34,7 @@
#include "core/dom/TreeScope.h"
#include "core/editing/EditingBoundary.h"
#include "core/events/EventTarget.h"
+#include "core/style/ComputedStyle.h"
#include "core/style/ComputedStyleConstants.h"
#include "platform/geometry/LayoutRect.h"
#include "public/platform/WebFocusType.h"
@@ -101,8 +102,10 @@ enum class SlotChangeType {
class NodeLayoutData {
public:
- explicit NodeLayoutData(LayoutObject* layout_object)
- : layout_object_(layout_object) {}
+ explicit NodeLayoutData(LayoutObject* layout_object,
+ RefPtr<ComputedStyle> non_attached_style)
+ : layout_object_(layout_object),
+ non_attached_style_(non_attached_style) {}
~NodeLayoutData() { CHECK(!layout_object_); }
LayoutObject* GetLayoutObject() const { return layout_object_; }
@@ -110,14 +113,24 @@ class NodeLayoutData {
DCHECK_NE(&SharedEmptyData(), this);
layout_object_ = layout_object;
}
+
+ ComputedStyle* GetNonAttachedStyle() const {
+ return non_attached_style_.Get();
+ }
+ void SetNonAttachedStyle(RefPtr<ComputedStyle> non_attached_style) {
+ DCHECK_NE(&SharedEmptyData(), this);
+ non_attached_style_ = non_attached_style;
+ }
+
static NodeLayoutData& SharedEmptyData() {
- DEFINE_STATIC_LOCAL(NodeLayoutData, shared_empty_data, (nullptr));
+ DEFINE_STATIC_LOCAL(NodeLayoutData, shared_empty_data, (nullptr, nullptr));
return shared_empty_data;
}
bool IsSharedEmptyData() { return this == &SharedEmptyData(); }
private:
LayoutObject* layout_object_;
+ RefPtr<ComputedStyle> non_attached_style_;
};
class NodeRareDataBase {
@@ -264,6 +277,14 @@ class CORE_EXPORT Node : public EventTarget {
bool SupportsAltText();
+ void SetNonAttachedStyle(RefPtr<ComputedStyle> non_attached_style);
+
+ ComputedStyle* GetNonAttachedStyle() const {
+ return HasRareData()
+ ? data_.rare_data_->GetNodeLayoutData()->GetNonAttachedStyle()
+ : data_.node_layout_data_->GetNonAttachedStyle();
+ }
+
// Other methods (not part of DOM)
bool IsElementNode() const { return GetFlag(kIsElementFlag); }

Powered by Google App Engine
This is Rietveld 408576698