Chromium Code Reviews| Index: third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp |
| diff --git a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp |
| index 14aa29a03b460b5fe4b0900391879a882f030e7a..f82e0cf34bfecaee19cab895c25acf249d58de58 100644 |
| --- a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp |
| +++ b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp |
| @@ -9,6 +9,7 @@ |
| #include "core/frame/Settings.h" |
| #include "core/layout/LayoutInline.h" |
| #include "core/layout/LayoutPart.h" |
| +#include "core/layout/svg/LayoutSVGRoot.h" |
| #include "core/paint/ObjectPaintProperties.h" |
| #include "core/paint/PaintLayer.h" |
| #include "platform/transforms/TransformationMatrix.h" |
| @@ -64,17 +65,14 @@ void PaintPropertyTreeBuilder::buildTreeNodes(FrameView& frameView, PaintPropert |
| void PaintPropertyTreeBuilder::updatePaintOffsetTranslation(const LayoutObject& object, PaintPropertyTreeBuilderContext& context) |
| { |
| - bool shouldCreatePaintOffsetTranslationNode = false; |
| - if (object.isSVGRoot()) { |
| - // SVG doesn't use paint offset internally so emit a paint offset at the html->svg boundary. |
| - shouldCreatePaintOffsetTranslationNode = true; |
| - } else if (object.isBoxModelObject()) { |
| + if (object.isBoxModelObject()) { |
| // TODO(trchen): Eliminate PaintLayer dependency. |
| PaintLayer* layer = toLayoutBoxModelObject(object).layer(); |
| - shouldCreatePaintOffsetTranslationNode = layer && layer->paintsWithTransform(GlobalPaintNormalPhase); |
| + if (!layer || !layer->paintsWithTransform(GlobalPaintNormalPhase)) |
| + return; |
| } |
| - if (context.paintOffset == LayoutPoint() || !shouldCreatePaintOffsetTranslationNode) |
| + if (context.paintOffset == LayoutPoint()) |
| return; |
| RefPtr<TransformPaintPropertyNode> paintOffsetTranslation = TransformPaintPropertyNode::create( |
| @@ -97,6 +95,28 @@ static FloatPoint3D transformOrigin(const LayoutBox& box) |
| void PaintPropertyTreeBuilder::updateTransform(const LayoutObject& object, PaintPropertyTreeBuilderContext& context) |
| { |
| + if (object.isSVG() && !object.isSVGRoot()) { |
| + // SVG does not use paint offset internally and the root should have already accounted for |
| + // any paint offset in the root's svgLocalToBorderBox transform. |
| + // FIXME(pdr): SVG text nodes inherit from HTML and do change paint offset. Figure out |
|
jbroman
2016/06/09 22:16:49
TODO, not FIXME
pdr.
2016/06/09 23:39:04
Newest patch answers the "fixme" and removes this
|
| + // whether this DCHECK should be removed or updated to handle text. |
| + // DCHECK(context.paintOffset == LayoutPoint()); |
|
jbroman
2016/06/09 22:16:49
Huh, removed? It's only a comment right now. Can y
pdr.
2016/06/09 23:39:04
Clarified with removal.
|
| + |
| + // FIXME(pdr): Check for the presence of a transform instead of the value. Checking for an |
|
jbroman
2016/06/09 22:16:49
TODO, not FIXME
pdr.
2016/06/09 23:39:04
Done.
|
| + // identity matrix will cause the property tree structure to change during animations if |
| + // the animation passes through the identity matrix. |
| + const AffineTransform& transform = object.localSVGTransform(); |
| + if (transform.isIdentity()) |
| + return; |
| + |
| + // The origin is included in the local transform, so use an empty origin. |
| + RefPtr<TransformPaintPropertyNode> svgTransform = TransformPaintPropertyNode::create( |
| + transform, FloatPoint3D(0, 0, 0), context.currentTransform); |
| + context.currentTransform = svgTransform.get(); |
| + object.getMutableForPainting().ensureObjectPaintProperties().setTransform(svgTransform.release()); |
| + return; |
| + } |
| + |
| const ComputedStyle& style = object.styleRef(); |
| if (!object.isBox() || !style.hasTransform()) |
| return; |
| @@ -232,20 +252,21 @@ void PaintPropertyTreeBuilder::updatePerspective(const LayoutObject& object, Pai |
| object.getMutableForPainting().ensureObjectPaintProperties().setPerspective(perspective.release()); |
| } |
| -void PaintPropertyTreeBuilder::updateSvgLocalTransform(const LayoutObject& object, PaintPropertyTreeBuilderContext& context) |
| +void PaintPropertyTreeBuilder::updateSvgLocalToBorderBoxTransform(const LayoutObject& object, PaintPropertyTreeBuilderContext& context) |
| { |
| - if (!object.isSVG()) |
| + if (!object.isSVGRoot()) |
| return; |
| - const AffineTransform& transform = object.localToSVGParentTransform(); |
| + AffineTransform transform = AffineTransform::translation(context.paintOffset.x().toFloat(), context.paintOffset.y().toFloat()); |
| + transform *= toLayoutSVGRoot(object).localToBorderBoxTransform(); |
| if (transform.isIdentity()) |
| return; |
| - // The origin is included in the local transform, so use an empty origin. |
| - RefPtr<TransformPaintPropertyNode> svgLocalTransform = TransformPaintPropertyNode::create( |
| + RefPtr<TransformPaintPropertyNode> svgLocalToBorderBoxTransform = TransformPaintPropertyNode::create( |
| transform, FloatPoint3D(0, 0, 0), context.currentTransform); |
| - context.currentTransform = svgLocalTransform.get(); |
| - object.getMutableForPainting().ensureObjectPaintProperties().setSvgLocalTransform(svgLocalTransform.release()); |
| + context.currentTransform = svgLocalToBorderBoxTransform.get(); |
| + context.paintOffset = LayoutPoint(); |
| + object.getMutableForPainting().ensureObjectPaintProperties().setSvgLocalToBorderBoxTransform(svgLocalToBorderBoxTransform.release()); |
| } |
| void PaintPropertyTreeBuilder::updateScrollTranslation(const LayoutObject& object, PaintPropertyTreeBuilderContext& context) |
| @@ -379,7 +400,7 @@ void PaintPropertyTreeBuilder::buildTreeNodes(const LayoutObject& object, PaintP |
| // TODO(trchen): Insert flattening transform here, as specified by |
| // http://www.w3.org/TR/css3-transforms/#transform-style-property |
| updatePerspective(object, context); |
| - updateSvgLocalTransform(object, context); |
| + updateSvgLocalToBorderBoxTransform(object, context); |
| updateScrollTranslation(object, context); |
| updateOutOfFlowContext(object, context); |
| } |