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) |