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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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. auto to 90deg, or auto to 90deg. |
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; |
390 } | 401 } |
391 } | 402 } |
392 | 403 |
393 // From 'auto' to 'auto'. | 404 // From 'auto' to 'auto'. |
394 if (fromOrientType == SVGMarkerOrientAuto) { | 405 if (fromOrientType == SVGMarkerOrientAuto || fromOrientType == SVGMarkerOrie ntAutoStartReverse) { |
fs
2014/09/08 15:31:41
What about 'auto' <-> 'auto-start-reverse'? (Looks
Erik Dahlström (inactive)
2014/09/09 09:25:07
Done.
| |
395 m_valueInSpecifiedUnits = 0; | 406 m_valueInSpecifiedUnits = 0; |
396 orientType()->setEnumValue(SVGMarkerOrientAuto); | 407 orientType()->setEnumValue(fromOrientType); |
397 return; | 408 return; |
398 } | 409 } |
399 | 410 |
400 // If the enumeration value is not angle or auto, its unknown. | 411 // If the enumeration value is not angle or auto, its unknown. |
401 if (fromOrientType != SVGMarkerOrientAngle) { | 412 if (fromOrientType != SVGMarkerOrientAngle) { |
402 m_valueInSpecifiedUnits = 0; | 413 m_valueInSpecifiedUnits = 0; |
403 orientType()->setEnumValue(SVGMarkerOrientUnknown); | 414 orientType()->setEnumValue(SVGMarkerOrientUnknown); |
404 return; | 415 return; |
405 } | 416 } |
406 | 417 |
407 // Regular from angle to angle animation, with all features like additive et c. | 418 // Regular from angle to angle animation, with all features like additive et c. |
408 float animatedValue = value(); | 419 float animatedValue = value(); |
409 animationElement->animateAdditiveNumber(percentage, repeatCount, fromAngle-> value(), toAngle->value(), toAtEndOfDurationAngle->value(), animatedValue); | 420 animationElement->animateAdditiveNumber(percentage, repeatCount, fromAngle-> value(), toAngle->value(), toAtEndOfDurationAngle->value(), animatedValue); |
410 orientType()->setEnumValue(SVGMarkerOrientAngle); | 421 orientType()->setEnumValue(SVGMarkerOrientAngle); |
411 setValue(animatedValue); | 422 setValue(animatedValue); |
412 } | 423 } |
413 | 424 |
414 float SVGAngle::calculateDistance(PassRefPtr<SVGPropertyBase> other, SVGElement* ) | 425 float SVGAngle::calculateDistance(PassRefPtr<SVGPropertyBase> other, SVGElement* ) |
415 { | 426 { |
416 return fabsf(value() - toSVGAngle(other)->value()); | 427 return fabsf(value() - toSVGAngle(other)->value()); |
417 } | 428 } |
418 | 429 |
419 void SVGAngle::orientTypeChanged() | 430 void SVGAngle::orientTypeChanged() |
420 { | 431 { |
421 if (orientType()->enumValue() == SVGMarkerOrientAuto) { | 432 if (orientType()->enumValue() == SVGMarkerOrientAuto || orientType()->enumVa lue() == SVGMarkerOrientAutoStartReverse) { |
422 m_unitType = SVG_ANGLETYPE_UNSPECIFIED; | 433 m_unitType = SVG_ANGLETYPE_UNSPECIFIED; |
423 m_valueInSpecifiedUnits = 0; | 434 m_valueInSpecifiedUnits = 0; |
424 } | 435 } |
425 } | 436 } |
426 | 437 |
427 } | 438 } |
OLD | NEW |