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

Unified Diff: Source/core/svg/SVGGraphicsElement.cpp

Issue 693423002: Devirtualize animatedLocalTransform() and rename it for clarity (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove some codes that snuck in Created 6 years, 1 month 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 | « Source/core/svg/SVGGraphicsElement.h ('k') | Source/core/svg/SVGTextElement.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/SVGGraphicsElement.cpp
diff --git a/Source/core/svg/SVGGraphicsElement.cpp b/Source/core/svg/SVGGraphicsElement.cpp
index 34711c5d6056af34e9f4b3db2871be334059e086..61075da967ce57a3aa76961c4b597e8d09c15498 100644
--- a/Source/core/svg/SVGGraphicsElement.cpp
+++ b/Source/core/svg/SVGGraphicsElement.cpp
@@ -122,7 +122,7 @@ PassRefPtr<SVGMatrixTearOff> SVGGraphicsElement::getScreenCTMFromJavascript()
return SVGMatrixTearOff::create(getScreenCTM());
}
-AffineTransform SVGGraphicsElement::animatedLocalTransform() const
+AffineTransform SVGGraphicsElement::calculateAnimatedLocalTransform() const
{
AffineTransform matrix;
RenderStyle* style = renderer() ? renderer()->style() : 0;
@@ -132,22 +132,28 @@ AffineTransform SVGGraphicsElement::animatedLocalTransform() const
TransformationMatrix transform;
float zoom = style->effectiveZoom();
- // 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 = renderer()->objectBoundingBox();
- scaledBBox.scale(zoom);
- transform.scale(1 / zoom);
- style->applyTransform(transform, scaledBBox);
- transform.scale(zoom);
+ // 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.
+ style->applyTransform(transform, IntSize(0, 0), RenderStyle::ExcludeTransformOrigin);
} else {
- style->applyTransform(transform, renderer()->objectBoundingBox());
+ // 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 = renderer()->objectBoundingBox();
+ scaledBBox.scale(zoom);
+ transform.scale(1 / zoom);
+ style->applyTransform(transform, scaledBBox);
+ transform.scale(zoom);
+ } else {
+ style->applyTransform(transform, renderer()->objectBoundingBox());
+ }
}
// Flatten any 3D transform.
@@ -254,8 +260,7 @@ RenderObject* SVGGraphicsElement::createRenderer(RenderStyle*)
void SVGGraphicsElement::toClipPath(Path& path)
{
updatePathFromGraphicsElement(this, path);
- // FIXME: How do we know the element has done a layout?
- path.transform(animatedLocalTransform());
+ path.transform(calculateAnimatedLocalTransform());
}
}
« no previous file with comments | « Source/core/svg/SVGGraphicsElement.h ('k') | Source/core/svg/SVGTextElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698