Changeset 35054 in webkit


Ignore:
Timestamp:
Jul 7, 2008 8:19:30 PM (16 years ago)
Author:
dino@apple.com
Message:

2008-07-07 Simon Fraser <Simon Fraser>

Reviewed by Darin.

Fix for https://bugs.webkit.org/show_bug.cgi?id=19933
nodeIterator with filter fails on documents not in a frame

Tests: traversal/node-iterator-009.html

traversal/tree-walker-006.html

  • bindings/js/JSNodeFilterCondition.cpp:
  • bindings/js/JSNodeFilterCondition.h:
  • bindings/js/JSNodeFilterCustom.cpp:
  • bindings/js/JSNodeIteratorCustom.cpp:
  • bindings/js/JSTreeWalkerCustom.cpp:
  • bindings/objc/DOM.mm:
  • dom/NodeFilter.cpp:
  • dom/NodeFilter.h:
  • dom/NodeFilterCondition.cpp:
  • dom/NodeFilterCondition.h:
  • dom/NodeIterator.cpp:
  • dom/NodeIterator.h:
  • dom/Traversal.cpp:
  • dom/Traversal.h:
  • dom/TreeWalker.cpp:
  • dom/TreeWalker.h:


Location:
trunk
Files:
4 added
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r35052 r35054  
     12008-07-07  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Reviewed by Darin.
     4
     5        Tests for https://bugs.webkit.org/show_bug.cgi?id=19933
     6        nodeIterator with filter fails on documents not in a frame
     7
     8        * traversal/node-iterator-009-expected.txt: Added.
     9        * traversal/node-iterator-009.html: Added.
     10        * traversal/tree-walker-006-expected.txt: Added.
     11        * traversal/tree-walker-006.html: Added.
     12
    1132008-07-07  Adele Peterson  <adele@apple.com>
    214
  • trunk/WebCore/ChangeLog

    r35052 r35054  
     12008-07-07  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Reviewed by Darin.
     4
     5        Fix for https://bugs.webkit.org/show_bug.cgi?id=19933
     6        nodeIterator with filter fails on documents not in a frame
     7
     8        Tests: traversal/node-iterator-009.html
     9               traversal/tree-walker-006.html
     10
     11        * bindings/js/JSNodeFilterCondition.cpp:
     12        * bindings/js/JSNodeFilterCondition.h:
     13        * bindings/js/JSNodeFilterCustom.cpp:
     14        * bindings/js/JSNodeIteratorCustom.cpp:
     15        * bindings/js/JSTreeWalkerCustom.cpp:
     16        * bindings/objc/DOM.mm:
     17        * dom/NodeFilter.cpp:
     18        * dom/NodeFilter.h:
     19        * dom/NodeFilterCondition.cpp:
     20        * dom/NodeFilterCondition.h:
     21        * dom/NodeIterator.cpp:
     22        * dom/NodeIterator.h:
     23        * dom/Traversal.cpp:
     24        * dom/Traversal.h:
     25        * dom/TreeWalker.cpp:
     26        * dom/TreeWalker.h:
     27
    1282008-07-07  Adele Peterson  <adele@apple.com>
    229
  • trunk/WebCore/bindings/js/JSNodeFilterCondition.cpp

    r34947 r35054  
    2121#include "JSNodeFilterCondition.h"
    2222
    23 #include "Document.h"
    24 #include "Frame.h"
    2523#include "JSNode.h"
    2624#include "JSNodeFilter.h"
    2725#include "NodeFilter.h"
    28 #include "ScriptController.h"
    2926#include <kjs/JSLock.h>
    3027
     
    3229
    3330using namespace KJS;
    34 
    35 // FIXME: Add takeException as a member of ExecState?
    36 static JSValue* takeException(ExecState* exec)
    37 {
    38     JSValue* exception = exec->exception();
    39     exec->clearException();
    40     return exception;
    41 }
    4231
    4332JSNodeFilterCondition::JSNodeFilterCondition(JSValue* filter)
     
    5241}
    5342
    54 short JSNodeFilterCondition::acceptNode(Node* filterNode, JSValue*& exception) const
     43short JSNodeFilterCondition::acceptNode(KJS::ExecState* exec, Node* filterNode) const
    5544{
    56     // FIXME: It makes no sense for this to depend on the document being in a frame!
    57     Frame* frame = filterNode->document()->frame();
    58     if (!frame)
    59         return NodeFilter::FILTER_REJECT;
    60 
    6145    JSLock lock(false);
    6246
     
    6650        return NodeFilter::FILTER_ACCEPT;
    6751
    68     ExecState* exec = frame->script()->globalObject()->globalExec();
     52   // The exec argument here should only be null if this was called from a
     53   // non-JavaScript language, and this is a JavaScript filter, and the document
     54   // in question is not associated with the frame. In that case, we're going to
     55   // behave incorrectly, and just reject nodes instead of calling the filter function.
     56   // To fix that we'd need to come up with a way to find a suitable JavaScript
     57   // execution context for the filter function to run in.
     58    if (!exec)
     59        return NodeFilter::FILTER_REJECT;
     60
    6961    ArgList args;
    7062    args.append(toJS(exec, filterNode));
    71     if (exec->hadException()) {
    72         exception = takeException(exec);
     63    if (exec->hadException())
    7364        return NodeFilter::FILTER_REJECT;
    74     }
     65
    7566    JSValue* result = call(exec, m_filter, callType, callData, m_filter, args);
    76     if (exec->hadException()) {
    77         exception = takeException(exec);
     67    if (exec->hadException())
    7868        return NodeFilter::FILTER_REJECT;
    79     }
     69
    8070    int intResult = result->toInt32(exec);
    81     if (exec->hadException()) {
    82         exception = takeException(exec);
     71    if (exec->hadException())
    8372        return NodeFilter::FILTER_REJECT;
    84     }
     73
    8574    return intResult;
    8675}
  • trunk/WebCore/bindings/js/JSNodeFilterCondition.h

    r34754 r35054  
    4242        JSNodeFilterCondition(KJS::JSValue* filter);
    4343
    44         virtual short acceptNode(Node*, KJS::JSValue*& exception) const;
     44        virtual short acceptNode(KJS::ExecState*, Node*) const;
    4545        virtual void mark();
    4646
  • trunk/WebCore/bindings/js/JSNodeFilterCustom.cpp

    r34754 r35054  
    4444JSValue* JSNodeFilter::acceptNode(ExecState* exec, const ArgList& args)
    4545{
    46     JSValue* exception = 0;
    47     short result = impl()->acceptNode(toNode(args[0]), exception);
    48     if (exception)
    49         exec->setException(exception);
    50     return jsNumber(exec, result);
     46    return jsNumber(exec, impl()->acceptNode(exec, toNode(args[0])));
    5147}
    5248
  • trunk/WebCore/bindings/js/JSNodeIteratorCustom.cpp

    r34587 r35054  
    4141{
    4242    ExceptionCode ec = 0;
    43     JSValue* exception = 0;
    44     RefPtr<Node> node = impl()->nextNode(ec, exception);
     43    RefPtr<Node> node = impl()->nextNode(exec, ec);
    4544    if (ec) {
    4645        setDOMException(exec, ec);
    4746        return jsUndefined();
    4847    }
    49     if (exception) {
    50         exec->setException(exception);
     48
     49    if (exec->hadException())
    5150        return jsUndefined();
    52     }
     51
    5352    return toJS(exec, node.get());
    5453}
     
    5756{
    5857    ExceptionCode ec = 0;
    59     JSValue* exception = 0;
    60     RefPtr<Node> node = impl()->previousNode(ec, exception);
     58    RefPtr<Node> node = impl()->previousNode(exec, ec);
    6159    if (ec) {
    6260        setDOMException(exec, ec);
    6361        return jsUndefined();
    6462    }
    65     if (exception) {
    66         exec->setException(exception);
     63
     64    if (exec->hadException())
    6765        return jsUndefined();
    68     }
     66
    6967    return toJS(exec, node.get());
    7068}
  • trunk/WebCore/bindings/js/JSTreeWalkerCustom.cpp

    r34587 r35054  
    4040JSValue* JSTreeWalker::parentNode(ExecState* exec, const ArgList& args)
    4141{
    42     JSValue* exception = 0;
    43     Node* node = impl()->parentNode(exception);
    44     if (exception) {
    45         exec->setException(exception);
     42    Node* node = impl()->parentNode(exec);
     43    if (exec->hadException())
    4644        return jsUndefined();
    47     }
    4845    return toJS(exec, node);
    4946}
     
    5148JSValue* JSTreeWalker::firstChild(ExecState* exec, const ArgList& args)
    5249{
    53     JSValue* exception = 0;
    54     Node* node = impl()->firstChild(exception);
    55     if (exception) {
    56         exec->setException(exception);
     50    Node* node = impl()->firstChild(exec);
     51    if (exec->hadException())
    5752        return jsUndefined();
    58     }
    5953    return toJS(exec, node);
    6054}
     
    6256JSValue* JSTreeWalker::lastChild(ExecState* exec, const ArgList& args)
    6357{
    64     JSValue* exception = 0;
    65     Node* node = impl()->lastChild(exception);
    66     if (exception) {
    67         exec->setException(exception);
     58    Node* node = impl()->lastChild(exec);
     59    if (exec->hadException())
    6860        return jsUndefined();
    69     }
    7061    return toJS(exec, node);
    7162}
     
    7364JSValue* JSTreeWalker::nextSibling(ExecState* exec, const ArgList& args)
    7465{
    75     JSValue* exception = 0;
    76     Node* node = impl()->nextSibling(exception);
    77     if (exception) {
    78         exec->setException(exception);
     66    Node* node = impl()->nextSibling(exec);
     67    if (exec->hadException())
    7968        return jsUndefined();
    80     }
    8169    return toJS(exec, node);
    8270}
     
    8472JSValue* JSTreeWalker::previousSibling(ExecState* exec, const ArgList& args)
    8573{
    86     JSValue* exception = 0;
    87     Node* node = impl()->previousSibling(exception);
    88     if (exception) {
    89         exec->setException(exception);
     74    Node* node = impl()->previousSibling(exec);
     75    if (exec->hadException())
    9076        return jsUndefined();
    91     }
    9277    return toJS(exec, node);
    9378}
     
    9580JSValue* JSTreeWalker::previousNode(ExecState* exec, const ArgList& args)
    9681{
    97     JSValue* exception = 0;
    98     Node* node = impl()->previousNode(exception);
    99     if (exception) {
    100         exec->setException(exception);
     82    Node* node = impl()->previousNode(exec);
     83    if (exec->hadException())
    10184        return jsUndefined();
    102     }
    10385    return toJS(exec, node);
    10486}
     
    10688JSValue* JSTreeWalker::nextNode(ExecState* exec, const ArgList& args)
    10789{
    108     JSValue* exception = 0;
    109     Node* node = impl()->nextNode(exception);
    110     if (exception) {
    111         exec->setException(exception);
     90    Node* node = impl()->nextNode(exec);
     91    if (exec->hadException())
    11292        return jsUndefined();
    113     }
    11493    return toJS(exec, node);
    11594}
  • trunk/WebCore/bindings/objc/DOM.mm

    r34641 r35054  
    698698    }
    699699
    700     virtual short acceptNode(Node*, JSValue*& exception) const;
     700    virtual short acceptNode(ExecState*, Node*) const;
    701701
    702702private:
     
    709709};
    710710
    711 short ObjCNodeFilterCondition::acceptNode(Node* node, JSValue*&) const
     711short ObjCNodeFilterCondition::acceptNode(ExecState*, Node* node) const
    712712{
    713713    if (!node)
  • trunk/WebCore/dom/NodeFilter.cpp

    r30089 r35054  
    2626#include "NodeFilter.h"
    2727
     28#include "Document.h"
     29#include "Frame.h"
     30#include "Node.h"
     31#include "ScriptController.h"
     32
    2833using namespace KJS;
    2934
    3035namespace WebCore {
    3136
    32 short NodeFilter::acceptNode(Node* node, JSValue*& exception) const
     37short NodeFilter::acceptNode(ExecState* exec, Node* node) const
    3338{
    3439    // cast to short silences "enumeral and non-enumeral types in return" warning
    35     return m_condition ? m_condition->acceptNode(node, exception) : static_cast<short>(FILTER_ACCEPT);
     40    return m_condition ? m_condition->acceptNode(exec, node) : static_cast<short>(FILTER_ACCEPT);
    3641}
    3742
     43ExecState* NodeFilter::execStateFromNode(Node* node)
     44{
     45    if (!node)
     46        return 0;
     47    Document* document = node->document();
     48    if (!document)
     49        return 0;
     50    Frame* frame = document->frame();
     51    if (!frame)
     52        return 0;
     53
     54    if (!frame->script()->isEnabled())
     55        return 0;
     56
     57    return frame->script()->globalObject()->globalExec();
     58}
     59
     60
    3861} // namespace WebCore
  • trunk/WebCore/dom/NodeFilter.h

    r34641 r35054  
    7171        }
    7272
    73         short acceptNode(Node*, KJS::JSValue*& exception) const;
     73        short acceptNode(KJS::ExecState*, Node*) const;
    7474        void mark() { m_condition->mark(); };
    7575
    7676        // For non-JS bindings. Silently ignores the JavaScript exception if any.
    77         short acceptNode(Node* node) const { KJS::JSValue* exception; return acceptNode(node, exception); }
     77        short acceptNode(Node* node) const { return acceptNode(execStateFromNode(node), node); }
     78
     79    public:
     80        static KJS::ExecState* execStateFromNode(Node*);
    7881
    7982    private:
    8083        NodeFilter(PassRefPtr<NodeFilterCondition> condition) : m_condition(condition) { }
     84
    8185        RefPtr<NodeFilterCondition> m_condition;
    8286    };
  • trunk/WebCore/dom/NodeFilterCondition.cpp

    r30089 r35054  
    3232namespace WebCore {
    3333
    34 short NodeFilterCondition::acceptNode(Node*, JSValue*&) const
     34short NodeFilterCondition::acceptNode(ExecState*, Node*) const
    3535{
    3636    return NodeFilter::FILTER_ACCEPT;
  • trunk/WebCore/dom/NodeFilterCondition.h

    r34432 r35054  
    2929
    3030namespace KJS {
    31     class JSValue;
     31    class ExecState;
    3232}
    3333
     
    3939    public:
    4040        virtual ~NodeFilterCondition() { }
    41         virtual short acceptNode(Node*, KJS::JSValue*& exception) const = 0;
     41        virtual short acceptNode(KJS::ExecState*, Node*) const = 0;
    4242        virtual void mark() { }
    4343    };
  • trunk/WebCore/dom/NodeIterator.cpp

    r31303 r35054  
    2626#include "NodeIterator.h"
    2727
     28#include <kjs/ExecState.h>
    2829#include "Document.h"
    2930#include "ExceptionCode.h"
     
    8687}
    8788
    88 PassRefPtr<Node> NodeIterator::nextNode(ExceptionCode& ec, JSValue*& exception)
     89PassRefPtr<Node> NodeIterator::nextNode(ExecState* exec, ExceptionCode& ec)
    8990{
    9091    if (m_detached) {
     
    100101        // In other words, FILTER_REJECT does not pass over descendants
    101102        // of the rejected node. Hence, FILTER_REJECT is the same as FILTER_SKIP.
    102         exception = 0;
    103103        RefPtr<Node> provisionalResult = m_candidateNode.node;
    104         bool nodeWasAccepted = acceptNode(provisionalResult.get(), exception) == NodeFilter::FILTER_ACCEPT;
    105         if (exception)
     104        bool nodeWasAccepted = acceptNode(exec, provisionalResult.get()) == NodeFilter::FILTER_ACCEPT;
     105        if (exec && exec->hadException())
    106106            break;
    107107        if (nodeWasAccepted) {
     
    116116}
    117117
    118 PassRefPtr<Node> NodeIterator::previousNode(ExceptionCode& ec, JSValue*& exception)
     118PassRefPtr<Node> NodeIterator::previousNode(ExecState* exec, ExceptionCode& ec)
    119119{
    120120    if (m_detached) {
     
    130130        // In other words, FILTER_REJECT does not pass over descendants
    131131        // of the rejected node. Hence, FILTER_REJECT is the same as FILTER_SKIP.
    132         exception = 0;
    133132        RefPtr<Node> provisionalResult = m_candidateNode.node;
    134         bool nodeWasAccepted = acceptNode(provisionalResult.get(), exception) == NodeFilter::FILTER_ACCEPT;
    135         if (exception)
     133        bool nodeWasAccepted = acceptNode(exec, provisionalResult.get()) == NodeFilter::FILTER_ACCEPT;
     134        if (exec && exec->hadException())
    136135            break;
    137136        if (nodeWasAccepted) {
     
    228227}
    229228
     229
    230230} // namespace WebCore
  • trunk/WebCore/dom/NodeIterator.h

    r34754 r35054  
    2626#define NodeIterator_h
    2727
     28#include "NodeFilter.h"
    2829#include "Traversal.h"
    2930#include <wtf/PassRefPtr.h>
     
    4243        ~NodeIterator();
    4344
    44         PassRefPtr<Node> nextNode(ExceptionCode&, KJS::JSValue*& exception);
    45         PassRefPtr<Node> previousNode(ExceptionCode&, KJS::JSValue*& exception);
     45        PassRefPtr<Node> nextNode(KJS::ExecState*, ExceptionCode&);
     46        PassRefPtr<Node> previousNode(KJS::ExecState*, ExceptionCode&);
    4647        void detach();
    4748
     
    5354
    5455        // For non-JS bindings. Silently ignores the JavaScript exception if any.
    55         PassRefPtr<Node> nextNode(ExceptionCode& ec) { KJS::JSValue* exception; return nextNode(ec, exception); }
    56         PassRefPtr<Node> previousNode(ExceptionCode& ec) { KJS::JSValue* exception; return previousNode(ec, exception); }
     56        PassRefPtr<Node> nextNode(ExceptionCode& ec) { return nextNode(NodeFilter::execStateFromNode(referenceNode()), ec); }
     57        PassRefPtr<Node> previousNode(ExceptionCode& ec) { return previousNode(NodeFilter::execStateFromNode(referenceNode()), ec); }
    5758
    5859    private:
  • trunk/WebCore/dom/Traversal.cpp

    r34754 r35054  
    4141}
    4242
    43 short Traversal::acceptNode(Node* node, JSValue*& exception) const
     43short Traversal::acceptNode(ExecState* exec, Node* node) const
    4444{
    4545    // FIXME: To handle XML properly we would have to check m_expandEntityReferences.
    4646
    47     // The bid twiddling here is done to map DOM node types, which are given as integers from
     47    // The bit twiddling here is done to map DOM node types, which are given as integers from
    4848    // 1 through 12, to whatToShow bit masks.
    4949    if (!(((1 << (node->nodeType() - 1)) & m_whatToShow)))
     
    5151    if (!m_filter)
    5252        return NodeFilter::FILTER_ACCEPT;
    53     return m_filter->acceptNode(node, exception);
     53    return m_filter->acceptNode(exec, node);
    5454}
    5555
  • trunk/WebCore/dom/Traversal.h

    r34754 r35054  
    3131namespace KJS {
    3232    class JSValue;
     33    class ExecState;
    3334}
    3435
     
    4748    protected:
    4849        Traversal(PassRefPtr<Node>, unsigned whatToShow, PassRefPtr<NodeFilter>, bool expandEntityReferences);
    49         short acceptNode(Node*, KJS::JSValue*& jsException) const;
     50        short acceptNode(KJS::ExecState*, Node*) const;
    5051
    5152    private:
  • trunk/WebCore/dom/TreeWalker.cpp

    r30089 r35054  
    2626#include "TreeWalker.h"
    2727
     28#include <kjs/ExecState.h>
    2829#include "ExceptionCode.h"
    2930#include "Node.h"
     
    5657}
    5758
    58 Node* TreeWalker::parentNode(JSValue*& exception)
    59 {
    60     exception = 0;
     59Node* TreeWalker::parentNode(ExecState* exec)
     60{
    6161    RefPtr<Node> node = m_current;
    6262    while (node != root()) {
     
    6464        if (!node)
    6565            return 0;
    66         short acceptNodeResult = acceptNode(node.get(), exception);
    67         if (exception)
    68             return 0;
    69         if (acceptNodeResult == NodeFilter::FILTER_ACCEPT)
    70             return setCurrent(node.release());
    71     }
    72     return 0;
    73 }
    74 
    75 Node* TreeWalker::firstChild(JSValue*& exception)
    76 {
    77     exception = 0;
     66        short acceptNodeResult = acceptNode(exec, node.get());
     67        if (exec && exec->hadException())
     68            return 0;
     69        if (acceptNodeResult == NodeFilter::FILTER_ACCEPT)
     70            return setCurrent(node.release());
     71    }
     72    return 0;
     73}
     74
     75Node* TreeWalker::firstChild(ExecState* exec)
     76{
    7877    for (RefPtr<Node> node = m_current->firstChild(); node; ) {
    79         short acceptNodeResult = acceptNode(node.get(), exception);
    80         if (exception)
     78        short acceptNodeResult = acceptNode(exec, node.get());
     79        if (exec && exec->hadException())
    8180            return 0;
    8281        switch (acceptNodeResult) {
     
    107106}
    108107
    109 Node* TreeWalker::lastChild(JSValue*& exception)
    110 {
    111     exception = 0;
     108Node* TreeWalker::lastChild(ExecState* exec)
     109{
    112110    for (RefPtr<Node> node = m_current->lastChild(); node; ) {
    113         short acceptNodeResult = acceptNode(node.get(), exception);
    114         if (exception)
     111        short acceptNodeResult = acceptNode(exec, node.get());
     112        if (exec && exec->hadException())
    115113            return 0;
    116114        switch (acceptNodeResult) {
     
    141139}
    142140
    143 Node* TreeWalker::previousSibling(JSValue*& exception)
    144 {
    145     exception = 0;
     141Node* TreeWalker::previousSibling(ExecState* exec)
     142{
    146143    RefPtr<Node> node = m_current;
    147144    if (node == root())
     
    149146    while (1) {
    150147        for (RefPtr<Node> sibling = node->previousSibling(); sibling; ) {
    151             short acceptNodeResult = acceptNode(sibling.get(), exception);
    152             if (exception)
     148            short acceptNodeResult = acceptNode(exec, sibling.get());
     149            if (exec && exec->hadException())
    153150                return 0;
    154151            switch (acceptNodeResult) {
     
    170167        if (!node || node == root())
    171168            return 0;
    172         short acceptNodeResult = acceptNode(node.get(), exception);
    173         if (exception)
    174             return 0;
    175         if (acceptNodeResult == NodeFilter::FILTER_ACCEPT)
    176             return 0;
    177     }
    178 }
    179 
    180 Node* TreeWalker::nextSibling(JSValue*& exception)
    181 {
    182     exception = 0;
     169        short acceptNodeResult = acceptNode(exec, node.get());
     170        if (exec && exec->hadException())
     171            return 0;
     172        if (acceptNodeResult == NodeFilter::FILTER_ACCEPT)
     173            return 0;
     174    }
     175}
     176
     177Node* TreeWalker::nextSibling(ExecState* exec)
     178{
    183179    RefPtr<Node> node = m_current;
    184180    if (node == root())
     
    186182    while (1) {
    187183        for (RefPtr<Node> sibling = node->nextSibling(); sibling; ) {
    188             short acceptNodeResult = acceptNode(sibling.get(), exception);
    189             if (exception)
     184            short acceptNodeResult = acceptNode(exec, sibling.get());
     185            if (exec && exec->hadException())
    190186                return 0;
    191187            switch (acceptNodeResult) {
     
    207203        if (!node || node == root())
    208204            return 0;
    209         short acceptNodeResult = acceptNode(node.get(), exception);
    210         if (exception)
    211             return 0;
    212         if (acceptNodeResult == NodeFilter::FILTER_ACCEPT)
    213             return 0;
    214     }
    215 }
    216 
    217 Node* TreeWalker::previousNode(JSValue*& exception)
    218 {
    219     exception = 0;
     205        short acceptNodeResult = acceptNode(exec, node.get());
     206        if (exec && exec->hadException())
     207            return 0;
     208        if (acceptNodeResult == NodeFilter::FILTER_ACCEPT)
     209            return 0;
     210    }
     211}
     212
     213Node* TreeWalker::previousNode(ExecState* exec)
     214{
    220215    RefPtr<Node> node = m_current;
    221216    while (node != root()) {
    222217        while (Node* previousSibling = node->previousSibling()) {
    223218            node = previousSibling;
    224             short acceptNodeResult = acceptNode(node.get(), exception);
    225             if (exception)
     219            short acceptNodeResult = acceptNode(exec, node.get());
     220            if (exec && exec->hadException())
    226221                return 0;
    227222            if (acceptNodeResult == NodeFilter::FILTER_REJECT)
     
    229224            while (Node* lastChild = node->lastChild()) {
    230225                node = lastChild;
    231                 acceptNodeResult = acceptNode(node.get(), exception);
    232                 if (exception)
     226                acceptNodeResult = acceptNode(exec, node.get());
     227                if (exec && exec->hadException())
    233228                    return 0;
    234229                if (acceptNodeResult == NodeFilter::FILTER_ACCEPT)
     
    246241            return 0;
    247242        node = parent;
    248         short acceptNodeResult = acceptNode(node.get(), exception);
    249         if (exception)
    250             return 0;
    251         if (acceptNodeResult == NodeFilter::FILTER_ACCEPT)
    252             return setCurrent(node.release());
    253     }
    254     return 0;
    255 }
    256 
    257 Node* TreeWalker::nextNode(JSValue*& exception)
    258 {
    259     exception = 0;
     243        short acceptNodeResult = acceptNode(exec, node.get());
     244        if (exec && exec->hadException())
     245            return 0;
     246        if (acceptNodeResult == NodeFilter::FILTER_ACCEPT)
     247            return setCurrent(node.release());
     248    }
     249    return 0;
     250}
     251
     252Node* TreeWalker::nextNode(ExecState* exec)
     253{
    260254    RefPtr<Node> node = m_current;
    261255Children:
    262256    while (Node* firstChild = node->firstChild()) {
    263257        node = firstChild;
    264         short acceptNodeResult = acceptNode(node.get(), exception);
    265         if (exception)
     258        short acceptNodeResult = acceptNode(exec, node.get());
     259        if (exec && exec->hadException())
    266260            return 0;
    267261        if (acceptNodeResult == NodeFilter::FILTER_ACCEPT)
     
    272266    while (Node* nextSibling = node->traverseNextSibling(root())) {
    273267        node = nextSibling;
    274         short acceptNodeResult = acceptNode(node.get(), exception);
    275         if (exception)
     268        short acceptNodeResult = acceptNode(exec, node.get());
     269        if (exec && exec->hadException())
    276270            return 0;
    277271        if (acceptNodeResult == NodeFilter::FILTER_ACCEPT)
  • trunk/WebCore/dom/TreeWalker.h

    r34754 r35054  
    2626#define TreeWalker_h
    2727
     28#include "NodeFilter.h"
    2829#include "Traversal.h"
    2930#include <wtf/PassRefPtr.h>
     
    4445        void setCurrentNode(PassRefPtr<Node>, ExceptionCode&);
    4546
    46         Node* parentNode(KJS::JSValue*& exception);
    47         Node* firstChild(KJS::JSValue*& exception);
    48         Node* lastChild(KJS::JSValue*& exception);
    49         Node* previousSibling(KJS::JSValue*& exception);
    50         Node* nextSibling(KJS::JSValue*& exception);
    51         Node* previousNode(KJS::JSValue*& exception);
    52         Node* nextNode(KJS::JSValue*& exception);
     47        Node* parentNode(KJS::ExecState*);
     48        Node* firstChild(KJS::ExecState*);
     49        Node* lastChild(KJS::ExecState*);
     50        Node* previousSibling(KJS::ExecState*);
     51        Node* nextSibling(KJS::ExecState*);
     52        Node* previousNode(KJS::ExecState*);
     53        Node* nextNode(KJS::ExecState*);
    5354
    5455        // For non-JS bindings. Silently ignores the JavaScript exception if any.
    55         Node* parentNode() { KJS::JSValue* exception; return parentNode(exception); }
    56         Node* firstChild() { KJS::JSValue* exception; return firstChild(exception); }
    57         Node* lastChild() { KJS::JSValue* exception; return lastChild(exception); }
    58         Node* previousSibling() { KJS::JSValue* exception; return previousSibling(exception); }
    59         Node* nextSibling() { KJS::JSValue* exception; return nextSibling(exception); }
    60         Node* previousNode() { KJS::JSValue* exception; return previousNode(exception); }
    61         Node* nextNode() { KJS::JSValue* exception; return nextNode(exception); }
     56        Node* parentNode() { return parentNode(NodeFilter::execStateFromNode(m_current.get())); }
     57        Node* firstChild() { return firstChild(NodeFilter::execStateFromNode(m_current.get())); }
     58        Node* lastChild() { return lastChild(NodeFilter::execStateFromNode(m_current.get())); }
     59        Node* previousSibling() { return previousSibling(NodeFilter::execStateFromNode(m_current.get())); }
     60        Node* nextSibling() { return nextSibling(NodeFilter::execStateFromNode(m_current.get())); }
     61        Node* previousNode() { return previousNode(NodeFilter::execStateFromNode(m_current.get())); }
     62        Node* nextNode() { return nextNode(NodeFilter::execStateFromNode(m_current.get())); }
    6263
    6364    private:
Note: See TracChangeset for help on using the changeset viewer.