Chromium Code Reviews| Index: Source/core/rendering/svg/SVGRenderSupport.cpp |
| diff --git a/Source/core/rendering/svg/SVGRenderSupport.cpp b/Source/core/rendering/svg/SVGRenderSupport.cpp |
| index e9bd6c5d8d6d1a2a1d223494d23d04c746d2e009..1842f3a0c528c3735b266b4ac3c59e71f4c2dcf7 100644 |
| --- a/Source/core/rendering/svg/SVGRenderSupport.cpp |
| +++ b/Source/core/rendering/svg/SVGRenderSupport.cpp |
| @@ -44,6 +44,13 @@ |
| namespace blink { |
| +static inline LayoutRect enclosingIntRectIfNotEmpty(const FloatRect& rect) |
| +{ |
| + if (rect.isEmpty()) |
| + return LayoutRect(); |
| + return enclosingIntRect(rect); |
| +} |
| + |
| LayoutRect SVGRenderSupport::clippedOverflowRectForPaintInvalidation(const RenderObject* object, const RenderLayerModelObject* paintInvalidationContainer, const PaintInvalidationState* paintInvalidationState) |
| { |
| // Return early for any cases where we don't actually paint |
| @@ -60,9 +67,7 @@ LayoutRect SVGRenderSupport::clippedOverflowRectForPaintInvalidation(const Rende |
| AffineTransform transform = paintInvalidationState->svgTransform() * object->localToParentTransform(); |
| paintInvalidationRect = transform.mapRect(paintInvalidationRect); |
| // FIXME: These are quirks carried forward from RenderSVGRoot::computeFloatRectForPaintInvalidation. |
|
pdr.
2014/11/21 08:32:05
This comment is no longer valid (similarly RenderS
fs
2014/11/21 11:23:15
Right. Updated.
|
| - LayoutRect rect; |
| - if (!paintInvalidationRect.isEmpty()) |
| - rect = enclosingIntRect(paintInvalidationRect); |
| + LayoutRect rect = enclosingIntRectIfNotEmpty(paintInvalidationRect); |
| // Offset by SVG root paint offset and apply clipping as needed. |
| rect.move(paintInvalidationState->paintOffset()); |
| if (paintInvalidationState->isClipped()) |
| @@ -70,15 +75,32 @@ LayoutRect SVGRenderSupport::clippedOverflowRectForPaintInvalidation(const Rende |
| return rect; |
| } |
| - object->computeFloatRectForPaintInvalidation(paintInvalidationContainer, paintInvalidationRect, paintInvalidationState); |
| - return enclosingLayoutRect(paintInvalidationRect); |
| + LayoutRect rect; |
| + const RenderSVGRoot* svgRoot = mapRectToSVGRootForPaintInvalidation(object, paintInvalidationRect, rect); |
| + svgRoot->mapRectToPaintInvalidationBacking(paintInvalidationContainer, rect, paintInvalidationState); |
| + return rect; |
| } |
| -void SVGRenderSupport::computeFloatRectForPaintInvalidation(const RenderObject* object, const RenderLayerModelObject* paintInvalidationContainer, FloatRect& paintInvalidationRect, const PaintInvalidationState* paintInvalidationState) |
| +const RenderSVGRoot* SVGRenderSupport::mapRectToSVGRootForPaintInvalidation(const RenderObject* object, const FloatRect& localPaintInvalidationRect, LayoutRect& rect) |
| { |
| - // Translate to coords in our parent renderer, and then call computeFloatRectForPaintInvalidation() on our parent. |
| - paintInvalidationRect = object->localToParentTransform().mapRect(paintInvalidationRect); |
| - object->parent()->computeFloatRectForPaintInvalidation(paintInvalidationContainer, paintInvalidationRect, paintInvalidationState); |
| + ASSERT(object && object->isSVG() && !object->isSVGRoot()); |
| + |
| + FloatRect paintInvalidationRect = localPaintInvalidationRect; |
| + // FIXME: Building the transform to the SVG root border box and then doing |
| + // mapRect() with that would be slightly more efficient, but requires some |
| + // additions to AffineTransform (preMultiply, preTranslate) to avoid |
| + // excessive copying and to get a similar fast-path for translations. |
| + const RenderObject* parent = object; |
| + do { |
| + paintInvalidationRect = parent->localToParentTransform().mapRect(paintInvalidationRect); |
| + parent = parent->parent(); |
| + } while (!parent->isSVGRoot()); |
| + |
| + const RenderSVGRoot* svgRoot = toRenderSVGRoot(parent); |
| + |
| + paintInvalidationRect = svgRoot->localToBorderBoxTransform().mapRect(paintInvalidationRect); |
| + rect = enclosingIntRectIfNotEmpty(paintInvalidationRect); |
| + return svgRoot; |
| } |
| void SVGRenderSupport::mapLocalToContainer(const RenderObject* object, const RenderLayerModelObject* paintInvalidationContainer, TransformState& transformState, bool* wasFixed, const PaintInvalidationState* paintInvalidationState) |