| 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/LayoutView.h" | 9 #include "core/layout/LayoutView.h" |
| 10 #include "core/paint/ObjectPaintProperties.h" | 10 #include "core/paint/ObjectPaintProperties.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 if (!child->isLocalFrame()) | 47 if (!child->isLocalFrame()) |
| 48 continue; | 48 continue; |
| 49 if (FrameView* childView = toLocalFrame(child)->view()) | 49 if (FrameView* childView = toLocalFrame(child)->view()) |
| 50 collectPropertyNodes(*childView); | 50 collectPropertyNodes(*childView); |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 | 53 |
| 54 void collectPropertyNodes(const LayoutObject& object) | 54 void collectPropertyNodes(const LayoutObject& object) |
| 55 { | 55 { |
| 56 if (const ObjectPaintProperties* paintProperties = object.objectPaintPro
perties()) | 56 if (const ObjectPaintProperties* paintProperties = object.objectPaintPro
perties()) |
| 57 Traits::addObjectPaintProperties(*paintProperties, *this); | 57 Traits::addObjectPaintProperties(object, *paintProperties, *this); |
| 58 for (LayoutObject* child = object.slowFirstChild(); child; child = child
->nextSibling()) | 58 for (LayoutObject* child = object.slowFirstChild(); child; child = child
->nextSibling()) |
| 59 collectPropertyNodes(*child); | 59 collectPropertyNodes(*child); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void showAllPropertyNodes(const PropertyTreeNode* node, unsigned indent = 0) | 62 void showAllPropertyNodes(const PropertyTreeNode* node, unsigned indent = 0) |
| 63 { | 63 { |
| 64 if (node) { | 64 if (node) { |
| 65 StringBuilder stringBuilder; | 65 StringBuilder stringBuilder; |
| 66 for (unsigned i = 0; i < indent; i++) | 66 for (unsigned i = 0; i < indent; i++) |
| 67 stringBuilder.append(' '); | 67 stringBuilder.append(' '); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 80 | 80 |
| 81 HashMap<const PropertyTreeNode*, String> m_nodeToDebugString; | 81 HashMap<const PropertyTreeNode*, String> m_nodeToDebugString; |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 template <> | 84 template <> |
| 85 class PropertyTreePrinterTraits<TransformPaintPropertyNode> { | 85 class PropertyTreePrinterTraits<TransformPaintPropertyNode> { |
| 86 public: | 86 public: |
| 87 static void addFrameViewProperties(const FrameView& frameView, PropertyTreeP
rinter<TransformPaintPropertyNode>& printer) | 87 static void addFrameViewProperties(const FrameView& frameView, PropertyTreeP
rinter<TransformPaintPropertyNode>& printer) |
| 88 { | 88 { |
| 89 if (const TransformPaintPropertyNode* preTranslation = frameView.preTran
slation()) | 89 if (const TransformPaintPropertyNode* preTranslation = frameView.preTran
slation()) |
| 90 printer.addPropertyNode(preTranslation, "PreTranslation"); | 90 printer.addPropertyNode(preTranslation, String("PreTranslation (Fram
eView)")); |
| 91 if (const TransformPaintPropertyNode* scrollTranslation = frameView.scro
llTranslation()) | 91 if (const TransformPaintPropertyNode* scrollTranslation = frameView.scro
llTranslation()) |
| 92 printer.addPropertyNode(scrollTranslation, "ScrollTranslation"); | 92 printer.addPropertyNode(scrollTranslation, String("ScrollTranslation
(FrameView)")); |
| 93 } | 93 } |
| 94 | 94 |
| 95 static void addObjectPaintProperties(const ObjectPaintProperties& paintPrope
rties, PropertyTreePrinter<TransformPaintPropertyNode>& printer) | 95 static void addObjectPaintProperties(const LayoutObject& object, const Objec
tPaintProperties& paintProperties, PropertyTreePrinter<TransformPaintPropertyNod
e>& printer) |
| 96 { | 96 { |
| 97 if (const TransformPaintPropertyNode* paintOffsetTranslation = paintProp
erties.paintOffsetTranslation()) | 97 if (const TransformPaintPropertyNode* paintOffsetTranslation = paintProp
erties.paintOffsetTranslation()) |
| 98 printer.addPropertyNode(paintOffsetTranslation, "PaintOffsetTranslat
ion"); | 98 printer.addPropertyNode(paintOffsetTranslation, "PaintOffsetTranslat
ion (" + object.debugName() + ")"); |
| 99 if (const TransformPaintPropertyNode* transform = paintProperties.transf
orm()) | 99 if (const TransformPaintPropertyNode* transform = paintProperties.transf
orm()) |
| 100 printer.addPropertyNode(transform, "Transform"); | 100 printer.addPropertyNode(transform, "Transform (" + object.debugName(
) + ")"); |
| 101 if (const TransformPaintPropertyNode* perspective = paintProperties.pers
pective()) | 101 if (const TransformPaintPropertyNode* perspective = paintProperties.pers
pective()) |
| 102 printer.addPropertyNode(perspective, "Perspective"); | 102 printer.addPropertyNode(perspective, "Perspective (" + object.debugN
ame() + ")"); |
| 103 if (const TransformPaintPropertyNode* svgLocalToBorderBoxTransform = pai
ntProperties.svgLocalToBorderBoxTransform()) | 103 if (const TransformPaintPropertyNode* svgLocalToBorderBoxTransform = pai
ntProperties.svgLocalToBorderBoxTransform()) |
| 104 printer.addPropertyNode(svgLocalToBorderBoxTransform, "SvgLocalToBor
derBoxTransform"); | 104 printer.addPropertyNode(svgLocalToBorderBoxTransform, "SvgLocalToBor
derBoxTransform (" + object.debugName() + ")"); |
| 105 if (const TransformPaintPropertyNode* scrollTranslation = paintPropertie
s.scrollTranslation()) | 105 if (const TransformPaintPropertyNode* scrollTranslation = paintPropertie
s.scrollTranslation()) |
| 106 printer.addPropertyNode(scrollTranslation, "ScrollTranslation"); | 106 printer.addPropertyNode(scrollTranslation, "ScrollTranslation (" + o
bject.debugName() + ")"); |
| 107 if (const TransformPaintPropertyNode* scrollbarPaintOffset = paintProper
ties.scrollbarPaintOffset()) | 107 if (const TransformPaintPropertyNode* scrollbarPaintOffset = paintProper
ties.scrollbarPaintOffset()) |
| 108 printer.addPropertyNode(scrollbarPaintOffset, "ScrollbarPaintOffset"
); | 108 printer.addPropertyNode(scrollbarPaintOffset, "ScrollbarPaintOffset
(" + object.debugName() + ")"); |
| 109 } | 109 } |
| 110 | 110 |
| 111 static void printNodeAsString(const TransformPaintPropertyNode* node, String
Builder& stringBuilder) | 111 static void printNodeAsString(const TransformPaintPropertyNode* node, String
Builder& stringBuilder) |
| 112 { | 112 { |
| 113 stringBuilder.append(" transform="); | 113 stringBuilder.append(" transform="); |
| 114 | 114 |
| 115 TransformationMatrix::DecomposedType decomposition; | 115 TransformationMatrix::DecomposedType decomposition; |
| 116 if (!node->matrix().decompose(decomposition)) { | 116 if (!node->matrix().decompose(decomposition)) { |
| 117 stringBuilder.append("degenerate"); | 117 stringBuilder.append("degenerate"); |
| 118 return; | 118 return; |
| 119 } | 119 } |
| 120 | 120 |
| 121 stringBuilder.append(String::format("translation=%f,%f,%f", decompositio
n.translateX, decomposition.translateY, decomposition.translateZ)); | 121 stringBuilder.append(String::format("translation=%f,%f,%f", decompositio
n.translateX, decomposition.translateY, decomposition.translateZ)); |
| 122 if (node->matrix().isIdentityOrTranslation()) | 122 if (node->matrix().isIdentityOrTranslation()) |
| 123 return; | 123 return; |
| 124 | 124 |
| 125 stringBuilder.append(String::format(", scale=%f,%f,%f", decomposition.sc
aleX, decomposition.scaleY, decomposition.scaleZ)); | 125 stringBuilder.append(String::format(", scale=%f,%f,%f", decomposition.sc
aleX, decomposition.scaleY, decomposition.scaleZ)); |
| 126 stringBuilder.append(String::format(", skew=%f,%f,%f", decomposition.ske
wXY, decomposition.skewXZ, decomposition.skewYZ)); | 126 stringBuilder.append(String::format(", skew=%f,%f,%f", decomposition.ske
wXY, decomposition.skewXZ, decomposition.skewYZ)); |
| 127 stringBuilder.append(String::format(", quaternion=%f,%f,%f,%f", decompos
ition.quaternionX, decomposition.quaternionY, decomposition.quaternionZ, decompo
sition.quaternionW)); | 127 stringBuilder.append(String::format(", quaternion=%f,%f,%f,%f", decompos
ition.quaternionX, decomposition.quaternionY, decomposition.quaternionZ, decompo
sition.quaternionW)); |
| 128 stringBuilder.append(String::format(", perspective=%f,%f,%f,%f", decompo
sition.perspectiveX, decomposition.perspectiveY, decomposition.perspectiveZ, dec
omposition.perspectiveW)); | 128 stringBuilder.append(String::format(", perspective=%f,%f,%f,%f", decompo
sition.perspectiveX, decomposition.perspectiveY, decomposition.perspectiveZ, dec
omposition.perspectiveW)); |
| 129 } | 129 } |
| 130 }; | 130 }; |
| 131 | 131 |
| 132 template <> | 132 template <> |
| 133 class PropertyTreePrinterTraits<ClipPaintPropertyNode> { | 133 class PropertyTreePrinterTraits<ClipPaintPropertyNode> { |
| 134 public: | 134 public: |
| 135 static void addFrameViewProperties(const FrameView& frameView, PropertyTreeP
rinter<ClipPaintPropertyNode>& printer) | 135 static void addFrameViewProperties(const FrameView& frameView, PropertyTreeP
rinter<ClipPaintPropertyNode>& printer) |
| 136 { | 136 { |
| 137 if (const ClipPaintPropertyNode* contentClip = frameView.contentClip()) | 137 if (const ClipPaintPropertyNode* contentClip = frameView.contentClip()) |
| 138 printer.addPropertyNode(contentClip, "ContentClip"); | 138 printer.addPropertyNode(contentClip, "ContentClip (FrameView)"); |
| 139 } | 139 } |
| 140 | 140 |
| 141 static void addObjectPaintProperties(const ObjectPaintProperties& paintPrope
rties, PropertyTreePrinter<ClipPaintPropertyNode>& printer) | 141 static void addObjectPaintProperties(const LayoutObject& object, const Objec
tPaintProperties& paintProperties, PropertyTreePrinter<ClipPaintPropertyNode>& p
rinter) |
| 142 { | 142 { |
| 143 if (const ClipPaintPropertyNode* cssClip = paintProperties.cssClip()) | 143 if (const ClipPaintPropertyNode* cssClip = paintProperties.cssClip()) |
| 144 printer.addPropertyNode(cssClip, "CssClip"); | 144 printer.addPropertyNode(cssClip, "CssClip (" + object.debugName() +
")"); |
| 145 if (const ClipPaintPropertyNode* cssClipFixedPosition = paintProperties.
cssClipFixedPosition()) | 145 if (const ClipPaintPropertyNode* cssClipFixedPosition = paintProperties.
cssClipFixedPosition()) |
| 146 printer.addPropertyNode(cssClipFixedPosition, "CssClipFixedPosition"
); | 146 printer.addPropertyNode(cssClipFixedPosition, "CssClipFixedPosition
(" + object.debugName() + ")"); |
| 147 if (const ClipPaintPropertyNode* overflowClip = paintProperties.overflow
Clip()) | 147 if (const ClipPaintPropertyNode* overflowClip = paintProperties.overflow
Clip()) |
| 148 printer.addPropertyNode(overflowClip, "OverflowClip"); | 148 printer.addPropertyNode(overflowClip, "OverflowClip (" + object.debu
gName() + ")"); |
| 149 } | 149 } |
| 150 | 150 |
| 151 static void printNodeAsString(const ClipPaintPropertyNode* node, StringBuild
er& stringBuilder) | 151 static void printNodeAsString(const ClipPaintPropertyNode* node, StringBuild
er& stringBuilder) |
| 152 { | 152 { |
| 153 stringBuilder.append(String::format(" localTransformSpace=%p ", node->lo
calTransformSpace())); | 153 stringBuilder.append(String::format(" localTransformSpace=%p ", node->lo
calTransformSpace())); |
| 154 stringBuilder.append(String::format("rect=%f,%f,%f,%f", | 154 stringBuilder.append(String::format("rect=%f,%f,%f,%f", |
| 155 node->clipRect().rect().x(), node->clipRect().rect().y(), | 155 node->clipRect().rect().x(), node->clipRect().rect().y(), |
| 156 node->clipRect().rect().width(), node->clipRect().rect().height())); | 156 node->clipRect().rect().width(), node->clipRect().rect().height())); |
| 157 } | 157 } |
| 158 }; | 158 }; |
| 159 | 159 |
| 160 template <> | 160 template <> |
| 161 class PropertyTreePrinterTraits<EffectPaintPropertyNode> { | 161 class PropertyTreePrinterTraits<EffectPaintPropertyNode> { |
| 162 public: | 162 public: |
| 163 static void addFrameViewProperties(const FrameView& frameView, PropertyTreeP
rinter<EffectPaintPropertyNode>& printer) | 163 static void addFrameViewProperties(const FrameView& frameView, PropertyTreeP
rinter<EffectPaintPropertyNode>& printer) |
| 164 { | 164 { |
| 165 // FrameView does not create any effect nodes. | 165 // FrameView does not create any effect nodes. |
| 166 } | 166 } |
| 167 | 167 |
| 168 static void addObjectPaintProperties(const ObjectPaintProperties& paintPrope
rties, PropertyTreePrinter<EffectPaintPropertyNode>& printer) | 168 static void addObjectPaintProperties(const LayoutObject& object, const Objec
tPaintProperties& paintProperties, PropertyTreePrinter<EffectPaintPropertyNode>&
printer) |
| 169 { | 169 { |
| 170 if (const EffectPaintPropertyNode* effect = paintProperties.effect()) | 170 if (const EffectPaintPropertyNode* effect = paintProperties.effect()) |
| 171 printer.addPropertyNode(effect, "Effect"); | 171 printer.addPropertyNode(effect, "Effect (" + object.debugName() + ")
"); |
| 172 } | 172 } |
| 173 | 173 |
| 174 static void printNodeAsString(const EffectPaintPropertyNode* node, StringBui
lder& stringBuilder) | 174 static void printNodeAsString(const EffectPaintPropertyNode* node, StringBui
lder& stringBuilder) |
| 175 { | 175 { |
| 176 stringBuilder.append(String::format(" opacity=%f", node->opacity())); | 176 stringBuilder.append(String::format(" opacity=%f", node->opacity())); |
| 177 } | 177 } |
| 178 }; | 178 }; |
| 179 | 179 |
| 180 } // anonymous namespace | 180 } // anonymous namespace |
| 181 | 181 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 193 | 193 |
| 194 void showEffectPropertyTree(const FrameView& rootFrame) | 194 void showEffectPropertyTree(const FrameView& rootFrame) |
| 195 { | 195 { |
| 196 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); | 196 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
| 197 PropertyTreePrinter<EffectPaintPropertyNode>(rootFrame).show(); | 197 PropertyTreePrinter<EffectPaintPropertyNode>(rootFrame).show(); |
| 198 } | 198 } |
| 199 | 199 |
| 200 } // namespace blink | 200 } // namespace blink |
| 201 | 201 |
| 202 #endif | 202 #endif |
| OLD | NEW |