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

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

Issue 2565403002: Perform "zoom compensation" for 'transform' on <svg:text> (Closed)
Patch Set: Created 4 years 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/LayoutTests/svg/transforms/text-with-transform-and-zoom-expected.html ('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/SVGElement.cpp
diff --git a/third_party/WebKit/Source/core/svg/SVGElement.cpp b/third_party/WebKit/Source/core/svg/SVGElement.cpp
index 41faa2662a826ee248b43067cc8304c4300be1c5..967313ceeed9bdcdab885e8ae73eb01016bb1f3d 100644
--- a/third_party/WebKit/Source/core/svg/SVGElement.cpp
+++ b/third_party/WebKit/Source/core/svg/SVGElement.cpp
@@ -331,42 +331,40 @@ AffineTransform SVGElement::calculateTransform(
TransformationMatrix transform;
float zoom = style->effectiveZoom();
+ FloatRect boundingBox = layoutObject()->objectBoundingBox();
+ ComputedStyle::ApplyTransformOrigin applyTransformOrigin =
+ ComputedStyle::IncludeTransformOrigin;
// SVGTextElements need special handling for the text positioning code.
if (isSVGTextElement(this)) {
- // Do not take into account SVG's zoom rules, transform-origin, or
- // percentage values.
+ // Do not take into account transform-origin, or percentage values.
+ boundingBox = FloatRect();
+ applyTransformOrigin = ComputedStyle::ExcludeTransformOrigin;
+ }
+
+ // CSS transforms operate with pre-scaled lengths. To make this work with
+ // SVG (which applies the zoom factor globally, at the root level) we
+ //
+ // * pre-scale the bounding box (to bring it into the same space as the
+ // other CSS values)
+ // * invert the zoom factor (to effectively compute the CSS transform
+ // under a 1.0 zoom)
+ //
+ // Note: objectBoundingBox is an emptyRect for elements like pattern or
+ // clipPath. See the "Object bounding box units" section of
+ // http://dev.w3.org/csswg/css3-transforms/
+ if (zoom != 1) {
+ boundingBox.scale(zoom);
+ transform.scale(1 / zoom);
style->applyTransform(
- transform, LayoutSize(0, 0), ComputedStyle::ExcludeTransformOrigin,
+ transform, boundingBox, applyTransformOrigin,
ComputedStyle::IncludeMotionPath,
ComputedStyle::IncludeIndependentTransformProperties);
+ transform.scale(zoom);
} else {
- // CSS transforms operate with pre-scaled lengths. To make this work with
- // SVG (which applies the zoom factor globally, at the root level) we
- //
- // * pre-scale the bounding box (to bring it into the same space as the
- // other CSS values)
- // * invert the zoom factor (to effectively compute the CSS transform
- // under a 1.0 zoom)
- //
- // Note: objectBoundingBox is an emptyRect for elements like pattern or
- // clipPath. See the "Object bounding box units" section of
- // http://dev.w3.org/csswg/css3-transforms/
- if (zoom != 1) {
- FloatRect scaledBBox = layoutObject()->objectBoundingBox();
- scaledBBox.scale(zoom);
- transform.scale(1 / zoom);
- style->applyTransform(
- transform, scaledBBox, ComputedStyle::IncludeTransformOrigin,
- ComputedStyle::IncludeMotionPath,
- ComputedStyle::IncludeIndependentTransformProperties);
- transform.scale(zoom);
- } else {
- style->applyTransform(
- transform, layoutObject()->objectBoundingBox(),
- ComputedStyle::IncludeTransformOrigin,
- ComputedStyle::IncludeMotionPath,
- ComputedStyle::IncludeIndependentTransformProperties);
- }
+ style->applyTransform(
+ transform, boundingBox, applyTransformOrigin,
+ ComputedStyle::IncludeMotionPath,
+ ComputedStyle::IncludeIndependentTransformProperties);
}
// Flatten any 3D transform.
matrix = transform.toAffineTransform();
« no previous file with comments | « third_party/WebKit/LayoutTests/svg/transforms/text-with-transform-and-zoom-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698