Index: Source/core/svg/GradientAttributes.h |
diff --git a/Source/core/svg/GradientAttributes.h b/Source/core/svg/GradientAttributes.h |
index ceaccf9016653decea22405e7045bc315bf8ffe8..bd81c3af44e2034c2ae41cecaf2d2d5c493f8e1d 100644 |
--- a/Source/core/svg/GradientAttributes.h |
+++ b/Source/core/svg/GradientAttributes.h |
@@ -52,6 +52,44 @@ struct GradientAttributes { |
m_gradientUnitsSet = true; |
} |
+ void setGradientTransformFromStyle(SVGGradientElement* element) |
+ { |
+ AffineTransform transform; |
+ RenderStyle* style = element->renderer() ? element->renderer()->style() : 0; |
+ |
+ // If CSS property was set, use that, otherwise fallback to attribute (if set). |
+ if (style && style->hasTransform()) { |
+ TransformationMatrix matrix; |
+ float zoom = style->effectiveZoom(); |
+ |
+ // CSS transforms operate with pre-scaled lengths. To make this work with SVG |
pdr.
2014/08/01 22:43:10
This logic is all duplicated from SVGGraphicsEleme
Erik Dahlström (inactive)
2014/08/04 13:57:57
Yes, who likes duplicated code, right? :) I'll see
|
+ // (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 = element->renderer()->objectBoundingBox(); |
+ scaledBBox.scale(zoom); |
+ transform.scale(1 / zoom); |
+ style->applyTransform(matrix, scaledBBox); |
+ matrix.scale(zoom); |
+ } else { |
+ style->applyTransform(matrix, element->renderer()->objectBoundingBox()); |
+ } |
+ |
+ // Flatten any 3D transform. |
+ transform = matrix.toAffineTransform(); |
+ } else if (element->gradientTransform()->isSpecified()) { |
+ element->gradientTransform()->currentValue()->concatenate(transform); |
+ } |
+ |
+ if (!transform.isIdentity()) |
pdr.
2014/08/01 22:43:10
Is this check needed?
Erik Dahlström (inactive)
2014/08/04 13:57:57
Technically no, since it won't make any visible di
|
+ setGradientTransform(transform); |
+ } |
+ |
void setGradientTransform(const AffineTransform& value) |
{ |
m_gradientTransform = value; |