Title: [142261] trunk/Source/WebCore
Revision
142261
Author
[email protected]
Date
2013-02-08 04:54:55 -0800 (Fri, 08 Feb 2013)

Log Message

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.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (142260 => 142261)


--- trunk/Source/WebCore/ChangeLog	2013-02-08 12:45:44 UTC (rev 142260)
+++ trunk/Source/WebCore/ChangeLog	2013-02-08 12:54:55 UTC (rev 142261)
@@ -1,3 +1,48 @@
+2013-02-08  Mike West  <[email protected]>
+
+        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  <[email protected]>
 
         Web Inspector: Replace workspace with project in UISourceCode constructor.

Modified: trunk/Source/WebCore/rendering/style/SVGRenderStyle.h (142260 => 142261)


--- trunk/Source/WebCore/rendering/style/SVGRenderStyle.h	2013-02-08 12:45:44 UTC (rev 142260)
+++ trunk/Source/WebCore/rendering/style/SVGRenderStyle.h	2013-02-08 12:54:55 UTC (rev 142261)
@@ -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 @@
     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;
     }
 

Modified: trunk/Source/WebCore/svg/SVGAnimatedLength.cpp (142260 => 142261)


--- trunk/Source/WebCore/svg/SVGAnimatedLength.cpp	2013-02-08 12:45:44 UTC (rev 142260)
+++ trunk/Source/WebCore/svg/SVGAnimatedLength.cpp	2013-02-08 12:54:55 UTC (rev 142261)
@@ -36,9 +36,7 @@
 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 @@
     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 @@
     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)

Modified: trunk/Source/WebCore/svg/SVGAnimatedLengthList.cpp (142260 => 142261)


--- trunk/Source/WebCore/svg/SVGAnimatedLengthList.cpp	2013-02-08 12:45:44 UTC (rev 142260)
+++ trunk/Source/WebCore/svg/SVGAnimatedLengthList.cpp	2013-02-08 12:54:55 UTC (rev 142261)
@@ -78,11 +78,8 @@
         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 @@
     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 @@
         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);
     }
 }
 

Modified: trunk/Source/WebCore/svg/SVGLength.cpp (142260 => 142261)


--- trunk/Source/WebCore/svg/SVGLength.cpp	2013-02-08 12:45:44 UTC (rev 142260)
+++ trunk/Source/WebCore/svg/SVGLength.cpp	2013-02-08 12:54:55 UTC (rev 142261)
@@ -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 @@
     : 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 @@
     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;

Modified: trunk/Source/WebCore/svg/SVGTextContentElement.cpp (142260 => 142261)


--- trunk/Source/WebCore/svg/SVGTextContentElement.cpp	2013-02-08 12:45:44 UTC (rev 142260)
+++ trunk/Source/WebCore/svg/SVGTextContentElement.cpp	2013-02-08 12:54:55 UTC (rev 142261)
@@ -95,11 +95,8 @@
 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));

Modified: trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp (142260 => 142261)


--- trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp	2013-02-08 12:45:44 UTC (rev 142260)
+++ trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp	2013-02-08 12:54:55 UTC (rev 142261)
@@ -202,10 +202,8 @@
     
     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())
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to