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

Unified Diff: third_party/WebKit/Source/core/svg/SVGPointList.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/SVGPointList.h ('k') | third_party/WebKit/Source/core/svg/SVGRect.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/SVGPointList.cpp
diff --git a/third_party/WebKit/Source/core/svg/SVGPointList.cpp b/third_party/WebKit/Source/core/svg/SVGPointList.cpp
index e7f67b8bf7635bf6707258b47e149823a4e67c58..85057dbdf278ef820cbbb86000f57f9355a2d89e 100644
--- a/third_party/WebKit/Source/core/svg/SVGPointList.cpp
+++ b/third_party/WebKit/Source/core/svg/SVGPointList.cpp
@@ -56,56 +56,50 @@ String SVGPointList::valueAsString() const
}
template <typename CharType>
-bool SVGPointList::parse(const CharType*& ptr, const CharType* end)
+SVGParsingError SVGPointList::parse(const CharType*& ptr, const CharType* end)
{
- clear();
-
- skipOptionalSVGSpaces(ptr, end);
- if (ptr >= end)
- return true;
+ if (!skipOptionalSVGSpaces(ptr, end))
+ return SVGParseStatus::NoError;
+ const CharType* listStart = ptr;
for (;;) {
- float x = 0.0f;
- float y = 0.0f;
- bool valid = parseNumber(ptr, end, x) && parseNumber(ptr, end, y, DisallowWhitespace);
- if (!valid) {
- return false;
- }
+ float x = 0;
+ float y = 0;
+ if (!parseNumber(ptr, end, x)
+ || !parseNumber(ptr, end, y, DisallowWhitespace))
+ return SVGParsingError(SVGParseStatus::ExpectedNumber, ptr - listStart);
+
append(SVGPoint::create(FloatPoint(x, y)));
- skipOptionalSVGSpaces(ptr, end);
- if (ptr < end && *ptr == ',') {
+ if (!skipOptionalSVGSpaces(ptr, end))
+ break;
+
+ if (*ptr == ',') {
++ptr;
skipOptionalSVGSpaces(ptr, end);
// ',' requires the list to be continued
continue;
}
-
- // check end of list
- if (ptr >= end)
- return true;
}
+ return SVGParseStatus::NoError;
}
SVGParsingError SVGPointList::setValueAsString(const String& value)
{
- if (value.isEmpty()) {
- clear();
+ clear();
+
+ if (value.isEmpty())
return SVGParseStatus::NoError;
- }
- bool valid = false;
if (value.is8Bit()) {
const LChar* ptr = value.characters8();
const LChar* end = ptr + value.length();
- valid = parse(ptr, end);
- } else {
- const UChar* ptr = value.characters16();
- const UChar* end = ptr + value.length();
- valid = parse(ptr, end);
+ return parse(ptr, end);
}
- return valid ? SVGParseStatus::NoError : SVGParseStatus::ParsingFailed;
+ const UChar* ptr = value.characters16();
+ const UChar* end = ptr + value.length();
+ return parse(ptr, end);
}
void SVGPointList::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement* contextElement)
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGPointList.h ('k') | third_party/WebKit/Source/core/svg/SVGRect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698