| 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 "config.h" | 31 #include "config.h" |
| 32 #include "core/svg/SVGInteger.h" | 32 #include "core/svg/SVGInteger.h" |
| 33 #include "core/html/parser/HTMLParserIdioms.h" | |
| 34 | 33 |
| 35 #include "core/svg/SVGAnimationElement.h" | 34 #include "core/svg/SVGAnimationElement.h" |
| 36 | 35 |
| 37 namespace WebCore { | 36 namespace WebCore { |
| 38 | 37 |
| 39 SVGInteger::SVGInteger(int value) | 38 SVGInteger::SVGInteger(int value) |
| 40 : SVGPropertyBase(classType()) | 39 : SVGPropertyBase(classType()) |
| 41 , m_value(value) | 40 , m_value(value) |
| 42 { | 41 { |
| 43 } | 42 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 60 } | 59 } |
| 61 | 60 |
| 62 void SVGInteger::setValueAsString(const String& string, ExceptionState& exceptio
nState) | 61 void SVGInteger::setValueAsString(const String& string, ExceptionState& exceptio
nState) |
| 63 { | 62 { |
| 64 if (string.isEmpty()) { | 63 if (string.isEmpty()) { |
| 65 m_value = 0; | 64 m_value = 0; |
| 66 return; | 65 return; |
| 67 } | 66 } |
| 68 | 67 |
| 69 bool valid = true; | 68 bool valid = true; |
| 70 m_value = stripLeadingAndTrailingHTMLSpaces(string).toIntStrict(&valid); | 69 m_value = string.toIntStrict(&valid); |
| 71 | 70 |
| 72 if (!valid) { | 71 if (!valid) { |
| 73 exceptionState.throwDOMException(SyntaxError, "The value provided ('" +
string + "') is invalid."); | 72 exceptionState.throwDOMException(SyntaxError, "The value provided ('" +
string + "') is invalid."); |
| 74 m_value = 0; | 73 m_value = 0; |
| 75 } | 74 } |
| 76 } | 75 } |
| 77 | 76 |
| 78 void SVGInteger::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement*) | 77 void SVGInteger::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement*) |
| 79 { | 78 { |
| 80 setValue(m_value + toSVGInteger(other)->value()); | 79 setValue(m_value + toSVGInteger(other)->value()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 92 animationElement->animateAdditiveNumber(percentage, repeatCount, fromInteger
->value(), toInteger->value(), toAtEndOfDurationInteger->value(), animatedFloat)
; | 91 animationElement->animateAdditiveNumber(percentage, repeatCount, fromInteger
->value(), toInteger->value(), toAtEndOfDurationInteger->value(), animatedFloat)
; |
| 93 m_value = static_cast<int>(roundf(animatedFloat)); | 92 m_value = static_cast<int>(roundf(animatedFloat)); |
| 94 } | 93 } |
| 95 | 94 |
| 96 float SVGInteger::calculateDistance(PassRefPtr<SVGPropertyBase> other, SVGElemen
t*) | 95 float SVGInteger::calculateDistance(PassRefPtr<SVGPropertyBase> other, SVGElemen
t*) |
| 97 { | 96 { |
| 98 return abs(m_value - toSVGInteger(other)->value()); | 97 return abs(m_value - toSVGInteger(other)->value()); |
| 99 } | 98 } |
| 100 | 99 |
| 101 } | 100 } |
| OLD | NEW |