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

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

Issue 456283002: Revert of [SVG2] Make transform, gradientTransform and patternTransform presentation attributes. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 4 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 | « Source/core/svg/SVGGraphicsElement.h ('k') | Source/core/svg/SVGLinearGradientElement.cpp » ('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 bd71b71796d39f608e7c0c2810ffe17dc0b07aa9..08e178a6969d1cfb0b55bb502638960209e31e5e 100644
--- a/Source/core/svg/SVGGraphicsElement.cpp
+++ b/Source/core/svg/SVGGraphicsElement.cpp
@@ -43,21 +43,6 @@
{
}
-bool SVGGraphicsElement::isPresentationAttribute(const QualifiedName& name) const
-{
- if (name == SVGNames::transformAttr)
- return true;
- return SVGElement::isPresentationAttribute(name);
-}
-
-void SVGGraphicsElement::collectStyleForPresentationAttribute(const QualifiedName& name, const AtomicString& value, MutableStylePropertySet* style)
-{
- if (name == SVGNames::transformAttr)
- addPropertyToPresentationAttributeStyle(style, CSSPropertyTransform, value);
- else
- SVGElement::collectStyleForPresentationAttribute(name, value, style);
-}
-
PassRefPtr<SVGMatrixTearOff> SVGGraphicsElement::getTransformToElement(SVGElement* target, ExceptionState& exceptionState)
{
AffineTransform ctm = getCTM(AllowStyleUpdate);
@@ -139,9 +124,36 @@
AffineTransform SVGGraphicsElement::animatedLocalTransform() const
{
AffineTransform matrix;
+ RenderStyle* style = renderer() ? renderer()->style() : 0;
+
// If CSS property was set, use that, otherwise fallback to attribute (if set).
- if (!getStyleTransform(matrix))
+ if (style && style->hasTransform()) {
+ 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);
+ } else {
+ style->applyTransform(transform, renderer()->objectBoundingBox());
+ }
+
+ // Flatten any 3D transform.
+ matrix = transform.toAffineTransform();
+ } else {
m_transform->currentValue()->concatenate(matrix);
+ }
if (m_supplementalTransform)
return *m_supplementalTransform * matrix;
@@ -190,8 +202,6 @@
return;
if (attrName == SVGNames::transformAttr) {
- invalidateSVGPresentationAttributeStyle();
- setNeedsStyleRecalc(LocalStyleChange);
object->setNeedsTransformUpdate();
RenderSVGResource::markForLayoutAndParentResourceInvalidation(object);
return;
« no previous file with comments | « Source/core/svg/SVGGraphicsElement.h ('k') | Source/core/svg/SVGLinearGradientElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698