Chromium Code Reviews| Index: third_party/WebKit/Source/core/layout/svg/SVGLayoutSupport.cpp |
| diff --git a/third_party/WebKit/Source/core/layout/svg/SVGLayoutSupport.cpp b/third_party/WebKit/Source/core/layout/svg/SVGLayoutSupport.cpp |
| index ae891e952ff47c2cedc1e46039b703a561cd24e5..1cdf7409301c5567036f831e2dc93eb45ff48905 100644 |
| --- a/third_party/WebKit/Source/core/layout/svg/SVGLayoutSupport.cpp |
| +++ b/third_party/WebKit/Source/core/layout/svg/SVGLayoutSupport.cpp |
| @@ -116,22 +116,27 @@ LayoutRect SVGLayoutSupport::clippedOverflowRectForPaintInvalidation(const Layou |
| return rect; |
| } |
| -const LayoutSVGRoot& SVGLayoutSupport::mapRectToSVGRootForPaintInvalidation(const LayoutObject& object, |
| - const FloatRect& localPaintInvalidationRect, LayoutRect& rect, float strokeWidthForHairlinePadding) |
| +static const LayoutSVGRoot& computeTransformToSVGRoot(const LayoutObject& object, AffineTransform& rootBorderBoxTransform) |
| { |
| ASSERT(object.isSVG() && !object.isSVGRoot()); |
| const LayoutObject* parent; |
| - AffineTransform rootBorderBoxTransform; |
| for (parent = &object; !parent->isSVGRoot(); parent = parent->parent()) |
| rootBorderBoxTransform.preMultiply(parent->localToParentTransform()); |
| const LayoutSVGRoot& svgRoot = toLayoutSVGRoot(*parent); |
| rootBorderBoxTransform.preMultiply(svgRoot.localToBorderBoxTransform()); |
| + return svgRoot; |
| +} |
| + |
| +const LayoutSVGRoot& SVGLayoutSupport::mapRectToSVGRootForPaintInvalidation(const LayoutObject& object, |
| + const FloatRect& localPaintInvalidationRect, LayoutRect& rect, float strokeWidthForHairlinePadding) |
| +{ |
| + AffineTransform rootBorderBoxTransform; |
| + const LayoutSVGRoot& svgRoot = computeTransformToSVGRoot(object, rootBorderBoxTransform); |
| rect = adjustedEnclosingIntRect(rootBorderBoxTransform.mapRect(localPaintInvalidationRect), |
| rootBorderBoxTransform, strokeWidthForHairlinePadding); |
| - |
| return svgRoot; |
| } |
| @@ -158,6 +163,22 @@ void SVGLayoutSupport::mapLocalToAncestor(const LayoutObject* object, const Layo |
| parent->mapLocalToAncestor(ancestor, transformState, mode, wasFixed, paintInvalidationState); |
| } |
| +void SVGLayoutSupport::mapAncestorToLocal(const LayoutObject& object, const LayoutBoxModelObject* ancestor, TransformState& transformState) |
| +{ |
| + // |object| is either a LayoutSVGModelObject or a LayoutSVGBlock here. In |
|
pdr.
2016/03/01 22:58:39
Can you add an assert for this?
fs
2016/03/02 08:54:30
It's a bit of a handful to express, but sure, adde
|
| + // the former case, |object| can never be an ancestor while in the latter |
| + // the caller is responsible for doing the ancestor check. Because of this, |
| + // computing the transform to the SVG root is always what we want to do here. |
| + ASSERT(ancestor != &object); |
| + AffineTransform localToSVGRoot; |
| + const LayoutSVGRoot& svgRoot = computeTransformToSVGRoot(object, localToSVGRoot); |
| + |
| + MapCoordinatesFlags mode = UseTransforms | ApplyContainerFlip; |
| + svgRoot.mapAncestorToLocal(ancestor, transformState, mode); |
| + |
| + transformState.applyTransform(localToSVGRoot); |
| +} |
| + |
| const LayoutObject* SVGLayoutSupport::pushMappingToContainer(const LayoutObject* object, const LayoutBoxModelObject* ancestorToStopAt, LayoutGeometryMap& geometryMap) |
| { |
| ASSERT_UNUSED(ancestorToStopAt, ancestorToStopAt != object); |