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

Unified Diff: third_party/WebKit/Source/core/svg/SVGNumberList.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
Index: third_party/WebKit/Source/core/svg/SVGNumberList.cpp
diff --git a/third_party/WebKit/Source/core/svg/SVGNumberList.cpp b/third_party/WebKit/Source/core/svg/SVGNumberList.cpp
index a701cef5eb0227dc1674a0124c5b02a71f8ee2db..4e09da42076e5eaf8d0f47af7bbab0e99f359360 100644
--- a/third_party/WebKit/Source/core/svg/SVGNumberList.cpp
+++ b/third_party/WebKit/Source/core/svg/SVGNumberList.cpp
@@ -55,44 +55,36 @@ String SVGNumberList::valueAsString() const
}
template <typename CharType>
-bool SVGNumberList::parse(const CharType*& ptr, const CharType* end)
+SVGParsingError SVGNumberList::parse(const CharType*& ptr, const CharType* end)
{
- clear();
-
+ const CharType* listStart = ptr;
while (ptr < end) {
float number = 0;
if (!parseNumber(ptr, end, number))
- return false;
+ return SVGParsingError(SVGParseStatus::ExpectedNumber, ptr - listStart);
append(SVGNumber::create(number));
}
-
- return true;
+ return SVGParseStatus::NoError;
}
SVGParsingError SVGNumberList::setValueAsString(const String& value)
{
- if (value.isEmpty()) {
- clear();
+ clear();
+
+ if (value.isEmpty())
return SVGParseStatus::NoError;
- }
- bool valid = false;
+ // Don't call |clear()| if an error is encountered. SVG policy is to use
+ // valid items before error.
+ // Spec: http://www.w3.org/TR/SVG/single-page.html#implnote-ErrorProcessing
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);
}
-
- if (!valid) {
- // No call to |clear()| here. SVG policy is to use valid items before error.
- // Spec: http://www.w3.org/TR/SVG/single-page.html#implnote-ErrorProcessing
- return SVGParseStatus::ParsingFailed;
- }
- return SVGParseStatus::NoError;
+ const UChar* ptr = value.characters16();
+ const UChar* end = ptr + value.length();
+ return parse(ptr, end);
}
void SVGNumberList::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement* contextElement)
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGNumberList.h ('k') | third_party/WebKit/Source/core/svg/SVGNumberOptionalNumber.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698