diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/bindings/js/JSCustomXPathNSResolver.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/bindings/js/JSCustomXPathNSResolver.cpp')
-rw-r--r-- | Source/WebCore/bindings/js/JSCustomXPathNSResolver.cpp | 54 |
1 files changed, 26 insertions, 28 deletions
diff --git a/Source/WebCore/bindings/js/JSCustomXPathNSResolver.cpp b/Source/WebCore/bindings/js/JSCustomXPathNSResolver.cpp index f1b63f85a..2f14dff6b 100644 --- a/Source/WebCore/bindings/js/JSCustomXPathNSResolver.cpp +++ b/Source/WebCore/bindings/js/JSCustomXPathNSResolver.cpp @@ -10,10 +10,10 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. 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 @@ -26,14 +26,14 @@ #include "config.h" #include "JSCustomXPathNSResolver.h" +#include "CommonVM.h" #include "Document.h" -#include "ExceptionCode.h" #include "Frame.h" +#include "JSDOMExceptionHandling.h" #include "JSDOMWindowCustom.h" #include "JSMainThreadExecState.h" #include "Page.h" -#include "PageConsole.h" -#include "SecurityOrigin.h" +#include "PageConsoleClient.h" #include <runtime/JSLock.h> #include <wtf/Ref.h> @@ -41,23 +41,21 @@ namespace WebCore { using namespace JSC; -PassRefPtr<JSCustomXPathNSResolver> JSCustomXPathNSResolver::create(ExecState* exec, JSValue value) +ExceptionOr<Ref<JSCustomXPathNSResolver>> JSCustomXPathNSResolver::create(ExecState& state, JSValue value) { if (value.isUndefinedOrNull()) - return 0; + return Exception { TypeError }; - JSObject* resolverObject = value.getObject(); - if (!resolverObject) { - setDOMException(exec, TYPE_MISMATCH_ERR); - return 0; - } + auto* resolverObject = value.getObject(); + if (!resolverObject) + return Exception { TYPE_MISMATCH_ERR }; - return adoptRef(new JSCustomXPathNSResolver(exec, resolverObject, asJSDOMWindow(exec->vmEntryGlobalObject()))); + return adoptRef(*new JSCustomXPathNSResolver(state.vm(), resolverObject, asJSDOMWindow(state.vmEntryGlobalObject()))); } -JSCustomXPathNSResolver::JSCustomXPathNSResolver(ExecState* exec, JSObject* customResolver, JSDOMWindow* globalObject) - : m_customResolver(exec->vm(), customResolver) - , m_globalObject(exec->vm(), globalObject) +JSCustomXPathNSResolver::JSCustomXPathNSResolver(VM& vm, JSObject* customResolver, JSDOMWindow* globalObject) + : m_customResolver(vm, customResolver) + , m_globalObject(vm, globalObject) { } @@ -69,37 +67,37 @@ String JSCustomXPathNSResolver::lookupNamespaceURI(const String& prefix) { ASSERT(m_customResolver); - JSLockHolder lock(JSDOMWindowBase::commonVM()); + JSLockHolder lock(commonVM()); ExecState* exec = m_globalObject->globalExec(); - JSValue function = m_customResolver->get(exec, Identifier(exec, "lookupNamespaceURI")); + JSValue function = m_customResolver->get(exec, Identifier::fromString(exec, "lookupNamespaceURI")); CallData callData; CallType callType = getCallData(function, callData); - if (callType == CallTypeNone) { + if (callType == CallType::None) { callType = m_customResolver->methodTable()->getCallData(m_customResolver.get(), callData); - if (callType == CallTypeNone) { - // FIXME: <http://webkit.org/b/114312> JSCustomXPathNSResolver::lookupNamespaceURI Console Message should include Line, Column, and SourceURL - if (PageConsole* console = m_globalObject->impl().pageConsole()) - console->addMessage(JSMessageSource, ErrorMessageLevel, "XPathNSResolver does not have a lookupNamespaceURI method."); + if (callType == CallType::None) { + if (PageConsoleClient* console = m_globalObject->wrapped().console()) + console->addMessage(MessageSource::JS, MessageLevel::Error, ASCIILiteral("XPathNSResolver does not have a lookupNamespaceURI method.")); return String(); } function = m_customResolver.get(); } - Ref<JSCustomXPathNSResolver> selfProtector(*this); + Ref<JSCustomXPathNSResolver> protectedThis(*this); MarkedArgumentBuffer args; args.append(jsStringWithCache(exec, prefix)); - JSValue retval = JSMainThreadExecState::call(exec, function, callType, callData, m_customResolver.get(), args); + NakedPtr<JSC::Exception> exception; + JSValue retval = JSMainThreadExecState::call(exec, function, callType, callData, m_customResolver.get(), args, exception); String result; - if (exec->hadException()) - reportCurrentException(exec); + if (exception) + reportException(exec, exception); else { if (!retval.isUndefinedOrNull()) - result = retval.toString(exec)->value(exec); + result = retval.toWTFString(exec); } return result; |