Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(518)

Unified Diff: third_party/WebKit/Source/core/layout/svg/SVGLayoutSupport.cpp

Issue 1747223002: Implement mapAncestorToLocal for LayoutSVG{ModelObject,Block} (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add ASSERT for expected types Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/svg/SVGLayoutSupport.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..0b1d828c3fbf2a16d8cc90176c6f62ab30baf395 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,23 @@ 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
+ // 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);
+ ASSERT(object.isSVGContainer() || object.isSVGShape() || object.isSVGImage() || object.isSVGText() || object.isSVGForeignObject());
+ 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);
« no previous file with comments | « third_party/WebKit/Source/core/layout/svg/SVGLayoutSupport.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698