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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 return LengthTypePT; | 99 return LengthTypePT; |
100 if (firstChar == 'p' && secondChar == 'c') | 100 if (firstChar == 'p' && secondChar == 'c') |
101 return LengthTypePC; | 101 return LengthTypePC; |
102 | 102 |
103 return LengthTypeUnknown; | 103 return LengthTypeUnknown; |
104 } | 104 } |
105 | 105 |
106 } // namespace | 106 } // namespace |
107 | 107 |
108 SVGLength::SVGLength(SVGLengthMode mode) | 108 SVGLength::SVGLength(SVGLengthMode mode) |
109 : NewSVGPropertyBase(classType()) | 109 : SVGPropertyBase(classType()) |
110 , m_valueInSpecifiedUnits(0) | 110 , m_valueInSpecifiedUnits(0) |
111 , m_unitMode(mode) | 111 , m_unitMode(mode) |
112 , m_unitType(LengthTypeNumber) | 112 , m_unitType(LengthTypeNumber) |
113 { | 113 { |
114 } | 114 } |
115 | 115 |
116 SVGLength::SVGLength(const SVGLength& o) | 116 SVGLength::SVGLength(const SVGLength& o) |
117 : NewSVGPropertyBase(classType()) | 117 : SVGPropertyBase(classType()) |
118 , m_valueInSpecifiedUnits(o.m_valueInSpecifiedUnits) | 118 , m_valueInSpecifiedUnits(o.m_valueInSpecifiedUnits) |
119 , m_unitMode(o.m_unitMode) | 119 , m_unitMode(o.m_unitMode) |
120 , m_unitType(o.m_unitType) | 120 , m_unitType(o.m_unitType) |
121 { | 121 { |
122 } | 122 } |
123 | 123 |
124 PassRefPtr<SVGLength> SVGLength::clone() const | 124 PassRefPtr<SVGLength> SVGLength::clone() const |
125 { | 125 { |
126 return adoptRef(new SVGLength(*this)); | 126 return adoptRef(new SVGLength(*this)); |
127 } | 127 } |
128 | 128 |
129 PassRefPtr<NewSVGPropertyBase> SVGLength::cloneForAnimation(const String& value)
const | 129 PassRefPtr<SVGPropertyBase> SVGLength::cloneForAnimation(const String& value) co
nst |
130 { | 130 { |
131 RefPtr<SVGLength> length = create(); | 131 RefPtr<SVGLength> length = create(); |
132 | 132 |
133 length->m_unitMode = m_unitMode; | 133 length->m_unitMode = m_unitMode; |
134 length->m_unitType = m_unitType; | 134 length->m_unitType = m_unitType; |
135 | 135 |
136 TrackExceptionState exceptionState; | 136 TrackExceptionState exceptionState; |
137 length->setValueAsString(value, exceptionState); | 137 length->setValueAsString(value, exceptionState); |
138 if (exceptionState.hadException()) { | 138 if (exceptionState.hadException()) { |
139 length->m_unitType = LengthTypeNumber; | 139 length->m_unitType = LengthTypeNumber; |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 | 427 |
428 float fromValue = nonRelativeLengthContext.convertValueFromUserUnits(fromVal
ueInUserUnits, unitMode(), toType, es); | 428 float fromValue = nonRelativeLengthContext.convertValueFromUserUnits(fromVal
ueInUserUnits, unitMode(), toType, es); |
429 if (es.hadException()) | 429 if (es.hadException()) |
430 return create(); | 430 return create(); |
431 | 431 |
432 float toValue = valueInSpecifiedUnits(); | 432 float toValue = valueInSpecifiedUnits(); |
433 length->newValueSpecifiedUnits(toType, WebCore::blend(fromValue, toValue, pr
ogress)); | 433 length->newValueSpecifiedUnits(toType, WebCore::blend(fromValue, toValue, pr
ogress)); |
434 return length; | 434 return length; |
435 } | 435 } |
436 | 436 |
437 void SVGLength::add(PassRefPtr<NewSVGPropertyBase> other, SVGElement* contextEle
ment) | 437 void SVGLength::add(PassRefPtr<SVGPropertyBase> other, SVGElement* contextElemen
t) |
438 { | 438 { |
439 SVGLengthContext lengthContext(contextElement); | 439 SVGLengthContext lengthContext(contextElement); |
440 | 440 |
441 setValue(value(lengthContext) + toSVGLength(other)->value(lengthContext), le
ngthContext, ASSERT_NO_EXCEPTION); | 441 setValue(value(lengthContext) + toSVGLength(other)->value(lengthContext), le
ngthContext, ASSERT_NO_EXCEPTION); |
442 } | 442 } |
443 | 443 |
444 void SVGLength::calculateAnimatedValue(SVGAnimationElement* animationElement, fl
oat percentage, unsigned repeatCount, PassRefPtr<NewSVGPropertyBase> fromValue,
PassRefPtr<NewSVGPropertyBase> toValue, PassRefPtr<NewSVGPropertyBase> toAtEndOf
DurationValue, SVGElement* contextElement) | 444 void SVGLength::calculateAnimatedValue(SVGAnimationElement* animationElement, fl
oat percentage, unsigned repeatCount, PassRefPtr<SVGPropertyBase> fromValue, Pas
sRefPtr<SVGPropertyBase> toValue, PassRefPtr<SVGPropertyBase> toAtEndOfDurationV
alue, SVGElement* contextElement) |
445 { | 445 { |
446 RefPtr<SVGLength> fromLength = toSVGLength(fromValue); | 446 RefPtr<SVGLength> fromLength = toSVGLength(fromValue); |
447 RefPtr<SVGLength> toLength = toSVGLength(toValue); | 447 RefPtr<SVGLength> toLength = toSVGLength(toValue); |
448 RefPtr<SVGLength> toAtEndOfDurationLength = toSVGLength(toAtEndOfDurationVal
ue); | 448 RefPtr<SVGLength> toAtEndOfDurationLength = toSVGLength(toAtEndOfDurationVal
ue); |
449 | 449 |
450 SVGLengthContext lengthContext(contextElement); | 450 SVGLengthContext lengthContext(contextElement); |
451 float animatedNumber = value(lengthContext, IGNORE_EXCEPTION); | 451 float animatedNumber = value(lengthContext, IGNORE_EXCEPTION); |
452 animationElement->animateAdditiveNumber(percentage, repeatCount, fromLength-
>value(lengthContext, IGNORE_EXCEPTION), toLength->value(lengthContext, IGNORE_E
XCEPTION), toAtEndOfDurationLength->value(lengthContext, IGNORE_EXCEPTION), anim
atedNumber); | 452 animationElement->animateAdditiveNumber(percentage, repeatCount, fromLength-
>value(lengthContext, IGNORE_EXCEPTION), toLength->value(lengthContext, IGNORE_E
XCEPTION), toAtEndOfDurationLength->value(lengthContext, IGNORE_EXCEPTION), anim
atedNumber); |
453 | 453 |
454 ASSERT(unitMode() == lengthModeForAnimatedLengthAttribute(animationElement->
attributeName())); | 454 ASSERT(unitMode() == lengthModeForAnimatedLengthAttribute(animationElement->
attributeName())); |
455 m_unitType = percentage < 0.5 ? fromLength->unitType() : toLength->unitType(
); | 455 m_unitType = percentage < 0.5 ? fromLength->unitType() : toLength->unitType(
); |
456 setValue(animatedNumber, lengthContext, ASSERT_NO_EXCEPTION); | 456 setValue(animatedNumber, lengthContext, ASSERT_NO_EXCEPTION); |
457 } | 457 } |
458 | 458 |
459 float SVGLength::calculateDistance(PassRefPtr<NewSVGPropertyBase> toValue, SVGEl
ement* contextElement) | 459 float SVGLength::calculateDistance(PassRefPtr<SVGPropertyBase> toValue, SVGEleme
nt* contextElement) |
460 { | 460 { |
461 SVGLengthContext lengthContext(contextElement); | 461 SVGLengthContext lengthContext(contextElement); |
462 RefPtr<SVGLength> toLength = toSVGLength(toValue); | 462 RefPtr<SVGLength> toLength = toSVGLength(toValue); |
463 | 463 |
464 return fabsf(toLength->value(lengthContext, IGNORE_EXCEPTION) - value(length
Context, IGNORE_EXCEPTION)); | 464 return fabsf(toLength->value(lengthContext, IGNORE_EXCEPTION) - value(length
Context, IGNORE_EXCEPTION)); |
465 } | 465 } |
466 | 466 |
467 } | 467 } |
OLD | NEW |