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

Unified Diff: third_party/WebKit/Source/core/svg/SVGLength.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/SVGLength.cpp
diff --git a/third_party/WebKit/Source/core/svg/SVGLength.cpp b/third_party/WebKit/Source/core/svg/SVGLength.cpp
index 51f0d2ab6f122f9f2556264d58c2efecd73ba677..f6113660a69c2cfe46eda49e81441d50bed844ae 100644
--- a/third_party/WebKit/Source/core/svg/SVGLength.cpp
+++ b/third_party/WebKit/Source/core/svg/SVGLength.cpp
@@ -21,16 +21,12 @@
#include "core/svg/SVGLength.h"
-#include "bindings/core/v8/ExceptionState.h"
#include "core/SVGNames.h"
#include "core/css/CSSPrimitiveValue.h"
#include "core/css/CSSValue.h"
#include "core/css/CSSValuePool.h"
#include "core/css/parser/CSSParser.h"
-#include "core/dom/ExceptionCode.h"
#include "core/svg/SVGAnimationElement.h"
-#include "core/svg/SVGParserUtilities.h"
-#include "platform/animation/AnimationUtilities.h"
#include "wtf/MathExtras.h"
#include "wtf/text/WTFString.h"
@@ -65,14 +61,11 @@ PassRefPtrWillBeRawPtr<SVGLength> SVGLength::clone() const
PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGLength::cloneForAnimation(const String& value) const
{
RefPtrWillBeRawPtr<SVGLength> length = create();
-
length->m_unitMode = m_unitMode;
- TrackExceptionState exceptionState;
- length->setValueAsString(value, exceptionState);
- if (exceptionState.hadException()) {
- length->m_value = CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::UserUnits);
- }
+ SVGParsingError status = length->setValueAsString(value);
+ if (status != NoError)
+ length->m_value = cssValuePool().createValue(0, CSSPrimitiveValue::UnitType::UserUnits);
return length.release();
}
@@ -139,28 +132,25 @@ float SVGLength::scaleByPercentage(float input) const
return result;
}
-void SVGLength::setValueAsString(const String& string, ExceptionState& exceptionState)
+SVGParsingError SVGLength::setValueAsString(const String& string)
{
if (string.isEmpty()) {
m_value = cssValuePool().createValue(0, CSSPrimitiveValue::UnitType::UserUnits);
- return;
+ return NoError;
}
CSSParserContext svgParserContext(SVGAttributeMode, 0);
RefPtrWillBeRawPtr<CSSValue> parsed = CSSParser::parseSingleValue(CSSPropertyX, string, svgParserContext);
- if (!parsed || !parsed->isPrimitiveValue()) {
- exceptionState.throwDOMException(SyntaxError, "The value provided ('" + string + "') is invalid.");
- return;
- }
+ if (!parsed || !parsed->isPrimitiveValue())
+ return ParsingAttributeFailedError;
CSSPrimitiveValue* newValue = toCSSPrimitiveValue(parsed.get());
// TODO(fs): Enable calc for SVG lengths
- if (newValue->isCalculated() || !isSupportedCSSUnitType(newValue->typeWithCalcResolved())) {
- exceptionState.throwDOMException(SyntaxError, "The value provided ('" + string + "') is invalid.");
- return;
- }
+ if (newValue->isCalculated() || !isSupportedCSSUnitType(newValue->typeWithCalcResolved()))
+ return ParsingAttributeFailedError;
m_value = newValue;
+ return NoError;
}
String SVGLength::valueAsString() const

Powered by Google App Engine
This is Rietveld 408576698