Migrate ExceptionCode ASSERTs in SVG to ASSERT_NO_EXCEPTION.
authormkwst@chromium.org <mkwst@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Feb 2013 12:54:55 +0000 (12:54 +0000)
committermkwst@chromium.org <mkwst@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Feb 2013 12:54:55 +0000 (12:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=109267

Reviewed by Jochen Eisinger.

The pattern:

    ExceptionCode ec = 0;
    methodThatGeneratesException(ec);
    ASSERT(!ec);

is more clearly and succinctly written as:

    methodThatGeneratesException(ASSERT_NO_EXCEPTION);

This patch replaces the occurances of the former in SVG code that never
touch 'ec' again with the latter. No change in behavior should result
from this refactoring.

* svg/SVGLength.cpp:
(WebCore::SVGLength::SVGLength):
(WebCore::SVGLength::setValue):
    This method checked the value of the ExceptionCode without first
    initializing it to 0. Now it initializes before doing potentially
    exception-generating work.
* rendering/style/SVGRenderStyle.h:
(WebCore::SVGRenderStyle::initialBaselineShiftValue):
(WebCore::SVGRenderStyle::initialKerning):
(WebCore::SVGRenderStyle::initialStrokeDashOffset):
(WebCore::SVGRenderStyle::initialStrokeWidth):
* svg/SVGAnimatedLength.cpp:
(WebCore::sharedSVGLength):
(WebCore::SVGAnimatedLengthAnimator::addAnimatedTypes):
(WebCore::SVGAnimatedLengthAnimator::calculateAnimatedValue):
* svg/SVGAnimatedLengthList.cpp:
(WebCore::SVGAnimatedLengthListAnimator::addAnimatedTypes):
(WebCore::SVGAnimatedLengthListAnimator::calculateAnimatedValue):
* svg/SVGTextContentElement.cpp:
(WebCore::SVGTextContentElement::textLengthAnimated):
* svg/animation/SVGSMILElement.cpp:
(WebCore::constructQualifiedName):
    Replace the above pattern with ASSERT_NO_EXCEPTION.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@142261 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/rendering/style/SVGRenderStyle.h
Source/WebCore/svg/SVGAnimatedLength.cpp
Source/WebCore/svg/SVGAnimatedLengthList.cpp
Source/WebCore/svg/SVGLength.cpp
Source/WebCore/svg/SVGTextContentElement.cpp
Source/WebCore/svg/animation/SVGSMILElement.cpp

index 71cc3f7..0a79dc9 100644 (file)
@@ -1,3 +1,48 @@
+2013-02-08  Mike West  <mkwst@chromium.org>
+
+        Migrate ExceptionCode ASSERTs in SVG to ASSERT_NO_EXCEPTION.
+        https://bugs.webkit.org/show_bug.cgi?id=109267
+
+        Reviewed by Jochen Eisinger.
+
+        The pattern:
+
+            ExceptionCode ec = 0;
+            methodThatGeneratesException(ec);
+            ASSERT(!ec);
+
+        is more clearly and succinctly written as:
+
+            methodThatGeneratesException(ASSERT_NO_EXCEPTION);
+
+        This patch replaces the occurances of the former in SVG code that never
+        touch 'ec' again with the latter. No change in behavior should result
+        from this refactoring.
+
+        * svg/SVGLength.cpp:
+        (WebCore::SVGLength::SVGLength):
+        (WebCore::SVGLength::setValue):
+            This method checked the value of the ExceptionCode without first
+            initializing it to 0. Now it initializes before doing potentially
+            exception-generating work.
+        * rendering/style/SVGRenderStyle.h:
+        (WebCore::SVGRenderStyle::initialBaselineShiftValue):
+        (WebCore::SVGRenderStyle::initialKerning):
+        (WebCore::SVGRenderStyle::initialStrokeDashOffset):
+        (WebCore::SVGRenderStyle::initialStrokeWidth):
+        * svg/SVGAnimatedLength.cpp:
+        (WebCore::sharedSVGLength):
+        (WebCore::SVGAnimatedLengthAnimator::addAnimatedTypes):
+        (WebCore::SVGAnimatedLengthAnimator::calculateAnimatedValue):
+        * svg/SVGAnimatedLengthList.cpp:
+        (WebCore::SVGAnimatedLengthListAnimator::addAnimatedTypes):
+        (WebCore::SVGAnimatedLengthListAnimator::calculateAnimatedValue):
+        * svg/SVGTextContentElement.cpp:
+        (WebCore::SVGTextContentElement::textLengthAnimated):
+        * svg/animation/SVGSMILElement.cpp:
+        (WebCore::constructQualifiedName):
+            Replace the above pattern with ASSERT_NO_EXCEPTION.
+
 2013-02-08  Vsevolod Vlasov  <vsevik@chromium.org>
 
         Web Inspector: Replace workspace with project in UISourceCode constructor.
index be0a479..ee69db6 100644 (file)
@@ -26,6 +26,7 @@
 #if ENABLE(SVG)
 #include "CSSValueList.h"
 #include "DataRef.h"
+#include "ExceptionCodePlaceholder.h"
 #include "GraphicsTypes.h"
 #include "Path.h"
 #include "RenderStyleConstants.h"
@@ -97,36 +98,28 @@ public:
     static SVGLength initialBaselineShiftValue()
     {
         SVGLength length;
-        ExceptionCode ec = 0;
-        length.newValueSpecifiedUnits(LengthTypeNumber, 0, ec);
-        ASSERT(!ec);
+        length.newValueSpecifiedUnits(LengthTypeNumber, 0, ASSERT_NO_EXCEPTION);
         return length;
     }
 
     static SVGLength initialKerning()
     {
         SVGLength length;
-        ExceptionCode ec = 0;
-        length.newValueSpecifiedUnits(LengthTypeNumber, 0, ec);
-        ASSERT(!ec);
+        length.newValueSpecifiedUnits(LengthTypeNumber, 0, ASSERT_NO_EXCEPTION);
         return length;
     }
 
     static SVGLength initialStrokeDashOffset()
     {
         SVGLength length;
-        ExceptionCode ec = 0;
-        length.newValueSpecifiedUnits(LengthTypeNumber, 0, ec);
-        ASSERT(!ec);
+        length.newValueSpecifiedUnits(LengthTypeNumber, 0, ASSERT_NO_EXCEPTION);
         return length;
     }
 
     static SVGLength initialStrokeWidth()
     {
         SVGLength length;
-        ExceptionCode ec = 0;
-        length.newValueSpecifiedUnits(LengthTypeNumber, 1, ec);
-        ASSERT(!ec);
+        length.newValueSpecifiedUnits(LengthTypeNumber, 1, ASSERT_NO_EXCEPTION);
         return length;
     }
 
index 7c26ebd..0ac8bf0 100644 (file)
@@ -36,9 +36,7 @@ SVGAnimatedLengthAnimator::SVGAnimatedLengthAnimator(SVGAnimationElement* animat
 static inline SVGLength& sharedSVGLength(SVGLengthMode mode, const String& valueAsString)
 {
     DEFINE_STATIC_LOCAL(SVGLength, sharedLength, ());
-    ExceptionCode ec = 0;
-    sharedLength.setValueAsString(valueAsString, mode, ec);
-    ASSERT(!ec);
+    sharedLength.setValueAsString(valueAsString, mode, ASSERT_NO_EXCEPTION);
     return sharedLength;
 }
 
@@ -81,9 +79,7 @@ void SVGAnimatedLengthAnimator::addAnimatedTypes(SVGAnimatedType* from, SVGAnima
     const SVGLength& fromLength = from->length();
     SVGLength& toLength = to->length();
 
-    ExceptionCode ec = 0;
-    toLength.setValue(toLength.value(lengthContext) + fromLength.value(lengthContext), lengthContext, ec);
-    ASSERT(!ec);
+    toLength.setValue(toLength.value(lengthContext) + fromLength.value(lengthContext), lengthContext, ASSERT_NO_EXCEPTION);
 }
 
 static SVGLength parseLengthFromString(SVGAnimationElement* animationElement, const String& string)
@@ -110,9 +106,7 @@ void SVGAnimatedLengthAnimator::calculateAnimatedValue(float percentage, unsigne
     SVGLengthType unitType = percentage < 0.5 ? fromSVGLength.unitType() : toSVGLength.unitType();
     m_animationElement->animateAdditiveNumber(percentage, repeatCount, fromSVGLength.value(lengthContext), toSVGLength.value(lengthContext), toAtEndOfDurationSVGLength.value(lengthContext), animatedNumber);
 
-    ExceptionCode ec = 0;
-    animatedSVGLength.setValue(lengthContext, animatedNumber, m_lengthMode, unitType, ec);
-    ASSERT(!ec);
+    animatedSVGLength.setValue(lengthContext, animatedNumber, m_lengthMode, unitType, ASSERT_NO_EXCEPTION);
 }
 
 float SVGAnimatedLengthAnimator::calculateDistance(const String& fromString, const String& toString)
index 812b90a..b6a23ac 100644 (file)
@@ -78,11 +78,8 @@ void SVGAnimatedLengthListAnimator::addAnimatedTypes(SVGAnimatedType* from, SVGA
         return;
 
     SVGLengthContext lengthContext(m_contextElement);
-    ExceptionCode ec = 0;
-    for (unsigned i = 0; i < fromLengthListSize; ++i) {
-        toLengthList[i].setValue(toLengthList[i].value(lengthContext) + fromLengthList[i].value(lengthContext), lengthContext, ec);
-        ASSERT(!ec);
-    }
+    for (unsigned i = 0; i < fromLengthListSize; ++i)
+        toLengthList[i].setValue(toLengthList[i].value(lengthContext) + fromLengthList[i].value(lengthContext), lengthContext, ASSERT_NO_EXCEPTION);
 }
 
 static SVGLengthList parseLengthListFromString(SVGAnimationElement* animationElement, const String& string)
@@ -114,7 +111,6 @@ void SVGAnimatedLengthListAnimator::calculateAnimatedValue(float percentage, uns
     unsigned toAtEndOfDurationListSize = toAtEndOfDurationLengthList.size();
 
     SVGLengthContext lengthContext(m_contextElement);
-    ExceptionCode ec = 0;
     for (unsigned i = 0; i < toLengthListSize; ++i) {
         float animatedNumber = animatedLengthList[i].value(lengthContext);
         SVGLengthType unitType = toLengthList[i].unitType();
@@ -127,8 +123,7 @@ void SVGAnimatedLengthListAnimator::calculateAnimatedValue(float percentage, uns
         float effectiveToAtEnd = i < toAtEndOfDurationListSize ? toAtEndOfDurationLengthList[i].value(lengthContext) : 0;
 
         m_animationElement->animateAdditiveNumber(percentage, repeatCount, effectiveFrom, toLengthList[i].value(lengthContext), effectiveToAtEnd, animatedNumber);
-        animatedLengthList[i].setValue(lengthContext, animatedNumber, m_lengthMode, unitType, ec);
-        ASSERT(!ec);
+        animatedLengthList[i].setValue(lengthContext, animatedNumber, m_lengthMode, unitType, ASSERT_NO_EXCEPTION);
     }
 }
 
index bf5bf42..34a4195 100644 (file)
@@ -27,6 +27,7 @@
 #include "CSSHelper.h"
 #include "CSSPrimitiveValue.h"
 #include "ExceptionCode.h"
+#include "ExceptionCodePlaceholder.h"
 #include "FloatConversion.h"
 #include "SVGNames.h"
 #include "SVGParserUtilities.h"
@@ -132,9 +133,7 @@ SVGLength::SVGLength(const SVGLengthContext& context, float value, SVGLengthMode
     : m_valueInSpecifiedUnits(0)
     , m_unit(storeUnit(mode, unitType))
 {
-    ExceptionCode ec = 0;
-    setValue(value, context, ec);
-    ASSERT(!ec);
+    setValue(value, context, ASSERT_NO_EXCEPTION);
 }
 
 SVGLength::SVGLength(const SVGLength& other)
@@ -209,6 +208,7 @@ void SVGLength::setValue(float value, const SVGLengthContext& context, Exception
     if (extractType(m_unit) == LengthTypePercentage)
         value = value / 100;
 
+    ec = 0;
     float convertedValue = context.convertValueFromUserUnits(value, extractMode(m_unit), extractType(m_unit), ec);
     if (!ec)
         m_valueInSpecifiedUnits = convertedValue;
index 3943ffe..cb86f08 100644 (file)
@@ -95,11 +95,8 @@ PassRefPtr<SVGAnimatedProperty> SVGTextContentElement::lookupOrCreateTextLengthW
 PassRefPtr<SVGAnimatedLength> SVGTextContentElement::textLengthAnimated()
 {
     DEFINE_STATIC_LOCAL(SVGLength, defaultTextLength, (LengthModeOther));
-    if (m_specifiedTextLength == defaultTextLength) {
-        ExceptionCode ec = 0;
-        m_textLength.value.newValueSpecifiedUnits(LengthTypeNumber, getComputedTextLength(), ec);
-        ASSERT(!ec);
-    }
+    if (m_specifiedTextLength == defaultTextLength)
+        m_textLength.value.newValueSpecifiedUnits(LengthTypeNumber, getComputedTextLength(), ASSERT_NO_EXCEPTION);
 
     m_textLength.shouldSynchronize = true;
     return static_pointer_cast<SVGAnimatedLength>(lookupOrCreateTextLengthWrapper(this));
index 677b7e0..cb8a444 100644 (file)
@@ -202,10 +202,8 @@ static inline QualifiedName constructQualifiedName(const SVGElement* svgElement,
     
     String prefix;
     String localName;
-    ExceptionCode ec = 0;
-    if (!Document::parseQualifiedName(attributeName, prefix, localName, ec))
+    if (!Document::parseQualifiedName(attributeName, prefix, localName, ASSERT_NO_EXCEPTION))
         return anyQName();
-    ASSERT(!ec);
     
     String namespaceURI = svgElement->lookupNamespaceURI(prefix);    
     if (namespaceURI.isEmpty())