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

Unified Diff: Source/core/svg/SVGNumber.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: split tests to combat slow xp trybots 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/svg/SVGLengthList.cpp ('k') | Source/core/svg/SVGParserUtilities.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/SVGNumber.cpp
diff --git a/Source/core/svg/SVGNumber.cpp b/Source/core/svg/SVGNumber.cpp
index b50bd1bbfba0154c082d8815ffa3265dde70cd84..8e91bbf76e8522e1512bb0a12f9d3494ceb600b0 100644
--- a/Source/core/svg/SVGNumber.cpp
+++ b/Source/core/svg/SVGNumber.cpp
@@ -62,7 +62,7 @@ String SVGNumber::valueAsString() const
template<typename CharType>
bool SVGNumber::parse(const CharType*& ptr, const CharType* end)
{
- if (!parseNumber(ptr, end, m_value, false)) {
+ if (!parseNumber(ptr, end, m_value, AllowLeadingAndTrailingWhitespace)) {
m_value = 0;
return false;
}
@@ -127,21 +127,12 @@ PassRefPtr<SVGNumber> SVGNumberAcceptPercentage::clone() const
void SVGNumberAcceptPercentage::setValueAsString(const String& string, ExceptionState& exceptionState)
{
- if (string.isEmpty()) {
- m_value = 0;
- return;
- }
-
- if (string.endsWith('%')) {
- SVGNumber::setValueAsString(string.left(string.length() - 1), exceptionState);
- if (exceptionState.hadException())
- return;
+ bool valid = parseNumberOrPercentage(string, m_value);
- m_value /= 100.0f;
- return;
+ if (!valid) {
+ exceptionState.throwDOMException(SyntaxError, "The value provided ('" + string + "') is invalid.");
+ m_value = 0;
}
-
- SVGNumber::setValueAsString(string, exceptionState);
}
SVGNumberAcceptPercentage::SVGNumberAcceptPercentage(float value)
« no previous file with comments | « Source/core/svg/SVGLengthList.cpp ('k') | Source/core/svg/SVGParserUtilities.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698