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 25 matching lines...) Expand all Loading... |
36 , SVGTests(this) | 36 , SVGTests(this) |
37 , m_transform(SVGAnimatedTransformList::create(this, SVGNames::transformAttr
, SVGTransformList::create())) | 37 , m_transform(SVGAnimatedTransformList::create(this, SVGNames::transformAttr
, SVGTransformList::create())) |
38 { | 38 { |
39 addToPropertyMap(m_transform); | 39 addToPropertyMap(m_transform); |
40 } | 40 } |
41 | 41 |
42 SVGGraphicsElement::~SVGGraphicsElement() | 42 SVGGraphicsElement::~SVGGraphicsElement() |
43 { | 43 { |
44 } | 44 } |
45 | 45 |
46 bool SVGGraphicsElement::isPresentationAttribute(const QualifiedName& name) cons
t | |
47 { | |
48 if (name == SVGNames::transformAttr) | |
49 return true; | |
50 return SVGElement::isPresentationAttribute(name); | |
51 } | |
52 | |
53 void SVGGraphicsElement::collectStyleForPresentationAttribute(const QualifiedNam
e& name, const AtomicString& value, MutableStylePropertySet* style) | |
54 { | |
55 if (name == SVGNames::transformAttr) | |
56 addPropertyToPresentationAttributeStyle(style, CSSPropertyTransform, val
ue); | |
57 else | |
58 SVGElement::collectStyleForPresentationAttribute(name, value, style); | |
59 } | |
60 | |
61 PassRefPtr<SVGMatrixTearOff> SVGGraphicsElement::getTransformToElement(SVGElemen
t* target, ExceptionState& exceptionState) | 46 PassRefPtr<SVGMatrixTearOff> SVGGraphicsElement::getTransformToElement(SVGElemen
t* target, ExceptionState& exceptionState) |
62 { | 47 { |
63 AffineTransform ctm = getCTM(AllowStyleUpdate); | 48 AffineTransform ctm = getCTM(AllowStyleUpdate); |
64 | 49 |
65 if (target && target->isSVGGraphicsElement()) { | 50 if (target && target->isSVGGraphicsElement()) { |
66 AffineTransform targetCTM = toSVGGraphicsElement(target)->getCTM(AllowSt
yleUpdate); | 51 AffineTransform targetCTM = toSVGGraphicsElement(target)->getCTM(AllowSt
yleUpdate); |
67 if (!targetCTM.isInvertible()) { | 52 if (!targetCTM.isInvertible()) { |
68 exceptionState.throwDOMException(InvalidStateError, "The target tran
sformation is not invertable."); | 53 exceptionState.throwDOMException(InvalidStateError, "The target tran
sformation is not invertable."); |
69 return nullptr; | 54 return nullptr; |
70 } | 55 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 } | 117 } |
133 | 118 |
134 PassRefPtr<SVGMatrixTearOff> SVGGraphicsElement::getScreenCTMFromJavascript() | 119 PassRefPtr<SVGMatrixTearOff> SVGGraphicsElement::getScreenCTMFromJavascript() |
135 { | 120 { |
136 return SVGMatrixTearOff::create(getScreenCTM()); | 121 return SVGMatrixTearOff::create(getScreenCTM()); |
137 } | 122 } |
138 | 123 |
139 AffineTransform SVGGraphicsElement::animatedLocalTransform() const | 124 AffineTransform SVGGraphicsElement::animatedLocalTransform() const |
140 { | 125 { |
141 AffineTransform matrix; | 126 AffineTransform matrix; |
| 127 RenderStyle* style = renderer() ? renderer()->style() : 0; |
| 128 |
142 // If CSS property was set, use that, otherwise fallback to attribute (if se
t). | 129 // If CSS property was set, use that, otherwise fallback to attribute (if se
t). |
143 if (!getStyleTransform(matrix)) | 130 if (style && style->hasTransform()) { |
| 131 TransformationMatrix transform; |
| 132 float zoom = style->effectiveZoom(); |
| 133 |
| 134 // CSS transforms operate with pre-scaled lengths. To make this work wit
h SVG |
| 135 // (which applies the zoom factor globally, at the root level) we |
| 136 // |
| 137 // * pre-scale the bounding box (to bring it into the same space as th
e other CSS values) |
| 138 // * invert the zoom factor (to effectively compute the CSS transform
under a 1.0 zoom) |
| 139 // |
| 140 // Note: objectBoundingBox is an emptyRect for elements like pattern or
clipPath. |
| 141 // See the "Object bounding box units" section of http://dev.w3.org/cssw
g/css3-transforms/ |
| 142 if (zoom != 1) { |
| 143 FloatRect scaledBBox = renderer()->objectBoundingBox(); |
| 144 scaledBBox.scale(zoom); |
| 145 transform.scale(1 / zoom); |
| 146 style->applyTransform(transform, scaledBBox); |
| 147 transform.scale(zoom); |
| 148 } else { |
| 149 style->applyTransform(transform, renderer()->objectBoundingBox()); |
| 150 } |
| 151 |
| 152 // Flatten any 3D transform. |
| 153 matrix = transform.toAffineTransform(); |
| 154 } else { |
144 m_transform->currentValue()->concatenate(matrix); | 155 m_transform->currentValue()->concatenate(matrix); |
| 156 } |
145 | 157 |
146 if (m_supplementalTransform) | 158 if (m_supplementalTransform) |
147 return *m_supplementalTransform * matrix; | 159 return *m_supplementalTransform * matrix; |
148 return matrix; | 160 return matrix; |
149 } | 161 } |
150 | 162 |
151 AffineTransform* SVGGraphicsElement::supplementalTransform() | 163 AffineTransform* SVGGraphicsElement::supplementalTransform() |
152 { | 164 { |
153 if (!m_supplementalTransform) | 165 if (!m_supplementalTransform) |
154 m_supplementalTransform = adoptPtr(new AffineTransform); | 166 m_supplementalTransform = adoptPtr(new AffineTransform); |
(...skipping 28 matching lines...) Expand all Loading... |
183 if (SVGTests::isKnownAttribute(attrName)) { | 195 if (SVGTests::isKnownAttribute(attrName)) { |
184 lazyReattachIfAttached(); | 196 lazyReattachIfAttached(); |
185 return; | 197 return; |
186 } | 198 } |
187 | 199 |
188 RenderObject* object = renderer(); | 200 RenderObject* object = renderer(); |
189 if (!object) | 201 if (!object) |
190 return; | 202 return; |
191 | 203 |
192 if (attrName == SVGNames::transformAttr) { | 204 if (attrName == SVGNames::transformAttr) { |
193 invalidateSVGPresentationAttributeStyle(); | |
194 setNeedsStyleRecalc(LocalStyleChange); | |
195 object->setNeedsTransformUpdate(); | 205 object->setNeedsTransformUpdate(); |
196 RenderSVGResource::markForLayoutAndParentResourceInvalidation(object); | 206 RenderSVGResource::markForLayoutAndParentResourceInvalidation(object); |
197 return; | 207 return; |
198 } | 208 } |
199 | 209 |
200 ASSERT_NOT_REACHED(); | 210 ASSERT_NOT_REACHED(); |
201 } | 211 } |
202 | 212 |
203 SVGElement* SVGGraphicsElement::nearestViewportElement() const | 213 SVGElement* SVGGraphicsElement::nearestViewportElement() const |
204 { | 214 { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 } | 253 } |
244 | 254 |
245 void SVGGraphicsElement::toClipPath(Path& path) | 255 void SVGGraphicsElement::toClipPath(Path& path) |
246 { | 256 { |
247 updatePathFromGraphicsElement(this, path); | 257 updatePathFromGraphicsElement(this, path); |
248 // FIXME: How do we know the element has done a layout? | 258 // FIXME: How do we know the element has done a layout? |
249 path.transform(animatedLocalTransform()); | 259 path.transform(animatedLocalTransform()); |
250 } | 260 } |
251 | 261 |
252 } | 262 } |
OLD | NEW |