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 12 matching lines...) Expand all Loading... |
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/SVGBoolean.h" | 31 #include "core/svg/SVGBoolean.h" |
32 | 32 |
33 #include "bindings/core/v8/ExceptionState.h" | |
34 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | |
35 #include "core/dom/ExceptionCode.h" | |
36 #include "core/svg/SVGAnimationElement.h" | 33 #include "core/svg/SVGAnimationElement.h" |
37 | 34 |
38 namespace blink { | 35 namespace blink { |
39 | 36 |
40 String SVGBoolean::valueAsString() const | 37 String SVGBoolean::valueAsString() const |
41 { | 38 { |
42 return m_value ? "true" : "false"; | 39 return m_value ? "true" : "false"; |
43 } | 40 } |
44 | 41 |
45 void SVGBoolean::setValueAsString(const String& value, ExceptionState& exception
State) | 42 SVGParsingError SVGBoolean::setValueAsString(const String& value) |
46 { | 43 { |
47 if (value == "true") { | 44 if (value == "true") { |
48 m_value = true; | 45 m_value = true; |
49 } else if (value == "false") { | 46 return NoError; |
| 47 } |
| 48 if (value == "false") { |
50 m_value = false; | 49 m_value = false; |
51 } else { | 50 return NoError; |
52 exceptionState.throwDOMException(SyntaxError, "The value provided ('" +
value + "') is invalid."); | |
53 } | 51 } |
| 52 return ParsingAttributeFailedError; |
54 } | 53 } |
55 | 54 |
56 void SVGBoolean::add(PassRefPtrWillBeRawPtr<SVGPropertyBase>, SVGElement*) | 55 void SVGBoolean::add(PassRefPtrWillBeRawPtr<SVGPropertyBase>, SVGElement*) |
57 { | 56 { |
58 ASSERT_NOT_REACHED(); | 57 ASSERT_NOT_REACHED(); |
59 } | 58 } |
60 | 59 |
61 void SVGBoolean::calculateAnimatedValue(SVGAnimationElement* animationElement, f
loat percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBase> f
rom, PassRefPtrWillBeRawPtr<SVGPropertyBase> to, PassRefPtrWillBeRawPtr<SVGPrope
rtyBase>, SVGElement*) | 60 void SVGBoolean::calculateAnimatedValue(SVGAnimationElement* animationElement, f
loat percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBase> f
rom, PassRefPtrWillBeRawPtr<SVGPropertyBase> to, PassRefPtrWillBeRawPtr<SVGPrope
rtyBase>, SVGElement*) |
62 { | 61 { |
63 ASSERT(animationElement); | 62 ASSERT(animationElement); |
64 bool fromBoolean = animationElement->animationMode() == ToAnimation ? m_valu
e : toSVGBoolean(from)->value(); | 63 bool fromBoolean = animationElement->animationMode() == ToAnimation ? m_valu
e : toSVGBoolean(from)->value(); |
65 bool toBoolean = toSVGBoolean(to)->value(); | 64 bool toBoolean = toSVGBoolean(to)->value(); |
66 | 65 |
67 animationElement->animateDiscreteType<bool>(percentage, fromBoolean, toBoole
an, m_value); | 66 animationElement->animateDiscreteType<bool>(percentage, fromBoolean, toBoole
an, m_value); |
68 } | 67 } |
69 | 68 |
70 float SVGBoolean::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase>, SVG
Element*) | 69 float SVGBoolean::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase>, SVG
Element*) |
71 { | 70 { |
72 // No paced animations for boolean. | 71 // No paced animations for boolean. |
73 return -1; | 72 return -1; |
74 } | 73 } |
75 | 74 |
76 } | 75 } |
OLD | NEW |