Reviewed by Darin.
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Nov 2007 04:26:11 +0000 (04:26 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Nov 2007 04:26:11 +0000 (04:26 +0000)
        Fix a bunch of cases where the exception code is checked by the function but is not zeroed first.

        * bindings/js/kjs_binding.cpp:
        (KJS::setDOMException):
        * dom/Attr.cpp:
        (WebCore::Attr::setPrefix):
        * dom/Document.cpp:
        (WebCore::Document::createElement):
        * dom/Element.cpp:
        (WebCore::Element::setPrefix):
        * dom/Range.cpp:
        (WebCore::Range::setStart):
        (WebCore::Range::setEnd):
        (WebCore::Range::isPointInRange):
        (WebCore::Range::comparePoint):
        (WebCore::Range::compareBoundaryPoints):
        (WebCore::Range::deleteContents):
        (WebCore::Range::processContents):
        (WebCore::Range::extractContents):
        (WebCore::Range::insertNode):
        (WebCore::Range::setStartAfter):
        (WebCore::Range::setEndBefore):
        (WebCore::Range::setEndAfter):
        (WebCore::Range::selectNode):
        (WebCore::Range::surroundContents):
        (WebCore::Range::setStartBefore):
        * editing/TextIterator.cpp:
        (WebCore::TextIterator::TextIterator):
        * html/CanvasRenderingContext2D.cpp:
        (WebCore::CanvasRenderingContext2D::createPattern):
        * html/HTMLMediaElement.cpp:
        (WebCore::HTMLMediaElement::play):
        (WebCore::HTMLMediaElement::pause):
        * html/HTMLSelectElement.cpp:
        (WebCore::HTMLSelectElement::add):
        (WebCore::HTMLSelectElement::setOption):
        * xml/XPathEvaluator.cpp:
        (WebCore::XPathEvaluator::evaluate):

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

WebCore/ChangeLog
WebCore/bindings/js/kjs_binding.cpp
WebCore/dom/Attr.cpp
WebCore/dom/Document.cpp
WebCore/dom/Element.cpp
WebCore/dom/Range.cpp
WebCore/editing/TextIterator.cpp
WebCore/html/CanvasRenderingContext2D.cpp
WebCore/html/HTMLMediaElement.cpp
WebCore/html/HTMLSelectElement.cpp
WebCore/xml/XPathEvaluator.cpp

index 6590412..7c6511d 100644 (file)
@@ -1,3 +1,46 @@
+2007-11-11  Antti Koivisto  <antti@apple.com>
+
+        Reviewed by Darin.
+
+        Fix a bunch of cases where the exception code is checked by the function but is not zeroed first.
+
+        * bindings/js/kjs_binding.cpp:
+        (KJS::setDOMException):
+        * dom/Attr.cpp:
+        (WebCore::Attr::setPrefix):
+        * dom/Document.cpp:
+        (WebCore::Document::createElement):
+        * dom/Element.cpp:
+        (WebCore::Element::setPrefix):
+        * dom/Range.cpp:
+        (WebCore::Range::setStart):
+        (WebCore::Range::setEnd):
+        (WebCore::Range::isPointInRange):
+        (WebCore::Range::comparePoint):
+        (WebCore::Range::compareBoundaryPoints):
+        (WebCore::Range::deleteContents):
+        (WebCore::Range::processContents):
+        (WebCore::Range::extractContents):
+        (WebCore::Range::insertNode):
+        (WebCore::Range::setStartAfter):
+        (WebCore::Range::setEndBefore):
+        (WebCore::Range::setEndAfter):
+        (WebCore::Range::selectNode):
+        (WebCore::Range::surroundContents):
+        (WebCore::Range::setStartBefore):
+        * editing/TextIterator.cpp:
+        (WebCore::TextIterator::TextIterator):
+        * html/CanvasRenderingContext2D.cpp:
+        (WebCore::CanvasRenderingContext2D::createPattern):
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::play):
+        (WebCore::HTMLMediaElement::pause):
+        * html/HTMLSelectElement.cpp:
+        (WebCore::HTMLSelectElement::add):
+        (WebCore::HTMLSelectElement::setOption):
+        * xml/XPathEvaluator.cpp:
+        (WebCore::XPathEvaluator::evaluate):
+
 2007-11-11  Darin Adler  <darin@apple.com>
 
         Reviewed by Mitz.
index eb27fa9..0e186a2 100644 (file)
@@ -402,7 +402,7 @@ static const char* const svgExceptionNames[] = {
 
 void setDOMException(ExecState* exec, ExceptionCode ec)
 {
-    if (ec == 0 || exec->hadException())
+    if (!ec || exec->hadException())
         return;
 
     const char* type = "DOM";
index 5573cc3..866c6d5 100644 (file)
@@ -88,6 +88,7 @@ const AtomicString& Attr::prefix() const
 
 void Attr::setPrefix(const AtomicString &_prefix, ExceptionCode& ec)
 {
+    ec = 0;
     checkSetPrefix(_prefix, ec);
     if (ec)
         return;
index de8d4e8..2437c89 100644 (file)
@@ -711,6 +711,7 @@ PassRefPtr<Element> Document::createElement(const QualifiedName& qName, bool cre
         e = new Element(qName, document());
     
     if (e && !qName.prefix().isNull()) {
+        ec = 0;
         e->setPrefix(qName.prefix(), ec);
         if (ec)
             return 0;
index d16e5ba..3df69f0 100644 (file)
@@ -550,6 +550,7 @@ String Element::nodeNamePreservingCase() const
 
 void Element::setPrefix(const AtomicString &_prefix, ExceptionCode& ec)
 {
+    ec = 0;
     checkSetPrefix(_prefix, ec);
     if (ec)
         return;
index 3fe5f71..2fb23cf 100644 (file)
@@ -213,7 +213,8 @@ void Range::setStart( Node *refNode, int offset, ExceptionCode& ec)
         return;
     }
 
-    checkNodeWOffset( refNode, offset, ec );
+    ec = 0;
+    checkNodeWOffset(refNode, offset, ec);
     if (ec)
         return;
 
@@ -251,7 +252,8 @@ void Range::setEnd( Node *refNode, int offset, ExceptionCode& ec)
         return;
     }
 
-    checkNodeWOffset( refNode, offset, ec );
+    ec = 0;
+    checkNodeWOffset(refNode, offset, ec);
     if (ec)
         return;
 
@@ -310,11 +312,11 @@ bool Range::isPointInRange(Node* refNode, int offset, ExceptionCode& ec)
         return false;
     }
 
+    ec = 0;
     checkNodeWOffset(refNode, offset, ec);
     if (ec)
         return false;
 
-
     // point is not before the start and not after the end
     if ((compareBoundaryPoints(refNode, offset, m_startContainer.get(), m_startOffset) != -1) && 
         (compareBoundaryPoints(refNode, offset, m_endContainer.get(), m_endOffset) != 1))
@@ -349,6 +351,7 @@ short Range::comparePoint(Node* refNode, int offset, ExceptionCode& ec)
         return 0;
     }
 
+    ec = 0;
     checkNodeWOffset(refNode, offset, ec);
     if (ec)
         return 0;
@@ -426,7 +429,10 @@ short Range::compareBoundaryPoints(CompareHow how, const Range *sourceRange, Exc
         return 0;
     }
 
+    ec = 0;
     Node *thisCont = commonAncestorContainer(ec);
+    if (ec)
+        return 0;
     Node *sourceCont = sourceRange->commonAncestorContainer(ec);
     if (ec)
         return 0;
@@ -575,6 +581,7 @@ void Range::deleteContents(ExceptionCode& ec) {
         return;
     }
 
+    ec = 0;
     checkDeleteExtract(ec);
     if (ec)
         return;
@@ -626,6 +633,7 @@ PassRefPtr<DocumentFragment> Range::processContents ( ActionType action, Excepti
 
     // ### perhaps disable node deletion notification for this range while we do this?
 
+    ec = 0;
     if (collapsed(ec))
         return 0;
     if (ec)
@@ -951,6 +959,7 @@ PassRefPtr<DocumentFragment> Range::extractContents(ExceptionCode& ec)
         return 0;
     }
 
+    ec = 0;
     checkDeleteExtract(ec);
     if (ec)
         return 0;
@@ -1045,16 +1054,15 @@ void Range::insertNode(PassRefPtr<Node> newNode, ExceptionCode& ec)
         return;
     }
 
-    if( m_startContainer->nodeType() == Node::TEXT_NODE ||
-        m_startContainer->nodeType() == Node::CDATA_SECTION_NODE )
-    {
-        Text *newText = static_cast<Text*>(m_startContainer.get())->splitText(m_startOffset,ec);
+    if(m_startContainer->nodeType() == Node::TEXT_NODE ||
+       m_startContainer->nodeType() == Node::CDATA_SECTION_NODE) {
+        ec = 0;
+        Text *newText = static_cast<Text*>(m_startContainer.get())->splitText(m_startOffset, ec);
         if (ec)
             return;
-        m_startContainer->parentNode()->insertBefore( newNode, newText, ec );
-    }
-    else {
-        m_startContainer->insertBefore( newNode, m_startContainer->childNode( m_startOffset ), ec );
+        m_startContainer->parentNode()->insertBefore(newNode, newText, ec);
+    } else {
+        m_startContainer->insertBefore(newNode, m_startContainer->childNode(m_startOffset), ec);
     }
 }
 
@@ -1221,11 +1229,12 @@ void Range::setStartAfter( Node *refNode, ExceptionCode& ec)
         return;
     }
 
+    ec = 0;
     checkNodeBA( refNode, ec );
     if (ec)
         return;
 
-    setStart( refNode->parentNode(), refNode->nodeIndex()+1, ec );
+    setStart(refNode->parentNode(), refNode->nodeIndex() + 1, ec);
 }
 
 void Range::setEndBefore( Node *refNode, ExceptionCode& ec)
@@ -1245,11 +1254,12 @@ void Range::setEndBefore( Node *refNode, ExceptionCode& ec)
         return;
     }
 
-    checkNodeBA( refNode, ec );
+    ec = 0;
+    checkNodeBA(refNode, ec);
     if (ec)
         return;
 
-    setEnd( refNode->parentNode(), refNode->nodeIndex(), ec );
+    setEnd(refNode->parentNode(), refNode->nodeIndex(), ec);
 }
 
 void Range::setEndAfter( Node *refNode, ExceptionCode& ec)
@@ -1269,11 +1279,12 @@ void Range::setEndAfter( Node *refNode, ExceptionCode& ec)
         return;
     }
 
-    checkNodeBA( refNode, ec );
+    ec = 0;
+    checkNodeBA(refNode, ec);
     if (ec)
         return;
 
-    setEnd( refNode->parentNode(), refNode->nodeIndex()+1, ec );
+    setEnd(refNode->parentNode(), refNode->nodeIndex() + 1, ec);
 
 }
 
@@ -1313,6 +1324,7 @@ void Range::selectNode( Node *refNode, ExceptionCode& ec)
         return;
     }
 
+    ec = 0;
     setStartBefore( refNode, ec );
     if (ec)
         return;
@@ -1422,6 +1434,7 @@ void Range::surroundContents(PassRefPtr<Node> passNewParent, ExceptionCode& ec)
         }
     }
 
+    ec = 0;
     while (Node* n = newParent->firstChild()) {
         newParent->removeChild(n, ec);
         if (ec)
@@ -1456,11 +1469,12 @@ void Range::setStartBefore( Node *refNode, ExceptionCode& ec)
         return;
     }
 
-    checkNodeBA( refNode, ec );
+    ec = 0;
+    checkNodeBA(refNode, ec);
     if (ec)
         return;
 
-    setStart( refNode->parentNode(), refNode->nodeIndex(), ec );
+    setStart(refNode->parentNode(), refNode->nodeIndex(), ec);
 }
 
 void Range::checkDeleteExtract(ExceptionCode& ec)
index 2b827b0..da92959 100644 (file)
@@ -94,7 +94,7 @@ TextIterator::TextIterator(const Range* r, bool emitCharactersBetweenAllVisibleP
     int startOffset = r->startOffset(ec);
     Node *endContainer = r->endContainer(ec);
     int endOffset = r->endOffset(ec);
-    if (ec != 0)
+    if (ec)
         return;
 
     // Callers should be handing us well-formed ranges. If we discover that this isn't
index 4a88430..d6f39d4 100644 (file)
@@ -1047,6 +1047,7 @@ PassRefPtr<CanvasPattern> CanvasRenderingContext2D::createPattern(HTMLImageEleme
     const String& repetitionType, ExceptionCode& ec)
 {
     bool repeatX, repeatY;
+    ec = 0;
     CanvasPattern::parseRepetitionType(repetitionType, repeatX, repeatY, ec);
     if (ec)
         return 0;
@@ -1057,6 +1058,7 @@ PassRefPtr<CanvasPattern> CanvasRenderingContext2D::createPattern(HTMLCanvasElem
     const String& repetitionType, ExceptionCode& ec)
 {
     bool repeatX, repeatY;
+    ec = 0;
     CanvasPattern::parseRepetitionType(repetitionType, repeatX, repeatY, ec);
     if (ec)
         return 0;
index 7dae125..d621a93 100644 (file)
@@ -601,6 +601,7 @@ void HTMLMediaElement::play(ExceptionCode& ec)
 {
     // 3.14.9.7. Playing the media resource
     if (!m_movie || networkState() == EMPTY) {
+        ec = 0;
         load(ec);
         if (ec)
             return;
@@ -624,6 +625,7 @@ void HTMLMediaElement::pause(ExceptionCode& ec)
 {
     // 3.14.9.7. Playing the media resource
     if (!m_movie || networkState() == EMPTY) {
+        ec = 0;
         load(ec);
         if (ec)
             return;
index da4dd2e..d0c045c 100644 (file)
@@ -216,13 +216,14 @@ unsigned HTMLSelectElement::length() const
     return len;
 }
 
-void HTMLSelectElement::add( HTMLElement *element, HTMLElement *before, ExceptionCode& ec)
+void HTMLSelectElement::add(HTMLElement *element, HTMLElement *before, ExceptionCode& ec)
 {
     RefPtr<HTMLElement> protectNewChild(element); // make sure the element is ref'd and deref'd so we don't leak it
 
     if (!element || !(element->hasLocalName(optionTag) || element->hasLocalName(hrTag)))
         return;
 
+    ec = 0;
     insertBefore(element, before, ec);
     if (!ec)
         setRecalcListItems();
@@ -1026,7 +1027,7 @@ void HTMLSelectElement::setOption(unsigned index, HTMLOptionElement* option, Exc
         remove(index);
     }
     // finally add the new element
-    if (ec == 0) {
+    if (!ec) {
         add(option, before, ec);
         if (diff >= 0 && option->selected())
             setSelectedIndex(index, !m_multiple);
index 71a147d..1707012 100644 (file)
@@ -64,6 +64,7 @@ PassRefPtr<XPathResult> XPathEvaluator::evaluate(const String& expression,
         return 0;
     }
 
+    ec = 0;
     RefPtr<XPathExpression> expr = createExpression(expression, resolver, ec);
     if (ec)
         return 0;