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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 SVGMarkerOrientEnumeration::SVGMarkerOrientEnumeration(SVGAngle* angle) | 51 SVGMarkerOrientEnumeration::SVGMarkerOrientEnumeration(SVGAngle* angle) |
52 : SVGEnumeration<SVGMarkerOrientType>(SVGMarkerOrientAngle) | 52 : SVGEnumeration<SVGMarkerOrientType>(SVGMarkerOrientAngle) |
53 , m_angle(angle) | 53 , m_angle(angle) |
54 { | 54 { |
55 } | 55 } |
56 | 56 |
57 SVGMarkerOrientEnumeration::~SVGMarkerOrientEnumeration() | 57 SVGMarkerOrientEnumeration::~SVGMarkerOrientEnumeration() |
58 { | 58 { |
59 } | 59 } |
60 | 60 |
| 61 void SVGMarkerOrientEnumeration::trace(Visitor* visitor) |
| 62 { |
| 63 visitor->trace(m_angle); |
| 64 SVGEnumeration<SVGMarkerOrientType>::trace(visitor); |
| 65 } |
| 66 |
61 void SVGMarkerOrientEnumeration::notifyChange() | 67 void SVGMarkerOrientEnumeration::notifyChange() |
62 { | 68 { |
63 ASSERT(m_angle); | 69 ASSERT(m_angle); |
64 m_angle->orientTypeChanged(); | 70 m_angle->orientTypeChanged(); |
65 } | 71 } |
66 | 72 |
67 void SVGMarkerOrientEnumeration::add(PassRefPtrWillBeRawPtr<SVGPropertyBase>, SV
GElement*) | 73 void SVGMarkerOrientEnumeration::add(PassRefPtrWillBeRawPtr<SVGPropertyBase>, SV
GElement*) |
68 { | 74 { |
69 // SVGMarkerOrientEnumeration is only animated via SVGAngle | 75 // SVGMarkerOrientEnumeration is only animated via SVGAngle |
70 ASSERT_NOT_REACHED(); | 76 ASSERT_NOT_REACHED(); |
71 } | 77 } |
72 | 78 |
73 void SVGMarkerOrientEnumeration::calculateAnimatedValue(SVGAnimationElement*, fl
oat percentage, unsigned repeatCount, PassRefPtr<SVGPropertyBase> from, PassRefP
tr<SVGPropertyBase> to, PassRefPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGE
lement* contextElement) | 79 void SVGMarkerOrientEnumeration::calculateAnimatedValue(SVGAnimationElement*, fl
oat percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBase> fr
om, PassRefPtrWillBeRawPtr<SVGPropertyBase> to, PassRefPtrWillBeRawPtr<SVGProper
tyBase> toAtEndOfDurationValue, SVGElement* contextElement) |
74 { | 80 { |
75 // SVGMarkerOrientEnumeration is only animated via SVGAngle | 81 // SVGMarkerOrientEnumeration is only animated via SVGAngle |
76 ASSERT_NOT_REACHED(); | 82 ASSERT_NOT_REACHED(); |
77 } | 83 } |
78 | 84 |
79 float SVGMarkerOrientEnumeration::calculateDistance(PassRefPtr<SVGPropertyBase>
to, SVGElement* contextElement) | 85 float SVGMarkerOrientEnumeration::calculateDistance(PassRefPtrWillBeRawPtr<SVGPr
opertyBase> to, SVGElement* contextElement) |
80 { | 86 { |
81 // SVGMarkerOrientEnumeration is only animated via SVGAngle | 87 // SVGMarkerOrientEnumeration is only animated via SVGAngle |
82 ASSERT_NOT_REACHED(); | 88 ASSERT_NOT_REACHED(); |
83 return -1.0; | 89 return -1.0; |
84 } | 90 } |
85 | 91 |
86 SVGAngle::SVGAngle() | 92 SVGAngle::SVGAngle() |
87 : m_unitType(SVG_ANGLETYPE_UNSPECIFIED) | 93 : m_unitType(SVG_ANGLETYPE_UNSPECIFIED) |
88 , m_valueInSpecifiedUnits(0) | 94 , m_valueInSpecifiedUnits(0) |
89 , m_orientType(SVGMarkerOrientEnumeration::create(this)) | 95 , m_orientType(SVGMarkerOrientEnumeration::create(this)) |
90 { | 96 { |
91 } | 97 } |
92 | 98 |
93 SVGAngle::SVGAngle(SVGAngleType unitType, float valueInSpecifiedUnits, SVGMarker
OrientType orientType) | 99 SVGAngle::SVGAngle(SVGAngleType unitType, float valueInSpecifiedUnits, SVGMarker
OrientType orientType) |
94 : m_unitType(unitType) | 100 : m_unitType(unitType) |
95 , m_valueInSpecifiedUnits(valueInSpecifiedUnits) | 101 , m_valueInSpecifiedUnits(valueInSpecifiedUnits) |
96 , m_orientType(SVGMarkerOrientEnumeration::create(this)) | 102 , m_orientType(SVGMarkerOrientEnumeration::create(this)) |
97 { | 103 { |
98 m_orientType->setEnumValue(orientType); | 104 m_orientType->setEnumValue(orientType); |
99 } | 105 } |
100 | 106 |
101 SVGAngle::~SVGAngle() | 107 SVGAngle::~SVGAngle() |
102 { | 108 { |
103 } | 109 } |
104 | 110 |
105 PassRefPtr<SVGAngle> SVGAngle::clone() const | 111 void SVGAngle::trace(Visitor* visitor) |
106 { | 112 { |
107 return adoptRef(new SVGAngle(m_unitType, m_valueInSpecifiedUnits, m_orientTy
pe->enumValue())); | 113 visitor->trace(m_orientType); |
| 114 SVGPropertyHelper<SVGAngle>::trace(visitor); |
| 115 } |
| 116 |
| 117 PassRefPtrWillBeRawPtr<SVGAngle> SVGAngle::clone() const |
| 118 { |
| 119 return adoptRefWillBeNoop(new SVGAngle(m_unitType, m_valueInSpecifiedUnits,
m_orientType->enumValue())); |
108 } | 120 } |
109 | 121 |
110 float SVGAngle::value() const | 122 float SVGAngle::value() const |
111 { | 123 { |
112 switch (m_unitType) { | 124 switch (m_unitType) { |
113 case SVG_ANGLETYPE_GRAD: | 125 case SVG_ANGLETYPE_GRAD: |
114 return grad2deg(m_valueInSpecifiedUnits); | 126 return grad2deg(m_valueInSpecifiedUnits); |
115 case SVG_ANGLETYPE_RAD: | 127 case SVG_ANGLETYPE_RAD: |
116 return rad2deg(m_valueInSpecifiedUnits); | 128 return rad2deg(m_valueInSpecifiedUnits); |
117 case SVG_ANGLETYPE_TURN: | 129 case SVG_ANGLETYPE_TURN: |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 ASSERT_NOT_REACHED(); | 367 ASSERT_NOT_REACHED(); |
356 break; | 368 break; |
357 } | 369 } |
358 | 370 |
359 m_unitType = unitType; | 371 m_unitType = unitType; |
360 m_orientType->setEnumValue(SVGMarkerOrientAngle); | 372 m_orientType->setEnumValue(SVGMarkerOrientAngle); |
361 } | 373 } |
362 | 374 |
363 void SVGAngle::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement*) | 375 void SVGAngle::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement*) |
364 { | 376 { |
365 RefPtr<SVGAngle> otherAngle = toSVGAngle(other); | 377 RefPtrWillBeRawPtr<SVGAngle> otherAngle = toSVGAngle(other); |
366 | 378 |
367 // Only respect by animations, if from and by are both specified in angles (
and not eg. 'auto'). | 379 // Only respect by animations, if from and by are both specified in angles (
and not eg. 'auto'). |
368 if (orientType()->enumValue() != SVGMarkerOrientAngle || otherAngle->orientT
ype()->enumValue() != SVGMarkerOrientAngle) | 380 if (orientType()->enumValue() != SVGMarkerOrientAngle || otherAngle->orientT
ype()->enumValue() != SVGMarkerOrientAngle) |
369 return; | 381 return; |
370 | 382 |
371 setValue(value() + otherAngle->value()); | 383 setValue(value() + otherAngle->value()); |
372 } | 384 } |
373 | 385 |
374 void SVGAngle::assign(const SVGAngle& other) | 386 void SVGAngle::assign(const SVGAngle& other) |
375 { | 387 { |
376 SVGMarkerOrientType otherOrientType = other.orientType()->enumValue(); | 388 SVGMarkerOrientType otherOrientType = other.orientType()->enumValue(); |
377 if (otherOrientType == SVGMarkerOrientAngle) | 389 if (otherOrientType == SVGMarkerOrientAngle) |
378 newValueSpecifiedUnits(other.unitType(), other.valueInSpecifiedUnits()); | 390 newValueSpecifiedUnits(other.unitType(), other.valueInSpecifiedUnits()); |
379 else | 391 else |
380 m_orientType->setEnumValue(otherOrientType); | 392 m_orientType->setEnumValue(otherOrientType); |
381 } | 393 } |
382 | 394 |
383 void SVGAngle::calculateAnimatedValue(SVGAnimationElement* animationElement, flo
at percentage, unsigned repeatCount, PassRefPtr<SVGPropertyBase> from, PassRefPt
r<SVGPropertyBase> to, PassRefPtr<SVGPropertyBase> toAtEndOfDuration, SVGElement
*) | 395 void SVGAngle::calculateAnimatedValue(SVGAnimationElement* animationElement, flo
at percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBase> fro
m, PassRefPtrWillBeRawPtr<SVGPropertyBase> to, PassRefPtrWillBeRawPtr<SVGPropert
yBase> toAtEndOfDuration, SVGElement*) |
384 { | 396 { |
385 ASSERT(animationElement); | 397 ASSERT(animationElement); |
386 bool isToAnimation = animationElement->animationMode() == ToAnimation; | 398 bool isToAnimation = animationElement->animationMode() == ToAnimation; |
387 | 399 |
388 RefPtr<SVGAngle> fromAngle = isToAnimation ? this : toSVGAngle(from); | 400 RefPtrWillBeRawPtr<SVGAngle> fromAngle = isToAnimation ? PassRefPtrWillBeRaw
Ptr<SVGAngle>(this) : toSVGAngle(from); |
389 RefPtr<SVGAngle> toAngle = toSVGAngle(to); | 401 RefPtrWillBeRawPtr<SVGAngle> toAngle = toSVGAngle(to); |
390 SVGMarkerOrientType fromOrientType = fromAngle->orientType()->enumValue(); | 402 SVGMarkerOrientType fromOrientType = fromAngle->orientType()->enumValue(); |
391 SVGMarkerOrientType toOrientType = toAngle->orientType()->enumValue(); | 403 SVGMarkerOrientType toOrientType = toAngle->orientType()->enumValue(); |
392 | 404 |
393 if (fromOrientType != toOrientType) { | 405 if (fromOrientType != toOrientType) { |
394 // Fall back to discrete animation. | 406 // Fall back to discrete animation. |
395 assign(percentage < 0.5f ? *fromAngle : *toAngle); | 407 assign(percentage < 0.5f ? *fromAngle : *toAngle); |
396 return; | 408 return; |
397 } | 409 } |
398 | 410 |
399 switch (fromOrientType) { | 411 switch (fromOrientType) { |
400 // From 'auto' to 'auto', or 'auto-start-reverse' to 'auto-start-reverse' | 412 // From 'auto' to 'auto', or 'auto-start-reverse' to 'auto-start-reverse' |
401 case SVGMarkerOrientAuto: | 413 case SVGMarkerOrientAuto: |
402 case SVGMarkerOrientAutoStartReverse: | 414 case SVGMarkerOrientAutoStartReverse: |
403 orientType()->setEnumValue(fromOrientType); | 415 orientType()->setEnumValue(fromOrientType); |
404 return; | 416 return; |
405 | 417 |
406 // 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. |
407 case SVGMarkerOrientAngle: | 419 case SVGMarkerOrientAngle: |
408 { | 420 { |
409 float animatedValue = value(); | 421 float animatedValue = value(); |
410 RefPtr<SVGAngle> toAtEndOfDurationAngle = toSVGAngle(toAtEndOfDurati
on); | 422 RefPtrWillBeRawPtr<SVGAngle> toAtEndOfDurationAngle = toSVGAngle(toA
tEndOfDuration); |
411 | 423 |
412 animationElement->animateAdditiveNumber(percentage, repeatCount, fro
mAngle->value(), toAngle->value(), toAtEndOfDurationAngle->value(), animatedValu
e); | 424 animationElement->animateAdditiveNumber(percentage, repeatCount, fro
mAngle->value(), toAngle->value(), toAtEndOfDurationAngle->value(), animatedValu
e); |
413 orientType()->setEnumValue(SVGMarkerOrientAngle); | 425 orientType()->setEnumValue(SVGMarkerOrientAngle); |
414 setValue(animatedValue); | 426 setValue(animatedValue); |
415 } | 427 } |
416 return; | 428 return; |
417 | 429 |
418 // If the enumeration value is not angle or auto, its unknown. | 430 // If the enumeration value is not angle or auto, its unknown. |
419 default: | 431 default: |
420 m_valueInSpecifiedUnits = 0; | 432 m_valueInSpecifiedUnits = 0; |
421 orientType()->setEnumValue(SVGMarkerOrientUnknown); | 433 orientType()->setEnumValue(SVGMarkerOrientUnknown); |
422 return; | 434 return; |
423 } | 435 } |
424 } | 436 } |
425 | 437 |
426 float SVGAngle::calculateDistance(PassRefPtr<SVGPropertyBase> other, SVGElement*
) | 438 float SVGAngle::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> other,
SVGElement*) |
427 { | 439 { |
428 return fabsf(value() - toSVGAngle(other)->value()); | 440 return fabsf(value() - toSVGAngle(other)->value()); |
429 } | 441 } |
430 | 442 |
431 void SVGAngle::orientTypeChanged() | 443 void SVGAngle::orientTypeChanged() |
432 { | 444 { |
433 if (orientType()->enumValue() == SVGMarkerOrientAuto || orientType()->enumVa
lue() == SVGMarkerOrientAutoStartReverse) { | 445 if (orientType()->enumValue() == SVGMarkerOrientAuto || orientType()->enumVa
lue() == SVGMarkerOrientAutoStartReverse) { |
434 m_unitType = SVG_ANGLETYPE_UNSPECIFIED; | 446 m_unitType = SVG_ANGLETYPE_UNSPECIFIED; |
435 m_valueInSpecifiedUnits = 0; | 447 m_valueInSpecifiedUnits = 0; |
436 } | 448 } |
437 } | 449 } |
438 | 450 |
439 } | 451 } |
OLD | NEW |