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

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

Issue 2299533002: WIP: Construct SPV2's scroll paint property tree (Closed)
Patch Set: Add more paint property builder tests, update comments/documentation" Created 4 years, 3 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 #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/LayoutView.h" 9 #include "core/layout/LayoutView.h"
10 #include "core/paint/ObjectPaintProperties.h" 10 #include "core/paint/ObjectPaintProperties.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 if (const EffectPaintPropertyNode* effect = paintProperties.effect()) 185 if (const EffectPaintPropertyNode* effect = paintProperties.effect())
186 printer.addPropertyNode(effect, "Effect (" + object.debugName() + ") "); 186 printer.addPropertyNode(effect, "Effect (" + object.debugName() + ") ");
187 } 187 }
188 188
189 static void printNodeAsString(const EffectPaintPropertyNode* node, StringBui lder& stringBuilder) 189 static void printNodeAsString(const EffectPaintPropertyNode* node, StringBui lder& stringBuilder)
190 { 190 {
191 stringBuilder.append(String::format(" opacity=%f", node->opacity())); 191 stringBuilder.append(String::format(" opacity=%f", node->opacity()));
192 } 192 }
193 }; 193 };
194 194
195 template <>
196 class PropertyTreePrinterTraits<ScrollPaintPropertyNode> {
197 public:
198 static void addFrameViewProperties(const FrameView& frameView, PropertyTreeP rinter<ScrollPaintPropertyNode>& printer)
199 {
200 if (const ScrollPaintPropertyNode* rootScroll = frameView.rootScroll())
201 printer.addPropertyNode(rootScroll, "RootScroll (FrameView)");
202 if (const ScrollPaintPropertyNode* scroll = frameView.scroll())
203 printer.addPropertyNode(scroll, "Scroll (FrameView)");
204 }
205
206 static void addObjectPaintProperties(const LayoutObject& object, const Objec tPaintProperties& paintProperties, PropertyTreePrinter<ScrollPaintPropertyNode>& printer)
207 {
208 if (const ScrollPaintPropertyNode* scroll = paintProperties.scroll())
209 printer.addPropertyNode(scroll, "Scroll (" + object.debugName() + ") ");
210 }
211
212 static void printNodeAsString(const ScrollPaintPropertyNode* node, StringBui lder& stringBuilder)
213 {
214 FloatSize scrollOffset = node->scrollOffsetTranslation()->matrix().to2DT ranslation();
215 stringBuilder.append(" scrollOffsetTranslation=");
216 stringBuilder.append(scrollOffset.toString());
217 stringBuilder.append(" clip=");
218 stringBuilder.append(node->clip().toString());
219 stringBuilder.append(" bounds=");
220 stringBuilder.append(node->bounds().toString());
221 stringBuilder.append(" userScrollableHorizontal=");
222 stringBuilder.append(node->userScrollableHorizontal() ? "yes" : "no");
223 stringBuilder.append(" userScrollableVertical=");
224 stringBuilder.append(node->userScrollableVertical() ? "yes" : "no");
225 }
226 };
227
195 class PaintPropertyTreeGraphBuilder { 228 class PaintPropertyTreeGraphBuilder {
196 public: 229 public:
197 PaintPropertyTreeGraphBuilder() { } 230 PaintPropertyTreeGraphBuilder() { }
198 231
199 void generateTreeGraph(const FrameView& frameView, StringBuilder& stringBuil der) 232 void generateTreeGraph(const FrameView& frameView, StringBuilder& stringBuil der)
200 { 233 {
201 m_layout.str(""); 234 m_layout.str("");
202 m_properties.str(""); 235 m_properties.str("");
203 m_ownerEdges.str(""); 236 m_ownerEdges.str("");
204 m_properties << std::setprecision(2) << std::setiosflags(std::ios_base:: fixed); 237 m_properties << std::setprecision(2) << std::setiosflags(std::ios_base:: fixed);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 std::ostream& os = m_properties; 344 std::ostream& os = m_properties;
312 os << "n" << &node << " [shape=diamond, label=\"" << label << "\\n"; 345 os << "n" << &node << " [shape=diamond, label=\"" << label << "\\n";
313 os << "opacity=" << node.opacity() << "\"];" << std::endl; 346 os << "opacity=" << node.opacity() << "\"];" << std::endl;
314 347
315 if (owner) 348 if (owner)
316 writeOwnerEdge(&node, owner); 349 writeOwnerEdge(&node, owner);
317 if (node.parent()) 350 if (node.parent())
318 writeParentEdge(&node, node.parent(), s_effectNodeColor, os); 351 writeParentEdge(&node, node.parent(), s_effectNodeColor, os);
319 } 352 }
320 353
354 void writePaintPropertyNode(const ScrollPaintPropertyNode&, const void*, con st char*)
355 {
356 // TODO(pdr): fill this out.
357 }
358
321 void writeObjectPaintPropertyNodes(const LayoutObject& object) 359 void writeObjectPaintPropertyNodes(const LayoutObject& object)
322 { 360 {
323 const ObjectPaintProperties* properties = object.objectPaintProperties() ; 361 const ObjectPaintProperties* properties = object.objectPaintProperties() ;
324 if (!properties) 362 if (!properties)
325 return; 363 return;
326 const TransformPaintPropertyNode* paintOffset = properties->paintOffsetT ranslation(); 364 const TransformPaintPropertyNode* paintOffset = properties->paintOffsetT ranslation();
327 if (paintOffset) 365 if (paintOffset)
328 writePaintPropertyNode(*paintOffset, &object, "paintOffset"); 366 writePaintPropertyNode(*paintOffset, &object, "paintOffset");
329 const TransformPaintPropertyNode* transform = properties->transform(); 367 const TransformPaintPropertyNode* transform = properties->transform();
330 if (transform) 368 if (transform)
(...skipping 18 matching lines...) Expand all
349 writePaintPropertyNode(*cssClip, &object, "cssClip"); 387 writePaintPropertyNode(*cssClip, &object, "cssClip");
350 const ClipPaintPropertyNode* cssClipFixedPosition = properties->cssClipF ixedPosition(); 388 const ClipPaintPropertyNode* cssClipFixedPosition = properties->cssClipF ixedPosition();
351 if (cssClipFixedPosition) 389 if (cssClipFixedPosition)
352 writePaintPropertyNode(*cssClipFixedPosition, &object, "cssClipFixed Position"); 390 writePaintPropertyNode(*cssClipFixedPosition, &object, "cssClipFixed Position");
353 const ClipPaintPropertyNode* overflowClip = properties->overflowClip(); 391 const ClipPaintPropertyNode* overflowClip = properties->overflowClip();
354 if (overflowClip) { 392 if (overflowClip) {
355 writePaintPropertyNode(*overflowClip, &object, "overflowClip"); 393 writePaintPropertyNode(*overflowClip, &object, "overflowClip");
356 if (object.isLayoutView() && overflowClip->parent()) 394 if (object.isLayoutView() && overflowClip->parent())
357 writePaintPropertyNode(*overflowClip->parent(), nullptr, "rootCl ip"); 395 writePaintPropertyNode(*overflowClip->parent(), nullptr, "rootCl ip");
358 } 396 }
397 const ScrollPaintPropertyNode* scroll = properties->scroll();
398 if (scroll)
399 writePaintPropertyNode(*scroll, &object, "scroll");
359 } 400 }
360 401
361 void writeFrameViewPaintPropertyNodes(const FrameView& frameView) 402 void writeFrameViewPaintPropertyNodes(const FrameView& frameView)
362 { 403 {
363 TransformPaintPropertyNode* rootTransform = frameView.rootTransform(); 404 TransformPaintPropertyNode* rootTransform = frameView.rootTransform();
364 if (rootTransform) 405 if (rootTransform)
365 writePaintPropertyNode(*rootTransform, &frameView, "rootTransform"); 406 writePaintPropertyNode(*rootTransform, &frameView, "rootTransform");
366 ClipPaintPropertyNode* rootClip = frameView.rootClip(); 407 ClipPaintPropertyNode* rootClip = frameView.rootClip();
367 if (rootClip) 408 if (rootClip)
368 writePaintPropertyNode(*rootClip, &frameView, "rootClip"); 409 writePaintPropertyNode(*rootClip, &frameView, "rootClip");
369 EffectPaintPropertyNode* rootEffect = frameView.rootEffect(); 410 EffectPaintPropertyNode* rootEffect = frameView.rootEffect();
370 if (rootEffect) 411 if (rootEffect)
371 writePaintPropertyNode(*rootEffect, &frameView, "rootEffect"); 412 writePaintPropertyNode(*rootEffect, &frameView, "rootEffect");
372 TransformPaintPropertyNode* preTranslation = frameView.preTranslation(); 413 TransformPaintPropertyNode* preTranslation = frameView.preTranslation();
373 if (preTranslation) 414 if (preTranslation)
374 writePaintPropertyNode(*preTranslation, &frameView, "preTranslation" ); 415 writePaintPropertyNode(*preTranslation, &frameView, "preTranslation" );
375 TransformPaintPropertyNode* scrollTranslation = frameView.scrollTranslat ion(); 416 TransformPaintPropertyNode* scrollTranslation = frameView.scrollTranslat ion();
376 if (scrollTranslation) 417 if (scrollTranslation)
377 writePaintPropertyNode(*scrollTranslation, &frameView, "scrollTransl ation"); 418 writePaintPropertyNode(*scrollTranslation, &frameView, "scrollTransl ation");
378 ClipPaintPropertyNode* contentClip = frameView.contentClip(); 419 ClipPaintPropertyNode* contentClip = frameView.contentClip();
379 if (contentClip) 420 if (contentClip)
380 writePaintPropertyNode(*contentClip, &frameView, "contentClip"); 421 writePaintPropertyNode(*contentClip, &frameView, "contentClip");
422 ScrollPaintPropertyNode* scroll = frameView.scroll();
423 if (scroll)
424 writePaintPropertyNode(*scroll, &frameView, "scroll");
381 } 425 }
382 426
383 void writeLayoutObjectNode(const LayoutObject& object) 427 void writeLayoutObjectNode(const LayoutObject& object)
384 { 428 {
385 std::ostream& os = m_layout; 429 std::ostream& os = m_layout;
386 os << "n" << &object 430 os << "n" << &object
387 << " [color=" << s_layoutNodeColor 431 << " [color=" << s_layoutNodeColor
388 << ", fontcolor=" << s_layoutNodeColor 432 << ", fontcolor=" << s_layoutNodeColor
389 << ", label=\"" << object.name(); 433 << ", label=\"" << object.name();
390 Node* node = object.node(); 434 Node* node = object.node();
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 void showClipPropertyTree(const blink::FrameView& rootFrame) 493 void showClipPropertyTree(const blink::FrameView& rootFrame)
450 { 494 {
451 blink::PropertyTreePrinter<blink::ClipPaintPropertyNode>().showTree(rootFram e); 495 blink::PropertyTreePrinter<blink::ClipPaintPropertyNode>().showTree(rootFram e);
452 } 496 }
453 497
454 void showEffectPropertyTree(const blink::FrameView& rootFrame) 498 void showEffectPropertyTree(const blink::FrameView& rootFrame)
455 { 499 {
456 blink::PropertyTreePrinter<blink::EffectPaintPropertyNode>().showTree(rootFr ame); 500 blink::PropertyTreePrinter<blink::EffectPaintPropertyNode>().showTree(rootFr ame);
457 } 501 }
458 502
503 void showScrollPropertyTree(const blink::FrameView& rootFrame)
504 {
505 blink::PropertyTreePrinter<blink::ScrollPaintPropertyNode>().showTree(rootFr ame);
506 }
507
459 void showPaintPropertyPath(const blink::TransformPaintPropertyNode* node) 508 void showPaintPropertyPath(const blink::TransformPaintPropertyNode* node)
460 { 509 {
461 blink::PropertyTreePrinter<blink::TransformPaintPropertyNode>().showPath(nod e); 510 blink::PropertyTreePrinter<blink::TransformPaintPropertyNode>().showPath(nod e);
462 } 511 }
463 512
464 void showPaintPropertyPath(const blink::ClipPaintPropertyNode* node) 513 void showPaintPropertyPath(const blink::ClipPaintPropertyNode* node)
465 { 514 {
466 blink::PropertyTreePrinter<blink::ClipPaintPropertyNode>().showPath(node); 515 blink::PropertyTreePrinter<blink::ClipPaintPropertyNode>().showPath(node);
467 } 516 }
468 517
469 void showPaintPropertyPath(const blink::EffectPaintPropertyNode* node) 518 void showPaintPropertyPath(const blink::EffectPaintPropertyNode* node)
470 { 519 {
471 blink::PropertyTreePrinter<blink::EffectPaintPropertyNode>().showPath(node); 520 blink::PropertyTreePrinter<blink::EffectPaintPropertyNode>().showPath(node);
472 } 521 }
473 522
523 void showPaintPropertyPath(const blink::ScrollPaintPropertyNode* node)
524 {
525 blink::PropertyTreePrinter<blink::ScrollPaintPropertyNode>().showPath(node);
526 }
527
474 String paintPropertyTreeGraph(const blink::FrameView& frameView) 528 String paintPropertyTreeGraph(const blink::FrameView& frameView)
475 { 529 {
476 blink::PaintPropertyTreeGraphBuilder builder; 530 blink::PaintPropertyTreeGraphBuilder builder;
477 StringBuilder stringBuilder; 531 StringBuilder stringBuilder;
478 builder.generateTreeGraph(frameView, stringBuilder); 532 builder.generateTreeGraph(frameView, stringBuilder);
479 return stringBuilder.toString(); 533 return stringBuilder.toString();
480 } 534 }
481 535
482 #endif 536 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698