OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> |
4 * Copyright (C) 2007 Apple Inc. All rights reserved. | 4 * Copyright (C) 2007 Apple Inc. All rights reserved. |
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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 typedef HashMap<QualifiedName, SVGLengthMode> LengthModeForLengthAttributeMa
p; | 190 typedef HashMap<QualifiedName, SVGLengthMode> LengthModeForLengthAttributeMa
p; |
191 DEFINE_STATIC_LOCAL(LengthModeForLengthAttributeMap, s_lengthModeMap, ()); | 191 DEFINE_STATIC_LOCAL(LengthModeForLengthAttributeMap, s_lengthModeMap, ()); |
192 | 192 |
193 if (s_lengthModeMap.isEmpty()) { | 193 if (s_lengthModeMap.isEmpty()) { |
194 s_lengthModeMap.set(SVGNames::xAttr, SVGLengthMode::Width); | 194 s_lengthModeMap.set(SVGNames::xAttr, SVGLengthMode::Width); |
195 s_lengthModeMap.set(SVGNames::yAttr, SVGLengthMode::Height); | 195 s_lengthModeMap.set(SVGNames::yAttr, SVGLengthMode::Height); |
196 s_lengthModeMap.set(SVGNames::cxAttr, SVGLengthMode::Width); | 196 s_lengthModeMap.set(SVGNames::cxAttr, SVGLengthMode::Width); |
197 s_lengthModeMap.set(SVGNames::cyAttr, SVGLengthMode::Height); | 197 s_lengthModeMap.set(SVGNames::cyAttr, SVGLengthMode::Height); |
198 s_lengthModeMap.set(SVGNames::dxAttr, SVGLengthMode::Width); | 198 s_lengthModeMap.set(SVGNames::dxAttr, SVGLengthMode::Width); |
199 s_lengthModeMap.set(SVGNames::dyAttr, SVGLengthMode::Height); | 199 s_lengthModeMap.set(SVGNames::dyAttr, SVGLengthMode::Height); |
| 200 s_lengthModeMap.set(SVGNames::frAttr, SVGLengthMode::Other); |
200 s_lengthModeMap.set(SVGNames::fxAttr, SVGLengthMode::Width); | 201 s_lengthModeMap.set(SVGNames::fxAttr, SVGLengthMode::Width); |
201 s_lengthModeMap.set(SVGNames::fyAttr, SVGLengthMode::Height); | 202 s_lengthModeMap.set(SVGNames::fyAttr, SVGLengthMode::Height); |
202 s_lengthModeMap.set(SVGNames::rAttr, SVGLengthMode::Other); | 203 s_lengthModeMap.set(SVGNames::rAttr, SVGLengthMode::Other); |
203 s_lengthModeMap.set(SVGNames::rxAttr, SVGLengthMode::Width); | 204 s_lengthModeMap.set(SVGNames::rxAttr, SVGLengthMode::Width); |
204 s_lengthModeMap.set(SVGNames::ryAttr, SVGLengthMode::Height); | 205 s_lengthModeMap.set(SVGNames::ryAttr, SVGLengthMode::Height); |
205 s_lengthModeMap.set(SVGNames::widthAttr, SVGLengthMode::Width); | 206 s_lengthModeMap.set(SVGNames::widthAttr, SVGLengthMode::Width); |
206 s_lengthModeMap.set(SVGNames::heightAttr, SVGLengthMode::Height); | 207 s_lengthModeMap.set(SVGNames::heightAttr, SVGLengthMode::Height); |
207 s_lengthModeMap.set(SVGNames::x1Attr, SVGLengthMode::Width); | 208 s_lengthModeMap.set(SVGNames::x1Attr, SVGLengthMode::Width); |
208 s_lengthModeMap.set(SVGNames::x2Attr, SVGLengthMode::Width); | 209 s_lengthModeMap.set(SVGNames::x2Attr, SVGLengthMode::Width); |
209 s_lengthModeMap.set(SVGNames::y1Attr, SVGLengthMode::Height); | 210 s_lengthModeMap.set(SVGNames::y1Attr, SVGLengthMode::Height); |
210 s_lengthModeMap.set(SVGNames::y2Attr, SVGLengthMode::Height); | 211 s_lengthModeMap.set(SVGNames::y2Attr, SVGLengthMode::Height); |
211 s_lengthModeMap.set(SVGNames::refXAttr, SVGLengthMode::Width); | 212 s_lengthModeMap.set(SVGNames::refXAttr, SVGLengthMode::Width); |
212 s_lengthModeMap.set(SVGNames::refYAttr, SVGLengthMode::Height); | 213 s_lengthModeMap.set(SVGNames::refYAttr, SVGLengthMode::Height); |
213 s_lengthModeMap.set(SVGNames::markerWidthAttr, SVGLengthMode::Width); | 214 s_lengthModeMap.set(SVGNames::markerWidthAttr, SVGLengthMode::Width); |
214 s_lengthModeMap.set(SVGNames::markerHeightAttr, SVGLengthMode::Height); | 215 s_lengthModeMap.set(SVGNames::markerHeightAttr, SVGLengthMode::Height); |
215 s_lengthModeMap.set(SVGNames::textLengthAttr, SVGLengthMode::Width); | 216 s_lengthModeMap.set(SVGNames::textLengthAttr, SVGLengthMode::Width); |
216 s_lengthModeMap.set(SVGNames::startOffsetAttr, SVGLengthMode::Width); | 217 s_lengthModeMap.set(SVGNames::startOffsetAttr, SVGLengthMode::Width); |
217 } | 218 } |
218 | 219 |
219 if (s_lengthModeMap.contains(attrName)) | 220 if (s_lengthModeMap.contains(attrName)) |
220 return s_lengthModeMap.get(attrName); | 221 return s_lengthModeMap.get(attrName); |
221 | 222 |
222 return SVGLengthMode::Other; | 223 return SVGLengthMode::Other; |
223 } | 224 } |
224 | 225 |
| 226 bool SVGLength::negativeValuesForbiddenForAnimatedLengthAttribute(const Qualifie
dName& attrName) |
| 227 { |
| 228 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, s_noNegativeValuesSet, ()); |
| 229 |
| 230 if (s_noNegativeValuesSet.isEmpty()) { |
| 231 s_noNegativeValuesSet.add(SVGNames::frAttr); |
| 232 s_noNegativeValuesSet.add(SVGNames::rAttr); |
| 233 s_noNegativeValuesSet.add(SVGNames::rxAttr); |
| 234 s_noNegativeValuesSet.add(SVGNames::ryAttr); |
| 235 s_noNegativeValuesSet.add(SVGNames::widthAttr); |
| 236 s_noNegativeValuesSet.add(SVGNames::heightAttr); |
| 237 s_noNegativeValuesSet.add(SVGNames::markerWidthAttr); |
| 238 s_noNegativeValuesSet.add(SVGNames::markerHeightAttr); |
| 239 s_noNegativeValuesSet.add(SVGNames::textLengthAttr); |
| 240 } |
| 241 |
| 242 return s_noNegativeValuesSet.contains(attrName); |
| 243 } |
| 244 |
225 void SVGLength::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement* c
ontextElement) | 245 void SVGLength::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement* c
ontextElement) |
226 { | 246 { |
227 SVGLengthContext lengthContext(contextElement); | 247 SVGLengthContext lengthContext(contextElement); |
228 setValue(value(lengthContext) + toSVGLength(other)->value(lengthContext), le
ngthContext); | 248 setValue(value(lengthContext) + toSVGLength(other)->value(lengthContext), le
ngthContext); |
229 } | 249 } |
230 | 250 |
231 void SVGLength::calculateAnimatedValue(SVGAnimationElement* animationElement, | 251 void SVGLength::calculateAnimatedValue(SVGAnimationElement* animationElement, |
232 float percentage, | 252 float percentage, |
233 unsigned repeatCount, | 253 unsigned repeatCount, |
234 PassRefPtrWillBeRawPtr<SVGPropertyBase> fromValue, | 254 PassRefPtrWillBeRawPtr<SVGPropertyBase> fromValue, |
(...skipping 19 matching lines...) Expand all Loading... |
254 | 274 |
255 float SVGLength::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> toVal
ue, SVGElement* contextElement) | 275 float SVGLength::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> toVal
ue, SVGElement* contextElement) |
256 { | 276 { |
257 SVGLengthContext lengthContext(contextElement); | 277 SVGLengthContext lengthContext(contextElement); |
258 RefPtrWillBeRawPtr<SVGLength> toLength = toSVGLength(toValue); | 278 RefPtrWillBeRawPtr<SVGLength> toLength = toSVGLength(toValue); |
259 | 279 |
260 return fabsf(toLength->value(lengthContext) - value(lengthContext)); | 280 return fabsf(toLength->value(lengthContext) - value(lengthContext)); |
261 } | 281 } |
262 | 282 |
263 } | 283 } |
OLD | NEW |