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 |
46 PassRefPtr<SVGMatrixTearOff> SVGGraphicsElement::getTransformToElement(SVGElemen
t* target, ExceptionState& exceptionState) | 61 PassRefPtr<SVGMatrixTearOff> SVGGraphicsElement::getTransformToElement(SVGElemen
t* target, ExceptionState& exceptionState) |
47 { | 62 { |
48 AffineTransform ctm = getCTM(AllowStyleUpdate); | 63 AffineTransform ctm = getCTM(AllowStyleUpdate); |
49 | 64 |
50 if (target && target->isSVGGraphicsElement()) { | 65 if (target && target->isSVGGraphicsElement()) { |
51 AffineTransform targetCTM = toSVGGraphicsElement(target)->getCTM(AllowSt
yleUpdate); | 66 AffineTransform targetCTM = toSVGGraphicsElement(target)->getCTM(AllowSt
yleUpdate); |
52 if (!targetCTM.isInvertible()) { | 67 if (!targetCTM.isInvertible()) { |
53 exceptionState.throwDOMException(InvalidStateError, "The target tran
sformation is not invertable."); | 68 exceptionState.throwDOMException(InvalidStateError, "The target tran
sformation is not invertable."); |
54 return nullptr; | 69 return nullptr; |
55 } | 70 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 } | 132 } |
118 | 133 |
119 PassRefPtr<SVGMatrixTearOff> SVGGraphicsElement::getScreenCTMFromJavascript() | 134 PassRefPtr<SVGMatrixTearOff> SVGGraphicsElement::getScreenCTMFromJavascript() |
120 { | 135 { |
121 return SVGMatrixTearOff::create(getScreenCTM()); | 136 return SVGMatrixTearOff::create(getScreenCTM()); |
122 } | 137 } |
123 | 138 |
124 AffineTransform SVGGraphicsElement::animatedLocalTransform() const | 139 AffineTransform SVGGraphicsElement::animatedLocalTransform() const |
125 { | 140 { |
126 AffineTransform matrix; | 141 AffineTransform matrix; |
127 RenderStyle* style = renderer() ? renderer()->style() : 0; | |
128 | |
129 // If CSS property was set, use that, otherwise fallback to attribute (if se
t). | 142 // If CSS property was set, use that, otherwise fallback to attribute (if se
t). |
130 if (style && style->hasTransform()) { | 143 if (!getStyleTransform(matrix)) |
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 { | |
155 m_transform->currentValue()->concatenate(matrix); | 144 m_transform->currentValue()->concatenate(matrix); |
156 } | |
157 | 145 |
158 if (m_supplementalTransform) | 146 if (m_supplementalTransform) |
159 return *m_supplementalTransform * matrix; | 147 return *m_supplementalTransform * matrix; |
160 return matrix; | 148 return matrix; |
161 } | 149 } |
162 | 150 |
163 AffineTransform* SVGGraphicsElement::supplementalTransform() | 151 AffineTransform* SVGGraphicsElement::supplementalTransform() |
164 { | 152 { |
165 if (!m_supplementalTransform) | 153 if (!m_supplementalTransform) |
166 m_supplementalTransform = adoptPtr(new AffineTransform); | 154 m_supplementalTransform = adoptPtr(new AffineTransform); |
(...skipping 28 matching lines...) Expand all Loading... |
195 if (SVGTests::isKnownAttribute(attrName)) { | 183 if (SVGTests::isKnownAttribute(attrName)) { |
196 lazyReattachIfAttached(); | 184 lazyReattachIfAttached(); |
197 return; | 185 return; |
198 } | 186 } |
199 | 187 |
200 RenderObject* object = renderer(); | 188 RenderObject* object = renderer(); |
201 if (!object) | 189 if (!object) |
202 return; | 190 return; |
203 | 191 |
204 if (attrName == SVGNames::transformAttr) { | 192 if (attrName == SVGNames::transformAttr) { |
| 193 invalidateSVGPresentationAttributeStyle(); |
| 194 setNeedsStyleRecalc(LocalStyleChange); |
205 object->setNeedsTransformUpdate(); | 195 object->setNeedsTransformUpdate(); |
206 RenderSVGResource::markForLayoutAndParentResourceInvalidation(object); | 196 RenderSVGResource::markForLayoutAndParentResourceInvalidation(object); |
207 return; | 197 return; |
208 } | 198 } |
209 | 199 |
210 ASSERT_NOT_REACHED(); | 200 ASSERT_NOT_REACHED(); |
211 } | 201 } |
212 | 202 |
213 SVGElement* SVGGraphicsElement::nearestViewportElement() const | 203 SVGElement* SVGGraphicsElement::nearestViewportElement() const |
214 { | 204 { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 } | 243 } |
254 | 244 |
255 void SVGGraphicsElement::toClipPath(Path& path) | 245 void SVGGraphicsElement::toClipPath(Path& path) |
256 { | 246 { |
257 updatePathFromGraphicsElement(this, path); | 247 updatePathFromGraphicsElement(this, path); |
258 // FIXME: How do we know the element has done a layout? | 248 // FIXME: How do we know the element has done a layout? |
259 path.transform(animatedLocalTransform()); | 249 path.transform(animatedLocalTransform()); |
260 } | 250 } |
261 | 251 |
262 } | 252 } |
OLD | NEW |