diff options
author | dglazkov@google.com <dglazkov@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-10 23:49:41 +0000 |
---|---|---|
committer | dglazkov@google.com <dglazkov@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-10 23:49:41 +0000 |
commit | 27961c57893201b2914f173cb517e33f37d0ae58 (patch) | |
tree | 0a9dcbfe745bf4922462091e54e3c65828aad9b6 /webkit | |
parent | bc48650ae075e11ac0cb37a8c7592191ea0c51c4 (diff) | |
download | chromium_src-27961c57893201b2914f173cb517e33f37d0ae58.zip chromium_src-27961c57893201b2914f173cb517e33f37d0ae58.tar.gz chromium_src-27961c57893201b2914f173cb517e33f37d0ae58.tar.bz2 |
Get rid of ExceptionContext (2/2)
Review URL: http://codereview.chromium.org/9754
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5141 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/SConscript.port | 1 | ||||
-rw-r--r-- | webkit/build/KJSBindings/KJSBindings.vcproj | 8 | ||||
-rw-r--r-- | webkit/build/V8Bindings/SConscript | 1 | ||||
-rw-r--r-- | webkit/build/V8Bindings/V8Bindings.vcproj | 28 | ||||
-rw-r--r-- | webkit/pending/ExceptionContext.h | 102 | ||||
-rw-r--r-- | webkit/port/bindings/v8/JSDOMBinding.cpp (renamed from webkit/port/bridge/ExceptionContextV8.cpp) | 79 | ||||
-rw-r--r-- | webkit/port/bindings/v8/JSDOMBinding.h | 52 | ||||
-rw-r--r-- | webkit/port/bindings/v8/runtime/ExecState.h | 50 | ||||
-rw-r--r-- | webkit/port/bindings/v8/runtime/JSLock.h | 38 | ||||
-rw-r--r-- | webkit/port/bindings/v8/v8_custom.cpp | 73 | ||||
-rw-r--r-- | webkit/port/bindings/v8/v8_nodefilter.cpp | 9 | ||||
-rw-r--r-- | webkit/port/bindings/v8/v8_nodefilter.h | 7 |
12 files changed, 220 insertions, 228 deletions
diff --git a/webkit/SConscript.port b/webkit/SConscript.port index 171d27d..7f4d01b 100644 --- a/webkit/SConscript.port +++ b/webkit/SConscript.port @@ -203,7 +203,6 @@ if env.get('KJS'): else: input_files.extend([ '$PORT_DIR/bindings/v8/ScriptController.cpp', - '$PORT_DIR/bridge/ExceptionContextV8.cpp', ]) env.ChromeStaticLibrary("port", input_files) diff --git a/webkit/build/KJSBindings/KJSBindings.vcproj b/webkit/build/KJSBindings/KJSBindings.vcproj index 9c47076..2fbb5a0e 100644 --- a/webkit/build/KJSBindings/KJSBindings.vcproj +++ b/webkit/build/KJSBindings/KJSBindings.vcproj @@ -2810,14 +2810,6 @@ </Filter> </Filter> <File - RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\js\ExceptionContext.cpp" - > - </File> - <File - RelativePath="..\..\pending\ExceptionContext.h" - > - </File> - <File RelativePath="..\..\..\third_party\WebKit\WebCore\bindings\js\GCController.cpp" > </File> diff --git a/webkit/build/V8Bindings/SConscript b/webkit/build/V8Bindings/SConscript index 0229d44..4517df0 100644 --- a/webkit/build/V8Bindings/SConscript +++ b/webkit/build/V8Bindings/SConscript @@ -318,6 +318,7 @@ inputs = [ '$DERIVED_DIR/V8XPathResult.cpp', '$DERIVED_DIR/V8XSLTProcessor.cpp', + '$PORT_DIR/bindings/v8/JSDOMBinding.cpp', '$PORT_DIR/bindings/v8/JSXPathNSResolver.cpp', '$PORT_DIR/bindings/v8/np_v8object.cpp', '$PORT_DIR/bindings/v8/npruntime.cpp', diff --git a/webkit/build/V8Bindings/V8Bindings.vcproj b/webkit/build/V8Bindings/V8Bindings.vcproj index 12041b7..677f2d8 100644 --- a/webkit/build/V8Bindings/V8Bindings.vcproj +++ b/webkit/build/V8Bindings/V8Bindings.vcproj @@ -2432,6 +2432,18 @@ > </File> </Filter> + <Filter + Name="runtime" + > + <File + RelativePath="..\..\port\bindings\v8\runtime\ExecState.h" + > + </File> + <File + RelativePath="..\..\port\bindings\v8\runtime\JSLock.h" + > + </File> + </Filter> <File RelativePath="..\..\port\bindings\v8\dom_wrapper_map.h" > @@ -2441,6 +2453,14 @@ > </File> <File + RelativePath="..\..\port\bindings\v8\JSDOMBinding.h" + > + </File> + <File + RelativePath="..\..\port\bindings\v8\JSDOMBinding.cpp" + > + </File> + <File RelativePath="..\..\port\bindings\v8\JSXPathNSResolver.cpp" > </File> @@ -2493,14 +2513,6 @@ > </File> <File - RelativePath="..\..\pending\ExceptionContext.h" - > - </File> - <File - RelativePath="..\..\port\bridge\ExceptionContextV8.cpp" - > - </File> - <File RelativePath="..\..\port\bindings\v8\v8_binding.h" > </File> diff --git a/webkit/pending/ExceptionContext.h b/webkit/pending/ExceptionContext.h deleted file mode 100644 index f9914dc..0000000 --- a/webkit/pending/ExceptionContext.h +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright 2008, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Javascript exception abstraction - -#ifndef ExceptionContext_h -#define ExceptionContext_h - -#include <wtf/Noncopyable.h> -#include "ScriptController.h" - -#if USE(JSC) -namespace JSC { -class ExecState; -} -#endif - - -namespace WebCore { - -class Node; -#if USE(V8) -class ExceptionCatcher; -#endif - -// Provides context of an exception. This class is an abstraction of JSC's -// ExecState. In V8, its purpose is to carry along the exceptions captured -// by the ExceptionCatcher. -class ExceptionContext : Noncopyable { -public: - ExceptionContext(Node*); -#if USE(V8) - ExceptionContext(); -#elif USE(JSC) - ExceptionContext(JSC::ExecState* exec) : m_exec(exec) {} - JSC::ExecState* exec() const { return m_exec; } -#endif - ~ExceptionContext() {} - - bool hadException(); - JSException exception() const; - - // Returns a non-exception code object. - static JSException noException(); - -private: -#if USE(V8) - friend class ExceptionCatcher; - void setException(JSException exception) { m_exception = exception; } - void setExceptionCatcher(ExceptionCatcher*); - JSException m_exception; - ExceptionCatcher* m_exceptionCatcher; -#elif USE(JSC) - JSC::ExecState* m_exec; -#endif -}; - -#if USE(V8) -// A wrapper around v8::TryCatch helper in order to facilitate updating -// ExceptionContext with the latest exceptions that may have occurred. -class ExceptionCatcher { -public: - ExceptionCatcher(ExceptionContext*); - ~ExceptionCatcher(); - void updateContext(); - void detachContext(); - -private: - ExceptionContext* m_context; - v8::TryCatch m_catcher; -}; -#endif - -} // namespace WebCore - -#endif // !defined(ExceptionContext_h) diff --git a/webkit/port/bridge/ExceptionContextV8.cpp b/webkit/port/bindings/v8/JSDOMBinding.cpp index 9b14d76..a76782f 100644 --- a/webkit/port/bridge/ExceptionContextV8.cpp +++ b/webkit/port/bindings/v8/JSDOMBinding.cpp @@ -28,81 +28,26 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "config.h" -#include "ExceptionContext.h" +#include "JSDOMBinding.h" +#include <runtime/ExecState.h> +#include "Document.h" #include "Node.h" namespace WebCore { -// Unlike JSC, which stores exceptions in ExecState that is accessible from -// ScriptController that is retrievable from Node*, V8 uses static chain of -// handlers (encapsulated as v8::TryCatch and here as ExceptionCatcher) -// to track exceptions, so it has no need for Node*. -ExceptionContext::ExceptionContext(Node* node) +void updateDOMNodeDocument(Node* node, Document* oldDocument, + Document* newDocument) { + // We don't do anything here in V8 bindings } -ExceptionContext::ExceptionContext() - : m_exception() - , m_exceptionCatcher(0) +JSC::ExecState* execStateFromNode(Node* node) { + // This should be never reached with V8 bindings (WebKit only uses it + // for non-JS bindings) + ASSERT_NOT_REACHED(); + return 0; } -void ExceptionContext::setExceptionCatcher(ExceptionCatcher* exceptionCatcher) -{ - if (m_exceptionCatcher && exceptionCatcher) - m_exceptionCatcher->detachContext(); - - m_exceptionCatcher = exceptionCatcher; -} - -bool ExceptionContext::hadException() -{ - if (m_exceptionCatcher) - m_exceptionCatcher->updateContext(); - - return !m_exception.IsEmpty(); -} - -JSException ExceptionContext::exception() const -{ - return m_exception; -} - -JSException ExceptionContext::noException() -{ - return v8::Local<v8::Value>(); -} - -ExceptionCatcher::ExceptionCatcher(ExceptionContext* exceptionContext) - : m_context(exceptionContext) - , m_catcher() -{ - exceptionContext->setExceptionCatcher(this); -} - -void ExceptionCatcher::detachContext() -{ - m_context = 0; -} - -void ExceptionCatcher::updateContext() -{ - ASSERT(m_context); - - if (m_catcher.HasCaught()) - m_context->setException(m_catcher.Exception()); - else - m_context->setException(ExceptionContext::noException()); -} - -ExceptionCatcher::~ExceptionCatcher() -{ - if (!m_context) - return; - - updateContext(); - m_context->setExceptionCatcher(0); -} - -} // namespace WebCore +} // namespace WebCore diff --git a/webkit/port/bindings/v8/JSDOMBinding.h b/webkit/port/bindings/v8/JSDOMBinding.h new file mode 100644 index 0000000..a151b62 --- /dev/null +++ b/webkit/port/bindings/v8/JSDOMBinding.h @@ -0,0 +1,52 @@ +// Copyright (c) 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Masquerade to pretend that we support JSC namespace and avoid unforking +// This is not a reimplementation of the JSC namespace. It's just enough code +// to avoid #ifdefs in WebKit code. + +#ifndef JSDOMBinding_h +#define JSDOMBinding_h + +namespace JSC { + class ExecState; +} + +namespace WebCore { + class Node; + class Document; + + void updateDOMNodeDocument(Node*, Document* oldDocument, + Document* newDocument); + + JSC::ExecState* execStateFromNode(Node*); +} + + +#endif // JSDOMBinding_h
\ No newline at end of file diff --git a/webkit/port/bindings/v8/runtime/ExecState.h b/webkit/port/bindings/v8/runtime/ExecState.h new file mode 100644 index 0000000..f33a0bd --- /dev/null +++ b/webkit/port/bindings/v8/runtime/ExecState.h @@ -0,0 +1,50 @@ +// Copyright (c) 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef ExecState_h +#define ExecState_h + +#include <v8.h> + +namespace JSC { + class ExecState { + public: + bool hadException() { return !m_exception.IsEmpty(); } + void setException(v8::Local<v8::Value> exception) + { + m_exception = exception; + } + v8::Local<v8::Value> exception() { return m_exception; } + + private: + v8::Local<v8::Value> m_exception; + }; +} + +#endif // ExecState_h
\ No newline at end of file diff --git a/webkit/port/bindings/v8/runtime/JSLock.h b/webkit/port/bindings/v8/runtime/JSLock.h new file mode 100644 index 0000000..12a9bc3 --- /dev/null +++ b/webkit/port/bindings/v8/runtime/JSLock.h @@ -0,0 +1,38 @@ +// Copyright (c) 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef JSLock_h +#define JSLock_h + +namespace JSC { + class JSLock { + }; +} + +#endif // JSLock_h
\ No newline at end of file diff --git a/webkit/port/bindings/v8/v8_custom.cpp b/webkit/port/bindings/v8/v8_custom.cpp index 5e7241d..b737061 100644 --- a/webkit/port/bindings/v8/v8_custom.cpp +++ b/webkit/port/bindings/v8/v8_custom.cpp @@ -25,6 +25,7 @@ #include <Assertions.h> #include <wtf/ASCIICType.h> +#include <runtime/ExecState.h> #include "v8_proxy.h" #include "v8_events.h" @@ -3040,10 +3041,10 @@ CALLBACK_FUNC_DECL(TreeWalkerParentNode) { TreeWalker* treeWalker = V8Proxy::ToNativeObject<TreeWalker>( V8ClassIndex::TREEWALKER, args.Holder()); - OwnPtr<ExceptionContext> context(new ExceptionContext()); - RefPtr<Node> result = treeWalker->parentNode(context.get()); - if (context->hadException()) { - v8::ThrowException(context->exception()); + JSC::ExecState exec; + RefPtr<Node> result = treeWalker->parentNode(&exec); + if (exec.hadException()) { + v8::ThrowException(exec.exception()); return v8::Undefined(); } if (!result) return v8::Null(); @@ -3055,10 +3056,10 @@ CALLBACK_FUNC_DECL(TreeWalkerFirstChild) { TreeWalker* treeWalker = V8Proxy::ToNativeObject<TreeWalker>( V8ClassIndex::TREEWALKER, args.Holder()); - OwnPtr<ExceptionContext> context(new ExceptionContext()); - RefPtr<Node> result = treeWalker->firstChild(context.get()); - if (context->hadException()) { - v8::ThrowException(context->exception()); + JSC::ExecState exec; + RefPtr<Node> result = treeWalker->firstChild(&exec); + if (exec.hadException()) { + v8::ThrowException(exec.exception()); return v8::Undefined(); } if (!result) return v8::Null(); @@ -3070,10 +3071,10 @@ CALLBACK_FUNC_DECL(TreeWalkerLastChild) { TreeWalker* treeWalker = V8Proxy::ToNativeObject<TreeWalker>( V8ClassIndex::TREEWALKER, args.Holder()); - OwnPtr<ExceptionContext> context(new ExceptionContext()); - RefPtr<Node> result = treeWalker->lastChild(context.get()); - if (context->hadException()) { - v8::ThrowException(context->exception()); + JSC::ExecState exec; + RefPtr<Node> result = treeWalker->lastChild(&exec); + if (exec.hadException()) { + v8::ThrowException(exec.exception()); return v8::Undefined(); } if (!result) return v8::Null(); @@ -3085,10 +3086,10 @@ CALLBACK_FUNC_DECL(TreeWalkerNextNode) { TreeWalker* treeWalker = V8Proxy::ToNativeObject<TreeWalker>( V8ClassIndex::TREEWALKER, args.Holder()); - OwnPtr<ExceptionContext> context(new ExceptionContext()); - RefPtr<Node> result = treeWalker->nextNode(context.get()); - if (context->hadException()) { - v8::ThrowException(context->exception()); + JSC::ExecState exec; + RefPtr<Node> result = treeWalker->nextNode(&exec); + if (exec.hadException()) { + v8::ThrowException(exec.exception()); return v8::Undefined(); } if (!result) return v8::Null(); @@ -3100,10 +3101,10 @@ CALLBACK_FUNC_DECL(TreeWalkerPreviousNode) { TreeWalker* treeWalker = V8Proxy::ToNativeObject<TreeWalker>( V8ClassIndex::TREEWALKER, args.Holder()); - OwnPtr<ExceptionContext> context(new ExceptionContext()); - RefPtr<Node> result = treeWalker->previousNode(context.get()); - if (context->hadException()) { - v8::ThrowException(context->exception()); + JSC::ExecState exec; + RefPtr<Node> result = treeWalker->previousNode(&exec); + if (exec.hadException()) { + v8::ThrowException(exec.exception()); return v8::Undefined(); } if (!result) return v8::Null(); @@ -3115,10 +3116,10 @@ CALLBACK_FUNC_DECL(TreeWalkerNextSibling) { TreeWalker* treeWalker = V8Proxy::ToNativeObject<TreeWalker>( V8ClassIndex::TREEWALKER, args.Holder()); - OwnPtr<ExceptionContext> context(new ExceptionContext()); - RefPtr<Node> result = treeWalker->nextSibling(context.get()); - if (context->hadException()) { - v8::ThrowException(context->exception()); + JSC::ExecState exec; + RefPtr<Node> result = treeWalker->nextSibling(&exec); + if (exec.hadException()) { + v8::ThrowException(exec.exception()); return v8::Undefined(); } if (!result) return v8::Null(); @@ -3130,10 +3131,10 @@ CALLBACK_FUNC_DECL(TreeWalkerPreviousSibling) { TreeWalker* treeWalker = V8Proxy::ToNativeObject<TreeWalker>( V8ClassIndex::TREEWALKER, args.Holder()); - OwnPtr<ExceptionContext> context(new ExceptionContext()); - RefPtr<Node> result = treeWalker->previousSibling(context.get()); - if (context->hadException()) { - v8::ThrowException(context->exception()); + JSC::ExecState exec; + RefPtr<Node> result = treeWalker->previousSibling(&exec); + if (exec.hadException()) { + v8::ThrowException(exec.exception()); return v8::Undefined(); } if (!result) return v8::Null(); @@ -3146,14 +3147,14 @@ CALLBACK_FUNC_DECL(NodeIteratorNextNode) { V8ClassIndex::NODEITERATOR, args.Holder()); ExceptionCode ec = 0; - OwnPtr<ExceptionContext> context(new ExceptionContext()); - RefPtr<Node> result = nodeIterator->nextNode(context.get(), ec); + JSC::ExecState exec; + RefPtr<Node> result = nodeIterator->nextNode(&exec, ec); if (ec != 0) { V8Proxy::SetDOMException(ec); return v8::Null(); } - if (context->hadException()) { - v8::ThrowException(context->exception()); + if (exec.hadException()) { + v8::ThrowException(exec.exception()); return v8::Undefined(); } if (!result) return v8::Null(); @@ -3166,14 +3167,14 @@ CALLBACK_FUNC_DECL(NodeIteratorPreviousNode) { V8ClassIndex::NODEITERATOR, args.Holder()); ExceptionCode ec = 0; - OwnPtr<ExceptionContext> context(new ExceptionContext()); - RefPtr<Node> result = nodeIterator->previousNode(context.get(), ec); + JSC::ExecState exec; + RefPtr<Node> result = nodeIterator->previousNode(&exec, ec); if (ec != 0) { V8Proxy::SetDOMException(ec); return v8::Null(); } - if (context->hadException()) { - v8::ThrowException(context->exception()); + if (exec.hadException()) { + v8::ThrowException(exec.exception()); return v8::Undefined(); } if (!result) return v8::Null(); diff --git a/webkit/port/bindings/v8/v8_nodefilter.cpp b/webkit/port/bindings/v8/v8_nodefilter.cpp index 3f958e5..19b9437 100644 --- a/webkit/port/bindings/v8/v8_nodefilter.cpp +++ b/webkit/port/bindings/v8/v8_nodefilter.cpp @@ -31,9 +31,9 @@ #include "v8_nodefilter.h" #include "v8_proxy.h" -#include "ExceptionContext.h" #include "NodeFilter.h" #include "Node.h" +#include <runtime/ExecState.h> namespace WebCore { @@ -52,13 +52,13 @@ V8NodeFilterCondition::~V8NodeFilterCondition() { m_filter.Clear(); } -short V8NodeFilterCondition::acceptNode(ExceptionContext* exception_context, +short V8NodeFilterCondition::acceptNode(JSC::ExecState* exec, Node* node) const { ASSERT(v8::Context::InContext()); if (!m_filter->IsFunction()) return NodeFilter::FILTER_ACCEPT; - ExceptionCatcher exception_catcher(exception_context); + v8::TryCatch exception_catcher; v8::Handle<v8::Object> this_obj = v8::Context::GetCurrent()->Global(); v8::Handle<v8::Function> callback = @@ -73,7 +73,8 @@ short V8NodeFilterCondition::acceptNode(ExceptionContext* exception_context, proxy->CallFunction(callback, this_obj, 1, args); delete[] args; - if (exception_context->hadException()) { + if (exception_catcher.HasCaught()) { + exec->setException(exception_catcher.Exception()); return NodeFilter::FILTER_REJECT; } diff --git a/webkit/port/bindings/v8/v8_nodefilter.h b/webkit/port/bindings/v8/v8_nodefilter.h index ef7906d..96ea520 100644 --- a/webkit/port/bindings/v8/v8_nodefilter.h +++ b/webkit/port/bindings/v8/v8_nodefilter.h @@ -8,6 +8,10 @@ #include <v8.h> #include "NodeFilterCondition.h" +namespace JSC { + class ExecState; +} + // NodeFilter is a JavaScript function that takes a Node as parameter // and returns a short (ACCEPT, SKIP, REJECT) as the result. namespace WebCore { @@ -19,8 +23,7 @@ class V8NodeFilterCondition : public NodeFilterCondition { explicit V8NodeFilterCondition(v8::Handle<v8::Value> filter); virtual ~V8NodeFilterCondition(); - virtual short acceptNode(ExceptionContext* exception_context, - Node* node) const; + virtual short acceptNode(JSC::ExecState*, Node*) const; private: mutable v8::Persistent<v8::Value> m_filter; |