OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> |
4 * Copyright (C) 2014 Google, Inc. | 4 * Copyright (C) 2014 Google, Inc. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 PassRefPtr<SVGMatrixTearOff> SVGGraphicsElement::getCTMFromJavascript() | 115 PassRefPtr<SVGMatrixTearOff> SVGGraphicsElement::getCTMFromJavascript() |
116 { | 116 { |
117 return SVGMatrixTearOff::create(getCTM()); | 117 return SVGMatrixTearOff::create(getCTM()); |
118 } | 118 } |
119 | 119 |
120 PassRefPtr<SVGMatrixTearOff> SVGGraphicsElement::getScreenCTMFromJavascript() | 120 PassRefPtr<SVGMatrixTearOff> SVGGraphicsElement::getScreenCTMFromJavascript() |
121 { | 121 { |
122 return SVGMatrixTearOff::create(getScreenCTM()); | 122 return SVGMatrixTearOff::create(getScreenCTM()); |
123 } | 123 } |
124 | 124 |
125 AffineTransform SVGGraphicsElement::animatedLocalTransform() const | 125 AffineTransform SVGGraphicsElement::calculateAnimatedLocalTransform() const |
126 { | 126 { |
127 AffineTransform matrix; | 127 AffineTransform matrix; |
128 RenderStyle* style = renderer() ? renderer()->style() : 0; | 128 RenderStyle* style = renderer() ? renderer()->style() : 0; |
129 | 129 |
130 // If CSS property was set, use that, otherwise fallback to attribute (if se
t). | 130 // If CSS property was set, use that, otherwise fallback to attribute (if se
t). |
131 if (style && style->hasTransform()) { | 131 if (style && style->hasTransform()) { |
132 TransformationMatrix transform; | 132 TransformationMatrix transform; |
133 float zoom = style->effectiveZoom(); | 133 float zoom = style->effectiveZoom(); |
134 | 134 |
135 // CSS transforms operate with pre-scaled lengths. To make this work wit
h SVG | 135 // SVGTextElements need special handling for the text positioning code. |
136 // (which applies the zoom factor globally, at the root level) we | 136 if (isSVGTextElement(this)) { |
137 // | 137 // Do not take into account SVG's zoom rules, transform-origin, or p
ercentage values. |
138 // * pre-scale the bounding box (to bring it into the same space as th
e other CSS values) | 138 style->applyTransform(transform, IntSize(0, 0), RenderStyle::Exclude
TransformOrigin); |
139 // * invert the zoom factor (to effectively compute the CSS transform
under a 1.0 zoom) | |
140 // | |
141 // Note: objectBoundingBox is an emptyRect for elements like pattern or
clipPath. | |
142 // See the "Object bounding box units" section of http://dev.w3.org/cssw
g/css3-transforms/ | |
143 if (zoom != 1) { | |
144 FloatRect scaledBBox = renderer()->objectBoundingBox(); | |
145 scaledBBox.scale(zoom); | |
146 transform.scale(1 / zoom); | |
147 style->applyTransform(transform, scaledBBox); | |
148 transform.scale(zoom); | |
149 } else { | 139 } else { |
150 style->applyTransform(transform, renderer()->objectBoundingBox()); | 140 // CSS transforms operate with pre-scaled lengths. To make this work
with SVG |
| 141 // (which applies the zoom factor globally, at the root level) we |
| 142 // |
| 143 // * pre-scale the bounding box (to bring it into the same space a
s the other CSS values) |
| 144 // * invert the zoom factor (to effectively compute the CSS transf
orm under a 1.0 zoom) |
| 145 // |
| 146 // Note: objectBoundingBox is an emptyRect for elements like pattern
or clipPath. |
| 147 // See the "Object bounding box units" section of http://dev.w3.org/
csswg/css3-transforms/ |
| 148 if (zoom != 1) { |
| 149 FloatRect scaledBBox = renderer()->objectBoundingBox(); |
| 150 scaledBBox.scale(zoom); |
| 151 transform.scale(1 / zoom); |
| 152 style->applyTransform(transform, scaledBBox); |
| 153 transform.scale(zoom); |
| 154 } else { |
| 155 style->applyTransform(transform, renderer()->objectBoundingBox()
); |
| 156 } |
151 } | 157 } |
152 | 158 |
153 // Flatten any 3D transform. | 159 // Flatten any 3D transform. |
154 matrix = transform.toAffineTransform(); | 160 matrix = transform.toAffineTransform(); |
155 } else { | 161 } else { |
156 m_transform->currentValue()->concatenate(matrix); | 162 m_transform->currentValue()->concatenate(matrix); |
157 } | 163 } |
158 | 164 |
159 if (hasSVGRareData()) | 165 if (hasSVGRareData()) |
160 return *svgRareData()->animateMotionTransform() * matrix; | 166 return *svgRareData()->animateMotionTransform() * matrix; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 | 253 |
248 RenderObject* SVGGraphicsElement::createRenderer(RenderStyle*) | 254 RenderObject* SVGGraphicsElement::createRenderer(RenderStyle*) |
249 { | 255 { |
250 // By default, any subclass is expected to do path-based drawing | 256 // By default, any subclass is expected to do path-based drawing |
251 return new RenderSVGPath(this); | 257 return new RenderSVGPath(this); |
252 } | 258 } |
253 | 259 |
254 void SVGGraphicsElement::toClipPath(Path& path) | 260 void SVGGraphicsElement::toClipPath(Path& path) |
255 { | 261 { |
256 updatePathFromGraphicsElement(this, path); | 262 updatePathFromGraphicsElement(this, path); |
257 // FIXME: How do we know the element has done a layout? | 263 path.transform(calculateAnimatedLocalTransform()); |
258 path.transform(animatedLocalTransform()); | |
259 } | 264 } |
260 | 265 |
261 } | 266 } |
OLD | NEW |