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

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: Revert back to rune@'s lgtmed patch Created 3 years, 7 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 94
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 {
104 WTF_MAKE_NONCOPYABLE(NodeLayoutData);
105
103 public: 106 public:
104 explicit NodeLayoutData(LayoutObject* layout_object) 107 explicit NodeLayoutData(LayoutObject* layout_object,
105 : layout_object_(layout_object) {} 108 RefPtr<ComputedStyle> non_attached_style)
109 : layout_object_(layout_object),
110 non_attached_style_(non_attached_style) {}
106 ~NodeLayoutData() { CHECK(!layout_object_); } 111 ~NodeLayoutData() { CHECK(!layout_object_); }
107 112
108 LayoutObject* GetLayoutObject() const { return layout_object_; } 113 LayoutObject* GetLayoutObject() const { return layout_object_; }
109 void SetLayoutObject(LayoutObject* layout_object) { 114 void SetLayoutObject(LayoutObject* layout_object) {
110 DCHECK_NE(&SharedEmptyData(), this); 115 DCHECK_NE(&SharedEmptyData(), this);
111 layout_object_ = layout_object; 116 layout_object_ = layout_object;
112 } 117 }
118
119 ComputedStyle* GetNonAttachedStyle() const {
120 return non_attached_style_.Get();
121 }
122 void SetNonAttachedStyle(RefPtr<ComputedStyle> non_attached_style) {
123 DCHECK_NE(&SharedEmptyData(), this);
124 non_attached_style_ = non_attached_style;
125 }
126
113 static NodeLayoutData& SharedEmptyData() { 127 static NodeLayoutData& SharedEmptyData() {
114 DEFINE_STATIC_LOCAL(NodeLayoutData, shared_empty_data, (nullptr)); 128 DEFINE_STATIC_LOCAL(NodeLayoutData, shared_empty_data, (nullptr, nullptr));
115 return shared_empty_data; 129 return shared_empty_data;
116 } 130 }
117 bool IsSharedEmptyData() { return this == &SharedEmptyData(); } 131 bool IsSharedEmptyData() { return this == &SharedEmptyData(); }
118 132
119 private: 133 private:
120 LayoutObject* layout_object_; 134 LayoutObject* layout_object_;
135 RefPtr<ComputedStyle> non_attached_style_;
121 }; 136 };
122 137
123 class NodeRareDataBase { 138 class NodeRareDataBase {
124 public: 139 public:
125 NodeLayoutData* GetNodeLayoutData() const { return node_layout_data_; } 140 NodeLayoutData* GetNodeLayoutData() const { return node_layout_data_; }
126 void SetNodeLayoutData(NodeLayoutData* node_layout_data) { 141 void SetNodeLayoutData(NodeLayoutData* node_layout_data) {
127 DCHECK(node_layout_data); 142 DCHECK(node_layout_data);
128 node_layout_data_ = node_layout_data; 143 node_layout_data_ = node_layout_data;
129 } 144 }
130 145
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 bool isSameNode(const Node* other) const { return this == other; } 272 bool isSameNode(const Node* other) const { return this == other; }
258 bool isDefaultNamespace(const AtomicString& namespace_uri) const; 273 bool isDefaultNamespace(const AtomicString& namespace_uri) const;
259 const AtomicString& lookupPrefix(const AtomicString& namespace_uri) const; 274 const AtomicString& lookupPrefix(const AtomicString& namespace_uri) const;
260 const AtomicString& lookupNamespaceURI(const String& prefix) const; 275 const AtomicString& lookupNamespaceURI(const String& prefix) const;
261 276
262 String textContent(bool convert_brs_to_newlines = false) const; 277 String textContent(bool convert_brs_to_newlines = false) const;
263 void setTextContent(const String&); 278 void setTextContent(const String&);
264 279
265 bool SupportsAltText(); 280 bool SupportsAltText();
266 281
282 void SetNonAttachedStyle(RefPtr<ComputedStyle> non_attached_style);
283
284 ComputedStyle* GetNonAttachedStyle() const {
285 return HasRareData()
286 ? data_.rare_data_->GetNodeLayoutData()->GetNonAttachedStyle()
287 : data_.node_layout_data_->GetNonAttachedStyle();
288 }
289
267 // Other methods (not part of DOM) 290 // Other methods (not part of DOM)
268 291
269 bool IsElementNode() const { return GetFlag(kIsElementFlag); } 292 bool IsElementNode() const { return GetFlag(kIsElementFlag); }
270 bool IsContainerNode() const { return GetFlag(kIsContainerFlag); } 293 bool IsContainerNode() const { return GetFlag(kIsContainerFlag); }
271 bool IsTextNode() const { return GetFlag(kIsTextFlag); } 294 bool IsTextNode() const { return GetFlag(kIsTextFlag); }
272 bool IsHTMLElement() const { return GetFlag(kIsHTMLFlag); } 295 bool IsHTMLElement() const { return GetFlag(kIsHTMLFlag); }
273 bool IsSVGElement() const { return GetFlag(kIsSVGFlag); } 296 bool IsSVGElement() const { return GetFlag(kIsSVGFlag); }
274 297
275 DISABLE_CFI_PERF bool IsPseudoElement() const { 298 DISABLE_CFI_PERF bool IsPseudoElement() const {
276 return GetPseudoId() != kPseudoIdNone; 299 return GetPseudoId() != kPseudoIdNone;
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 } // namespace blink 1037 } // namespace blink
1015 1038
1016 #ifndef NDEBUG 1039 #ifndef NDEBUG
1017 // Outside the WebCore namespace for ease of invocation from gdb. 1040 // Outside the WebCore namespace for ease of invocation from gdb.
1018 void showNode(const blink::Node*); 1041 void showNode(const blink::Node*);
1019 void showTree(const blink::Node*); 1042 void showTree(const blink::Node*);
1020 void showNodePath(const blink::Node*); 1043 void showNodePath(const blink::Node*);
1021 #endif 1044 #endif
1022 1045
1023 #endif // Node_h 1046 #endif // Node_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Element.cpp ('k') | third_party/WebKit/Source/core/dom/Node.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698