Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: Source/core/svg/SVGInteger.cpp

Issue 302643004: [SVG2] Allow leading and trailing whitespace in svg attributes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@relax_todouble_wtf
Patch Set: review fixes Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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"
33 34
34 #include "core/svg/SVGAnimationElement.h" 35 #include "core/svg/SVGAnimationElement.h"
35 36
36 namespace WebCore { 37 namespace WebCore {
37 38
38 SVGInteger::SVGInteger(int value) 39 SVGInteger::SVGInteger(int value)
39 : SVGPropertyBase(classType()) 40 : SVGPropertyBase(classType())
40 , m_value(value) 41 , m_value(value)
41 { 42 {
42 } 43 }
(...skipping 16 matching lines...) Expand all
59 } 60 }
60 61
61 void SVGInteger::setValueAsString(const String& string, ExceptionState& exceptio nState) 62 void SVGInteger::setValueAsString(const String& string, ExceptionState& exceptio nState)
62 { 63 {
63 if (string.isEmpty()) { 64 if (string.isEmpty()) {
64 m_value = 0; 65 m_value = 0;
65 return; 66 return;
66 } 67 }
67 68
68 bool valid = true; 69 bool valid = true;
69 m_value = string.toIntStrict(&valid); 70 m_value = stripLeadingAndTrailingHTMLSpaces(string).toIntStrict(&valid);
70 71
71 if (!valid) { 72 if (!valid) {
72 exceptionState.throwDOMException(SyntaxError, "The value provided ('" + string + "') is invalid."); 73 exceptionState.throwDOMException(SyntaxError, "The value provided ('" + string + "') is invalid.");
73 m_value = 0; 74 m_value = 0;
74 } 75 }
75 } 76 }
76 77
77 void SVGInteger::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement*) 78 void SVGInteger::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement*)
78 { 79 {
79 setValue(m_value + toSVGInteger(other)->value()); 80 setValue(m_value + toSVGInteger(other)->value());
(...skipping 11 matching lines...) Expand all
91 animationElement->animateAdditiveNumber(percentage, repeatCount, fromInteger ->value(), toInteger->value(), toAtEndOfDurationInteger->value(), animatedFloat) ; 92 animationElement->animateAdditiveNumber(percentage, repeatCount, fromInteger ->value(), toInteger->value(), toAtEndOfDurationInteger->value(), animatedFloat) ;
92 m_value = static_cast<int>(roundf(animatedFloat)); 93 m_value = static_cast<int>(roundf(animatedFloat));
93 } 94 }
94 95
95 float SVGInteger::calculateDistance(PassRefPtr<SVGPropertyBase> other, SVGElemen t*) 96 float SVGInteger::calculateDistance(PassRefPtr<SVGPropertyBase> other, SVGElemen t*)
96 { 97 {
97 return abs(m_value - toSVGInteger(other)->value()); 98 return abs(m_value - toSVGInteger(other)->value());
98 } 99 }
99 100
100 } 101 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698