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

Unified Diff: third_party/WebKit/Source/core/svg/SVGSVGElement.cpp

Issue 2853223002: getScreenCTM on <use> should not include the additional translation (Closed)
Patch Set: Created 3 years, 8 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/svg/SVGSVGElement.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/svg/SVGSVGElement.cpp
diff --git a/third_party/WebKit/Source/core/svg/SVGSVGElement.cpp b/third_party/WebKit/Source/core/svg/SVGSVGElement.cpp
index 7dd63702bf9145e1e99ae6d1d03cc74b64f018ae..39ae107b87d9f7e87d649979cd67d40b998206ee 100644
--- a/third_party/WebKit/Source/core/svg/SVGSVGElement.cpp
+++ b/third_party/WebKit/Source/core/svg/SVGSVGElement.cpp
@@ -456,12 +456,44 @@ SVGTransformTearOff* SVGSVGElement::createSVGTransformFromMatrix(
return SVGTransformTearOff::Create(matrix);
}
-AffineTransform SVGSVGElement::LocalCoordinateSpaceTransform() const {
+AffineTransform SVGSVGElement::LocalCoordinateSpaceTransform(
+ CTMScope mode) const {
AffineTransform transform;
if (!IsOutermostSVGSVGElement()) {
SVGLengthContext length_context(this);
transform.Translate(x_->CurrentValue()->Value(length_context),
y_->CurrentValue()->Value(length_context));
+ } else if (mode == kScreenScope) {
+ if (LayoutObject* layout_object = this->GetLayoutObject()) {
+ TransformationMatrix transform;
+ // Adjust for the zoom level factored into CSS coordinates (WK bug
+ // #96361).
+ transform.Scale(1.0 / layout_object->StyleRef().EffectiveZoom());
+
+ // Origin in the document. (This, together with the inverse-scale above,
+ // performs the same operation as
+ // Document::adjustFloatRectForScrollAndAbsoluteZoom, but in
+ // transformation matrix form.)
+ if (FrameView* view = GetDocument().View()) {
+ LayoutRect visible_content_rect(view->VisibleContentRect());
+ transform.Translate(-visible_content_rect.X(),
+ -visible_content_rect.Y());
+ }
+
+ // Apply transforms from our ancestor coordinate space, including any
+ // non-SVG ancestor transforms.
+ transform.Multiply(layout_object->LocalToAbsoluteTransform());
+
+ // At the SVG/HTML boundary (aka LayoutSVGRoot), we need to apply the
+ // localToBorderBoxTransform to map an element from SVG viewport
+ // coordinates to CSS box coordinates.
+ transform.Multiply(
+ ToLayoutSVGRoot(layout_object)->LocalToBorderBoxTransform());
+ // Drop any potential non-affine parts, because we're not able to convey
+ // that information further anyway until getScreenCTM returns a DOMMatrix
+ // (4x4 matrix.)
+ return transform.ToAffineTransform();
+ }
}
if (!HasEmptyViewBox()) {
FloatSize size = CurrentViewportSize();
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGSVGElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698