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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintPropertyTreePrinter.cpp

Issue 2574713003: Add toString() for paint property node classes (Closed)
Patch Set: Update test Created 4 years 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 #include "core/paint/PaintPropertyTreePrinter.h" 5 #include "core/paint/PaintPropertyTreePrinter.h"
6 6
7 #include "core/frame/FrameView.h" 7 #include "core/frame/FrameView.h"
8 #include "core/frame/LocalFrame.h" 8 #include "core/frame/LocalFrame.h"
9 #include "core/layout/LayoutPart.h" 9 #include "core/layout/LayoutPart.h"
10 #include "core/layout/LayoutView.h" 10 #include "core/layout/LayoutView.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 83 }
84 84
85 void addAllPropertyNodes(StringBuilder& stringBuilder, 85 void addAllPropertyNodes(StringBuilder& stringBuilder,
86 const PropertyTreeNode* node, 86 const PropertyTreeNode* node,
87 unsigned indent = 0) { 87 unsigned indent = 0) {
88 DCHECK(node); 88 DCHECK(node);
89 for (unsigned i = 0; i < indent; i++) 89 for (unsigned i = 0; i < indent; i++)
90 stringBuilder.append(' '); 90 stringBuilder.append(' ');
91 if (m_nodeToDebugString.contains(node)) 91 if (m_nodeToDebugString.contains(node))
92 stringBuilder.append(m_nodeToDebugString.get(node)); 92 stringBuilder.append(m_nodeToDebugString.get(node));
93 stringBuilder.append(String::format(" %p", node)); 93 stringBuilder.append(String::format(" %p ", node));
94 Traits::printNodeAsString(node, stringBuilder); 94 stringBuilder.append(node->toString());
95 stringBuilder.append("\n"); 95 stringBuilder.append("\n");
96 96
97 for (const auto* childNode : m_nodeToDebugString.keys()) { 97 for (const auto* childNode : m_nodeToDebugString.keys()) {
98 if (childNode->parent() == node) 98 if (childNode->parent() == node)
99 addAllPropertyNodes(stringBuilder, childNode, indent + 2); 99 addAllPropertyNodes(stringBuilder, childNode, indent + 2);
100 } 100 }
101 } 101 }
102 102
103 // Root nodes may not be directly accessible but they can be determined by 103 // Root nodes may not be directly accessible but they can be determined by
104 // walking up to the parent of a previously collected node. 104 // walking up to the parent of a previously collected node.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 if (const TransformPaintPropertyNode* scrollTranslation = 155 if (const TransformPaintPropertyNode* scrollTranslation =
156 paintProperties.scrollTranslation()) 156 paintProperties.scrollTranslation())
157 printer.addPropertyNode(scrollTranslation, 157 printer.addPropertyNode(scrollTranslation,
158 "ScrollTranslation (" + object.debugName() + ")"); 158 "ScrollTranslation (" + object.debugName() + ")");
159 if (const TransformPaintPropertyNode* scrollbarPaintOffset = 159 if (const TransformPaintPropertyNode* scrollbarPaintOffset =
160 paintProperties.scrollbarPaintOffset()) 160 paintProperties.scrollbarPaintOffset())
161 printer.addPropertyNode( 161 printer.addPropertyNode(
162 scrollbarPaintOffset, 162 scrollbarPaintOffset,
163 "ScrollbarPaintOffset (" + object.debugName() + ")"); 163 "ScrollbarPaintOffset (" + object.debugName() + ")");
164 } 164 }
165
166 static void printNodeAsString(const TransformPaintPropertyNode* node,
167 StringBuilder& stringBuilder) {
168 stringBuilder.append(" transform=");
169
170 TransformationMatrix::DecomposedType decomposition;
171 if (!node->matrix().decompose(decomposition)) {
172 stringBuilder.append("degenerate");
173 return;
174 }
175
176 stringBuilder.append(
177 String::format("translation=%f,%f,%f", decomposition.translateX,
178 decomposition.translateY, decomposition.translateZ));
179 if (node->matrix().isIdentityOrTranslation())
180 return;
181
182 stringBuilder.append(
183 String::format(", scale=%f,%f,%f", decomposition.scaleX,
184 decomposition.scaleY, decomposition.scaleZ));
185 stringBuilder.append(String::format(", skew=%f,%f,%f", decomposition.skewXY,
186 decomposition.skewXZ,
187 decomposition.skewYZ));
188 stringBuilder.append(
189 String::format(", quaternion=%f,%f,%f,%f", decomposition.quaternionX,
190 decomposition.quaternionY, decomposition.quaternionZ,
191 decomposition.quaternionW));
192 stringBuilder.append(
193 String::format(", perspective=%f,%f,%f,%f", decomposition.perspectiveX,
194 decomposition.perspectiveY, decomposition.perspectiveZ,
195 decomposition.perspectiveW));
196 }
197 }; 165 };
198 166
199 template <> 167 template <>
200 class PropertyTreePrinterTraits<ClipPaintPropertyNode> { 168 class PropertyTreePrinterTraits<ClipPaintPropertyNode> {
201 public: 169 public:
202 static void addFrameViewProperties( 170 static void addFrameViewProperties(
203 const FrameView& frameView, 171 const FrameView& frameView,
204 PropertyTreePrinter<ClipPaintPropertyNode>& printer) { 172 PropertyTreePrinter<ClipPaintPropertyNode>& printer) {
205 if (const ClipPaintPropertyNode* contentClip = frameView.contentClip()) 173 if (const ClipPaintPropertyNode* contentClip = frameView.contentClip())
206 printer.addPropertyNode(contentClip, "ContentClip (FrameView)"); 174 printer.addPropertyNode(contentClip, "ContentClip (FrameView)");
(...skipping 13 matching lines...) Expand all
220 if (const ClipPaintPropertyNode* innerBorderRadiusClip = 188 if (const ClipPaintPropertyNode* innerBorderRadiusClip =
221 paintProperties.innerBorderRadiusClip()) 189 paintProperties.innerBorderRadiusClip())
222 printer.addPropertyNode( 190 printer.addPropertyNode(
223 innerBorderRadiusClip, 191 innerBorderRadiusClip,
224 "InnerBorderRadiusClip (" + object.debugName() + ")"); 192 "InnerBorderRadiusClip (" + object.debugName() + ")");
225 if (const ClipPaintPropertyNode* overflowClip = 193 if (const ClipPaintPropertyNode* overflowClip =
226 paintProperties.overflowClip()) 194 paintProperties.overflowClip())
227 printer.addPropertyNode(overflowClip, 195 printer.addPropertyNode(overflowClip,
228 "OverflowClip (" + object.debugName() + ")"); 196 "OverflowClip (" + object.debugName() + ")");
229 } 197 }
230
231 static void printNodeAsString(const ClipPaintPropertyNode* node,
232 StringBuilder& stringBuilder) {
233 stringBuilder.append(String::format(" localTransformSpace=%p ",
234 node->localTransformSpace()));
235 stringBuilder.append(String::format(
236 "rect=%f,%f,%f,%f", node->clipRect().rect().x(),
237 node->clipRect().rect().y(), node->clipRect().rect().width(),
238 node->clipRect().rect().height()));
239 }
240 }; 198 };
241 199
242 template <> 200 template <>
243 class PropertyTreePrinterTraits<EffectPaintPropertyNode> { 201 class PropertyTreePrinterTraits<EffectPaintPropertyNode> {
244 public: 202 public:
245 static void addFrameViewProperties( 203 static void addFrameViewProperties(
246 const FrameView& frameView, 204 const FrameView& frameView,
247 PropertyTreePrinter<EffectPaintPropertyNode>& printer) {} 205 PropertyTreePrinter<EffectPaintPropertyNode>& printer) {}
248 206
249 static void addObjectPaintProperties( 207 static void addObjectPaintProperties(
250 const LayoutObject& object, 208 const LayoutObject& object,
251 const ObjectPaintProperties& paintProperties, 209 const ObjectPaintProperties& paintProperties,
252 PropertyTreePrinter<EffectPaintPropertyNode>& printer) { 210 PropertyTreePrinter<EffectPaintPropertyNode>& printer) {
253 if (const EffectPaintPropertyNode* effect = paintProperties.effect()) 211 if (const EffectPaintPropertyNode* effect = paintProperties.effect())
254 printer.addPropertyNode(effect, "Effect (" + object.debugName() + ")"); 212 printer.addPropertyNode(effect, "Effect (" + object.debugName() + ")");
255 } 213 }
256
257 static void printNodeAsString(const EffectPaintPropertyNode* node,
258 StringBuilder& stringBuilder) {
259 stringBuilder.append(String::format(" opacity=%f", node->opacity()));
260 }
261 }; 214 };
262 215
263 template <> 216 template <>
264 class PropertyTreePrinterTraits<ScrollPaintPropertyNode> { 217 class PropertyTreePrinterTraits<ScrollPaintPropertyNode> {
265 public: 218 public:
266 static void addFrameViewProperties( 219 static void addFrameViewProperties(
267 const FrameView& frameView, 220 const FrameView& frameView,
268 PropertyTreePrinter<ScrollPaintPropertyNode>& printer) { 221 PropertyTreePrinter<ScrollPaintPropertyNode>& printer) {
269 if (const ScrollPaintPropertyNode* scroll = frameView.scroll()) 222 if (const ScrollPaintPropertyNode* scroll = frameView.scroll())
270 printer.addPropertyNode(scroll, "Scroll (FrameView)"); 223 printer.addPropertyNode(scroll, "Scroll (FrameView)");
271 } 224 }
272 225
273 static void addObjectPaintProperties( 226 static void addObjectPaintProperties(
274 const LayoutObject& object, 227 const LayoutObject& object,
275 const ObjectPaintProperties& paintProperties, 228 const ObjectPaintProperties& paintProperties,
276 PropertyTreePrinter<ScrollPaintPropertyNode>& printer) { 229 PropertyTreePrinter<ScrollPaintPropertyNode>& printer) {
277 if (const ScrollPaintPropertyNode* scroll = paintProperties.scroll()) 230 if (const ScrollPaintPropertyNode* scroll = paintProperties.scroll())
278 printer.addPropertyNode(scroll, "Scroll (" + object.debugName() + ")"); 231 printer.addPropertyNode(scroll, "Scroll (" + object.debugName() + ")");
279 } 232 }
280
281 static void printNodeAsString(const ScrollPaintPropertyNode* node,
282 StringBuilder& stringBuilder) {
283 FloatSize scrollOffset =
284 node->scrollOffsetTranslation()->matrix().to2DTranslation();
285 stringBuilder.append(" scrollOffsetTranslation=");
286 stringBuilder.append(scrollOffset.toString());
287 stringBuilder.append(" clip=");
288 stringBuilder.append(node->clip().toString());
289 stringBuilder.append(" bounds=");
290 stringBuilder.append(node->bounds().toString());
291 stringBuilder.append(" userScrollableHorizontal=");
292 stringBuilder.append(node->userScrollableHorizontal() ? "yes" : "no");
293 stringBuilder.append(" userScrollableVertical=");
294 stringBuilder.append(node->userScrollableVertical() ? "yes" : "no");
295 stringBuilder.append(" threadedScrollingDisabled=");
296 stringBuilder.append(node->threadedScrollingDisabled() ? "yes" : "no");
297 stringBuilder.append(" hasBackgroundAttachmentFixedDescendants=");
298 stringBuilder.append(
299 node->hasBackgroundAttachmentFixedDescendants() ? "yes" : "no");
300 }
301 }; 233 };
302 234
303 class PaintPropertyTreeGraphBuilder { 235 class PaintPropertyTreeGraphBuilder {
304 public: 236 public:
305 PaintPropertyTreeGraphBuilder() {} 237 PaintPropertyTreeGraphBuilder() {}
306 238
307 void generateTreeGraph(const FrameView& frameView, 239 void generateTreeGraph(const FrameView& frameView,
308 StringBuilder& stringBuilder) { 240 StringBuilder& stringBuilder) {
309 m_layout.str(""); 241 m_layout.str("");
310 m_properties.str(""); 242 m_properties.str("");
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 } 625 }
694 626
695 String paintPropertyTreeGraph(const blink::FrameView& frameView) { 627 String paintPropertyTreeGraph(const blink::FrameView& frameView) {
696 blink::PaintPropertyTreeGraphBuilder builder; 628 blink::PaintPropertyTreeGraphBuilder builder;
697 StringBuilder stringBuilder; 629 StringBuilder stringBuilder;
698 builder.generateTreeGraph(frameView, stringBuilder); 630 builder.generateTreeGraph(frameView, stringBuilder);
699 return stringBuilder.toString(); 631 return stringBuilder.toString();
700 } 632 }
701 633
702 #endif 634 #endif
OLDNEW
« no previous file with comments | « cc/output/filter_operations_unittest.cc ('k') | third_party/WebKit/Source/platform/graphics/CompositorFilterOperations.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698