diff options
51 files changed, 229 insertions, 260 deletions
diff --git a/third_party/WebKit/Source/core/svg/LinearGradientAttributes.h b/third_party/WebKit/Source/core/svg/LinearGradientAttributes.h index 809d8b1..7b6f0a4 100644 --- a/third_party/WebKit/Source/core/svg/LinearGradientAttributes.h +++ b/third_party/WebKit/Source/core/svg/LinearGradientAttributes.h @@ -39,7 +39,7 @@ public: , m_x2Set(false) , m_y2Set(false) { - m_x2->setValueAsString("100%", ASSERT_NO_EXCEPTION); + m_x2->setValueAsString("100%"); } SVGLength* x1() const { return m_x1.get(); } diff --git a/third_party/WebKit/Source/core/svg/RadialGradientAttributes.h b/third_party/WebKit/Source/core/svg/RadialGradientAttributes.h index 7a752b7..2c70442 100644 --- a/third_party/WebKit/Source/core/svg/RadialGradientAttributes.h +++ b/third_party/WebKit/Source/core/svg/RadialGradientAttributes.h @@ -41,9 +41,9 @@ public: , m_fySet(false) , m_frSet(false) { - m_cx->setValueAsString("50%", IGNORE_EXCEPTION); - m_cy->setValueAsString("50%", IGNORE_EXCEPTION); - m_r->setValueAsString("50%", IGNORE_EXCEPTION); + m_cx->setValueAsString("50%"); + m_cy->setValueAsString("50%"); + m_r->setValueAsString("50%"); } SVGLength* cx() const { return m_cx.get(); } diff --git a/third_party/WebKit/Source/core/svg/SVGAngle.cpp b/third_party/WebKit/Source/core/svg/SVGAngle.cpp index 991acb4..282f645 100644 --- a/third_party/WebKit/Source/core/svg/SVGAngle.cpp +++ b/third_party/WebKit/Source/core/svg/SVGAngle.cpp @@ -21,9 +21,6 @@ #include "core/svg/SVGAngle.h" -#include "bindings/core/v8/ExceptionState.h" -#include "bindings/core/v8/ExceptionStatePlaceholder.h" -#include "core/dom/ExceptionCode.h" #include "core/svg/SVGAnimationElement.h" #include "core/svg/SVGParserUtilities.h" #include "wtf/MathExtras.h" @@ -236,22 +233,22 @@ static bool parseValue(const String& value, float& valueInSpecifiedUnits, SVGAng return true; } -void SVGAngle::setValueAsString(const String& value, ExceptionState& exceptionState) +SVGParsingError SVGAngle::setValueAsString(const String& value) { if (value.isEmpty()) { newValueSpecifiedUnits(SVG_ANGLETYPE_UNSPECIFIED, 0); - return; + return NoError; } if (value == "auto") { newValueSpecifiedUnits(SVG_ANGLETYPE_UNSPECIFIED, 0); m_orientType->setEnumValue(SVGMarkerOrientAuto); - return; + return NoError; } if (value == "auto-start-reverse") { newValueSpecifiedUnits(SVG_ANGLETYPE_UNSPECIFIED, 0); m_orientType->setEnumValue(SVGMarkerOrientAutoStartReverse); - return; + return NoError; } float valueInSpecifiedUnits = 0; @@ -259,14 +256,13 @@ void SVGAngle::setValueAsString(const String& value, ExceptionState& exceptionSt bool success = value.is8Bit() ? parseValue<LChar>(value, valueInSpecifiedUnits, unitType) : parseValue<UChar>(value, valueInSpecifiedUnits, unitType); - if (!success) { - exceptionState.throwDOMException(SyntaxError, "The value provided ('" + value + "') is invalid."); - return; - } + if (!success) + return ParsingAttributeFailedError; m_orientType->setEnumValue(SVGMarkerOrientAngle); m_unitType = unitType; m_valueInSpecifiedUnits = valueInSpecifiedUnits; + return NoError; } void SVGAngle::newValueSpecifiedUnits(SVGAngleType unitType, float valueInSpecifiedUnits) diff --git a/third_party/WebKit/Source/core/svg/SVGAngle.h b/third_party/WebKit/Source/core/svg/SVGAngle.h index 3a3ff8c..a915f85 100644 --- a/third_party/WebKit/Source/core/svg/SVGAngle.h +++ b/third_party/WebKit/Source/core/svg/SVGAngle.h @@ -23,6 +23,7 @@ #define SVGAngle_h #include "core/svg/SVGEnumeration.h" +#include "core/svg/SVGParsingError.h" #include "core/svg/properties/SVGPropertyHelper.h" #include "platform/heap/Handle.h" @@ -103,7 +104,7 @@ public: PassRefPtrWillBeRawPtr<SVGAngle> clone() const; String valueAsString() const override; - void setValueAsString(const String&, ExceptionState&); + SVGParsingError setValueAsString(const String&); void add(PassRefPtrWillBeRawPtr<SVGPropertyBase>, SVGElement*) override; void calculateAnimatedValue(SVGAnimationElement*, float percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBase> from, PassRefPtrWillBeRawPtr<SVGPropertyBase> to, PassRefPtrWillBeRawPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement* contextElement) override; diff --git a/third_party/WebKit/Source/core/svg/SVGAngleTearOff.cpp b/third_party/WebKit/Source/core/svg/SVGAngleTearOff.cpp index d20417c..ee043be 100644 --- a/third_party/WebKit/Source/core/svg/SVGAngleTearOff.cpp +++ b/third_party/WebKit/Source/core/svg/SVGAngleTearOff.cpp @@ -114,10 +114,13 @@ void SVGAngleTearOff::setValueAsString(const String& value, ExceptionState& exce String oldValue = target()->valueAsString(); - target()->setValueAsString(value, exceptionState); + SVGParsingError status = target()->setValueAsString(value); - if (!exceptionState.hadException() && !hasExposedAngleUnit()) { - target()->setValueAsString(oldValue, ASSERT_NO_EXCEPTION); // rollback to old value + if (status == NoError && !hasExposedAngleUnit()) { + target()->setValueAsString(oldValue); // rollback to old value + status = ParsingAttributeFailedError; + } + if (status != NoError) { exceptionState.throwDOMException(SyntaxError, "The value provided ('" + value + "') is invalid."); return; } diff --git a/third_party/WebKit/Source/core/svg/SVGAnimatedLength.cpp b/third_party/WebKit/Source/core/svg/SVGAnimatedLength.cpp index 2bd0f16..7a2b26a 100644 --- a/third_party/WebKit/Source/core/svg/SVGAnimatedLength.cpp +++ b/third_party/WebKit/Source/core/svg/SVGAnimatedLength.cpp @@ -30,28 +30,25 @@ #include "core/svg/SVGAnimatedLength.h" -#include "core/svg/SVGElement.h" #include "core/svg/SVGLength.h" namespace blink { void SVGAnimatedLength::setDefaultValueAsString(const String& value) { - baseValue()->setValueAsString(value, ASSERT_NO_EXCEPTION); + baseValue()->setValueAsString(value); } -void SVGAnimatedLength::setBaseValueAsString(const String& value, SVGParsingError& parseError) +SVGParsingError SVGAnimatedLength::setBaseValueAsString(const String& value) { - TrackExceptionState es; + SVGParsingError parseStatus = baseValue()->setValueAsString(value); - baseValue()->setValueAsString(value, es); - - if (es.hadException()) { - parseError = ParsingAttributeFailedError; + if (parseStatus != NoError) baseValue()->newValueSpecifiedUnits(CSSPrimitiveValue::UnitType::UserUnits, 0); - } else if (SVGLength::negativeValuesForbiddenForAnimatedLengthAttribute(attributeName()) && baseValue()->valueInSpecifiedUnits() < 0) { - parseError = NegativeValueForbiddenError; - } + else if (SVGLength::negativeValuesForbiddenForAnimatedLengthAttribute(attributeName()) && baseValue()->valueInSpecifiedUnits() < 0) + parseStatus = NegativeValueForbiddenError; + + return parseStatus; } } diff --git a/third_party/WebKit/Source/core/svg/SVGAnimatedLength.h b/third_party/WebKit/Source/core/svg/SVGAnimatedLength.h index dc4ba7d..6ef6568 100644 --- a/third_party/WebKit/Source/core/svg/SVGAnimatedLength.h +++ b/third_party/WebKit/Source/core/svg/SVGAnimatedLength.h @@ -45,7 +45,7 @@ public: } void setDefaultValueAsString(const String&); - void setBaseValueAsString(const String&, SVGParsingError&) override; + SVGParsingError setBaseValueAsString(const String&) override; protected: SVGAnimatedLength(SVGElement* contextElement, const QualifiedName& attributeName, PassRefPtrWillBeRawPtr<SVGLength> initialValue) diff --git a/third_party/WebKit/Source/core/svg/SVGAnimatedTypeAnimator.cpp b/third_party/WebKit/Source/core/svg/SVGAnimatedTypeAnimator.cpp index e625e7e..795d773 100644 --- a/third_party/WebKit/Source/core/svg/SVGAnimatedTypeAnimator.cpp +++ b/third_party/WebKit/Source/core/svg/SVGAnimatedTypeAnimator.cpp @@ -98,22 +98,22 @@ PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGAnimatedTypeAnimator::createPropertyF return SVGColorProperty::create(value); case AnimatedNumber: { RefPtrWillBeRawPtr<SVGNumber> property = SVGNumber::create(); - property->setValueAsString(value, IGNORE_EXCEPTION); + property->setValueAsString(value); return property.release(); } case AnimatedLength: { RefPtrWillBeRawPtr<SVGLength> property = SVGLength::create(); - property->setValueAsString(value, IGNORE_EXCEPTION); + property->setValueAsString(value); return property.release(); } case AnimatedLengthList: { RefPtrWillBeRawPtr<SVGLengthList> property = SVGLengthList::create(); - property->setValueAsString(value, IGNORE_EXCEPTION); + property->setValueAsString(value); return property.release(); } case AnimatedString: { RefPtrWillBeRawPtr<SVGString> property = SVGString::create(); - property->setValueAsString(value, IGNORE_EXCEPTION); + property->setValueAsString(value); return property.release(); } diff --git a/third_party/WebKit/Source/core/svg/SVGBoolean.cpp b/third_party/WebKit/Source/core/svg/SVGBoolean.cpp index a323744..5af4bd3 100644 --- a/third_party/WebKit/Source/core/svg/SVGBoolean.cpp +++ b/third_party/WebKit/Source/core/svg/SVGBoolean.cpp @@ -30,9 +30,6 @@ #include "core/svg/SVGBoolean.h" -#include "bindings/core/v8/ExceptionState.h" -#include "bindings/core/v8/ExceptionStatePlaceholder.h" -#include "core/dom/ExceptionCode.h" #include "core/svg/SVGAnimationElement.h" namespace blink { @@ -42,15 +39,17 @@ String SVGBoolean::valueAsString() const return m_value ? "true" : "false"; } -void SVGBoolean::setValueAsString(const String& value, ExceptionState& exceptionState) +SVGParsingError SVGBoolean::setValueAsString(const String& value) { if (value == "true") { m_value = true; - } else if (value == "false") { + return NoError; + } + if (value == "false") { m_value = false; - } else { - exceptionState.throwDOMException(SyntaxError, "The value provided ('" + value + "') is invalid."); + return NoError; } + return ParsingAttributeFailedError; } void SVGBoolean::add(PassRefPtrWillBeRawPtr<SVGPropertyBase>, SVGElement*) diff --git a/third_party/WebKit/Source/core/svg/SVGBoolean.h b/third_party/WebKit/Source/core/svg/SVGBoolean.h index c5aef85..c04e5fb 100644 --- a/third_party/WebKit/Source/core/svg/SVGBoolean.h +++ b/third_party/WebKit/Source/core/svg/SVGBoolean.h @@ -31,6 +31,7 @@ #ifndef SVGBoolean_h #define SVGBoolean_h +#include "core/svg/SVGParsingError.h" #include "core/svg/properties/SVGPropertyHelper.h" namespace blink { @@ -49,7 +50,7 @@ public: PassRefPtrWillBeRawPtr<SVGBoolean> clone() const { return create(m_value); } String valueAsString() const override; - void setValueAsString(const String&, ExceptionState&); + SVGParsingError setValueAsString(const String&); void add(PassRefPtrWillBeRawPtr<SVGPropertyBase>, SVGElement*) override; void calculateAnimatedValue(SVGAnimationElement*, float percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBase> from, PassRefPtrWillBeRawPtr<SVGPropertyBase> to, PassRefPtrWillBeRawPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement*) override; diff --git a/third_party/WebKit/Source/core/svg/SVGElement.cpp b/third_party/WebKit/Source/core/svg/SVGElement.cpp index 81a4381..c7f4aec 100644 --- a/third_party/WebKit/Source/core/svg/SVGElement.cpp +++ b/third_party/WebKit/Source/core/svg/SVGElement.cpp @@ -635,8 +635,7 @@ bool SVGElement::inUseShadowTree() const void SVGElement::parseAttribute(const QualifiedName& name, const AtomicString& oldValue, const AtomicString& value) { if (SVGAnimatedPropertyBase* property = propertyFromAttribute(name)) { - SVGParsingError parseError = NoError; - property->setBaseValueAsString(value, parseError); + SVGParsingError parseError = property->setBaseValueAsString(value); reportAttributeParsingError(parseError, name, value); return; } @@ -646,8 +645,7 @@ void SVGElement::parseAttribute(const QualifiedName& name, const AtomicString& o // the className here. svgAttributeChanged actually causes the resulting // style updates (instead of Element::parseAttribute). We don't // tell Element about the change to avoid parsing the class list twice - SVGParsingError parseError = NoError; - m_className->setBaseValueAsString(value, parseError); + SVGParsingError parseError = m_className->setBaseValueAsString(value); reportAttributeParsingError(parseError, name, value); } else if (name == tabindexAttr) { Element::parseAttribute(name, oldValue, value); diff --git a/third_party/WebKit/Source/core/svg/SVGEnumeration.cpp b/third_party/WebKit/Source/core/svg/SVGEnumeration.cpp index e6ad2d6..ed579ac 100644 --- a/third_party/WebKit/Source/core/svg/SVGEnumeration.cpp +++ b/third_party/WebKit/Source/core/svg/SVGEnumeration.cpp @@ -30,9 +30,6 @@ #include "core/svg/SVGEnumeration.h" -#include "bindings/core/v8/ExceptionState.h" -#include "bindings/core/v8/ExceptionStatePlaceholder.h" -#include "core/dom/ExceptionCode.h" #include "core/svg/SVGAnimationElement.h" namespace blink { @@ -46,7 +43,7 @@ SVGEnumerationBase::~SVGEnumerationBase() PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGEnumerationBase::cloneForAnimation(const String& value) const { RefPtrWillBeRawPtr<SVGEnumerationBase> svgEnumeration = clone(); - svgEnumeration->setValueAsString(value, IGNORE_EXCEPTION); + svgEnumeration->setValueAsString(value); return svgEnumeration.release(); } @@ -67,7 +64,7 @@ void SVGEnumerationBase::setValue(unsigned short value) notifyChange(); } -void SVGEnumerationBase::setValueAsString(const String& string, ExceptionState& exceptionState) +SVGParsingError SVGEnumerationBase::setValueAsString(const String& string) { for (const auto& entry : m_entries) { if (string == entry.second) { @@ -75,12 +72,12 @@ void SVGEnumerationBase::setValueAsString(const String& string, ExceptionState& ASSERT(entry.first); m_value = entry.first; notifyChange(); - return; + return NoError; } } - exceptionState.throwDOMException(SyntaxError, "The value provided ('" + string + "') is invalid."); notifyChange(); + return ParsingAttributeFailedError; } void SVGEnumerationBase::add(PassRefPtrWillBeRawPtr<SVGPropertyBase>, SVGElement*) diff --git a/third_party/WebKit/Source/core/svg/SVGEnumeration.h b/third_party/WebKit/Source/core/svg/SVGEnumeration.h index 62758d7..3eda15a 100644 --- a/third_party/WebKit/Source/core/svg/SVGEnumeration.h +++ b/third_party/WebKit/Source/core/svg/SVGEnumeration.h @@ -31,12 +31,11 @@ #ifndef SVGEnumeration_h #define SVGEnumeration_h +#include "core/svg/SVGParsingError.h" #include "core/svg/properties/SVGProperty.h" namespace blink { -class ExceptionState; - class SVGEnumerationBase : public SVGPropertyBase { public: typedef std::pair<unsigned short, String> StringEntry; @@ -56,7 +55,7 @@ public: PassRefPtrWillBeRawPtr<SVGPropertyBase> cloneForAnimation(const String&) const override; String valueAsString() const override; - void setValueAsString(const String&, ExceptionState&); + SVGParsingError setValueAsString(const String&); void add(PassRefPtrWillBeRawPtr<SVGPropertyBase>, SVGElement*) override; void calculateAnimatedValue(SVGAnimationElement*, float percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBase> from, PassRefPtrWillBeRawPtr<SVGPropertyBase> to, PassRefPtrWillBeRawPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement*) override; diff --git a/third_party/WebKit/Source/core/svg/SVGFEConvolveMatrixElement.cpp b/third_party/WebKit/Source/core/svg/SVGFEConvolveMatrixElement.cpp index 9f75d78..4f7ecf2 100644 --- a/third_party/WebKit/Source/core/svg/SVGFEConvolveMatrixElement.cpp +++ b/third_party/WebKit/Source/core/svg/SVGFEConvolveMatrixElement.cpp @@ -49,7 +49,7 @@ public: return adoptRefWillBeNoop(new SVGAnimatedOrder(contextElement)); } - void setBaseValueAsString(const String&, SVGParsingError&) override; + SVGParsingError setBaseValueAsString(const String&) override; protected: SVGAnimatedOrder(SVGElement* contextElement) @@ -58,15 +58,16 @@ protected: } }; -void SVGAnimatedOrder::setBaseValueAsString(const String& value, SVGParsingError& parseError) +SVGParsingError SVGAnimatedOrder::setBaseValueAsString(const String& value) { - SVGAnimatedIntegerOptionalInteger::setBaseValueAsString(value, parseError); + SVGParsingError parseStatus = SVGAnimatedIntegerOptionalInteger::setBaseValueAsString(value); ASSERT(contextElement()); - if (parseError == NoError && (firstInteger()->baseValue()->value() < 1 || secondInteger()->baseValue()->value() < 1)) { + if (parseStatus == NoError && (firstInteger()->baseValue()->value() < 1 || secondInteger()->baseValue()->value() < 1)) { contextElement()->document().accessSVGExtensions().reportWarning( "feConvolveMatrix: problem parsing order=\"" + value + "\"."); } + return parseStatus; } inline SVGFEConvolveMatrixElement::SVGFEConvolveMatrixElement(Document& document) diff --git a/third_party/WebKit/Source/core/svg/SVGFitToViewBox.cpp b/third_party/WebKit/Source/core/svg/SVGFitToViewBox.cpp index 0de541a..9346b98 100644 --- a/third_party/WebKit/Source/core/svg/SVGFitToViewBox.cpp +++ b/third_party/WebKit/Source/core/svg/SVGFitToViewBox.cpp @@ -38,7 +38,7 @@ public: return adoptRefWillBeNoop(new SVGAnimatedViewBoxRect(contextElement)); } - void setBaseValueAsString(const String&, SVGParsingError&) override; + SVGParsingError setBaseValueAsString(const String&) override; protected: SVGAnimatedViewBoxRect(SVGElement* contextElement) @@ -47,21 +47,15 @@ protected: } }; -void SVGAnimatedViewBoxRect::setBaseValueAsString(const String& value, SVGParsingError& parseError) +SVGParsingError SVGAnimatedViewBoxRect::setBaseValueAsString(const String& value) { - TrackExceptionState es; + SVGParsingError parseStatus = baseValue()->setValueAsString(value); - baseValue()->setValueAsString(value, es); - - if (es.hadException()) { - parseError = ParsingAttributeFailedError; - return; - } - - if (baseValue()->width() < 0 || baseValue()->height() < 0) { - parseError = NegativeValueForbiddenError; + if (parseStatus == NoError && (baseValue()->width() < 0 || baseValue()->height() < 0)) { + parseStatus = NegativeValueForbiddenError; baseValue()->setInvalid(); } + return parseStatus; } SVGFitToViewBox::SVGFitToViewBox(SVGElement* element, PropertyMapPolicy propertyMapPolicy) diff --git a/third_party/WebKit/Source/core/svg/SVGInteger.cpp b/third_party/WebKit/Source/core/svg/SVGInteger.cpp index 6c822b9..8ccddc5 100644 --- a/third_party/WebKit/Source/core/svg/SVGInteger.cpp +++ b/third_party/WebKit/Source/core/svg/SVGInteger.cpp @@ -29,8 +29,8 @@ */ #include "core/svg/SVGInteger.h" -#include "core/html/parser/HTMLParserIdioms.h" +#include "core/html/parser/HTMLParserIdioms.h" #include "core/svg/SVGAnimationElement.h" namespace blink { @@ -50,20 +50,21 @@ String SVGInteger::valueAsString() const return String::number(m_value); } -void SVGInteger::setValueAsString(const String& string, ExceptionState& exceptionState) +SVGParsingError SVGInteger::setValueAsString(const String& string) { if (string.isEmpty()) { m_value = 0; - return; + return NoError; } bool valid = true; m_value = stripLeadingAndTrailingHTMLSpaces(string).toIntStrict(&valid); if (!valid) { - exceptionState.throwDOMException(SyntaxError, "The value provided ('" + string + "') is invalid."); m_value = 0; + return ParsingAttributeFailedError; } + return NoError; } void SVGInteger::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement*) diff --git a/third_party/WebKit/Source/core/svg/SVGInteger.h b/third_party/WebKit/Source/core/svg/SVGInteger.h index ae20a3d..98a2bd8 100644 --- a/third_party/WebKit/Source/core/svg/SVGInteger.h +++ b/third_party/WebKit/Source/core/svg/SVGInteger.h @@ -31,8 +31,7 @@ #ifndef SVGInteger_h #define SVGInteger_h -#include "bindings/core/v8/ExceptionMessages.h" -#include "bindings/core/v8/ExceptionStatePlaceholder.h" +#include "core/svg/SVGParsingError.h" #include "core/svg/properties/SVGPropertyHelper.h" namespace blink { @@ -53,7 +52,7 @@ public: void setValue(int value) { m_value = value; } String valueAsString() const override; - virtual void setValueAsString(const String&, ExceptionState&); + SVGParsingError setValueAsString(const String&); void add(PassRefPtrWillBeRawPtr<SVGPropertyBase>, SVGElement*) override; void calculateAnimatedValue(SVGAnimationElement*, float percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBase> from, PassRefPtrWillBeRawPtr<SVGPropertyBase> to, PassRefPtrWillBeRawPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement* contextElement) override; diff --git a/third_party/WebKit/Source/core/svg/SVGIntegerOptionalInteger.cpp b/third_party/WebKit/Source/core/svg/SVGIntegerOptionalInteger.cpp index 16c02de..b064168 100644 --- a/third_party/WebKit/Source/core/svg/SVGIntegerOptionalInteger.cpp +++ b/third_party/WebKit/Source/core/svg/SVGIntegerOptionalInteger.cpp @@ -76,16 +76,18 @@ String SVGIntegerOptionalInteger::valueAsString() const return String::number(m_firstInteger->value()) + " " + String::number(m_secondInteger->value()); } -void SVGIntegerOptionalInteger::setValueAsString(const String& value, ExceptionState& exceptionState) +SVGParsingError SVGIntegerOptionalInteger::setValueAsString(const String& value) { float x, y; + SVGParsingError parseStatus = NoError; if (!parseNumberOptionalNumber(value, x, y)) { - exceptionState.throwDOMException(SyntaxError, "The value provided ('" + value + "') is invalid."); + parseStatus = ParsingAttributeFailedError; x = y = 0; } m_firstInteger->setValue(x); m_secondInteger->setValue(y); + return parseStatus; } void SVGIntegerOptionalInteger::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement*) diff --git a/third_party/WebKit/Source/core/svg/SVGIntegerOptionalInteger.h b/third_party/WebKit/Source/core/svg/SVGIntegerOptionalInteger.h index a84cf09..baff70f 100644 --- a/third_party/WebKit/Source/core/svg/SVGIntegerOptionalInteger.h +++ b/third_party/WebKit/Source/core/svg/SVGIntegerOptionalInteger.h @@ -32,6 +32,7 @@ #define SVGIntegerOptionalInteger_h #include "core/svg/SVGInteger.h" +#include "core/svg/SVGParsingError.h" #include "platform/heap/Handle.h" namespace blink { @@ -51,7 +52,7 @@ public: PassRefPtrWillBeRawPtr<SVGPropertyBase> cloneForAnimation(const String&) const override; String valueAsString() const override; - void setValueAsString(const String&, ExceptionState&); + SVGParsingError setValueAsString(const String&); void add(PassRefPtrWillBeRawPtr<SVGPropertyBase>, SVGElement*) override; void calculateAnimatedValue(SVGAnimationElement*, float percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBase> from, PassRefPtrWillBeRawPtr<SVGPropertyBase> to, PassRefPtrWillBeRawPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement* contextElement) override; diff --git a/third_party/WebKit/Source/core/svg/SVGLength.cpp b/third_party/WebKit/Source/core/svg/SVGLength.cpp index 51f0d2a..f611366 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 diff --git a/third_party/WebKit/Source/core/svg/SVGLength.h b/third_party/WebKit/Source/core/svg/SVGLength.h index dc17da6..398d5ed 100644 --- a/third_party/WebKit/Source/core/svg/SVGLength.h +++ b/third_party/WebKit/Source/core/svg/SVGLength.h @@ -23,12 +23,12 @@ #include "core/css/CSSPrimitiveValue.h" #include "core/svg/SVGLengthContext.h" +#include "core/svg/SVGParsingError.h" #include "core/svg/properties/SVGProperty.h" #include "platform/heap/Handle.h" namespace blink { -class ExceptionState; class QualifiedName; class SVGLengthTearOff; @@ -75,7 +75,7 @@ public: float scaleByPercentage(float) const; String valueAsString() const override; - void setValueAsString(const String&, ExceptionState&); + SVGParsingError setValueAsString(const String&); void newValueSpecifiedUnits(CSSPrimitiveValue::UnitType, float valueInSpecifiedUnits); void convertToSpecifiedUnits(CSSPrimitiveValue::UnitType, const SVGLengthContext&); diff --git a/third_party/WebKit/Source/core/svg/SVGLengthList.cpp b/third_party/WebKit/Source/core/svg/SVGLengthList.cpp index 7399fc6..1797877 100644 --- a/third_party/WebKit/Source/core/svg/SVGLengthList.cpp +++ b/third_party/WebKit/Source/core/svg/SVGLengthList.cpp @@ -20,7 +20,6 @@ #include "core/svg/SVGLengthList.h" -#include "bindings/core/v8/ExceptionStatePlaceholder.h" #include "core/svg/SVGAnimationElement.h" #include "core/svg/SVGParserUtilities.h" #include "wtf/text/StringBuilder.h" @@ -48,7 +47,7 @@ PassRefPtrWillBeRawPtr<SVGLengthList> SVGLengthList::clone() PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGLengthList::cloneForAnimation(const String& value) const { RefPtrWillBeRawPtr<SVGLengthList> ret = SVGLengthList::create(m_mode); - ret->setValueAsString(value, IGNORE_EXCEPTION); + ret->setValueAsString(value); return ret.release(); } @@ -72,7 +71,7 @@ String SVGLengthList::valueAsString() const } template <typename CharType> -void SVGLengthList::parseInternal(const CharType*& ptr, const CharType* end, ExceptionState& exceptionState) +SVGParsingError SVGLengthList::parseInternal(const CharType*& ptr, const CharType* end) { clear(); while (ptr < end) { @@ -81,34 +80,38 @@ void SVGLengthList::parseInternal(const CharType*& ptr, const CharType* end, Exc ptr++; if (ptr == start) break; - - RefPtrWillBeRawPtr<SVGLength> length = SVGLength::create(m_mode); String valueString(start, ptr - start); if (valueString.isEmpty()) - return; - length->setValueAsString(valueString, exceptionState); - if (exceptionState.hadException()) - return; + break; + + RefPtrWillBeRawPtr<SVGLength> length = SVGLength::create(m_mode); + SVGParsingError lengthParseStatus = length->setValueAsString(valueString); + if (lengthParseStatus != NoError) + return lengthParseStatus; append(length); skipOptionalSVGSpacesOrDelimiter(ptr, end); } + return NoError; } -void SVGLengthList::setValueAsString(const String& value, ExceptionState& exceptionState) +SVGParsingError SVGLengthList::setValueAsString(const String& value) { if (value.isEmpty()) { clear(); - return; + return NoError; } + + SVGParsingError parseStatus; if (value.is8Bit()) { const LChar* ptr = value.characters8(); const LChar* end = ptr + value.length(); - parseInternal(ptr, end, exceptionState); + parseStatus = parseInternal(ptr, end); } else { const UChar* ptr = value.characters16(); const UChar* end = ptr + value.length(); - parseInternal(ptr, end, exceptionState); + parseStatus = parseInternal(ptr, end); } + return parseStatus; } void SVGLengthList::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement* contextElement) diff --git a/third_party/WebKit/Source/core/svg/SVGLengthList.h b/third_party/WebKit/Source/core/svg/SVGLengthList.h index 55992d8..be69fa7 100644 --- a/third_party/WebKit/Source/core/svg/SVGLengthList.h +++ b/third_party/WebKit/Source/core/svg/SVGLengthList.h @@ -31,8 +31,8 @@ #ifndef SVGLengthList_h #define SVGLengthList_h -#include "bindings/core/v8/ScriptWrappable.h" #include "core/svg/SVGLength.h" +#include "core/svg/SVGParsingError.h" #include "core/svg/properties/SVGListPropertyHelper.h" namespace blink { @@ -50,7 +50,7 @@ public: ~SVGLengthList() override; - void setValueAsString(const String&, ExceptionState&); + SVGParsingError setValueAsString(const String&); // SVGPropertyBase: PassRefPtrWillBeRawPtr<SVGPropertyBase> cloneForAnimation(const String&) const override; @@ -72,7 +72,7 @@ private: PassRefPtrWillBeRawPtr<SVGLength> createPaddingItem() const override; template <typename CharType> - void parseInternal(const CharType*& ptr, const CharType* end, ExceptionState&); + SVGParsingError parseInternal(const CharType*& ptr, const CharType* end); SVGLengthMode m_mode; }; diff --git a/third_party/WebKit/Source/core/svg/SVGLengthTearOff.cpp b/third_party/WebKit/Source/core/svg/SVGLengthTearOff.cpp index 2fdbb89..4b99836 100644 --- a/third_party/WebKit/Source/core/svg/SVGLengthTearOff.cpp +++ b/third_party/WebKit/Source/core/svg/SVGLengthTearOff.cpp @@ -131,10 +131,10 @@ float SVGLengthTearOff::valueInSpecifiedUnits() return target()->valueInSpecifiedUnits(); } -void SVGLengthTearOff::setValueInSpecifiedUnits(float value, ExceptionState& es) +void SVGLengthTearOff::setValueInSpecifiedUnits(float value, ExceptionState& exceptionState) { if (isImmutable()) { - es.throwDOMException(NoModificationAllowedError, "The attribute is read-only."); + exceptionState.throwDOMException(NoModificationAllowedError, "The attribute is read-only."); return; } target()->setValueInSpecifiedUnits(value); @@ -147,20 +147,23 @@ String SVGLengthTearOff::valueAsString() return hasExposedLengthUnit() ? target()->valueAsString() : String::number(0); } -void SVGLengthTearOff::setValueAsString(const String& str, ExceptionState& es) +void SVGLengthTearOff::setValueAsString(const String& str, ExceptionState& exceptionState) { if (isImmutable()) { - es.throwDOMException(NoModificationAllowedError, "The attribute is read-only."); + exceptionState.throwDOMException(NoModificationAllowedError, "The attribute is read-only."); return; } String oldValue = target()->valueAsString(); - target()->setValueAsString(str, es); + SVGParsingError status = target()->setValueAsString(str); - if (!es.hadException() && !hasExposedLengthUnit()) { - target()->setValueAsString(oldValue, ASSERT_NO_EXCEPTION); // rollback to old value - es.throwDOMException(SyntaxError, "The value provided ('" + str + "') is invalid."); + if (status == NoError && !hasExposedLengthUnit()) { + target()->setValueAsString(oldValue); // rollback to old value + status = ParsingAttributeFailedError; + } + if (status != NoError) { + exceptionState.throwDOMException(SyntaxError, "The value provided ('" + str + "') is invalid."); return; } diff --git a/third_party/WebKit/Source/core/svg/SVGMarkerElement.h b/third_party/WebKit/Source/core/svg/SVGMarkerElement.h index a713ae6..6a89d0c 100644 --- a/third_party/WebKit/Source/core/svg/SVGMarkerElement.h +++ b/third_party/WebKit/Source/core/svg/SVGMarkerElement.h @@ -21,7 +21,6 @@ #ifndef SVGMarkerElement_h #define SVGMarkerElement_h -#include "bindings/core/v8/ExceptionState.h" #include "core/svg/SVGAnimatedAngle.h" #include "core/svg/SVGAnimatedBoolean.h" #include "core/svg/SVGAnimatedEnumeration.h" diff --git a/third_party/WebKit/Source/core/svg/SVGNumber.cpp b/third_party/WebKit/Source/core/svg/SVGNumber.cpp index 3393b60..a20b364 100644 --- a/third_party/WebKit/Source/core/svg/SVGNumber.cpp +++ b/third_party/WebKit/Source/core/svg/SVGNumber.cpp @@ -66,11 +66,11 @@ bool SVGNumber::parse(const CharType*& ptr, const CharType* end) return true; } -void SVGNumber::setValueAsString(const String& string, ExceptionState& exceptionState) +SVGParsingError SVGNumber::setValueAsString(const String& string) { if (string.isEmpty()) { m_value = 0; - return; + return NoError; } bool valid = false; @@ -85,9 +85,10 @@ void SVGNumber::setValueAsString(const String& string, ExceptionState& exception } if (!valid) { - exceptionState.throwDOMException(SyntaxError, "The value provided ('" + string + "') is invalid."); m_value = 0; + return ParsingAttributeFailedError; } + return NoError; } void SVGNumber::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement*) @@ -116,14 +117,13 @@ PassRefPtrWillBeRawPtr<SVGNumber> SVGNumberAcceptPercentage::clone() const return create(m_value); } -void SVGNumberAcceptPercentage::setValueAsString(const String& string, ExceptionState& exceptionState) +SVGParsingError SVGNumberAcceptPercentage::setValueAsString(const String& string) { - bool valid = parseNumberOrPercentage(string, m_value); + if (parseNumberOrPercentage(string, m_value)) + return NoError; - if (!valid) { - exceptionState.throwDOMException(SyntaxError, "The value provided ('" + string + "') is invalid."); - m_value = 0; - } + m_value = 0; + return ParsingAttributeFailedError; } SVGNumberAcceptPercentage::SVGNumberAcceptPercentage(float value) diff --git a/third_party/WebKit/Source/core/svg/SVGNumber.h b/third_party/WebKit/Source/core/svg/SVGNumber.h index 4cd1132..e83b715 100644 --- a/third_party/WebKit/Source/core/svg/SVGNumber.h +++ b/third_party/WebKit/Source/core/svg/SVGNumber.h @@ -31,7 +31,7 @@ #ifndef SVGNumber_h #define SVGNumber_h -#include "bindings/core/v8/ExceptionMessages.h" +#include "core/svg/SVGParsingError.h" #include "core/svg/properties/SVGPropertyHelper.h" namespace blink { @@ -55,7 +55,7 @@ public: void setValue(float value) { m_value = value; } String valueAsString() const override; - virtual void setValueAsString(const String&, ExceptionState&); + virtual SVGParsingError setValueAsString(const String&); void add(PassRefPtrWillBeRawPtr<SVGPropertyBase>, SVGElement*) override; void calculateAnimatedValue(SVGAnimationElement*, float percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBase> from, PassRefPtrWillBeRawPtr<SVGPropertyBase> to, PassRefPtrWillBeRawPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement* contextElement) override; @@ -86,7 +86,7 @@ public: } PassRefPtrWillBeRawPtr<SVGNumber> clone() const override; - void setValueAsString(const String&, ExceptionState&) override; + SVGParsingError setValueAsString(const String&) override; private: explicit SVGNumberAcceptPercentage(float); diff --git a/third_party/WebKit/Source/core/svg/SVGNumberList.cpp b/third_party/WebKit/Source/core/svg/SVGNumberList.cpp index c3a5867..03f74df 100644 --- a/third_party/WebKit/Source/core/svg/SVGNumberList.cpp +++ b/third_party/WebKit/Source/core/svg/SVGNumberList.cpp @@ -69,11 +69,11 @@ bool SVGNumberList::parse(const CharType*& ptr, const CharType* end) return true; } -void SVGNumberList::setValueAsString(const String& value, ExceptionState& exceptionState) +SVGParsingError SVGNumberList::setValueAsString(const String& value) { if (value.isEmpty()) { clear(); - return; + return NoError; } bool valid = false; @@ -88,10 +88,11 @@ void SVGNumberList::setValueAsString(const String& value, ExceptionState& except } if (!valid) { - exceptionState.throwDOMException(SyntaxError, "Problem parsing number list \""+value+"\""); // 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 ParsingAttributeFailedError; } + return NoError; } void SVGNumberList::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement* contextElement) diff --git a/third_party/WebKit/Source/core/svg/SVGNumberList.h b/third_party/WebKit/Source/core/svg/SVGNumberList.h index 40aa370..ef81b5e 100644 --- a/third_party/WebKit/Source/core/svg/SVGNumberList.h +++ b/third_party/WebKit/Source/core/svg/SVGNumberList.h @@ -31,8 +31,8 @@ #ifndef SVGNumberList_h #define SVGNumberList_h -#include "bindings/core/v8/ScriptWrappable.h" #include "core/svg/SVGNumber.h" +#include "core/svg/SVGParsingError.h" #include "core/svg/properties/SVGListPropertyHelper.h" namespace blink { @@ -50,7 +50,7 @@ public: ~SVGNumberList() override; - void setValueAsString(const String&, ExceptionState&); + SVGParsingError setValueAsString(const String&); // SVGPropertyBase: String valueAsString() const override; diff --git a/third_party/WebKit/Source/core/svg/SVGNumberOptionalNumber.cpp b/third_party/WebKit/Source/core/svg/SVGNumberOptionalNumber.cpp index e7dad4a..6e90076 100644 --- a/third_party/WebKit/Source/core/svg/SVGNumberOptionalNumber.cpp +++ b/third_party/WebKit/Source/core/svg/SVGNumberOptionalNumber.cpp @@ -73,16 +73,18 @@ String SVGNumberOptionalNumber::valueAsString() const return String::number(m_firstNumber->value()) + " " + String::number(m_secondNumber->value()); } -void SVGNumberOptionalNumber::setValueAsString(const String& value, ExceptionState& exceptionState) +SVGParsingError SVGNumberOptionalNumber::setValueAsString(const String& value) { float x, y; + SVGParsingError parseStatus = NoError; if (!parseNumberOptionalNumber(value, x, y)) { - exceptionState.throwDOMException(SyntaxError, "The value provided ('" + value + "') is invalid."); + parseStatus = ParsingAttributeFailedError; x = y = 0; } m_firstNumber->setValue(x); m_secondNumber->setValue(y); + return parseStatus; } void SVGNumberOptionalNumber::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement*) diff --git a/third_party/WebKit/Source/core/svg/SVGNumberOptionalNumber.h b/third_party/WebKit/Source/core/svg/SVGNumberOptionalNumber.h index 956b5e1..66c637f 100644 --- a/third_party/WebKit/Source/core/svg/SVGNumberOptionalNumber.h +++ b/third_party/WebKit/Source/core/svg/SVGNumberOptionalNumber.h @@ -32,6 +32,7 @@ #define SVGNumberOptionalNumber_h #include "core/svg/SVGNumber.h" +#include "core/svg/SVGParsingError.h" #include "platform/heap/Handle.h" namespace blink { @@ -51,7 +52,7 @@ public: PassRefPtrWillBeRawPtr<SVGPropertyBase> cloneForAnimation(const String&) const override; String valueAsString() const override; - void setValueAsString(const String&, ExceptionState&); + SVGParsingError setValueAsString(const String&); void add(PassRefPtrWillBeRawPtr<SVGPropertyBase>, SVGElement*) override; void calculateAnimatedValue(SVGAnimationElement*, float percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBase> from, PassRefPtrWillBeRawPtr<SVGPropertyBase> to, PassRefPtrWillBeRawPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement* contextElement) override; diff --git a/third_party/WebKit/Source/core/svg/SVGPath.cpp b/third_party/WebKit/Source/core/svg/SVGPath.cpp index d8db81a..0f6500a 100644 --- a/third_party/WebKit/Source/core/svg/SVGPath.cpp +++ b/third_party/WebKit/Source/core/svg/SVGPath.cpp @@ -22,7 +22,6 @@ #include "core/svg/SVGPath.h" -#include "bindings/core/v8/ExceptionState.h" #include "core/SVGNames.h" #include "core/svg/SVGAnimationElement.h" #include "core/svg/SVGPathBlender.h" @@ -94,13 +93,14 @@ PassRefPtrWillBeRawPtr<SVGPath> SVGPath::clone() const return SVGPath::create(m_pathValue); } - -void SVGPath::setValueAsString(const String& string, ExceptionState& exceptionState) +SVGParsingError SVGPath::setValueAsString(const String& string) { + SVGParsingError parseStatus = NoError; OwnPtr<SVGPathByteStream> byteStream = SVGPathByteStream::create(); if (!buildByteStreamFromString(string, *byteStream)) - exceptionState.throwDOMException(SyntaxError, "Problem parsing path \"" + string + "\""); + parseStatus = ParsingAttributeFailedError; m_pathValue = CSSPathValue::create(byteStream.release()); + return parseStatus; } PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGPath::cloneForAnimation(const String& value) const diff --git a/third_party/WebKit/Source/core/svg/SVGPath.h b/third_party/WebKit/Source/core/svg/SVGPath.h index a498add..f27f34c 100644 --- a/third_party/WebKit/Source/core/svg/SVGPath.h +++ b/third_party/WebKit/Source/core/svg/SVGPath.h @@ -32,14 +32,12 @@ #define SVGPath_h #include "core/css/CSSPathValue.h" +#include "core/svg/SVGParsingError.h" #include "core/svg/SVGPathByteStream.h" #include "core/svg/properties/SVGProperty.h" namespace blink { -class ExceptionState; -class Path; - class SVGPath : public SVGPropertyBase { public: typedef void TearOffType; @@ -62,7 +60,7 @@ public: PassRefPtrWillBeRawPtr<SVGPath> clone() const; PassRefPtrWillBeRawPtr<SVGPropertyBase> cloneForAnimation(const String&) const override; String valueAsString() const override; - void setValueAsString(const String&, ExceptionState&); + SVGParsingError setValueAsString(const String&); void add(PassRefPtrWillBeRawPtr<SVGPropertyBase>, SVGElement*) override; void calculateAnimatedValue(SVGAnimationElement*, float percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBase> fromValue, PassRefPtrWillBeRawPtr<SVGPropertyBase> toValue, PassRefPtrWillBeRawPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement*) override; diff --git a/third_party/WebKit/Source/core/svg/SVGPathElement.cpp b/third_party/WebKit/Source/core/svg/SVGPathElement.cpp index 36f5179..b21d54b 100644 --- a/third_party/WebKit/Source/core/svg/SVGPathElement.cpp +++ b/third_party/WebKit/Source/core/svg/SVGPathElement.cpp @@ -36,13 +36,14 @@ public: return adoptRefWillBeNoop(new SVGAnimatedPathLength(contextElement)); } - void setBaseValueAsString(const String& value, SVGParsingError& parseError) override + SVGParsingError setBaseValueAsString(const String& value) override { - SVGAnimatedNumber::setBaseValueAsString(value, parseError); + SVGParsingError parseStatus = SVGAnimatedNumber::setBaseValueAsString(value); ASSERT(contextElement()); - if (parseError == NoError && baseValue()->value() < 0) + if (parseStatus == NoError && baseValue()->value() < 0) contextElement()->document().accessSVGExtensions().reportError("A negative value for path attribute <pathLength> is not allowed"); + return parseStatus; } private: diff --git a/third_party/WebKit/Source/core/svg/SVGPoint.cpp b/third_party/WebKit/Source/core/svg/SVGPoint.cpp index f50d2fb..8f0c894 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 diff --git a/third_party/WebKit/Source/core/svg/SVGPoint.h b/third_party/WebKit/Source/core/svg/SVGPoint.h index 5393a90..ec513b7 100644 --- a/third_party/WebKit/Source/core/svg/SVGPoint.h +++ b/third_party/WebKit/Source/core/svg/SVGPoint.h @@ -31,6 +31,7 @@ #ifndef SVGPoint_h #define SVGPoint_h +#include "core/svg/SVGParsingError.h" #include "core/svg/properties/SVGPropertyHelper.h" #include "platform/geometry/FloatPoint.h" @@ -66,7 +67,7 @@ public: FloatPoint matrixTransform(const AffineTransform&) const; String valueAsString() const override; - void setValueAsString(const String&, ExceptionState&); + SVGParsingError setValueAsString(const String&); void add(PassRefPtrWillBeRawPtr<SVGPropertyBase>, SVGElement*) override; void calculateAnimatedValue(SVGAnimationElement*, float percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBase> from, PassRefPtrWillBeRawPtr<SVGPropertyBase> to, PassRefPtrWillBeRawPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement* contextElement) override; @@ -79,7 +80,7 @@ private: explicit SVGPoint(const FloatPoint&); template<typename CharType> - void parse(const CharType*& ptr, const CharType* end, ExceptionState&); + bool parse(const CharType*& ptr, const CharType* end); FloatPoint m_value; }; diff --git a/third_party/WebKit/Source/core/svg/SVGPointList.cpp b/third_party/WebKit/Source/core/svg/SVGPointList.cpp index d1b2ac7..117969e 100644 --- a/third_party/WebKit/Source/core/svg/SVGPointList.cpp +++ b/third_party/WebKit/Source/core/svg/SVGPointList.cpp @@ -88,11 +88,11 @@ bool SVGPointList::parse(const CharType*& ptr, const CharType* end) } } -void SVGPointList::setValueAsString(const String& value, ExceptionState& exceptionState) +SVGParsingError SVGPointList::setValueAsString(const String& value) { if (value.isEmpty()) { clear(); - return; + return NoError; } bool valid = false; @@ -105,9 +105,7 @@ void SVGPointList::setValueAsString(const String& value, ExceptionState& excepti const UChar* end = ptr + value.length(); valid = parse(ptr, end); } - - if (!valid) - exceptionState.throwDOMException(SyntaxError, "Problem parsing points=\""+value+"\""); + return valid ? NoError : ParsingAttributeFailedError; } void SVGPointList::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement* contextElement) diff --git a/third_party/WebKit/Source/core/svg/SVGPointList.h b/third_party/WebKit/Source/core/svg/SVGPointList.h index 8a8e00c..b5052e4 100644 --- a/third_party/WebKit/Source/core/svg/SVGPointList.h +++ b/third_party/WebKit/Source/core/svg/SVGPointList.h @@ -31,7 +31,7 @@ #ifndef SVGPointList_h #define SVGPointList_h -#include "bindings/core/v8/ScriptWrappable.h" +#include "core/svg/SVGParsingError.h" #include "core/svg/SVGPoint.h" #include "core/svg/properties/SVGListPropertyHelper.h" @@ -50,7 +50,7 @@ public: ~SVGPointList() override; - void setValueAsString(const String&, ExceptionState&); + SVGParsingError setValueAsString(const String&); // SVGPropertyBase: String valueAsString() const override; diff --git a/third_party/WebKit/Source/core/svg/SVGPreserveAspectRatio.cpp b/third_party/WebKit/Source/core/svg/SVGPreserveAspectRatio.cpp index 04c5d5a..5ec1b4f 100644 --- a/third_party/WebKit/Source/core/svg/SVGPreserveAspectRatio.cpp +++ b/third_party/WebKit/Source/core/svg/SVGPreserveAspectRatio.cpp @@ -21,9 +21,6 @@ #include "core/svg/SVGPreserveAspectRatio.h" -#include "bindings/core/v8/ExceptionState.h" -#include "bindings/core/v8/ExceptionStatePlaceholder.h" -#include "core/dom/ExceptionCode.h" #include "core/svg/SVGAnimationElement.h" #include "core/svg/SVGParserUtilities.h" #include "platform/geometry/FloatRect.h" @@ -151,12 +148,12 @@ bool SVGPreserveAspectRatio::parseInternal(const CharType*& ptr, const CharType* return true; } -void SVGPreserveAspectRatio::setValueAsString(const String& string, ExceptionState& exceptionState) +SVGParsingError SVGPreserveAspectRatio::setValueAsString(const String& string) { setDefault(); if (string.isEmpty()) - return; + return NoError; bool valid = false; if (string.is8Bit()) { @@ -168,10 +165,7 @@ void SVGPreserveAspectRatio::setValueAsString(const String& string, ExceptionSta const UChar* end = ptr + string.length(); valid = parseInternal(ptr, end, true); } - - if (!valid) { - exceptionState.throwDOMException(SyntaxError, "The value provided ('" + string + "') is invalid."); - } + return valid ? NoError : ParsingAttributeFailedError; } bool SVGPreserveAspectRatio::parse(const LChar*& ptr, const LChar* end, bool validate) diff --git a/third_party/WebKit/Source/core/svg/SVGPreserveAspectRatio.h b/third_party/WebKit/Source/core/svg/SVGPreserveAspectRatio.h index 7474aca4..0bd39e0 100644 --- a/third_party/WebKit/Source/core/svg/SVGPreserveAspectRatio.h +++ b/third_party/WebKit/Source/core/svg/SVGPreserveAspectRatio.h @@ -21,6 +21,7 @@ #ifndef SVGPreserveAspectRatio_h #define SVGPreserveAspectRatio_h +#include "core/svg/SVGParsingError.h" #include "core/svg/properties/SVGPropertyHelper.h" namespace blink { @@ -76,7 +77,7 @@ public: float physWidth, float physHeight) const; String valueAsString() const override; - virtual void setValueAsString(const String&, ExceptionState&); + SVGParsingError setValueAsString(const String&); bool parse(const UChar*& ptr, const UChar* end, bool validate); bool parse(const LChar*& ptr, const LChar* end, bool validate); diff --git a/third_party/WebKit/Source/core/svg/SVGRect.cpp b/third_party/WebKit/Source/core/svg/SVGRect.cpp index 1574a96..a8f6970 100644 --- a/third_party/WebKit/Source/core/svg/SVGRect.cpp +++ b/third_party/WebKit/Source/core/svg/SVGRect.cpp @@ -21,8 +21,6 @@ #include "core/svg/SVGRect.h" -#include "bindings/core/v8/ExceptionState.h" -#include "core/dom/ExceptionCode.h" #include "core/svg/SVGAnimationElement.h" #include "core/svg/SVGParserUtilities.h" #include "wtf/text/StringBuilder.h" @@ -47,10 +45,8 @@ PassRefPtrWillBeRawPtr<SVGRect> SVGRect::clone() const } template<typename CharType> -void SVGRect::parse(const CharType*& ptr, const CharType* end, ExceptionState& exceptionState) +bool SVGRect::parse(const CharType*& ptr, const CharType* end) { - const CharType* start = ptr; - skipOptionalSVGSpaces(ptr, end); float x = 0.0f; @@ -59,45 +55,43 @@ void SVGRect::parse(const CharType*& ptr, const CharType* end, ExceptionState& e 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) { - exceptionState.throwDOMException(SyntaxError, "Problem parsing rect \"" + String(start, end - start) + "\""); - setInvalid(); - return; - } + if (!valid) + return false; - skipOptionalSVGSpaces(ptr, end); - if (ptr < end) { // nothing should come after the last, fourth number - exceptionState.throwDOMException(SyntaxError, "Problem parsing rect \"" + String(start, end - start) + "\""); - setInvalid(); - return; + if (skipOptionalSVGSpaces(ptr, end)) { + // Nothing should come after the last, fourth number. + return false; } m_value = FloatRect(x, y, width, height); m_isValid = true; + return true; } -void SVGRect::setValueAsString(const String& string, ExceptionState& exceptionState) +SVGParsingError SVGRect::setValueAsString(const String& string) { - if (string.isNull()) { - setInvalid(); - return; - } + setInvalid(); + + if (string.isNull()) + return NoError; + if (string.isEmpty()) { m_value = FloatRect(0.0f, 0.0f, 0.0f, 0.0f); m_isValid = true; - 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 SVGRect::valueAsString() const diff --git a/third_party/WebKit/Source/core/svg/SVGRect.h b/third_party/WebKit/Source/core/svg/SVGRect.h index 88d9c77..bee8df8 100644 --- a/third_party/WebKit/Source/core/svg/SVGRect.h +++ b/third_party/WebKit/Source/core/svg/SVGRect.h @@ -20,6 +20,7 @@ #ifndef SVGRect_h #define SVGRect_h +#include "core/svg/SVGParsingError.h" #include "core/svg/properties/SVGPropertyHelper.h" #include "platform/geometry/FloatRect.h" #include "wtf/Allocator.h" @@ -64,7 +65,7 @@ public: void setHeight(float f) { m_value.setHeight(f); } String valueAsString() const override; - void setValueAsString(const String&, ExceptionState&); + SVGParsingError setValueAsString(const String&); void add(PassRefPtrWillBeRawPtr<SVGPropertyBase>, SVGElement*) override; void calculateAnimatedValue(SVGAnimationElement*, float percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBase> from, PassRefPtrWillBeRawPtr<SVGPropertyBase> to, PassRefPtrWillBeRawPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement* contextElement) override; @@ -80,7 +81,7 @@ private: SVGRect(const FloatRect&); template<typename CharType> - void parse(const CharType*& ptr, const CharType* end, ExceptionState&); + bool parse(const CharType*& ptr, const CharType* end); bool m_isValid; FloatRect m_value; diff --git a/third_party/WebKit/Source/core/svg/SVGStaticStringList.cpp b/third_party/WebKit/Source/core/svg/SVGStaticStringList.cpp index 5853162..09e6b38 100644 --- a/third_party/WebKit/Source/core/svg/SVGStaticStringList.cpp +++ b/third_party/WebKit/Source/core/svg/SVGStaticStringList.cpp @@ -97,14 +97,9 @@ SVGStringListTearOff* SVGStaticStringList::tearOff() return m_tearOff.get(); } -void SVGStaticStringList::setBaseValueAsString(const String& value, SVGParsingError& parseError) +SVGParsingError SVGStaticStringList::setBaseValueAsString(const String& value) { - TrackExceptionState es; - - m_value->setValueAsString(value, es); - - if (es.hadException()) - parseError = ParsingAttributeFailedError; + return m_value->setValueAsString(value); } } diff --git a/third_party/WebKit/Source/core/svg/SVGStaticStringList.h b/third_party/WebKit/Source/core/svg/SVGStaticStringList.h index 7eccaab..d71ad55 100644 --- a/third_party/WebKit/Source/core/svg/SVGStaticStringList.h +++ b/third_party/WebKit/Source/core/svg/SVGStaticStringList.h @@ -59,7 +59,7 @@ public: void animationEnded() override; bool needsSynchronizeAttribute() override; - void setBaseValueAsString(const String& value, SVGParsingError& parseError); + SVGParsingError setBaseValueAsString(const String&); SVGStringList* value() { return m_value.get(); } SVGStringListTearOff* tearOff(); diff --git a/third_party/WebKit/Source/core/svg/SVGString.h b/third_party/WebKit/Source/core/svg/SVGString.h index d7472ff..7388e99 100644 --- a/third_party/WebKit/Source/core/svg/SVGString.h +++ b/third_party/WebKit/Source/core/svg/SVGString.h @@ -31,12 +31,11 @@ #ifndef SVGString_h #define SVGString_h +#include "core/svg/SVGParsingError.h" #include "core/svg/properties/SVGProperty.h" namespace blink { -class ExceptionState; - class SVGString : public SVGPropertyBase { public: // SVGString does not have a tear-off type. @@ -60,7 +59,11 @@ public: } String valueAsString() const override { return m_value; } - void setValueAsString(const String& value, ExceptionState&) { m_value = value; } + SVGParsingError setValueAsString(const String& value) + { + m_value = value; + return NoError; + } void add(PassRefPtrWillBeRawPtr<SVGPropertyBase>, SVGElement*) override; void calculateAnimatedValue(SVGAnimationElement*, float percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBase> from, PassRefPtrWillBeRawPtr<SVGPropertyBase> to, PassRefPtrWillBeRawPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement*) override; diff --git a/third_party/WebKit/Source/core/svg/SVGStringList.cpp b/third_party/WebKit/Source/core/svg/SVGStringList.cpp index 565070c..120a4d38 100644 --- a/third_party/WebKit/Source/core/svg/SVGStringList.cpp +++ b/third_party/WebKit/Source/core/svg/SVGStringList.cpp @@ -102,12 +102,14 @@ void SVGStringList::parseInternal(const CharType*& ptr, const CharType* end) } } -void SVGStringList::setValueAsString(const String& data, ExceptionState&) +SVGParsingError SVGStringList::setValueAsString(const String& data) { // FIXME: Add more error checking and reporting. m_values.clear(); + if (data.isEmpty()) - return; + return NoError; + if (data.is8Bit()) { const LChar* ptr = data.characters8(); const LChar* end = ptr + data.length(); @@ -117,6 +119,7 @@ void SVGStringList::setValueAsString(const String& data, ExceptionState&) const UChar* end = ptr + data.length(); parseInternal(ptr, end); } + return NoError; } String SVGStringList::valueAsString() const diff --git a/third_party/WebKit/Source/core/svg/SVGStringList.h b/third_party/WebKit/Source/core/svg/SVGStringList.h index a787c52..c11286b 100644 --- a/third_party/WebKit/Source/core/svg/SVGStringList.h +++ b/third_party/WebKit/Source/core/svg/SVGStringList.h @@ -31,12 +31,13 @@ #ifndef SVGStringList_h #define SVGStringList_h -#include "bindings/core/v8/ScriptWrappable.h" +#include "core/svg/SVGParsingError.h" #include "core/svg/SVGString.h" #include "core/svg/properties/SVGPropertyHelper.h" namespace blink { +class ExceptionState; class SVGStringListTearOff; // Implementation of SVGStringList spec: @@ -74,7 +75,7 @@ public: void replaceItem(const String&, size_t, ExceptionState&); // SVGPropertyBase: - void setValueAsString(const String&, ExceptionState&); + SVGParsingError setValueAsString(const String&); String valueAsString() const override; void add(PassRefPtrWillBeRawPtr<SVGPropertyBase>, SVGElement*) override; diff --git a/third_party/WebKit/Source/core/svg/SVGTransformList.cpp b/third_party/WebKit/Source/core/svg/SVGTransformList.cpp index 6076f5f..28861ba 100644 --- a/third_party/WebKit/Source/core/svg/SVGTransformList.cpp +++ b/third_party/WebKit/Source/core/svg/SVGTransformList.cpp @@ -266,11 +266,11 @@ String SVGTransformList::valueAsString() const return builder.toString(); } -void SVGTransformList::setValueAsString(const String& value, ExceptionState& exceptionState) +SVGParsingError SVGTransformList::setValueAsString(const String& value) { if (value.isEmpty()) { clear(); - return; + return NoError; } bool valid = false; @@ -286,8 +286,10 @@ void SVGTransformList::setValueAsString(const String& value, ExceptionState& exc if (!valid) { clear(); - exceptionState.throwDOMException(SyntaxError, "Problem parsing transform list=\""+value+"\""); + return ParsingAttributeFailedError; } + + return NoError; } PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGTransformList::cloneForAnimation(const String& value) const diff --git a/third_party/WebKit/Source/core/svg/SVGTransformList.h b/third_party/WebKit/Source/core/svg/SVGTransformList.h index 5c9a5e4..bfed98d 100644 --- a/third_party/WebKit/Source/core/svg/SVGTransformList.h +++ b/third_party/WebKit/Source/core/svg/SVGTransformList.h @@ -31,7 +31,7 @@ #ifndef SVGTransformList_h #define SVGTransformList_h -#include "bindings/core/v8/ScriptWrappable.h" +#include "core/svg/SVGParsingError.h" #include "core/svg/SVGTransform.h" #include "core/svg/properties/SVGListPropertyHelper.h" @@ -59,7 +59,7 @@ public: // SVGPropertyBase: PassRefPtrWillBeRawPtr<SVGPropertyBase> cloneForAnimation(const String&) const override; String valueAsString() const override; - void setValueAsString(const String&, ExceptionState&); + SVGParsingError setValueAsString(const String&); bool parse(const UChar*& ptr, const UChar* end); bool parse(const LChar*& ptr, const LChar* end); diff --git a/third_party/WebKit/Source/core/svg/properties/SVGAnimatedProperty.h b/third_party/WebKit/Source/core/svg/properties/SVGAnimatedProperty.h index 85008ba..c5f8427 100644 --- a/third_party/WebKit/Source/core/svg/properties/SVGAnimatedProperty.h +++ b/third_party/WebKit/Source/core/svg/properties/SVGAnimatedProperty.h @@ -60,7 +60,7 @@ public: virtual void setAnimatedValue(PassRefPtrWillBeRawPtr<SVGPropertyBase>) = 0; virtual void animationEnded(); - virtual void setBaseValueAsString(const String& value, SVGParsingError& parseError) = 0; + virtual SVGParsingError setBaseValueAsString(const String&) = 0; virtual bool needsSynchronizeAttribute() = 0; virtual void synchronizeAttribute(); @@ -143,14 +143,9 @@ public: return m_currentValue; } - void setBaseValueAsString(const String& value, SVGParsingError& parseError) override + SVGParsingError setBaseValueAsString(const String& value) override { - TrackExceptionState es; - - m_baseValue->setValueAsString(value, es); - - if (es.hadException()) - parseError = ParsingAttributeFailedError; + return m_baseValue->setValueAsString(value); } PassRefPtrWillBeRawPtr<SVGPropertyBase> createAnimatedValue() override diff --git a/third_party/WebKit/Source/core/svg/properties/SVGPropertyHelper.h b/third_party/WebKit/Source/core/svg/properties/SVGPropertyHelper.h index aa1b1e5..866d1e5 100644 --- a/third_party/WebKit/Source/core/svg/properties/SVGPropertyHelper.h +++ b/third_party/WebKit/Source/core/svg/properties/SVGPropertyHelper.h @@ -5,7 +5,6 @@ #ifndef SVGPropertyHelper_h #define SVGPropertyHelper_h -#include "bindings/core/v8/ExceptionStatePlaceholder.h" #include "core/svg/properties/SVGProperty.h" namespace blink { @@ -21,7 +20,7 @@ public: virtual PassRefPtrWillBeRawPtr<SVGPropertyBase> cloneForAnimation(const String& value) const { RefPtrWillBeRawPtr<Derived> property = Derived::create(); - property->setValueAsString(value, IGNORE_EXCEPTION); + property->setValueAsString(value); return property.release(); } }; |