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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 } | 123 } |
124 | 124 |
125 SVGLength::SVGLength(const SVGLength& o) | 125 SVGLength::SVGLength(const SVGLength& o) |
126 : SVGPropertyBase(classType()) | 126 : SVGPropertyBase(classType()) |
127 , m_valueInSpecifiedUnits(o.m_valueInSpecifiedUnits) | 127 , m_valueInSpecifiedUnits(o.m_valueInSpecifiedUnits) |
128 , m_unitMode(o.m_unitMode) | 128 , m_unitMode(o.m_unitMode) |
129 , m_unitType(o.m_unitType) | 129 , m_unitType(o.m_unitType) |
130 { | 130 { |
131 } | 131 } |
132 | 132 |
133 PassRefPtr<SVGLength> SVGLength::clone() const | 133 PassRefPtrWillBeRawPtr<SVGLength> SVGLength::clone() const |
134 { | 134 { |
135 return adoptRef(new SVGLength(*this)); | 135 return adoptRefWillBeNoop(new SVGLength(*this)); |
136 } | 136 } |
137 | 137 |
138 PassRefPtr<SVGPropertyBase> SVGLength::cloneForAnimation(const String& value) co
nst | 138 PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGLength::cloneForAnimation(const Strin
g& value) const |
139 { | 139 { |
140 RefPtr<SVGLength> length = create(); | 140 RefPtrWillBeRawPtr<SVGLength> length = create(); |
141 | 141 |
142 length->m_unitMode = m_unitMode; | 142 length->m_unitMode = m_unitMode; |
143 length->m_unitType = m_unitType; | 143 length->m_unitType = m_unitType; |
144 | 144 |
145 TrackExceptionState exceptionState; | 145 TrackExceptionState exceptionState; |
146 length->setValueAsString(value, exceptionState); | 146 length->setValueAsString(value, exceptionState); |
147 if (exceptionState.hadException()) { | 147 if (exceptionState.hadException()) { |
148 length->m_unitType = LengthTypeNumber; | 148 length->m_unitType = LengthTypeNumber; |
149 length->m_valueInSpecifiedUnits = 0; | 149 length->m_valueInSpecifiedUnits = 0; |
150 } | 150 } |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 SVGLengthType originalType = unitType(); | 255 SVGLengthType originalType = unitType(); |
256 m_unitType = type; | 256 m_unitType = type; |
257 setValue(valueInUserUnits, context, exceptionState); | 257 setValue(valueInUserUnits, context, exceptionState); |
258 if (!exceptionState.hadException()) | 258 if (!exceptionState.hadException()) |
259 return; | 259 return; |
260 | 260 |
261 // Eventually restore old unit and type | 261 // Eventually restore old unit and type |
262 m_unitType = originalType; | 262 m_unitType = originalType; |
263 } | 263 } |
264 | 264 |
265 PassRefPtr<SVGLength> SVGLength::fromCSSPrimitiveValue(CSSPrimitiveValue* value) | 265 PassRefPtrWillBeRawPtr<SVGLength> SVGLength::fromCSSPrimitiveValue(CSSPrimitiveV
alue* value) |
266 { | 266 { |
267 ASSERT(value); | 267 ASSERT(value); |
268 | 268 |
269 SVGLengthType svgType; | 269 SVGLengthType svgType; |
270 switch (value->primitiveType()) { | 270 switch (value->primitiveType()) { |
271 case CSSPrimitiveValue::CSS_NUMBER: | 271 case CSSPrimitiveValue::CSS_NUMBER: |
272 svgType = LengthTypeNumber; | 272 svgType = LengthTypeNumber; |
273 break; | 273 break; |
274 case CSSPrimitiveValue::CSS_PERCENTAGE: | 274 case CSSPrimitiveValue::CSS_PERCENTAGE: |
275 svgType = LengthTypePercentage; | 275 svgType = LengthTypePercentage; |
(...skipping 18 matching lines...) Expand all Loading... |
294 break; | 294 break; |
295 case CSSPrimitiveValue::CSS_PT: | 295 case CSSPrimitiveValue::CSS_PT: |
296 svgType = LengthTypePT; | 296 svgType = LengthTypePT; |
297 break; | 297 break; |
298 default: | 298 default: |
299 ASSERT(value->primitiveType() == CSSPrimitiveValue::CSS_PC); | 299 ASSERT(value->primitiveType() == CSSPrimitiveValue::CSS_PC); |
300 svgType = LengthTypePC; | 300 svgType = LengthTypePC; |
301 break; | 301 break; |
302 }; | 302 }; |
303 | 303 |
304 RefPtr<SVGLength> length = SVGLength::create(); | 304 RefPtrWillBeRawPtr<SVGLength> length = SVGLength::create(); |
305 length->newValueSpecifiedUnits(svgType, value->getFloatValue()); | 305 length->newValueSpecifiedUnits(svgType, value->getFloatValue()); |
306 return length.release(); | 306 return length.release(); |
307 } | 307 } |
308 | 308 |
309 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> SVGLength::toCSSPrimitiveValue(PassRef
Ptr<SVGLength> passLength) | 309 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> SVGLength::toCSSPrimitiveValue(PassRef
PtrWillBeRawPtr<SVGLength> passLength) |
310 { | 310 { |
311 RefPtr<SVGLength> length = passLength; | 311 RefPtrWillBeRawPtr<SVGLength> length = passLength; |
312 | 312 |
313 CSSPrimitiveValue::UnitType cssType = CSSPrimitiveValue::CSS_UNKNOWN; | 313 CSSPrimitiveValue::UnitType cssType = CSSPrimitiveValue::CSS_UNKNOWN; |
314 switch (length->unitType()) { | 314 switch (length->unitType()) { |
315 case LengthTypeUnknown: | 315 case LengthTypeUnknown: |
316 break; | 316 break; |
317 case LengthTypeNumber: | 317 case LengthTypeNumber: |
318 cssType = CSSPrimitiveValue::CSS_NUMBER; | 318 cssType = CSSPrimitiveValue::CSS_NUMBER; |
319 break; | 319 break; |
320 case LengthTypePercentage: | 320 case LengthTypePercentage: |
321 cssType = CSSPrimitiveValue::CSS_PERCENTAGE; | 321 cssType = CSSPrimitiveValue::CSS_PERCENTAGE; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 s_lengthModeMap.set(SVGNames::textLengthAttr, LengthModeWidth); | 379 s_lengthModeMap.set(SVGNames::textLengthAttr, LengthModeWidth); |
380 s_lengthModeMap.set(SVGNames::startOffsetAttr, LengthModeWidth); | 380 s_lengthModeMap.set(SVGNames::startOffsetAttr, LengthModeWidth); |
381 } | 381 } |
382 | 382 |
383 if (s_lengthModeMap.contains(attrName)) | 383 if (s_lengthModeMap.contains(attrName)) |
384 return s_lengthModeMap.get(attrName); | 384 return s_lengthModeMap.get(attrName); |
385 | 385 |
386 return LengthModeOther; | 386 return LengthModeOther; |
387 } | 387 } |
388 | 388 |
389 PassRefPtr<SVGLength> SVGLength::blend(PassRefPtr<SVGLength> passFrom, float pro
gress) const | 389 PassRefPtrWillBeRawPtr<SVGLength> SVGLength::blend(PassRefPtrWillBeRawPtr<SVGLen
gth> passFrom, float progress) const |
390 { | 390 { |
391 RefPtr<SVGLength> from = passFrom; | 391 RefPtrWillBeRawPtr<SVGLength> from = passFrom; |
392 | 392 |
393 SVGLengthType toType = unitType(); | 393 SVGLengthType toType = unitType(); |
394 SVGLengthType fromType = from->unitType(); | 394 SVGLengthType fromType = from->unitType(); |
395 if ((from->isZero() && isZero()) | 395 if ((from->isZero() && isZero()) |
396 || fromType == LengthTypeUnknown | 396 || fromType == LengthTypeUnknown |
397 || toType == LengthTypeUnknown | 397 || toType == LengthTypeUnknown |
398 || (!from->isZero() && fromType != LengthTypePercentage && toType == Len
gthTypePercentage) | 398 || (!from->isZero() && fromType != LengthTypePercentage && toType == Len
gthTypePercentage) |
399 || (!isZero() && fromType == LengthTypePercentage && toType != LengthTyp
ePercentage) | 399 || (!isZero() && fromType == LengthTypePercentage && toType != LengthTyp
ePercentage) |
400 || (!from->isZero() && !isZero() && (fromType == LengthTypeEMS || fromTy
pe == LengthTypeEXS) && fromType != toType)) | 400 || (!from->isZero() && !isZero() && (fromType == LengthTypeEMS || fromTy
pe == LengthTypeEXS) && fromType != toType)) |
401 return clone(); | 401 return clone(); |
402 | 402 |
403 RefPtr<SVGLength> length = create(); | 403 RefPtrWillBeRawPtr<SVGLength> length = create(); |
404 | 404 |
405 if (fromType == LengthTypePercentage || toType == LengthTypePercentage) { | 405 if (fromType == LengthTypePercentage || toType == LengthTypePercentage) { |
406 float fromPercent = from->valueAsPercentage() * 100; | 406 float fromPercent = from->valueAsPercentage() * 100; |
407 float toPercent = valueAsPercentage() * 100; | 407 float toPercent = valueAsPercentage() * 100; |
408 length->newValueSpecifiedUnits(LengthTypePercentage, blink::blend(fromPe
rcent, toPercent, progress)); | 408 length->newValueSpecifiedUnits(LengthTypePercentage, blink::blend(fromPe
rcent, toPercent, progress)); |
409 return length; | 409 return length; |
410 } | 410 } |
411 | 411 |
412 if (fromType == toType || from->isZero() || isZero() || fromType == LengthTy
peEMS || fromType == LengthTypeEXS) { | 412 if (fromType == toType || from->isZero() || isZero() || fromType == LengthTy
peEMS || fromType == LengthTypeEXS) { |
413 float fromValue = from->valueInSpecifiedUnits(); | 413 float fromValue = from->valueInSpecifiedUnits(); |
(...skipping 23 matching lines...) Expand all Loading... |
437 return length; | 437 return length; |
438 } | 438 } |
439 | 439 |
440 void SVGLength::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement* c
ontextElement) | 440 void SVGLength::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement* c
ontextElement) |
441 { | 441 { |
442 SVGLengthContext lengthContext(contextElement); | 442 SVGLengthContext lengthContext(contextElement); |
443 | 443 |
444 setValue(value(lengthContext) + toSVGLength(other)->value(lengthContext), le
ngthContext, ASSERT_NO_EXCEPTION); | 444 setValue(value(lengthContext) + toSVGLength(other)->value(lengthContext), le
ngthContext, ASSERT_NO_EXCEPTION); |
445 } | 445 } |
446 | 446 |
447 void SVGLength::calculateAnimatedValue(SVGAnimationElement* animationElement, fl
oat percentage, unsigned repeatCount, PassRefPtr<SVGPropertyBase> fromValue, Pas
sRefPtr<SVGPropertyBase> toValue, PassRefPtr<SVGPropertyBase> toAtEndOfDurationV
alue, SVGElement* contextElement) | 447 void SVGLength::calculateAnimatedValue(SVGAnimationElement* animationElement, fl
oat percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBase> fr
omValue, PassRefPtrWillBeRawPtr<SVGPropertyBase> toValue, PassRefPtrWillBeRawPtr
<SVGPropertyBase> toAtEndOfDurationValue, SVGElement* contextElement) |
448 { | 448 { |
449 RefPtr<SVGLength> fromLength = toSVGLength(fromValue); | 449 RefPtrWillBeRawPtr<SVGLength> fromLength = toSVGLength(fromValue); |
450 RefPtr<SVGLength> toLength = toSVGLength(toValue); | 450 RefPtrWillBeRawPtr<SVGLength> toLength = toSVGLength(toValue); |
451 RefPtr<SVGLength> toAtEndOfDurationLength = toSVGLength(toAtEndOfDurationVal
ue); | 451 RefPtrWillBeRawPtr<SVGLength> toAtEndOfDurationLength = toSVGLength(toAtEndO
fDurationValue); |
452 | 452 |
453 SVGLengthContext lengthContext(contextElement); | 453 SVGLengthContext lengthContext(contextElement); |
454 float animatedNumber = value(lengthContext, IGNORE_EXCEPTION); | 454 float animatedNumber = value(lengthContext, IGNORE_EXCEPTION); |
455 animationElement->animateAdditiveNumber(percentage, repeatCount, fromLength-
>value(lengthContext, IGNORE_EXCEPTION), toLength->value(lengthContext, IGNORE_E
XCEPTION), toAtEndOfDurationLength->value(lengthContext, IGNORE_EXCEPTION), anim
atedNumber); | 455 animationElement->animateAdditiveNumber(percentage, repeatCount, fromLength-
>value(lengthContext, IGNORE_EXCEPTION), toLength->value(lengthContext, IGNORE_E
XCEPTION), toAtEndOfDurationLength->value(lengthContext, IGNORE_EXCEPTION), anim
atedNumber); |
456 | 456 |
457 ASSERT(unitMode() == lengthModeForAnimatedLengthAttribute(animationElement->
attributeName())); | 457 ASSERT(unitMode() == lengthModeForAnimatedLengthAttribute(animationElement->
attributeName())); |
458 m_unitType = percentage < 0.5 ? fromLength->unitType() : toLength->unitType(
); | 458 m_unitType = percentage < 0.5 ? fromLength->unitType() : toLength->unitType(
); |
459 setValue(animatedNumber, lengthContext, ASSERT_NO_EXCEPTION); | 459 setValue(animatedNumber, lengthContext, ASSERT_NO_EXCEPTION); |
460 } | 460 } |
461 | 461 |
462 float SVGLength::calculateDistance(PassRefPtr<SVGPropertyBase> toValue, SVGEleme
nt* contextElement) | 462 float SVGLength::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> toVal
ue, SVGElement* contextElement) |
463 { | 463 { |
464 SVGLengthContext lengthContext(contextElement); | 464 SVGLengthContext lengthContext(contextElement); |
465 RefPtr<SVGLength> toLength = toSVGLength(toValue); | 465 RefPtrWillBeRawPtr<SVGLength> toLength = toSVGLength(toValue); |
466 | 466 |
467 return fabsf(toLength->value(lengthContext, IGNORE_EXCEPTION) - value(length
Context, IGNORE_EXCEPTION)); | 467 return fabsf(toLength->value(lengthContext, IGNORE_EXCEPTION) - value(length
Context, IGNORE_EXCEPTION)); |
468 } | 468 } |
469 | 469 |
470 } | 470 } |
OLD | NEW |