OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2010 Rob Buis <buis@kde.org> | 2 * Copyright (C) 2007, 2010 Rob Buis <buis@kde.org> |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 String SVGViewSpec::transformString() const | 126 String SVGViewSpec::transformString() const |
127 { | 127 { |
128 return SVGPropertyTraits<SVGTransformList>::toString(m_transform); | 128 return SVGPropertyTraits<SVGTransformList>::toString(m_transform); |
129 } | 129 } |
130 | 130 |
131 String SVGViewSpec::viewBoxString() const | 131 String SVGViewSpec::viewBoxString() const |
132 { | 132 { |
133 return SVGPropertyTraits<FloatRect>::toString(viewBoxBaseValue()); | 133 return SVGPropertyTraits<FloatRect>::toString(viewBoxBaseValue()); |
134 } | 134 } |
135 | 135 |
136 void SVGViewSpec::setPreserveAspectRatioString(const String& preserve) | |
137 { | |
138 SVGPreserveAspectRatio preserveAspectRatio; | |
139 preserveAspectRatio.parse(preserve); | |
140 setPreserveAspectRatioBaseValue(preserveAspectRatio); | |
141 } | |
142 | |
143 String SVGViewSpec::preserveAspectRatioString() const | 136 String SVGViewSpec::preserveAspectRatioString() const |
144 { | 137 { |
145 return SVGPropertyTraits<SVGPreserveAspectRatio>::toString(preserveAspectRat
ioBaseValue()); | 138 return SVGPropertyTraits<SVGPreserveAspectRatio>::toString(preserveAspectRat
ioBaseValue()); |
146 } | 139 } |
147 | 140 |
148 SVGElement* SVGViewSpec::viewTarget() const | 141 SVGElement* SVGViewSpec::viewTarget() const |
149 { | 142 { |
150 if (!m_contextElement) | 143 if (!m_contextElement) |
151 return 0; | 144 return 0; |
152 return static_cast<SVGElement*>(m_contextElement->treeScope()->getElementByI
d(m_viewTargetString)); | 145 return static_cast<SVGElement*>(m_contextElement->treeScope()->getElementByI
d(m_viewTargetString)); |
153 } | 146 } |
154 | 147 |
155 SVGTransformListPropertyTearOff* SVGViewSpec::transform() | 148 SVGTransformListPropertyTearOff* SVGViewSpec::transform() |
156 { | 149 { |
| 150 if (!m_contextElement) |
| 151 return 0; |
157 // Return the animVal here, as its readonly by default - which is exactly wh
at we want here. | 152 // Return the animVal here, as its readonly by default - which is exactly wh
at we want here. |
158 return static_cast<SVGTransformListPropertyTearOff*>(static_pointer_cast<SVG
AnimatedTransformList>(lookupOrCreateTransformWrapper(this))->animVal()); | 153 return static_cast<SVGTransformListPropertyTearOff*>(static_pointer_cast<SVG
AnimatedTransformList>(lookupOrCreateTransformWrapper(this))->animVal()); |
159 } | 154 } |
160 | 155 |
| 156 PassRefPtr<SVGAnimatedRect> SVGViewSpec::viewBoxAnimated() |
| 157 { |
| 158 if (!m_contextElement) |
| 159 return 0; |
| 160 return static_pointer_cast<SVGAnimatedRect>(lookupOrCreateViewBoxWrapper(thi
s)); |
| 161 } |
| 162 |
| 163 PassRefPtr<SVGAnimatedPreserveAspectRatio> SVGViewSpec::preserveAspectRatioAnima
ted() |
| 164 { |
| 165 if (!m_contextElement) |
| 166 return 0; |
| 167 return static_pointer_cast<SVGAnimatedPreserveAspectRatio>(lookupOrCreatePre
serveAspectRatioWrapper(this)); |
| 168 } |
| 169 |
161 PassRefPtr<SVGAnimatedProperty> SVGViewSpec::lookupOrCreateViewBoxWrapper(void*
maskedOwnerType) | 170 PassRefPtr<SVGAnimatedProperty> SVGViewSpec::lookupOrCreateViewBoxWrapper(void*
maskedOwnerType) |
162 { | 171 { |
163 ASSERT(maskedOwnerType); | 172 ASSERT(maskedOwnerType); |
164 SVGViewSpec* ownerType = static_cast<SVGViewSpec*>(maskedOwnerType); | 173 SVGViewSpec* ownerType = static_cast<SVGViewSpec*>(maskedOwnerType); |
| 174 ASSERT(ownerType->contextElement()); |
165 return SVGAnimatedProperty::lookupOrCreateWrapper<SVGElement, SVGAnimatedRec
t, FloatRect>(ownerType->contextElement(), viewBoxPropertyInfo(), ownerType->m_v
iewBox); | 175 return SVGAnimatedProperty::lookupOrCreateWrapper<SVGElement, SVGAnimatedRec
t, FloatRect>(ownerType->contextElement(), viewBoxPropertyInfo(), ownerType->m_v
iewBox); |
166 } | 176 } |
167 | 177 |
168 PassRefPtr<SVGAnimatedProperty> SVGViewSpec::lookupOrCreatePreserveAspectRatioWr
apper(void* maskedOwnerType) | 178 PassRefPtr<SVGAnimatedProperty> SVGViewSpec::lookupOrCreatePreserveAspectRatioWr
apper(void* maskedOwnerType) |
169 { | 179 { |
170 ASSERT(maskedOwnerType); | 180 ASSERT(maskedOwnerType); |
171 SVGViewSpec* ownerType = static_cast<SVGViewSpec*>(maskedOwnerType); | 181 SVGViewSpec* ownerType = static_cast<SVGViewSpec*>(maskedOwnerType); |
| 182 ASSERT(ownerType->contextElement()); |
172 return SVGAnimatedProperty::lookupOrCreateWrapper<SVGElement, SVGAnimatedPre
serveAspectRatio, SVGPreserveAspectRatio>(ownerType->contextElement(), preserveA
spectRatioPropertyInfo(), ownerType->m_preserveAspectRatio); | 183 return SVGAnimatedProperty::lookupOrCreateWrapper<SVGElement, SVGAnimatedPre
serveAspectRatio, SVGPreserveAspectRatio>(ownerType->contextElement(), preserveA
spectRatioPropertyInfo(), ownerType->m_preserveAspectRatio); |
173 } | 184 } |
174 | 185 |
175 PassRefPtr<SVGAnimatedProperty> SVGViewSpec::lookupOrCreateTransformWrapper(void
* maskedOwnerType) | 186 PassRefPtr<SVGAnimatedProperty> SVGViewSpec::lookupOrCreateTransformWrapper(void
* maskedOwnerType) |
176 { | 187 { |
177 ASSERT(maskedOwnerType); | 188 ASSERT(maskedOwnerType); |
178 SVGViewSpec* ownerType = static_cast<SVGViewSpec*>(maskedOwnerType); | 189 SVGViewSpec* ownerType = static_cast<SVGViewSpec*>(maskedOwnerType); |
| 190 ASSERT(ownerType->contextElement()); |
179 return SVGAnimatedProperty::lookupOrCreateWrapper<SVGElement, SVGAnimatedTra
nsformList, SVGTransformList>(ownerType->contextElement(), transformPropertyInfo
(), ownerType->m_transform); | 191 return SVGAnimatedProperty::lookupOrCreateWrapper<SVGElement, SVGAnimatedTra
nsformList, SVGTransformList>(ownerType->contextElement(), transformPropertyInfo
(), ownerType->m_transform); |
180 } | 192 } |
181 | 193 |
182 void SVGViewSpec::reset() | 194 void SVGViewSpec::reset() |
183 { | 195 { |
184 m_zoomAndPan = SVGZoomAndPanMagnify; | 196 m_zoomAndPan = SVGZoomAndPanMagnify; |
185 m_transform.clear(); | 197 m_transform.clear(); |
186 m_viewBox = FloatRect(); | 198 m_viewBox = FloatRect(); |
187 m_preserveAspectRatio = SVGPreserveAspectRatio(); | 199 m_preserveAspectRatio = SVGPreserveAspectRatio(); |
188 m_viewTargetString = emptyString(); | 200 m_viewTargetString = emptyString(); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 | 290 |
279 if (currViewSpec >= end || *currViewSpec != ')') | 291 if (currViewSpec >= end || *currViewSpec != ')') |
280 return false; | 292 return false; |
281 | 293 |
282 return true; | 294 return true; |
283 } | 295 } |
284 | 296 |
285 } | 297 } |
286 | 298 |
287 #endif // ENABLE(SVG) | 299 #endif // ENABLE(SVG) |
OLD | NEW |