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

Unified Diff: third_party/WebKit/Source/core/svg/SVGIntegerOptionalInteger.cpp

Issue 2590433002: Stricter float-to-int conversion in SVGIntegerOptionalInteger (Closed)
Patch Set: ...and back to doing things differently. Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/svg/SVGIntegerOptionalInteger.cpp
diff --git a/third_party/WebKit/Source/core/svg/SVGIntegerOptionalInteger.cpp b/third_party/WebKit/Source/core/svg/SVGIntegerOptionalInteger.cpp
index fba370ea729959dd0f5d28c812199fed7b87ddfe..85ccecc00ceccb9f86381d7741ed5f5ea90a8c73 100644
--- a/third_party/WebKit/Source/core/svg/SVGIntegerOptionalInteger.cpp
+++ b/third_party/WebKit/Source/core/svg/SVGIntegerOptionalInteger.cpp
@@ -52,17 +52,10 @@ SVGIntegerOptionalInteger* SVGIntegerOptionalInteger::clone() const {
SVGPropertyBase* SVGIntegerOptionalInteger::cloneForAnimation(
const String& value) const {
- float floatX, floatY;
- if (!parseNumberOptionalNumber(value, floatX, floatY)) {
- return SVGIntegerOptionalInteger::create(SVGInteger::create(0),
- SVGInteger::create(0));
- }
-
- int x = static_cast<int>(roundf(floatX));
- int y = static_cast<int>(roundf(floatY));
-
- return SVGIntegerOptionalInteger::create(SVGInteger::create(x),
- SVGInteger::create(y));
+ SVGIntegerOptionalInteger* clone =
+ create(SVGInteger::create(0), SVGInteger::create(0));
+ clone->setValueAsString(value);
+ return clone;
}
String SVGIntegerOptionalInteger::valueAsString() const {
@@ -83,8 +76,8 @@ SVGParsingError SVGIntegerOptionalInteger::setValueAsString(
x = y = 0;
}
- m_firstInteger->setValue(x);
- m_secondInteger->setValue(y);
+ m_firstInteger->setValue(clampTo<int>(x));
+ m_secondInteger->setValue(clampTo<int>(y));
return parseStatus;
}
@@ -125,8 +118,8 @@ void SVGIntegerOptionalInteger::calculateAnimatedValue(
percentage, repeatCount, fromInteger->secondInteger()->value(),
toInteger->secondInteger()->value(),
toAtEndOfDurationInteger->secondInteger()->value(), y);
- m_firstInteger->setValue(static_cast<int>(roundf(x)));
- m_secondInteger->setValue(static_cast<int>(roundf(y)));
+ m_firstInteger->setValue(clampTo<int>(roundf(x)));
+ m_secondInteger->setValue(clampTo<int>(roundf(y)));
}
float SVGIntegerOptionalInteger::calculateDistance(SVGPropertyBase* other,

Powered by Google App Engine
This is Rietveld 408576698