OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2007, 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) Research In Motion Limited 2010. All rights reserved. | 4 * Copyright (C) Research In Motion Limited 2010. 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 20 matching lines...) Expand all Loading... |
31 #include "wtf/text/WTFString.h" | 31 #include "wtf/text/WTFString.h" |
32 | 32 |
33 namespace blink { | 33 namespace blink { |
34 | 34 |
35 template<> const SVGEnumerationStringEntries& getStaticStringEntries<SVGMarkerOr
ientType>() | 35 template<> const SVGEnumerationStringEntries& getStaticStringEntries<SVGMarkerOr
ientType>() |
36 { | 36 { |
37 DEFINE_STATIC_LOCAL(SVGEnumerationStringEntries, entries, ()); | 37 DEFINE_STATIC_LOCAL(SVGEnumerationStringEntries, entries, ()); |
38 if (entries.isEmpty()) { | 38 if (entries.isEmpty()) { |
39 entries.append(std::make_pair(SVGMarkerOrientAuto, "auto")); | 39 entries.append(std::make_pair(SVGMarkerOrientAuto, "auto")); |
40 entries.append(std::make_pair(SVGMarkerOrientAngle, "angle")); | 40 entries.append(std::make_pair(SVGMarkerOrientAngle, "angle")); |
| 41 entries.append(std::make_pair(SVGMarkerOrientAutoStartReverse, "auto-sta
rt-reverse")); |
41 } | 42 } |
42 return entries; | 43 return entries; |
43 } | 44 } |
44 | 45 |
| 46 template<> unsigned short getMaxExposedEnumValue<SVGMarkerOrientType>() |
| 47 { |
| 48 return SVGMarkerOrientAngle; |
| 49 } |
| 50 |
45 SVGMarkerOrientEnumeration::SVGMarkerOrientEnumeration(SVGAngle* angle) | 51 SVGMarkerOrientEnumeration::SVGMarkerOrientEnumeration(SVGAngle* angle) |
46 : SVGEnumeration<SVGMarkerOrientType>(SVGMarkerOrientAngle) | 52 : SVGEnumeration<SVGMarkerOrientType>(SVGMarkerOrientAngle) |
47 , m_angle(angle) | 53 , m_angle(angle) |
48 { | 54 { |
49 } | 55 } |
50 | 56 |
51 SVGMarkerOrientEnumeration::~SVGMarkerOrientEnumeration() | 57 SVGMarkerOrientEnumeration::~SVGMarkerOrientEnumeration() |
52 { | 58 { |
53 } | 59 } |
54 | 60 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 if (value.isEmpty()) { | 230 if (value.isEmpty()) { |
225 newValueSpecifiedUnits(SVG_ANGLETYPE_UNSPECIFIED, 0); | 231 newValueSpecifiedUnits(SVG_ANGLETYPE_UNSPECIFIED, 0); |
226 return; | 232 return; |
227 } | 233 } |
228 | 234 |
229 if (value == "auto") { | 235 if (value == "auto") { |
230 newValueSpecifiedUnits(SVG_ANGLETYPE_UNSPECIFIED, 0); | 236 newValueSpecifiedUnits(SVG_ANGLETYPE_UNSPECIFIED, 0); |
231 m_orientType->setEnumValue(SVGMarkerOrientAuto); | 237 m_orientType->setEnumValue(SVGMarkerOrientAuto); |
232 return; | 238 return; |
233 } | 239 } |
| 240 if (value == "auto-start-reverse") { |
| 241 newValueSpecifiedUnits(SVG_ANGLETYPE_UNSPECIFIED, 0); |
| 242 m_orientType->setEnumValue(SVGMarkerOrientAutoStartReverse); |
| 243 return; |
| 244 } |
234 | 245 |
235 float valueInSpecifiedUnits = 0; | 246 float valueInSpecifiedUnits = 0; |
236 SVGAngleType unitType = SVG_ANGLETYPE_UNKNOWN; | 247 SVGAngleType unitType = SVG_ANGLETYPE_UNKNOWN; |
237 | 248 |
238 bool success = value.is8Bit() ? parseValue<LChar>(value, valueInSpecifiedUni
ts, unitType) | 249 bool success = value.is8Bit() ? parseValue<LChar>(value, valueInSpecifiedUni
ts, unitType) |
239 : parseValue<UChar>(value, valueInSpecifiedUni
ts, unitType); | 250 : parseValue<UChar>(value, valueInSpecifiedUni
ts, unitType); |
240 if (!success) { | 251 if (!success) { |
241 exceptionState.throwDOMException(SyntaxError, "The value provided ('" +
value + "') is invalid."); | 252 exceptionState.throwDOMException(SyntaxError, "The value provided ('" +
value + "') is invalid."); |
242 return; | 253 return; |
243 } | 254 } |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 bool isToAnimation = animationElement->animationMode() == ToAnimation; | 377 bool isToAnimation = animationElement->animationMode() == ToAnimation; |
367 | 378 |
368 RefPtr<SVGAngle> fromAngle = isToAnimation ? this : toSVGAngle(from); | 379 RefPtr<SVGAngle> fromAngle = isToAnimation ? this : toSVGAngle(from); |
369 RefPtr<SVGAngle> toAngle = toSVGAngle(to); | 380 RefPtr<SVGAngle> toAngle = toSVGAngle(to); |
370 RefPtr<SVGAngle> toAtEndOfDurationAngle = toSVGAngle(toAtEndOfDuration); | 381 RefPtr<SVGAngle> toAtEndOfDurationAngle = toSVGAngle(toAtEndOfDuration); |
371 | 382 |
372 SVGMarkerOrientType fromOrientType = fromAngle->orientType()->enumValue(); | 383 SVGMarkerOrientType fromOrientType = fromAngle->orientType()->enumValue(); |
373 SVGMarkerOrientType toOrientType = toAngle->orientType()->enumValue(); | 384 SVGMarkerOrientType toOrientType = toAngle->orientType()->enumValue(); |
374 | 385 |
375 if (fromOrientType != toOrientType) { | 386 if (fromOrientType != toOrientType) { |
376 // Animating from eg. auto to 90deg, or auto to 90deg. | 387 // Animating from eg. 90deg to auto. |
377 if (fromOrientType == SVGMarkerOrientAngle) { | 388 if (fromOrientType == SVGMarkerOrientAngle) { |
378 // Animating from an angle value to eg. 'auto' - this disabled addit
ive as 'auto' is a keyword.. | 389 // Animating from an angle value to eg. 'auto' - this disabled addit
ive as 'auto' is a keyword.. |
379 if (toOrientType == SVGMarkerOrientAuto) { | 390 if (toOrientType == SVGMarkerOrientAuto || toOrientType == SVGMarker
OrientAutoStartReverse) { |
380 if (percentage < 0.5f) { | 391 if (percentage < 0.5f) { |
381 newValueSpecifiedUnits(fromAngle->unitType(), fromAngle->val
ueInSpecifiedUnits()); | 392 newValueSpecifiedUnits(fromAngle->unitType(), fromAngle->val
ueInSpecifiedUnits()); |
382 return; | 393 return; |
383 } | 394 } |
384 orientType()->setEnumValue(SVGMarkerOrientAuto); | 395 orientType()->setEnumValue(toOrientType); |
385 return; | 396 return; |
386 } | 397 } |
387 m_valueInSpecifiedUnits = 0; | 398 m_valueInSpecifiedUnits = 0; |
388 orientType()->setEnumValue(SVGMarkerOrientUnknown); | 399 orientType()->setEnumValue(SVGMarkerOrientUnknown); |
389 return; | 400 return; |
| 401 } else if (toOrientType == SVGMarkerOrientAuto || toOrientType == SVGMar
kerOrientAutoStartReverse) { |
| 402 // Animating from e.g 'auto' to 'auto-start-reverse' |
| 403 if (percentage >= 0.5f) { |
| 404 m_valueInSpecifiedUnits = 0; |
| 405 orientType()->setEnumValue(toOrientType); |
| 406 return; |
| 407 } |
390 } | 408 } |
391 } | 409 } |
392 | 410 |
393 // From 'auto' to 'auto'. | 411 // From 'auto' to 'auto', or 'auto-start-reverse' to 'auto-start-reverse' |
394 if (fromOrientType == SVGMarkerOrientAuto) { | 412 if (fromOrientType == SVGMarkerOrientAuto || fromOrientType == SVGMarkerOrie
ntAutoStartReverse) { |
395 m_valueInSpecifiedUnits = 0; | 413 m_valueInSpecifiedUnits = 0; |
396 orientType()->setEnumValue(SVGMarkerOrientAuto); | 414 orientType()->setEnumValue(fromOrientType); |
397 return; | 415 return; |
398 } | 416 } |
399 | 417 |
400 // If the enumeration value is not angle or auto, its unknown. | 418 // If the enumeration value is not angle or auto, its unknown. |
401 if (fromOrientType != SVGMarkerOrientAngle) { | 419 if (fromOrientType != SVGMarkerOrientAngle) { |
402 m_valueInSpecifiedUnits = 0; | 420 m_valueInSpecifiedUnits = 0; |
403 orientType()->setEnumValue(SVGMarkerOrientUnknown); | 421 orientType()->setEnumValue(SVGMarkerOrientUnknown); |
404 return; | 422 return; |
405 } | 423 } |
406 | 424 |
407 // Regular from angle to angle animation, with all features like additive et
c. | 425 // Regular from angle to angle animation, with all features like additive et
c. |
408 float animatedValue = value(); | 426 float animatedValue = value(); |
409 animationElement->animateAdditiveNumber(percentage, repeatCount, fromAngle->
value(), toAngle->value(), toAtEndOfDurationAngle->value(), animatedValue); | 427 animationElement->animateAdditiveNumber(percentage, repeatCount, fromAngle->
value(), toAngle->value(), toAtEndOfDurationAngle->value(), animatedValue); |
410 orientType()->setEnumValue(SVGMarkerOrientAngle); | 428 orientType()->setEnumValue(SVGMarkerOrientAngle); |
411 setValue(animatedValue); | 429 setValue(animatedValue); |
412 } | 430 } |
413 | 431 |
414 float SVGAngle::calculateDistance(PassRefPtr<SVGPropertyBase> other, SVGElement*
) | 432 float SVGAngle::calculateDistance(PassRefPtr<SVGPropertyBase> other, SVGElement*
) |
415 { | 433 { |
416 return fabsf(value() - toSVGAngle(other)->value()); | 434 return fabsf(value() - toSVGAngle(other)->value()); |
417 } | 435 } |
418 | 436 |
419 void SVGAngle::orientTypeChanged() | 437 void SVGAngle::orientTypeChanged() |
420 { | 438 { |
421 if (orientType()->enumValue() == SVGMarkerOrientAuto) { | 439 if (orientType()->enumValue() == SVGMarkerOrientAuto || orientType()->enumVa
lue() == SVGMarkerOrientAutoStartReverse) { |
422 m_unitType = SVG_ANGLETYPE_UNSPECIFIED; | 440 m_unitType = SVG_ANGLETYPE_UNSPECIFIED; |
423 m_valueInSpecifiedUnits = 0; | 441 m_valueInSpecifiedUnits = 0; |
424 } | 442 } |
425 } | 443 } |
426 | 444 |
427 } | 445 } |
OLD | NEW |