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

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

Issue 1620203002: Extended error reporting for SVGNumber/Point/Rect and related types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Blind is blind. Created 4 years, 11 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 | « third_party/WebKit/Source/core/svg/SVGNumber.h ('k') | third_party/WebKit/Source/core/svg/SVGNumberList.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/svg/SVGNumber.cpp
diff --git a/third_party/WebKit/Source/core/svg/SVGNumber.cpp b/third_party/WebKit/Source/core/svg/SVGNumber.cpp
index 7bf387971e117ad212cef52eea98289d971d7aa1..490e775c7866ffc0dfcbc28aab41515fb8aa7166 100644
--- a/third_party/WebKit/Source/core/svg/SVGNumber.cpp
+++ b/third_party/WebKit/Source/core/svg/SVGNumber.cpp
@@ -51,44 +51,33 @@ String SVGNumber::valueAsString() const
}
template<typename CharType>
-bool SVGNumber::parse(const CharType*& ptr, const CharType* end)
+SVGParsingError SVGNumber::parse(const CharType*& ptr, const CharType* end)
{
- if (!parseNumber(ptr, end, m_value, AllowLeadingAndTrailingWhitespace)) {
- m_value = 0;
- return false;
- }
-
- if (ptr != end) {
- m_value = 0;
- return false;
- }
-
- return true;
+ float value = 0;
+ const CharType* start = ptr;
+ if (!parseNumber(ptr, end, value, AllowLeadingAndTrailingWhitespace))
+ return SVGParsingError(SVGParseStatus::ExpectedNumber, ptr - start);
+ if (ptr != end)
+ return SVGParsingError(SVGParseStatus::TrailingGarbage, ptr - start);
+ m_value = value;
+ return SVGParseStatus::NoError;
}
SVGParsingError SVGNumber::setValueAsString(const String& string)
{
- if (string.isEmpty()) {
- m_value = 0;
+ m_value = 0;
+
+ if (string.isEmpty())
return SVGParseStatus::NoError;
- }
- bool valid = false;
if (string.is8Bit()) {
const LChar* ptr = string.characters8();
const LChar* end = ptr + string.length();
- valid = parse(ptr, end);
- } else {
- const UChar* ptr = string.characters16();
- const UChar* end = ptr + string.length();
- valid = parse(ptr, end);
+ return parse(ptr, end);
}
-
- if (!valid) {
- m_value = 0;
- return SVGParseStatus::ParsingFailed;
- }
- return SVGParseStatus::NoError;
+ const UChar* ptr = string.characters16();
+ const UChar* end = ptr + string.length();
+ return parse(ptr, end);
}
void SVGNumber::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement*)
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGNumber.h ('k') | third_party/WebKit/Source/core/svg/SVGNumberList.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698