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

Side by Side Diff: third_party/WebKit/Source/core/dom/Node.h

Issue 2821193003: Store nonAttachedStyle on NodeLayoutData instead of on HashMap in Document. (Closed)
Patch Set: Add DCHECK and assign nullptr in constructor 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004-2011, 2014 Apple Inc. All rights reserved. 5 * Copyright (C) 2004-2011, 2014 Apple Inc. All rights reserved.
6 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 6 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
7 * (http://www.torchmobile.com/) 7 * (http://www.torchmobile.com/)
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 16 matching lines...) Expand all
27 #define Node_h 27 #define Node_h
28 28
29 #include "bindings/core/v8/ExceptionState.h" 29 #include "bindings/core/v8/ExceptionState.h"
30 #include "bindings/core/v8/TraceWrapperMember.h" 30 #include "bindings/core/v8/TraceWrapperMember.h"
31 #include "core/CoreExport.h" 31 #include "core/CoreExport.h"
32 #include "core/dom/MutationObserver.h" 32 #include "core/dom/MutationObserver.h"
33 #include "core/dom/SimulatedClickOptions.h" 33 #include "core/dom/SimulatedClickOptions.h"
34 #include "core/dom/TreeScope.h" 34 #include "core/dom/TreeScope.h"
35 #include "core/editing/EditingBoundary.h" 35 #include "core/editing/EditingBoundary.h"
36 #include "core/events/EventTarget.h" 36 #include "core/events/EventTarget.h"
37 #include "core/style/ComputedStyle.h"
37 #include "core/style/ComputedStyleConstants.h" 38 #include "core/style/ComputedStyleConstants.h"
38 #include "platform/geometry/LayoutRect.h" 39 #include "platform/geometry/LayoutRect.h"
39 #include "public/platform/WebFocusType.h" 40 #include "public/platform/WebFocusType.h"
40 41
41 // This needs to be here because Element.cpp also depends on it. 42 // This needs to be here because Element.cpp also depends on it.
42 #define DUMP_NODE_STATISTICS 0 43 #define DUMP_NODE_STATISTICS 0
43 44
44 namespace blink { 45 namespace blink {
45 46
46 class ContainerNode; 47 class ContainerNode;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 kNotDefinedFlag = 2 << kNodeCustomElementShift, 95 kNotDefinedFlag = 2 << kNodeCustomElementShift,
95 }; 96 };
96 97
97 enum class SlotChangeType { 98 enum class SlotChangeType {
98 kInitial, 99 kInitial,
99 kChained, 100 kChained,
100 }; 101 };
101 102
102 class NodeLayoutData { 103 class NodeLayoutData {
103 public: 104 public:
104 explicit NodeLayoutData(LayoutObject* layout_object) 105 explicit NodeLayoutData(LayoutObject* layout_object,
105 : layout_object_(layout_object) {} 106 RefPtr<ComputedStyle> non_attached_style)
rune 2017/04/19 20:34:52 Shouldn't this be a WTF_MAKE_NONCOPYABLE like e.g.
nainar 2017/04/19 23:43:41 You are right. Done.
107 : layout_object_(layout_object),
108 non_attached_style_(non_attached_style) {}
106 ~NodeLayoutData() { CHECK(!layout_object_); } 109 ~NodeLayoutData() { CHECK(!layout_object_); }
107 110
108 LayoutObject* GetLayoutObject() const { return layout_object_; } 111 LayoutObject* GetLayoutObject() const { return layout_object_; }
109 void SetLayoutObject(LayoutObject* layout_object) { 112 void SetLayoutObject(LayoutObject* layout_object) {
110 DCHECK_NE(&SharedEmptyData(), this); 113 DCHECK_NE(&SharedEmptyData(), this);
111 layout_object_ = layout_object; 114 layout_object_ = layout_object;
112 } 115 }
116
117 ComputedStyle* GetNonAttachedStyle() const {
118 return non_attached_style_.Get();
119 }
120 void SetNonAttachedStyle(RefPtr<ComputedStyle> non_attached_style) {
121 DCHECK_NE(&SharedEmptyData(), this);
122 non_attached_style_ = non_attached_style;
123 }
124
113 static NodeLayoutData& SharedEmptyData() { 125 static NodeLayoutData& SharedEmptyData() {
114 DEFINE_STATIC_LOCAL(NodeLayoutData, shared_empty_data, (nullptr)); 126 DEFINE_STATIC_LOCAL(NodeLayoutData, shared_empty_data, (nullptr, nullptr));
115 return shared_empty_data; 127 return shared_empty_data;
116 } 128 }
117 bool IsSharedEmptyData() { return this == &SharedEmptyData(); } 129 bool IsSharedEmptyData() { return this == &SharedEmptyData(); }
118 130
119 private: 131 private:
120 LayoutObject* layout_object_; 132 LayoutObject* layout_object_;
133 RefPtr<ComputedStyle> non_attached_style_;
121 }; 134 };
122 135
123 class NodeRareDataBase { 136 class NodeRareDataBase {
124 public: 137 public:
125 NodeLayoutData* GetNodeLayoutData() const { return node_layout_data_; } 138 NodeLayoutData* GetNodeLayoutData() const { return node_layout_data_; }
126 void SetNodeLayoutData(NodeLayoutData* node_layout_data) { 139 void SetNodeLayoutData(NodeLayoutData* node_layout_data) {
127 DCHECK(node_layout_data); 140 DCHECK(node_layout_data);
128 node_layout_data_ = node_layout_data; 141 node_layout_data_ = node_layout_data;
129 } 142 }
130 143
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 bool isSameNode(const Node* other) const { return this == other; } 270 bool isSameNode(const Node* other) const { return this == other; }
258 bool isDefaultNamespace(const AtomicString& namespace_uri) const; 271 bool isDefaultNamespace(const AtomicString& namespace_uri) const;
259 const AtomicString& lookupPrefix(const AtomicString& namespace_uri) const; 272 const AtomicString& lookupPrefix(const AtomicString& namespace_uri) const;
260 const AtomicString& lookupNamespaceURI(const String& prefix) const; 273 const AtomicString& lookupNamespaceURI(const String& prefix) const;
261 274
262 String textContent(bool convert_brs_to_newlines = false) const; 275 String textContent(bool convert_brs_to_newlines = false) const;
263 void setTextContent(const String&); 276 void setTextContent(const String&);
264 277
265 bool SupportsAltText(); 278 bool SupportsAltText();
266 279
280 void SetNonAttachedStyle(RefPtr<ComputedStyle> non_attached_style);
281
282 ComputedStyle* GetNonAttachedStyle() const {
283 return HasRareData()
284 ? data_.rare_data_->GetNodeLayoutData()->GetNonAttachedStyle()
285 : data_.node_layout_data_->GetNonAttachedStyle();
286 }
287
267 // Other methods (not part of DOM) 288 // Other methods (not part of DOM)
268 289
269 bool IsElementNode() const { return GetFlag(kIsElementFlag); } 290 bool IsElementNode() const { return GetFlag(kIsElementFlag); }
270 bool IsContainerNode() const { return GetFlag(kIsContainerFlag); } 291 bool IsContainerNode() const { return GetFlag(kIsContainerFlag); }
271 bool IsTextNode() const { return GetFlag(kIsTextFlag); } 292 bool IsTextNode() const { return GetFlag(kIsTextFlag); }
272 bool IsHTMLElement() const { return GetFlag(kIsHTMLFlag); } 293 bool IsHTMLElement() const { return GetFlag(kIsHTMLFlag); }
273 bool IsSVGElement() const { return GetFlag(kIsSVGFlag); } 294 bool IsSVGElement() const { return GetFlag(kIsSVGFlag); }
274 295
275 DISABLE_CFI_PERF bool IsPseudoElement() const { 296 DISABLE_CFI_PERF bool IsPseudoElement() const {
276 return GetPseudoId() != kPseudoIdNone; 297 return GetPseudoId() != kPseudoIdNone;
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 } // namespace blink 1041 } // namespace blink
1021 1042
1022 #ifndef NDEBUG 1043 #ifndef NDEBUG
1023 // Outside the WebCore namespace for ease of invocation from gdb. 1044 // Outside the WebCore namespace for ease of invocation from gdb.
1024 void showNode(const blink::Node*); 1045 void showNode(const blink::Node*);
1025 void showTree(const blink::Node*); 1046 void showTree(const blink::Node*);
1026 void showNodePath(const blink::Node*); 1047 void showNodePath(const blink::Node*);
1027 #endif 1048 #endif
1028 1049
1029 #endif // Node_h 1050 #endif // Node_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698