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

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

Issue 1544673003: Refactor propagation of parsing errors for SVG attributes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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/SVGPoint.cpp
diff --git a/third_party/WebKit/Source/core/svg/SVGPoint.cpp b/third_party/WebKit/Source/core/svg/SVGPoint.cpp
index f50d2fbdcc099bb28ae2ecf13624d94f26910ac5..8f0c89420fce9504fb29c8355a758ab686768594 100644
--- a/third_party/WebKit/Source/core/svg/SVGPoint.cpp
+++ b/third_party/WebKit/Source/core/svg/SVGPoint.cpp
@@ -30,8 +30,6 @@
#include "core/svg/SVGPoint.h"
-#include "bindings/core/v8/ExceptionState.h"
-#include "core/dom/ExceptionCode.h"
#include "core/svg/SVGAnimationElement.h"
#include "core/svg/SVGParserUtilities.h"
#include "platform/transforms/AffineTransform.h"
@@ -55,28 +53,24 @@ PassRefPtrWillBeRawPtr<SVGPoint> SVGPoint::clone() const
}
template<typename CharType>
-void SVGPoint::parse(const CharType*& ptr, const CharType* end, ExceptionState& exceptionState)
+bool SVGPoint::parse(const CharType*& ptr, const CharType* end)
{
- const CharType* start = ptr;
-
skipOptionalSVGSpaces(ptr, end);
float x = 0.0f;
float y = 0.0f;
bool valid = parseNumber(ptr, end, x) && parseNumber(ptr, end, y, DisallowWhitespace);
- if (!valid) {
- exceptionState.throwDOMException(SyntaxError, "Problem parsing point \"" + String(start, end - start) + "\"");
- return;
- }
+ if (!valid)
+ return false;
- skipOptionalSVGSpaces(ptr, end);
- if (ptr < end) { // nothing should come after the last, fourth number
- exceptionState.throwDOMException(SyntaxError, "Problem parsing point \"" + String(start, end - start) + "\"");
- return;
+ if (skipOptionalSVGSpaces(ptr, end)) {
+ // Nothing should come after the second number.
+ return false;
}
m_value = FloatPoint(x, y);
+ return true;
}
FloatPoint SVGPoint::matrixTransform(const AffineTransform& transform) const
@@ -86,23 +80,24 @@ FloatPoint SVGPoint::matrixTransform(const AffineTransform& transform) const
return FloatPoint::narrowPrecision(newX, newY);
}
-void SVGPoint::setValueAsString(const String& string, ExceptionState& exceptionState)
+SVGParsingError SVGPoint::setValueAsString(const String& string)
{
if (string.isEmpty()) {
m_value = FloatPoint(0.0f, 0.0f);
- return;
+ return NoError;
}
+ bool valid;
if (string.is8Bit()) {
const LChar* ptr = string.characters8();
const LChar* end = ptr + string.length();
- parse(ptr, end, exceptionState);
- return;
+ valid = parse(ptr, end);
+ } else {
+ const UChar* ptr = string.characters16();
+ const UChar* end = ptr + string.length();
+ valid = parse(ptr, end);
}
-
- const UChar* ptr = string.characters16();
- const UChar* end = ptr + string.length();
- parse(ptr, end, exceptionState);
+ return valid ? NoError : ParsingAttributeFailedError;
}
String SVGPoint::valueAsString() const

Powered by Google App Engine
This is Rietveld 408576698