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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/paint/PropertyTreeState.h

Issue 2639143002: Revert of Move property tree debugging code to platform/graphics/paint/. (Closed)
Patch Set: Created 3 years, 11 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef PropertyTreeState_h 5 #ifndef PropertyTreeState_h
6 #define PropertyTreeState_h 6 #define PropertyTreeState_h
7 7
8 #include "platform/graphics/paint/ClipPaintPropertyNode.h" 8 #include "platform/graphics/paint/ClipPaintPropertyNode.h"
9 #include "platform/graphics/paint/EffectPaintPropertyNode.h" 9 #include "platform/graphics/paint/EffectPaintPropertyNode.h"
10 #include "platform/graphics/paint/ScrollPaintPropertyNode.h" 10 #include "platform/graphics/paint/ScrollPaintPropertyNode.h"
11 #include "platform/graphics/paint/TransformPaintPropertyNode.h" 11 #include "platform/graphics/paint/TransformPaintPropertyNode.h"
12 #include "wtf/HashFunctions.h" 12 #include "wtf/HashFunctions.h"
13 #include "wtf/HashTraits.h" 13 #include "wtf/HashTraits.h"
14 #include "wtf/text/StringBuilder.h"
15 14
16 namespace blink { 15 namespace blink {
17 16
18 // A complete set of paint properties including those that are inherited from 17 // A complete set of paint properties including those that are inherited from
19 // other objects. RefPtrs are used to guard against use-after-free bugs and 18 // other objects. RefPtrs are used to guard against use-after-free bugs and
20 // DCHECKs ensure PropertyTreeState never retains the last reference to a 19 // DCHECKs ensure PropertyTreeState never retains the last reference to a
21 // property tree node. 20 // property tree node.
22 class PLATFORM_EXPORT PropertyTreeState { 21 class PLATFORM_EXPORT PropertyTreeState {
23 public: 22 public:
24 PropertyTreeState(const TransformPaintPropertyNode* transform, 23 PropertyTreeState(const TransformPaintPropertyNode* transform,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // 105 //
107 // The PropertyTreeStateIterator will behave like this: 106 // The PropertyTreeStateIterator will behave like this:
108 // 107 //
109 // PropertyTreeStateIterator iterator(PropertyTreeState(T, C, E)); 108 // PropertyTreeStateIterator iterator(PropertyTreeState(T, C, E));
110 // DCHECK(iterator.innermostNode() == Effect); 109 // DCHECK(iterator.innermostNode() == Effect);
111 // DCHECK(iterator.next()->innermostNode() == Clip); 110 // DCHECK(iterator.next()->innermostNode() == Clip);
112 // DCHECK(iterator.next()->innermostNode() == Transform); 111 // DCHECK(iterator.next()->innermostNode() == Transform);
113 // DCHECK(iterator.next()->innermostNode() == None); 112 // DCHECK(iterator.next()->innermostNode() == None);
114 InnermostNode innermostNode() const; 113 InnermostNode innermostNode() const;
115 114
116 #if DCHECK_IS_ON()
117 // Dumps the tree from this state up to the root as a string.
118 String toTreeString() const;
119 #endif
120
121 private: 115 private:
122 RefPtr<const TransformPaintPropertyNode> m_transform; 116 RefPtr<const TransformPaintPropertyNode> m_transform;
123 RefPtr<const ClipPaintPropertyNode> m_clip; 117 RefPtr<const ClipPaintPropertyNode> m_clip;
124 RefPtr<const EffectPaintPropertyNode> m_effect; 118 RefPtr<const EffectPaintPropertyNode> m_effect;
125 RefPtr<const ScrollPaintPropertyNode> m_scroll; 119 RefPtr<const ScrollPaintPropertyNode> m_scroll;
126 }; 120 };
127 121
128 inline bool operator==(const PropertyTreeState& a, const PropertyTreeState& b) { 122 inline bool operator==(const PropertyTreeState& a, const PropertyTreeState& b) {
129 return a.transform() == b.transform() && a.clip() == b.clip() && 123 return a.transform() == b.transform() && a.clip() == b.clip() &&
130 a.effect() == b.effect() && a.scroll() == b.scroll(); 124 a.effect() == b.effect() && a.scroll() == b.scroll();
131 } 125 }
132 126
133 // Iterates over the sequence transforms, clips and effects for a 127 // Iterates over the sequence transforms, clips and effects for a
134 // PropertyTreeState between that state and the "root" state (all nodes equal 128 // PropertyTreeState between that state and the "root" state (all nodes equal
135 // to *::Root()), in the order that they apply. 129 // to *::Root()), in the order that they apply.
136 // 130 //
137 // See also PropertyTreeState::innermostNode for a more detailed example. 131 // See also PropertyTreeState::innermostNode for a more detailed example.
138 class PLATFORM_EXPORT PropertyTreeStateIterator { 132 class PLATFORM_EXPORT PropertyTreeStateIterator {
139 public: 133 public:
140 PropertyTreeStateIterator(const PropertyTreeState& properties) 134 PropertyTreeStateIterator(const PropertyTreeState& properties)
141 : m_properties(properties) {} 135 : m_properties(properties) {}
142 const PropertyTreeState* next(); 136 const PropertyTreeState* next();
143 137
144 private: 138 private:
145 PropertyTreeState m_properties; 139 PropertyTreeState m_properties;
146 }; 140 };
147 141
148 #if DCHECK_IS_ON()
149
150 template <typename PropertyTreeNode>
151 class PropertyTreeStatePrinter {
152 public:
153 String pathAsString(const PropertyTreeNode* lastNode) {
154 const PropertyTreeNode* node = lastNode;
155 while (!node->isRoot()) {
156 addPropertyNode(node, "");
157 node = node->parent();
158 }
159
160 StringBuilder stringBuilder;
161 addAllPropertyNodes(stringBuilder, node);
162 return stringBuilder.toString();
163 }
164
165 void addPropertyNode(const PropertyTreeNode* node, String debugInfo) {
166 m_nodeToDebugString.set(node, debugInfo);
167 }
168
169 void addAllPropertyNodes(StringBuilder& stringBuilder,
170 const PropertyTreeNode* node,
171 unsigned indent = 0) {
172 DCHECK(node);
173 for (unsigned i = 0; i < indent; i++)
174 stringBuilder.append(' ');
175 if (m_nodeToDebugString.contains(node))
176 stringBuilder.append(m_nodeToDebugString.get(node));
177 stringBuilder.append(String::format(" %p ", node));
178 stringBuilder.append(node->toString());
179 stringBuilder.append("\n");
180
181 for (const auto* childNode : m_nodeToDebugString.keys()) {
182 if (childNode->parent() == node)
183 addAllPropertyNodes(stringBuilder, childNode, indent + 2);
184 }
185 }
186
187 HashMap<const PropertyTreeNode*, String> m_nodeToDebugString;
188 };
189
190 #endif
191
192 } // namespace blink 142 } // namespace blink
193 143
194 #endif // PropertyTreeState_h 144 #endif // PropertyTreeState_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698