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 11 matching lines...) Expand all Loading... |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
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/SVGInteger.h" | 31 #include "core/svg/SVGInteger.h" |
| 32 |
32 #include "core/html/parser/HTMLParserIdioms.h" | 33 #include "core/html/parser/HTMLParserIdioms.h" |
33 | |
34 #include "core/svg/SVGAnimationElement.h" | 34 #include "core/svg/SVGAnimationElement.h" |
35 | 35 |
36 namespace blink { | 36 namespace blink { |
37 | 37 |
38 SVGInteger::SVGInteger(int value) | 38 SVGInteger::SVGInteger(int value) |
39 : m_value(value) | 39 : m_value(value) |
40 { | 40 { |
41 } | 41 } |
42 | 42 |
43 PassRefPtrWillBeRawPtr<SVGInteger> SVGInteger::clone() const | 43 PassRefPtrWillBeRawPtr<SVGInteger> SVGInteger::clone() const |
44 { | 44 { |
45 return create(m_value); | 45 return create(m_value); |
46 } | 46 } |
47 | 47 |
48 String SVGInteger::valueAsString() const | 48 String SVGInteger::valueAsString() const |
49 { | 49 { |
50 return String::number(m_value); | 50 return String::number(m_value); |
51 } | 51 } |
52 | 52 |
53 void SVGInteger::setValueAsString(const String& string, ExceptionState& exceptio
nState) | 53 SVGParsingError SVGInteger::setValueAsString(const String& string) |
54 { | 54 { |
55 if (string.isEmpty()) { | 55 if (string.isEmpty()) { |
56 m_value = 0; | 56 m_value = 0; |
57 return; | 57 return NoError; |
58 } | 58 } |
59 | 59 |
60 bool valid = true; | 60 bool valid = true; |
61 m_value = stripLeadingAndTrailingHTMLSpaces(string).toIntStrict(&valid); | 61 m_value = stripLeadingAndTrailingHTMLSpaces(string).toIntStrict(&valid); |
62 | 62 |
63 if (!valid) { | 63 if (!valid) { |
64 exceptionState.throwDOMException(SyntaxError, "The value provided ('" +
string + "') is invalid."); | |
65 m_value = 0; | 64 m_value = 0; |
| 65 return ParsingAttributeFailedError; |
66 } | 66 } |
| 67 return NoError; |
67 } | 68 } |
68 | 69 |
69 void SVGInteger::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement*) | 70 void SVGInteger::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement*) |
70 { | 71 { |
71 setValue(m_value + toSVGInteger(other)->value()); | 72 setValue(m_value + toSVGInteger(other)->value()); |
72 } | 73 } |
73 | 74 |
74 void SVGInteger::calculateAnimatedValue(SVGAnimationElement* animationElement, f
loat percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBase> f
rom, PassRefPtrWillBeRawPtr<SVGPropertyBase> to, PassRefPtrWillBeRawPtr<SVGPrope
rtyBase> toAtEndOfDuration, SVGElement*) | 75 void SVGInteger::calculateAnimatedValue(SVGAnimationElement* animationElement, f
loat percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBase> f
rom, PassRefPtrWillBeRawPtr<SVGPropertyBase> to, PassRefPtrWillBeRawPtr<SVGPrope
rtyBase> toAtEndOfDuration, SVGElement*) |
75 { | 76 { |
76 ASSERT(animationElement); | 77 ASSERT(animationElement); |
77 | 78 |
78 RefPtrWillBeRawPtr<SVGInteger> fromInteger = toSVGInteger(from); | 79 RefPtrWillBeRawPtr<SVGInteger> fromInteger = toSVGInteger(from); |
79 RefPtrWillBeRawPtr<SVGInteger> toInteger = toSVGInteger(to); | 80 RefPtrWillBeRawPtr<SVGInteger> toInteger = toSVGInteger(to); |
80 RefPtrWillBeRawPtr<SVGInteger> toAtEndOfDurationInteger = toSVGInteger(toAtE
ndOfDuration); | 81 RefPtrWillBeRawPtr<SVGInteger> toAtEndOfDurationInteger = toSVGInteger(toAtE
ndOfDuration); |
81 | 82 |
82 float animatedFloat = m_value; | 83 float animatedFloat = m_value; |
83 animationElement->animateAdditiveNumber(percentage, repeatCount, fromInteger
->value(), toInteger->value(), toAtEndOfDurationInteger->value(), animatedFloat)
; | 84 animationElement->animateAdditiveNumber(percentage, repeatCount, fromInteger
->value(), toInteger->value(), toAtEndOfDurationInteger->value(), animatedFloat)
; |
84 m_value = static_cast<int>(roundf(animatedFloat)); | 85 m_value = static_cast<int>(roundf(animatedFloat)); |
85 } | 86 } |
86 | 87 |
87 float SVGInteger::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> othe
r, SVGElement*) | 88 float SVGInteger::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> othe
r, SVGElement*) |
88 { | 89 { |
89 return abs(m_value - toSVGInteger(other)->value()); | 90 return abs(m_value - toSVGInteger(other)->value()); |
90 } | 91 } |
91 | 92 |
92 } | 93 } |
OLD | NEW |