| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "core/svg/SVGNumberOptionalNumber.h" | 32 #include "core/svg/SVGNumberOptionalNumber.h" |
| 33 | 33 |
| 34 #include "core/svg/SVGAnimationElement.h" | 34 #include "core/svg/SVGAnimationElement.h" |
| 35 #include "core/svg/SVGParserUtilities.h" | 35 #include "core/svg/SVGParserUtilities.h" |
| 36 | 36 |
| 37 namespace blink { | 37 namespace blink { |
| 38 | 38 |
| 39 SVGNumberOptionalNumber::SVGNumberOptionalNumber(PassRefPtr<SVGNumber> firstNumb
er, PassRefPtr<SVGNumber> secondNumber) | 39 SVGNumberOptionalNumber::SVGNumberOptionalNumber(PassRefPtrWillBeRawPtr<SVGNumbe
r> firstNumber, PassRefPtrWillBeRawPtr<SVGNumber> secondNumber) |
| 40 : SVGPropertyBase(classType()) | 40 : SVGPropertyBase(classType()) |
| 41 , m_firstNumber(firstNumber) | 41 , m_firstNumber(firstNumber) |
| 42 , m_secondNumber(secondNumber) | 42 , m_secondNumber(secondNumber) |
| 43 { | 43 { |
| 44 } | 44 } |
| 45 | 45 |
| 46 PassRefPtr<SVGNumberOptionalNumber> SVGNumberOptionalNumber::clone() const | 46 void SVGNumberOptionalNumber::trace(Visitor* visitor) |
| 47 { |
| 48 visitor->trace(m_firstNumber); |
| 49 visitor->trace(m_secondNumber); |
| 50 SVGPropertyBase::trace(visitor); |
| 51 } |
| 52 |
| 53 PassRefPtrWillBeRawPtr<SVGNumberOptionalNumber> SVGNumberOptionalNumber::clone()
const |
| 47 { | 54 { |
| 48 return SVGNumberOptionalNumber::create(m_firstNumber->clone(), m_secondNumbe
r->clone()); | 55 return SVGNumberOptionalNumber::create(m_firstNumber->clone(), m_secondNumbe
r->clone()); |
| 49 } | 56 } |
| 50 | 57 |
| 51 PassRefPtr<SVGPropertyBase> SVGNumberOptionalNumber::cloneForAnimation(const Str
ing& value) const | 58 PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGNumberOptionalNumber::cloneForAnimati
on(const String& value) const |
| 52 { | 59 { |
| 53 float x, y; | 60 float x, y; |
| 54 if (!parseNumberOptionalNumber(value, x, y)) { | 61 if (!parseNumberOptionalNumber(value, x, y)) { |
| 55 x = y = 0; | 62 x = y = 0; |
| 56 } | 63 } |
| 57 | 64 |
| 58 return SVGNumberOptionalNumber::create(SVGNumber::create(x), SVGNumber::crea
te(y)); | 65 return SVGNumberOptionalNumber::create(SVGNumber::create(x), SVGNumber::crea
te(y)); |
| 59 } | 66 } |
| 60 | 67 |
| 61 String SVGNumberOptionalNumber::valueAsString() const | 68 String SVGNumberOptionalNumber::valueAsString() const |
| (...skipping 12 matching lines...) Expand all Loading... |
| 74 exceptionState.throwDOMException(SyntaxError, "The value provided ('" +
value + "') is invalid."); | 81 exceptionState.throwDOMException(SyntaxError, "The value provided ('" +
value + "') is invalid."); |
| 75 x = y = 0; | 82 x = y = 0; |
| 76 } | 83 } |
| 77 | 84 |
| 78 m_firstNumber->setValue(x); | 85 m_firstNumber->setValue(x); |
| 79 m_secondNumber->setValue(y); | 86 m_secondNumber->setValue(y); |
| 80 } | 87 } |
| 81 | 88 |
| 82 void SVGNumberOptionalNumber::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other,
SVGElement*) | 89 void SVGNumberOptionalNumber::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other,
SVGElement*) |
| 83 { | 90 { |
| 84 RefPtr<SVGNumberOptionalNumber> otherNumberOptionalNumber = toSVGNumberOptio
nalNumber(other); | 91 RefPtrWillBeRawPtr<SVGNumberOptionalNumber> otherNumberOptionalNumber = toSV
GNumberOptionalNumber(other); |
| 85 | 92 |
| 86 m_firstNumber->setValue(m_firstNumber->value() + otherNumberOptionalNumber->
m_firstNumber->value()); | 93 m_firstNumber->setValue(m_firstNumber->value() + otherNumberOptionalNumber->
m_firstNumber->value()); |
| 87 m_secondNumber->setValue(m_secondNumber->value() + otherNumberOptionalNumber
->m_secondNumber->value()); | 94 m_secondNumber->setValue(m_secondNumber->value() + otherNumberOptionalNumber
->m_secondNumber->value()); |
| 88 } | 95 } |
| 89 | 96 |
| 90 void SVGNumberOptionalNumber::calculateAnimatedValue(SVGAnimationElement* animat
ionElement, float percentage, unsigned repeatCount, PassRefPtr<SVGPropertyBase>
from, PassRefPtr<SVGPropertyBase> to, PassRefPtr<SVGPropertyBase> toAtEndOfDurat
ion, SVGElement*) | 97 void SVGNumberOptionalNumber::calculateAnimatedValue(SVGAnimationElement* animat
ionElement, float percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPr
opertyBase> from, PassRefPtrWillBeRawPtr<SVGPropertyBase> to, PassRefPtrWillBeRa
wPtr<SVGPropertyBase> toAtEndOfDuration, SVGElement*) |
| 91 { | 98 { |
| 92 ASSERT(animationElement); | 99 ASSERT(animationElement); |
| 93 | 100 |
| 94 RefPtr<SVGNumberOptionalNumber> fromNumber = toSVGNumberOptionalNumber(from)
; | 101 RefPtrWillBeRawPtr<SVGNumberOptionalNumber> fromNumber = toSVGNumberOptional
Number(from); |
| 95 RefPtr<SVGNumberOptionalNumber> toNumber = toSVGNumberOptionalNumber(to); | 102 RefPtrWillBeRawPtr<SVGNumberOptionalNumber> toNumber = toSVGNumberOptionalNu
mber(to); |
| 96 RefPtr<SVGNumberOptionalNumber> toAtEndOfDurationNumber = toSVGNumberOptiona
lNumber(toAtEndOfDuration); | 103 RefPtrWillBeRawPtr<SVGNumberOptionalNumber> toAtEndOfDurationNumber = toSVGN
umberOptionalNumber(toAtEndOfDuration); |
| 97 | 104 |
| 98 float x = m_firstNumber->value(); | 105 float x = m_firstNumber->value(); |
| 99 float y = m_secondNumber->value(); | 106 float y = m_secondNumber->value(); |
| 100 animationElement->animateAdditiveNumber(percentage, repeatCount, fromNumber-
>firstNumber()->value(), toNumber->firstNumber()->value(), toAtEndOfDurationNumb
er->firstNumber()->value(), x); | 107 animationElement->animateAdditiveNumber(percentage, repeatCount, fromNumber-
>firstNumber()->value(), toNumber->firstNumber()->value(), toAtEndOfDurationNumb
er->firstNumber()->value(), x); |
| 101 animationElement->animateAdditiveNumber(percentage, repeatCount, fromNumber-
>secondNumber()->value(), toNumber->secondNumber()->value(), toAtEndOfDurationNu
mber->secondNumber()->value(), y); | 108 animationElement->animateAdditiveNumber(percentage, repeatCount, fromNumber-
>secondNumber()->value(), toNumber->secondNumber()->value(), toAtEndOfDurationNu
mber->secondNumber()->value(), y); |
| 102 m_firstNumber->setValue(x); | 109 m_firstNumber->setValue(x); |
| 103 m_secondNumber->setValue(y); | 110 m_secondNumber->setValue(y); |
| 104 } | 111 } |
| 105 | 112 |
| 106 float SVGNumberOptionalNumber::calculateDistance(PassRefPtr<SVGPropertyBase> oth
er, SVGElement*) | 113 float SVGNumberOptionalNumber::calculateDistance(PassRefPtrWillBeRawPtr<SVGPrope
rtyBase> other, SVGElement*) |
| 107 { | 114 { |
| 108 // FIXME: Distance calculation is not possible for SVGNumberOptionalNumber r
ight now. We need the distance for every single value. | 115 // FIXME: Distance calculation is not possible for SVGNumberOptionalNumber r
ight now. We need the distance for every single value. |
| 109 return -1; | 116 return -1; |
| 110 } | 117 } |
| 111 | 118 |
| 112 } | 119 } |
| OLD | NEW |