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

Unified Diff: third_party/WebKit/Source/core/svg/SVGRect.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/SVGRect.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/svg/SVGRect.cpp
diff --git a/third_party/WebKit/Source/core/svg/SVGRect.cpp b/third_party/WebKit/Source/core/svg/SVGRect.cpp
index 328b59f36ff3cc8a76ee374229751ec4e96c00bb..3866ed411663723dffdda3e5eafcd0b17b049448 100644
--- a/third_party/WebKit/Source/core/svg/SVGRect.cpp
+++ b/third_party/WebKit/Source/core/svg/SVGRect.cpp
@@ -45,27 +45,27 @@ PassRefPtrWillBeRawPtr<SVGRect> SVGRect::clone() const
}
template<typename CharType>
-bool SVGRect::parse(const CharType*& ptr, const CharType* end)
+SVGParsingError SVGRect::parse(const CharType*& ptr, const CharType* end)
{
- skipOptionalSVGSpaces(ptr, end);
-
- float x = 0.0f;
- float y = 0.0f;
- float width = 0.0f;
- float height = 0.0f;
- bool valid = parseNumber(ptr, end, x) && parseNumber(ptr, end, y) && parseNumber(ptr, end, width) && parseNumber(ptr, end, height, DisallowWhitespace);
-
- if (!valid)
- return false;
+ const CharType* start = ptr;
+ float x = 0;
+ float y = 0;
+ float width = 0;
+ float height = 0;
+ if (!parseNumber(ptr, end, x)
+ || !parseNumber(ptr, end, y)
+ || !parseNumber(ptr, end, width)
+ || !parseNumber(ptr, end, height, DisallowWhitespace))
+ return SVGParsingError(SVGParseStatus::ExpectedNumber, ptr - start);
if (skipOptionalSVGSpaces(ptr, end)) {
// Nothing should come after the last, fourth number.
- return false;
+ return SVGParsingError(SVGParseStatus::TrailingGarbage, ptr - start);
}
m_value = FloatRect(x, y, width, height);
m_isValid = true;
- return true;
+ return SVGParseStatus::NoError;
}
SVGParsingError SVGRect::setValueAsString(const String& string)
@@ -81,17 +81,14 @@ SVGParsingError SVGRect::setValueAsString(const String& string)
return SVGParseStatus::NoError;
}
- bool valid;
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);
}
- return valid ? SVGParseStatus::NoError : SVGParseStatus::ParsingFailed;
+ const UChar* ptr = string.characters16();
+ const UChar* end = ptr + string.length();
+ return parse(ptr, end);
}
String SVGRect::valueAsString() const
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGRect.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698