| 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 17 matching lines...) Expand all Loading... |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "core/svg/SVGNumberOptionalNumber.h" | 31 #include "core/svg/SVGNumberOptionalNumber.h" |
| 32 | 32 |
| 33 #include "core/svg/SVGAnimationElement.h" | 33 #include "core/svg/SVGAnimationElement.h" |
| 34 #include "core/svg/SVGParserUtilities.h" | 34 #include "core/svg/SVGParserUtilities.h" |
| 35 | 35 |
| 36 namespace blink { | 36 namespace blink { |
| 37 | 37 |
| 38 SVGNumberOptionalNumber::SVGNumberOptionalNumber(PassRefPtrWillBeRawPtr<SVGNumbe
r> firstNumber, PassRefPtrWillBeRawPtr<SVGNumber> secondNumber) | 38 SVGNumberOptionalNumber::SVGNumberOptionalNumber(RawPtr<SVGNumber> firstNumber,
RawPtr<SVGNumber> secondNumber) |
| 39 : SVGPropertyBase(classType()) | 39 : SVGPropertyBase(classType()) |
| 40 , m_firstNumber(firstNumber) | 40 , m_firstNumber(firstNumber) |
| 41 , m_secondNumber(secondNumber) | 41 , m_secondNumber(secondNumber) |
| 42 { | 42 { |
| 43 } | 43 } |
| 44 | 44 |
| 45 DEFINE_TRACE(SVGNumberOptionalNumber) | 45 DEFINE_TRACE(SVGNumberOptionalNumber) |
| 46 { | 46 { |
| 47 visitor->trace(m_firstNumber); | 47 visitor->trace(m_firstNumber); |
| 48 visitor->trace(m_secondNumber); | 48 visitor->trace(m_secondNumber); |
| 49 SVGPropertyBase::trace(visitor); | 49 SVGPropertyBase::trace(visitor); |
| 50 } | 50 } |
| 51 | 51 |
| 52 PassRefPtrWillBeRawPtr<SVGNumberOptionalNumber> SVGNumberOptionalNumber::clone()
const | 52 RawPtr<SVGNumberOptionalNumber> SVGNumberOptionalNumber::clone() const |
| 53 { | 53 { |
| 54 return SVGNumberOptionalNumber::create(m_firstNumber->clone(), m_secondNumbe
r->clone()); | 54 return SVGNumberOptionalNumber::create(m_firstNumber->clone(), m_secondNumbe
r->clone()); |
| 55 } | 55 } |
| 56 | 56 |
| 57 PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGNumberOptionalNumber::cloneForAnimati
on(const String& value) const | 57 RawPtr<SVGPropertyBase> SVGNumberOptionalNumber::cloneForAnimation(const String&
value) const |
| 58 { | 58 { |
| 59 float x, y; | 59 float x, y; |
| 60 if (!parseNumberOptionalNumber(value, x, y)) { | 60 if (!parseNumberOptionalNumber(value, x, y)) { |
| 61 x = y = 0; | 61 x = y = 0; |
| 62 } | 62 } |
| 63 | 63 |
| 64 return SVGNumberOptionalNumber::create(SVGNumber::create(x), SVGNumber::crea
te(y)); | 64 return SVGNumberOptionalNumber::create(SVGNumber::create(x), SVGNumber::crea
te(y)); |
| 65 } | 65 } |
| 66 | 66 |
| 67 String SVGNumberOptionalNumber::valueAsString() const | 67 String SVGNumberOptionalNumber::valueAsString() const |
| (...skipping 12 matching lines...) Expand all Loading... |
| 80 if (!parseNumberOptionalNumber(value, x, y)) { | 80 if (!parseNumberOptionalNumber(value, x, y)) { |
| 81 parseStatus = SVGParseStatus::ExpectedNumber; | 81 parseStatus = SVGParseStatus::ExpectedNumber; |
| 82 x = y = 0; | 82 x = y = 0; |
| 83 } | 83 } |
| 84 | 84 |
| 85 m_firstNumber->setValue(x); | 85 m_firstNumber->setValue(x); |
| 86 m_secondNumber->setValue(y); | 86 m_secondNumber->setValue(y); |
| 87 return parseStatus; | 87 return parseStatus; |
| 88 } | 88 } |
| 89 | 89 |
| 90 void SVGNumberOptionalNumber::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other,
SVGElement*) | 90 void SVGNumberOptionalNumber::add(RawPtr<SVGPropertyBase> other, SVGElement*) |
| 91 { | 91 { |
| 92 RefPtrWillBeRawPtr<SVGNumberOptionalNumber> otherNumberOptionalNumber = toSV
GNumberOptionalNumber(other); | 92 RawPtr<SVGNumberOptionalNumber> otherNumberOptionalNumber = toSVGNumberOptio
nalNumber(other); |
| 93 | 93 |
| 94 m_firstNumber->setValue(m_firstNumber->value() + otherNumberOptionalNumber->
m_firstNumber->value()); | 94 m_firstNumber->setValue(m_firstNumber->value() + otherNumberOptionalNumber->
m_firstNumber->value()); |
| 95 m_secondNumber->setValue(m_secondNumber->value() + otherNumberOptionalNumber
->m_secondNumber->value()); | 95 m_secondNumber->setValue(m_secondNumber->value() + otherNumberOptionalNumber
->m_secondNumber->value()); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void SVGNumberOptionalNumber::calculateAnimatedValue(SVGAnimationElement* animat
ionElement, float percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPr
opertyBase> from, PassRefPtrWillBeRawPtr<SVGPropertyBase> to, PassRefPtrWillBeRa
wPtr<SVGPropertyBase> toAtEndOfDuration, SVGElement*) | 98 void SVGNumberOptionalNumber::calculateAnimatedValue(SVGAnimationElement* animat
ionElement, float percentage, unsigned repeatCount, RawPtr<SVGPropertyBase> from
, RawPtr<SVGPropertyBase> to, RawPtr<SVGPropertyBase> toAtEndOfDuration, SVGElem
ent*) |
| 99 { | 99 { |
| 100 ASSERT(animationElement); | 100 ASSERT(animationElement); |
| 101 | 101 |
| 102 RefPtrWillBeRawPtr<SVGNumberOptionalNumber> fromNumber = toSVGNumberOptional
Number(from); | 102 RawPtr<SVGNumberOptionalNumber> fromNumber = toSVGNumberOptionalNumber(from)
; |
| 103 RefPtrWillBeRawPtr<SVGNumberOptionalNumber> toNumber = toSVGNumberOptionalNu
mber(to); | 103 RawPtr<SVGNumberOptionalNumber> toNumber = toSVGNumberOptionalNumber(to); |
| 104 RefPtrWillBeRawPtr<SVGNumberOptionalNumber> toAtEndOfDurationNumber = toSVGN
umberOptionalNumber(toAtEndOfDuration); | 104 RawPtr<SVGNumberOptionalNumber> toAtEndOfDurationNumber = toSVGNumberOptiona
lNumber(toAtEndOfDuration); |
| 105 | 105 |
| 106 float x = m_firstNumber->value(); | 106 float x = m_firstNumber->value(); |
| 107 float y = m_secondNumber->value(); | 107 float y = m_secondNumber->value(); |
| 108 animationElement->animateAdditiveNumber(percentage, repeatCount, fromNumber-
>firstNumber()->value(), toNumber->firstNumber()->value(), toAtEndOfDurationNumb
er->firstNumber()->value(), x); | 108 animationElement->animateAdditiveNumber(percentage, repeatCount, fromNumber-
>firstNumber()->value(), toNumber->firstNumber()->value(), toAtEndOfDurationNumb
er->firstNumber()->value(), x); |
| 109 animationElement->animateAdditiveNumber(percentage, repeatCount, fromNumber-
>secondNumber()->value(), toNumber->secondNumber()->value(), toAtEndOfDurationNu
mber->secondNumber()->value(), y); | 109 animationElement->animateAdditiveNumber(percentage, repeatCount, fromNumber-
>secondNumber()->value(), toNumber->secondNumber()->value(), toAtEndOfDurationNu
mber->secondNumber()->value(), y); |
| 110 m_firstNumber->setValue(x); | 110 m_firstNumber->setValue(x); |
| 111 m_secondNumber->setValue(y); | 111 m_secondNumber->setValue(y); |
| 112 } | 112 } |
| 113 | 113 |
| 114 float SVGNumberOptionalNumber::calculateDistance(PassRefPtrWillBeRawPtr<SVGPrope
rtyBase> other, SVGElement*) | 114 float SVGNumberOptionalNumber::calculateDistance(RawPtr<SVGPropertyBase> other,
SVGElement*) |
| 115 { | 115 { |
| 116 // FIXME: Distance calculation is not possible for SVGNumberOptionalNumber r
ight now. We need the distance for every single value. | 116 // FIXME: Distance calculation is not possible for SVGNumberOptionalNumber r
ight now. We need the distance for every single value. |
| 117 return -1; | 117 return -1; |
| 118 } | 118 } |
| 119 | 119 |
| 120 } // namespace blink | 120 } // namespace blink |
| OLD | NEW |