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

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

Issue 1644293003: Error reporting for SVGInteger and SVGIntegerOptionalInteger (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: TestExpectations; Drop redundant test. Created 4 years, 10 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 SVGParsingError SVGInteger::setValueAsString(const String& string) 53 SVGParsingError SVGInteger::setValueAsString(const String& string)
54 { 54 {
55 if (string.isEmpty()) { 55 m_value = 0;
56 m_value = 0; 56
57 if (string.isEmpty())
57 return SVGParseStatus::NoError; 58 return SVGParseStatus::NoError;
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 // toIntStrict returns 0 if valid == false.
63 if (!valid) { 63 return valid ? SVGParseStatus::NoError : SVGParseStatus::ExpectedInteger;
64 m_value = 0;
65 return SVGParseStatus::ParsingFailed;
66 }
67 return SVGParseStatus::NoError;
68 } 64 }
69 65
70 void SVGInteger::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement*) 66 void SVGInteger::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement*)
71 { 67 {
72 setValue(m_value + toSVGInteger(other)->value()); 68 setValue(m_value + toSVGInteger(other)->value());
73 } 69 }
74 70
75 void SVGInteger::calculateAnimatedValue(SVGAnimationElement* animationElement, f loat percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBase> f rom, PassRefPtrWillBeRawPtr<SVGPropertyBase> to, PassRefPtrWillBeRawPtr<SVGPrope rtyBase> toAtEndOfDuration, SVGElement*) 71 void SVGInteger::calculateAnimatedValue(SVGAnimationElement* animationElement, f loat percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBase> f rom, PassRefPtrWillBeRawPtr<SVGPropertyBase> to, PassRefPtrWillBeRawPtr<SVGPrope rtyBase> toAtEndOfDuration, SVGElement*)
76 { 72 {
77 ASSERT(animationElement); 73 ASSERT(animationElement);
78 74
79 RefPtrWillBeRawPtr<SVGInteger> fromInteger = toSVGInteger(from); 75 RefPtrWillBeRawPtr<SVGInteger> fromInteger = toSVGInteger(from);
80 RefPtrWillBeRawPtr<SVGInteger> toInteger = toSVGInteger(to); 76 RefPtrWillBeRawPtr<SVGInteger> toInteger = toSVGInteger(to);
81 RefPtrWillBeRawPtr<SVGInteger> toAtEndOfDurationInteger = toSVGInteger(toAtE ndOfDuration); 77 RefPtrWillBeRawPtr<SVGInteger> toAtEndOfDurationInteger = toSVGInteger(toAtE ndOfDuration);
82 78
83 float animatedFloat = m_value; 79 float animatedFloat = m_value;
84 animationElement->animateAdditiveNumber(percentage, repeatCount, fromInteger ->value(), toInteger->value(), toAtEndOfDurationInteger->value(), animatedFloat) ; 80 animationElement->animateAdditiveNumber(percentage, repeatCount, fromInteger ->value(), toInteger->value(), toAtEndOfDurationInteger->value(), animatedFloat) ;
85 m_value = static_cast<int>(roundf(animatedFloat)); 81 m_value = static_cast<int>(roundf(animatedFloat));
86 } 82 }
87 83
88 float SVGInteger::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> othe r, SVGElement*) 84 float SVGInteger::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> othe r, SVGElement*)
89 { 85 {
90 return abs(m_value - toSVGInteger(other)->value()); 86 return abs(m_value - toSVGInteger(other)->value());
91 } 87 }
92 88
93 } // namespace blink 89 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698