| 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 19 matching lines...) Expand all Loading... |
| 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 WebCore { | 37 namespace WebCore { |
| 38 | 38 |
| 39 SVGNumberOptionalNumber::SVGNumberOptionalNumber(PassRefPtr<SVGNumber> firstNumb
er, PassRefPtr<SVGNumber> secondNumber) | 39 SVGNumberOptionalNumber::SVGNumberOptionalNumber(PassRefPtr<SVGNumber> firstNumb
er, PassRefPtr<SVGNumber> secondNumber) |
| 40 : NewSVGPropertyBase(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 PassRefPtr<SVGNumberOptionalNumber> SVGNumberOptionalNumber::clone() const |
| 47 { | 47 { |
| 48 return SVGNumberOptionalNumber::create(m_firstNumber->clone(), m_secondNumbe
r->clone()); | 48 return SVGNumberOptionalNumber::create(m_firstNumber->clone(), m_secondNumbe
r->clone()); |
| 49 } | 49 } |
| 50 | 50 |
| 51 PassRefPtr<NewSVGPropertyBase> SVGNumberOptionalNumber::cloneForAnimation(const
String& value) const | 51 PassRefPtr<SVGPropertyBase> SVGNumberOptionalNumber::cloneForAnimation(const Str
ing& value) const |
| 52 { | 52 { |
| 53 float x, y; | 53 float x, y; |
| 54 if (!parseNumberOptionalNumber(value, x, y)) { | 54 if (!parseNumberOptionalNumber(value, x, y)) { |
| 55 x = y = 0; | 55 x = y = 0; |
| 56 } | 56 } |
| 57 | 57 |
| 58 return SVGNumberOptionalNumber::create(SVGNumber::create(x), SVGNumber::crea
te(y)); | 58 return SVGNumberOptionalNumber::create(SVGNumber::create(x), SVGNumber::crea
te(y)); |
| 59 } | 59 } |
| 60 | 60 |
| 61 String SVGNumberOptionalNumber::valueAsString() const | 61 String SVGNumberOptionalNumber::valueAsString() const |
| (...skipping 10 matching lines...) Expand all Loading... |
| 72 float x, y; | 72 float x, y; |
| 73 if (!parseNumberOptionalNumber(value, x, y)) { | 73 if (!parseNumberOptionalNumber(value, x, y)) { |
| 74 exceptionState.throwDOMException(SyntaxError, "The value provided ('" +
value + "') is invalid."); | 74 exceptionState.throwDOMException(SyntaxError, "The value provided ('" +
value + "') is invalid."); |
| 75 x = y = 0; | 75 x = y = 0; |
| 76 } | 76 } |
| 77 | 77 |
| 78 m_firstNumber->setValue(x); | 78 m_firstNumber->setValue(x); |
| 79 m_secondNumber->setValue(y); | 79 m_secondNumber->setValue(y); |
| 80 } | 80 } |
| 81 | 81 |
| 82 void SVGNumberOptionalNumber::add(PassRefPtr<NewSVGPropertyBase> other, SVGEleme
nt*) | 82 void SVGNumberOptionalNumber::add(PassRefPtr<SVGPropertyBase> other, SVGElement*
) |
| 83 { | 83 { |
| 84 RefPtr<SVGNumberOptionalNumber> otherNumberOptionalNumber = toSVGNumberOptio
nalNumber(other); | 84 RefPtr<SVGNumberOptionalNumber> otherNumberOptionalNumber = toSVGNumberOptio
nalNumber(other); |
| 85 | 85 |
| 86 m_firstNumber->setValue(m_firstNumber->value() + otherNumberOptionalNumber->
m_firstNumber->value()); | 86 m_firstNumber->setValue(m_firstNumber->value() + otherNumberOptionalNumber->
m_firstNumber->value()); |
| 87 m_secondNumber->setValue(m_secondNumber->value() + otherNumberOptionalNumber
->m_secondNumber->value()); | 87 m_secondNumber->setValue(m_secondNumber->value() + otherNumberOptionalNumber
->m_secondNumber->value()); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void SVGNumberOptionalNumber::calculateAnimatedValue(SVGAnimationElement* animat
ionElement, float percentage, unsigned repeatCount, PassRefPtr<NewSVGPropertyBas
e> from, PassRefPtr<NewSVGPropertyBase> to, PassRefPtr<NewSVGPropertyBase> toAtE
ndOfDuration, SVGElement*) | 90 void SVGNumberOptionalNumber::calculateAnimatedValue(SVGAnimationElement* animat
ionElement, float percentage, unsigned repeatCount, PassRefPtr<SVGPropertyBase>
from, PassRefPtr<SVGPropertyBase> to, PassRefPtr<SVGPropertyBase> toAtEndOfDurat
ion, SVGElement*) |
| 91 { | 91 { |
| 92 ASSERT(animationElement); | 92 ASSERT(animationElement); |
| 93 | 93 |
| 94 RefPtr<SVGNumberOptionalNumber> fromNumber = toSVGNumberOptionalNumber(from)
; | 94 RefPtr<SVGNumberOptionalNumber> fromNumber = toSVGNumberOptionalNumber(from)
; |
| 95 RefPtr<SVGNumberOptionalNumber> toNumber = toSVGNumberOptionalNumber(to); | 95 RefPtr<SVGNumberOptionalNumber> toNumber = toSVGNumberOptionalNumber(to); |
| 96 RefPtr<SVGNumberOptionalNumber> toAtEndOfDurationNumber = toSVGNumberOptiona
lNumber(toAtEndOfDuration); | 96 RefPtr<SVGNumberOptionalNumber> toAtEndOfDurationNumber = toSVGNumberOptiona
lNumber(toAtEndOfDuration); |
| 97 | 97 |
| 98 float x = m_firstNumber->value(); | 98 float x = m_firstNumber->value(); |
| 99 float y = m_secondNumber->value(); | 99 float y = m_secondNumber->value(); |
| 100 animationElement->animateAdditiveNumber(percentage, repeatCount, fromNumber-
>firstNumber()->value(), toNumber->firstNumber()->value(), toAtEndOfDurationNumb
er->firstNumber()->value(), x); | 100 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); | 101 animationElement->animateAdditiveNumber(percentage, repeatCount, fromNumber-
>secondNumber()->value(), toNumber->secondNumber()->value(), toAtEndOfDurationNu
mber->secondNumber()->value(), y); |
| 102 m_firstNumber->setValue(x); | 102 m_firstNumber->setValue(x); |
| 103 m_secondNumber->setValue(y); | 103 m_secondNumber->setValue(y); |
| 104 } | 104 } |
| 105 | 105 |
| 106 float SVGNumberOptionalNumber::calculateDistance(PassRefPtr<NewSVGPropertyBase>
other, SVGElement*) | 106 float SVGNumberOptionalNumber::calculateDistance(PassRefPtr<SVGPropertyBase> oth
er, SVGElement*) |
| 107 { | 107 { |
| 108 // FIXME: Distance calculation is not possible for SVGNumberOptionalNumber r
ight now. We need the distance for every single value. | 108 // FIXME: Distance calculation is not possible for SVGNumberOptionalNumber r
ight now. We need the distance for every single value. |
| 109 return -1; | 109 return -1; |
| 110 } | 110 } |
| 111 | 111 |
| 112 } | 112 } |
| OLD | NEW |