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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 return SVGMatrixTearOff::create(getCTM()); | 125 return SVGMatrixTearOff::create(getCTM()); |
126 } | 126 } |
127 | 127 |
128 PassRefPtrWillBeRawPtr<SVGMatrixTearOff> SVGGraphicsElement::getScreenCTMFromJav
ascript() | 128 PassRefPtrWillBeRawPtr<SVGMatrixTearOff> SVGGraphicsElement::getScreenCTMFromJav
ascript() |
129 { | 129 { |
130 return SVGMatrixTearOff::create(getScreenCTM()); | 130 return SVGMatrixTearOff::create(getScreenCTM()); |
131 } | 131 } |
132 | 132 |
133 bool SVGGraphicsElement::hasAnimatedLocalTransform() const | 133 bool SVGGraphicsElement::hasAnimatedLocalTransform() const |
134 { | 134 { |
135 LayoutStyle* style = renderer() ? renderer()->style() : 0; | 135 LayoutStyle* style = layoutObject() ? layoutObject()->style() : 0; |
136 | 136 |
137 // Each of these is used in SVGGraphicsElement::calculateAnimatedLocalTransf
orm to create an animated local transform. | 137 // Each of these is used in SVGGraphicsElement::calculateAnimatedLocalTransf
orm to create an animated local transform. |
138 return (style && style->hasTransform()) || !m_transform->currentValue()->isE
mpty() || hasSVGRareData(); | 138 return (style && style->hasTransform()) || !m_transform->currentValue()->isE
mpty() || hasSVGRareData(); |
139 } | 139 } |
140 | 140 |
141 AffineTransform SVGGraphicsElement::calculateAnimatedLocalTransform() const | 141 AffineTransform SVGGraphicsElement::calculateAnimatedLocalTransform() const |
142 { | 142 { |
143 AffineTransform matrix; | 143 AffineTransform matrix; |
144 LayoutStyle* style = renderer() ? renderer()->style() : 0; | 144 LayoutStyle* style = layoutObject() ? layoutObject()->style() : 0; |
145 | 145 |
146 // If CSS property was set, use that, otherwise fallback to attribute (if se
t). | 146 // If CSS property was set, use that, otherwise fallback to attribute (if se
t). |
147 if (style && style->hasTransform()) { | 147 if (style && style->hasTransform()) { |
148 TransformationMatrix transform; | 148 TransformationMatrix transform; |
149 float zoom = style->effectiveZoom(); | 149 float zoom = style->effectiveZoom(); |
150 | 150 |
151 // SVGTextElements need special handling for the text positioning code. | 151 // SVGTextElements need special handling for the text positioning code. |
152 if (isSVGTextElement(this)) { | 152 if (isSVGTextElement(this)) { |
153 // Do not take into account SVG's zoom rules, transform-origin, or p
ercentage values. | 153 // Do not take into account SVG's zoom rules, transform-origin, or p
ercentage values. |
154 style->applyTransform(transform, LayoutSize(0, 0), LayoutStyle::Excl
udeTransformOrigin); | 154 style->applyTransform(transform, LayoutSize(0, 0), LayoutStyle::Excl
udeTransformOrigin); |
155 } else { | 155 } else { |
156 // CSS transforms operate with pre-scaled lengths. To make this work
with SVG | 156 // CSS transforms operate with pre-scaled lengths. To make this work
with SVG |
157 // (which applies the zoom factor globally, at the root level) we | 157 // (which applies the zoom factor globally, at the root level) we |
158 // | 158 // |
159 // * pre-scale the bounding box (to bring it into the same space a
s the other CSS values) | 159 // * pre-scale the bounding box (to bring it into the same space a
s the other CSS values) |
160 // * invert the zoom factor (to effectively compute the CSS transf
orm under a 1.0 zoom) | 160 // * invert the zoom factor (to effectively compute the CSS transf
orm under a 1.0 zoom) |
161 // | 161 // |
162 // Note: objectBoundingBox is an emptyRect for elements like pattern
or clipPath. | 162 // Note: objectBoundingBox is an emptyRect for elements like pattern
or clipPath. |
163 // See the "Object bounding box units" section of http://dev.w3.org/
csswg/css3-transforms/ | 163 // See the "Object bounding box units" section of http://dev.w3.org/
csswg/css3-transforms/ |
164 if (zoom != 1) { | 164 if (zoom != 1) { |
165 FloatRect scaledBBox = renderer()->objectBoundingBox(); | 165 FloatRect scaledBBox = layoutObject()->objectBoundingBox(); |
166 scaledBBox.scale(zoom); | 166 scaledBBox.scale(zoom); |
167 transform.scale(1 / zoom); | 167 transform.scale(1 / zoom); |
168 style->applyTransform(transform, scaledBBox); | 168 style->applyTransform(transform, scaledBBox); |
169 transform.scale(zoom); | 169 transform.scale(zoom); |
170 } else { | 170 } else { |
171 style->applyTransform(transform, renderer()->objectBoundingBox()
); | 171 style->applyTransform(transform, layoutObject()->objectBoundingB
ox()); |
172 } | 172 } |
173 } | 173 } |
174 | 174 |
175 // Flatten any 3D transform. | 175 // Flatten any 3D transform. |
176 matrix = transform.toAffineTransform(); | 176 matrix = transform.toAffineTransform(); |
177 } else { | 177 } else { |
178 m_transform->currentValue()->concatenate(matrix); | 178 m_transform->currentValue()->concatenate(matrix); |
179 } | 179 } |
180 | 180 |
181 if (hasSVGRareData()) | 181 if (hasSVGRareData()) |
(...skipping 29 matching lines...) Expand all Loading... |
211 } | 211 } |
212 | 212 |
213 SVGElement::InvalidationGuard invalidationGuard(this); | 213 SVGElement::InvalidationGuard invalidationGuard(this); |
214 | 214 |
215 // Reattach so the isValid() check will be run again during renderer creatio
n. | 215 // Reattach so the isValid() check will be run again during renderer creatio
n. |
216 if (SVGTests::isKnownAttribute(attrName)) { | 216 if (SVGTests::isKnownAttribute(attrName)) { |
217 lazyReattachIfAttached(); | 217 lazyReattachIfAttached(); |
218 return; | 218 return; |
219 } | 219 } |
220 | 220 |
221 LayoutObject* object = renderer(); | 221 LayoutObject* object = layoutObject(); |
222 if (!object) | 222 if (!object) |
223 return; | 223 return; |
224 | 224 |
225 if (attrName == SVGNames::transformAttr) { | 225 if (attrName == SVGNames::transformAttr) { |
226 object->setNeedsTransformUpdate(); | 226 object->setNeedsTransformUpdate(); |
227 markForLayoutAndParentResourceInvalidation(object); | 227 markForLayoutAndParentResourceInvalidation(object); |
228 return; | 228 return; |
229 } | 229 } |
230 | 230 |
231 ASSERT_NOT_REACHED(); | 231 ASSERT_NOT_REACHED(); |
(...skipping 17 matching lines...) Expand all Loading... |
249 farthest = toSVGElement(current); | 249 farthest = toSVGElement(current); |
250 } | 250 } |
251 return farthest; | 251 return farthest; |
252 } | 252 } |
253 | 253 |
254 FloatRect SVGGraphicsElement::getBBox() | 254 FloatRect SVGGraphicsElement::getBBox() |
255 { | 255 { |
256 document().updateLayoutIgnorePendingStylesheets(); | 256 document().updateLayoutIgnorePendingStylesheets(); |
257 | 257 |
258 // FIXME: Eventually we should support getBBox for detached elements. | 258 // FIXME: Eventually we should support getBBox for detached elements. |
259 if (!renderer()) | 259 if (!layoutObject()) |
260 return FloatRect(); | 260 return FloatRect(); |
261 | 261 |
262 return renderer()->objectBoundingBox(); | 262 return layoutObject()->objectBoundingBox(); |
263 } | 263 } |
264 | 264 |
265 PassRefPtrWillBeRawPtr<SVGRectTearOff> SVGGraphicsElement::getBBoxFromJavascript
() | 265 PassRefPtrWillBeRawPtr<SVGRectTearOff> SVGGraphicsElement::getBBoxFromJavascript
() |
266 { | 266 { |
267 return SVGRectTearOff::create(SVGRect::create(getBBox()), 0, PropertyIsNotAn
imVal); | 267 return SVGRectTearOff::create(SVGRect::create(getBBox()), 0, PropertyIsNotAn
imVal); |
268 } | 268 } |
269 | 269 |
270 LayoutObject* SVGGraphicsElement::createLayoutObject(const LayoutStyle&) | 270 LayoutObject* SVGGraphicsElement::createLayoutObject(const LayoutStyle&) |
271 { | 271 { |
272 // By default, any subclass is expected to do path-based drawing | 272 // By default, any subclass is expected to do path-based drawing |
273 return new LayoutSVGPath(this); | 273 return new LayoutSVGPath(this); |
274 } | 274 } |
275 | 275 |
276 void SVGGraphicsElement::toClipPath(Path& path) | 276 void SVGGraphicsElement::toClipPath(Path& path) |
277 { | 277 { |
278 updatePathFromGraphicsElement(this, path); | 278 updatePathFromGraphicsElement(this, path); |
279 path.transform(calculateAnimatedLocalTransform()); | 279 path.transform(calculateAnimatedLocalTransform()); |
280 } | 280 } |
281 | 281 |
282 } | 282 } |
OLD | NEW |