Commit acca0adc authored by antti@apple.com's avatar 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):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@27701 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 268b841c
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.
......
......@@ -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";
......
......@@ -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;
......
......@@ -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;
......
......@@ -550,6 +550,7 @@ String Element::nodeNamePreservingCase() const
void Element::setPrefix(const AtomicString &_prefix, ExceptionCode& ec)
{
ec = 0;
checkSetPrefix(_prefix, ec);
if (ec)
return;
......
......@@ -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)
......
......@@ -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
......
......@@ -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;
......
......@@ -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;
......
......@@ -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);
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment