OLD | NEW |
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 22 matching lines...) Expand all Loading... |
33 | 33 |
34 void showPath(const PropertyTreeNode* node) | 34 void showPath(const PropertyTreeNode* node) |
35 { | 35 { |
36 for (const PropertyTreeNode* n = node; n; n = n->parent()) | 36 for (const PropertyTreeNode* n = node; n; n = n->parent()) |
37 addPropertyNode(n, ""); | 37 addPropertyNode(n, ""); |
38 showAllPropertyNodes(nullptr); | 38 showAllPropertyNodes(nullptr); |
39 } | 39 } |
40 | 40 |
41 void addPropertyNode(const PropertyTreeNode* node, String debugInfo) | 41 void addPropertyNode(const PropertyTreeNode* node, String debugInfo) |
42 { | 42 { |
| 43 // showAllPropertyNodes determines the root node itself so roots should |
| 44 // not be added explicitly. |
| 45 DCHECK(node && !node->isRoot()); |
43 m_nodeToDebugString.set(node, debugInfo); | 46 m_nodeToDebugString.set(node, debugInfo); |
44 } | 47 } |
45 | 48 |
46 private: | 49 private: |
47 using Traits = PropertyTreePrinterTraits<PropertyTreeNode>; | 50 using Traits = PropertyTreePrinterTraits<PropertyTreeNode>; |
48 | 51 |
49 void collectPropertyNodes(const FrameView& frameView) | 52 void collectPropertyNodes(const FrameView& frameView) |
50 { | 53 { |
51 Traits::addFrameViewProperties(frameView, *this); | 54 Traits::addFrameViewProperties(frameView, *this); |
52 if (LayoutView* layoutView = frameView.layoutView()) | 55 if (LayoutView* layoutView = frameView.layoutView()) |
53 collectPropertyNodes(*layoutView); | 56 collectPropertyNodes(*layoutView); |
54 for (Frame* child = frameView.frame().tree().firstChild(); child; child
= child->tree().nextSibling()) { | 57 for (Frame* child = frameView.frame().tree().firstChild(); child; child
= child->tree().nextSibling()) { |
55 if (!child->isLocalFrame()) | 58 if (!child->isLocalFrame()) |
56 continue; | 59 continue; |
57 if (FrameView* childView = toLocalFrame(child)->view()) | 60 if (FrameView* childView = toLocalFrame(child)->view()) |
58 collectPropertyNodes(*childView); | 61 collectPropertyNodes(*childView); |
59 } | 62 } |
60 } | 63 } |
61 | 64 |
62 void collectPropertyNodes(const LayoutObject& object) | 65 void collectPropertyNodes(const LayoutObject& object) |
63 { | 66 { |
64 if (const ObjectPaintProperties* paintProperties = object.objectPaintPro
perties()) | 67 if (const ObjectPaintProperties* paintProperties = object.objectPaintPro
perties()) |
65 Traits::addObjectPaintProperties(object, *paintProperties, *this); | 68 Traits::addObjectPaintProperties(object, *paintProperties, *this); |
66 for (LayoutObject* child = object.slowFirstChild(); child; child = child
->nextSibling()) | 69 for (LayoutObject* child = object.slowFirstChild(); child; child = child
->nextSibling()) |
67 collectPropertyNodes(*child); | 70 collectPropertyNodes(*child); |
68 } | 71 } |
69 | 72 |
70 void showAllPropertyNodes(const PropertyTreeNode* node, unsigned indent = 0) | 73 void showAllPropertyNodes(const PropertyTreeNode* node, unsigned indent = 0) |
71 { | 74 { |
72 if (node) { | 75 // If no node is specified, show the root node. |
73 StringBuilder stringBuilder; | 76 if (!node) { |
74 for (unsigned i = 0; i < indent; i++) | 77 for (const auto* childNode : m_nodeToDebugString.keys()) { |
75 stringBuilder.append(' '); | 78 if (childNode->parent() && childNode->parent()->isRoot()) { |
76 if (m_nodeToDebugString.contains(node)) | 79 showAllPropertyNodes(childNode->parent()); |
77 stringBuilder.append(m_nodeToDebugString.get(node)); | 80 break; |
78 stringBuilder.append(String::format(" %p", node)); | 81 } |
79 Traits::printNodeAsString(node, stringBuilder); | 82 } |
80 fprintf(stderr, "%s\n", stringBuilder.toString().ascii().data()); | 83 return; |
81 } | 84 } |
82 | 85 |
| 86 StringBuilder stringBuilder; |
| 87 for (unsigned i = 0; i < indent; i++) |
| 88 stringBuilder.append(' '); |
| 89 if (node->isRoot()) |
| 90 stringBuilder.append("root"); |
| 91 else if (m_nodeToDebugString.contains(node)) |
| 92 stringBuilder.append(m_nodeToDebugString.get(node)); |
| 93 stringBuilder.append(String::format(" %p", node)); |
| 94 Traits::printNodeAsString(node, stringBuilder); |
| 95 fprintf(stderr, "%s\n", stringBuilder.toString().ascii().data()); |
| 96 |
83 for (const auto* childNode : m_nodeToDebugString.keys()) { | 97 for (const auto* childNode : m_nodeToDebugString.keys()) { |
84 if (childNode->parent() == node) | 98 if (childNode->parent() == node) |
85 showAllPropertyNodes(childNode, indent + 2); | 99 showAllPropertyNodes(childNode, indent + 2); |
86 } | 100 } |
87 } | 101 } |
88 | 102 |
89 HashMap<const PropertyTreeNode*, String> m_nodeToDebugString; | 103 HashMap<const PropertyTreeNode*, String> m_nodeToDebugString; |
90 }; | 104 }; |
91 | 105 |
92 template <> | 106 template <> |
93 class PropertyTreePrinterTraits<TransformPaintPropertyNode> { | 107 class PropertyTreePrinterTraits<TransformPaintPropertyNode> { |
94 public: | 108 public: |
95 static void addFrameViewProperties(const FrameView& frameView, PropertyTreeP
rinter<TransformPaintPropertyNode>& printer) | 109 static void addFrameViewProperties(const FrameView& frameView, PropertyTreeP
rinter<TransformPaintPropertyNode>& printer) |
96 { | 110 { |
97 if (const TransformPaintPropertyNode* rootTransform = frameView.rootTran
sform()) | |
98 printer.addPropertyNode(rootTransform, "RootTransform (FrameView)"); | |
99 if (const TransformPaintPropertyNode* preTranslation = frameView.preTran
slation()) | 111 if (const TransformPaintPropertyNode* preTranslation = frameView.preTran
slation()) |
100 printer.addPropertyNode(preTranslation, "PreTranslation (FrameView)"
); | 112 printer.addPropertyNode(preTranslation, "PreTranslation (FrameView)"
); |
101 if (const TransformPaintPropertyNode* scrollTranslation = frameView.scro
llTranslation()) | 113 if (const TransformPaintPropertyNode* scrollTranslation = frameView.scro
llTranslation()) |
102 printer.addPropertyNode(scrollTranslation, "ScrollTranslation (Frame
View)"); | 114 printer.addPropertyNode(scrollTranslation, "ScrollTranslation (Frame
View)"); |
103 } | 115 } |
104 | 116 |
105 static void addObjectPaintProperties(const LayoutObject& object, const Objec
tPaintProperties& paintProperties, PropertyTreePrinter<TransformPaintPropertyNod
e>& printer) | 117 static void addObjectPaintProperties(const LayoutObject& object, const Objec
tPaintProperties& paintProperties, PropertyTreePrinter<TransformPaintPropertyNod
e>& printer) |
106 { | 118 { |
107 if (const TransformPaintPropertyNode* paintOffsetTranslation = paintProp
erties.paintOffsetTranslation()) | 119 if (const TransformPaintPropertyNode* paintOffsetTranslation = paintProp
erties.paintOffsetTranslation()) |
108 printer.addPropertyNode(paintOffsetTranslation, "PaintOffsetTranslat
ion (" + object.debugName() + ")"); | 120 printer.addPropertyNode(paintOffsetTranslation, "PaintOffsetTranslat
ion (" + object.debugName() + ")"); |
(...skipping 28 matching lines...) Expand all Loading... |
137 stringBuilder.append(String::format(", quaternion=%f,%f,%f,%f", decompos
ition.quaternionX, decomposition.quaternionY, decomposition.quaternionZ, decompo
sition.quaternionW)); | 149 stringBuilder.append(String::format(", quaternion=%f,%f,%f,%f", decompos
ition.quaternionX, decomposition.quaternionY, decomposition.quaternionZ, decompo
sition.quaternionW)); |
138 stringBuilder.append(String::format(", perspective=%f,%f,%f,%f", decompo
sition.perspectiveX, decomposition.perspectiveY, decomposition.perspectiveZ, dec
omposition.perspectiveW)); | 150 stringBuilder.append(String::format(", perspective=%f,%f,%f,%f", decompo
sition.perspectiveX, decomposition.perspectiveY, decomposition.perspectiveZ, dec
omposition.perspectiveW)); |
139 } | 151 } |
140 }; | 152 }; |
141 | 153 |
142 template <> | 154 template <> |
143 class PropertyTreePrinterTraits<ClipPaintPropertyNode> { | 155 class PropertyTreePrinterTraits<ClipPaintPropertyNode> { |
144 public: | 156 public: |
145 static void addFrameViewProperties(const FrameView& frameView, PropertyTreeP
rinter<ClipPaintPropertyNode>& printer) | 157 static void addFrameViewProperties(const FrameView& frameView, PropertyTreeP
rinter<ClipPaintPropertyNode>& printer) |
146 { | 158 { |
147 if (const ClipPaintPropertyNode* rootClip = frameView.rootClip()) | |
148 printer.addPropertyNode(rootClip, "RootClip (FrameView)"); | |
149 if (const ClipPaintPropertyNode* contentClip = frameView.contentClip()) | 159 if (const ClipPaintPropertyNode* contentClip = frameView.contentClip()) |
150 printer.addPropertyNode(contentClip, "ContentClip (FrameView)"); | 160 printer.addPropertyNode(contentClip, "ContentClip (FrameView)"); |
151 } | 161 } |
152 | 162 |
153 static void addObjectPaintProperties(const LayoutObject& object, const Objec
tPaintProperties& paintProperties, PropertyTreePrinter<ClipPaintPropertyNode>& p
rinter) | 163 static void addObjectPaintProperties(const LayoutObject& object, const Objec
tPaintProperties& paintProperties, PropertyTreePrinter<ClipPaintPropertyNode>& p
rinter) |
154 { | 164 { |
155 if (const ClipPaintPropertyNode* cssClip = paintProperties.cssClip()) | 165 if (const ClipPaintPropertyNode* cssClip = paintProperties.cssClip()) |
156 printer.addPropertyNode(cssClip, "CssClip (" + object.debugName() +
")"); | 166 printer.addPropertyNode(cssClip, "CssClip (" + object.debugName() +
")"); |
157 if (const ClipPaintPropertyNode* cssClipFixedPosition = paintProperties.
cssClipFixedPosition()) | 167 if (const ClipPaintPropertyNode* cssClipFixedPosition = paintProperties.
cssClipFixedPosition()) |
158 printer.addPropertyNode(cssClipFixedPosition, "CssClipFixedPosition
(" + object.debugName() + ")"); | 168 printer.addPropertyNode(cssClipFixedPosition, "CssClipFixedPosition
(" + object.debugName() + ")"); |
159 if (const ClipPaintPropertyNode* overflowClip = paintProperties.overflow
Clip()) | 169 if (const ClipPaintPropertyNode* overflowClip = paintProperties.overflow
Clip()) |
160 printer.addPropertyNode(overflowClip, "OverflowClip (" + object.debu
gName() + ")"); | 170 printer.addPropertyNode(overflowClip, "OverflowClip (" + object.debu
gName() + ")"); |
161 } | 171 } |
162 | 172 |
163 static void printNodeAsString(const ClipPaintPropertyNode* node, StringBuild
er& stringBuilder) | 173 static void printNodeAsString(const ClipPaintPropertyNode* node, StringBuild
er& stringBuilder) |
164 { | 174 { |
165 stringBuilder.append(String::format(" localTransformSpace=%p ", node->lo
calTransformSpace())); | 175 stringBuilder.append(String::format(" localTransformSpace=%p ", node->lo
calTransformSpace())); |
166 stringBuilder.append(String::format("rect=%f,%f,%f,%f", | 176 stringBuilder.append(String::format("rect=%f,%f,%f,%f", |
167 node->clipRect().rect().x(), node->clipRect().rect().y(), | 177 node->clipRect().rect().x(), node->clipRect().rect().y(), |
168 node->clipRect().rect().width(), node->clipRect().rect().height())); | 178 node->clipRect().rect().width(), node->clipRect().rect().height())); |
169 } | 179 } |
170 }; | 180 }; |
171 | 181 |
172 template <> | 182 template <> |
173 class PropertyTreePrinterTraits<EffectPaintPropertyNode> { | 183 class PropertyTreePrinterTraits<EffectPaintPropertyNode> { |
174 public: | 184 public: |
175 static void addFrameViewProperties(const FrameView& frameView, PropertyTreeP
rinter<EffectPaintPropertyNode>& printer) | 185 static void addFrameViewProperties(const FrameView& frameView, PropertyTreeP
rinter<EffectPaintPropertyNode>& printer) |
176 { | 186 { |
177 if (const EffectPaintPropertyNode* rootEffect = frameView.rootEffect()) | |
178 printer.addPropertyNode(rootEffect, "RootEffect (FrameView)"); | |
179 } | 187 } |
180 | 188 |
181 static void addObjectPaintProperties(const LayoutObject& object, const Objec
tPaintProperties& paintProperties, PropertyTreePrinter<EffectPaintPropertyNode>&
printer) | 189 static void addObjectPaintProperties(const LayoutObject& object, const Objec
tPaintProperties& paintProperties, PropertyTreePrinter<EffectPaintPropertyNode>&
printer) |
182 { | 190 { |
183 if (const EffectPaintPropertyNode* effect = paintProperties.effect()) | 191 if (const EffectPaintPropertyNode* effect = paintProperties.effect()) |
184 printer.addPropertyNode(effect, "Effect (" + object.debugName() + ")
"); | 192 printer.addPropertyNode(effect, "Effect (" + object.debugName() + ")
"); |
185 } | 193 } |
186 | 194 |
187 static void printNodeAsString(const EffectPaintPropertyNode* node, StringBui
lder& stringBuilder) | 195 static void printNodeAsString(const EffectPaintPropertyNode* node, StringBui
lder& stringBuilder) |
188 { | 196 { |
189 stringBuilder.append(String::format(" opacity=%f", node->opacity())); | 197 stringBuilder.append(String::format(" opacity=%f", node->opacity())); |
190 } | 198 } |
191 }; | 199 }; |
192 | 200 |
193 template <> | 201 template <> |
194 class PropertyTreePrinterTraits<ScrollPaintPropertyNode> { | 202 class PropertyTreePrinterTraits<ScrollPaintPropertyNode> { |
195 public: | 203 public: |
196 static void addFrameViewProperties(const FrameView& frameView, PropertyTreeP
rinter<ScrollPaintPropertyNode>& printer) | 204 static void addFrameViewProperties(const FrameView& frameView, PropertyTreeP
rinter<ScrollPaintPropertyNode>& printer) |
197 { | 205 { |
198 if (const ScrollPaintPropertyNode* rootScroll = frameView.rootScroll()) | |
199 printer.addPropertyNode(rootScroll, "RootScroll (FrameView)"); | |
200 if (const ScrollPaintPropertyNode* scroll = frameView.scroll()) | 206 if (const ScrollPaintPropertyNode* scroll = frameView.scroll()) |
201 printer.addPropertyNode(scroll, "Scroll (FrameView)"); | 207 printer.addPropertyNode(scroll, "Scroll (FrameView)"); |
202 } | 208 } |
203 | 209 |
204 static void addObjectPaintProperties(const LayoutObject& object, const Objec
tPaintProperties& paintProperties, PropertyTreePrinter<ScrollPaintPropertyNode>&
printer) | 210 static void addObjectPaintProperties(const LayoutObject& object, const Objec
tPaintProperties& paintProperties, PropertyTreePrinter<ScrollPaintPropertyNode>&
printer) |
205 { | 211 { |
206 if (const ScrollPaintPropertyNode* scroll = paintProperties.scroll()) | 212 if (const ScrollPaintPropertyNode* scroll = paintProperties.scroll()) |
207 printer.addPropertyNode(scroll, "Scroll (" + object.debugName() + ")
"); | 213 printer.addPropertyNode(scroll, "Scroll (" + object.debugName() + ")
"); |
208 } | 214 } |
209 | 215 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 if (object.isLayoutView() && overflowClip->parent()) | 400 if (object.isLayoutView() && overflowClip->parent()) |
395 writePaintPropertyNode(*overflowClip->parent(), nullptr, "rootCl
ip"); | 401 writePaintPropertyNode(*overflowClip->parent(), nullptr, "rootCl
ip"); |
396 } | 402 } |
397 const ScrollPaintPropertyNode* scroll = properties->scroll(); | 403 const ScrollPaintPropertyNode* scroll = properties->scroll(); |
398 if (scroll) | 404 if (scroll) |
399 writePaintPropertyNode(*scroll, &object, "scroll"); | 405 writePaintPropertyNode(*scroll, &object, "scroll"); |
400 } | 406 } |
401 | 407 |
402 void writeFrameViewPaintPropertyNodes(const FrameView& frameView) | 408 void writeFrameViewPaintPropertyNodes(const FrameView& frameView) |
403 { | 409 { |
404 TransformPaintPropertyNode* rootTransform = frameView.rootTransform(); | |
405 if (rootTransform) | |
406 writePaintPropertyNode(*rootTransform, &frameView, "rootTransform"); | |
407 ClipPaintPropertyNode* rootClip = frameView.rootClip(); | |
408 if (rootClip) | |
409 writePaintPropertyNode(*rootClip, &frameView, "rootClip"); | |
410 EffectPaintPropertyNode* rootEffect = frameView.rootEffect(); | |
411 if (rootEffect) | |
412 writePaintPropertyNode(*rootEffect, &frameView, "rootEffect"); | |
413 TransformPaintPropertyNode* preTranslation = frameView.preTranslation(); | 410 TransformPaintPropertyNode* preTranslation = frameView.preTranslation(); |
414 if (preTranslation) | 411 if (preTranslation) |
415 writePaintPropertyNode(*preTranslation, &frameView, "preTranslation"
); | 412 writePaintPropertyNode(*preTranslation, &frameView, "preTranslation"
); |
416 TransformPaintPropertyNode* scrollTranslation = frameView.scrollTranslat
ion(); | 413 TransformPaintPropertyNode* scrollTranslation = frameView.scrollTranslat
ion(); |
417 if (scrollTranslation) | 414 if (scrollTranslation) |
418 writePaintPropertyNode(*scrollTranslation, &frameView, "scrollTransl
ation"); | 415 writePaintPropertyNode(*scrollTranslation, &frameView, "scrollTransl
ation"); |
419 ClipPaintPropertyNode* contentClip = frameView.contentClip(); | 416 ClipPaintPropertyNode* contentClip = frameView.contentClip(); |
420 if (contentClip) | 417 if (contentClip) |
421 writePaintPropertyNode(*contentClip, &frameView, "contentClip"); | 418 writePaintPropertyNode(*contentClip, &frameView, "contentClip"); |
422 ScrollPaintPropertyNode* scroll = frameView.scroll(); | 419 ScrollPaintPropertyNode* scroll = frameView.scroll(); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 | 531 |
535 String paintPropertyTreeGraph(const blink::FrameView& frameView) | 532 String paintPropertyTreeGraph(const blink::FrameView& frameView) |
536 { | 533 { |
537 blink::PaintPropertyTreeGraphBuilder builder; | 534 blink::PaintPropertyTreeGraphBuilder builder; |
538 StringBuilder stringBuilder; | 535 StringBuilder stringBuilder; |
539 builder.generateTreeGraph(frameView, stringBuilder); | 536 builder.generateTreeGraph(frameView, stringBuilder); |
540 return stringBuilder.toString(); | 537 return stringBuilder.toString(); |
541 } | 538 } |
542 | 539 |
543 #endif | 540 #endif |
OLD | NEW |