summaryrefslogtreecommitdiff
path: root/Source/WebCore/bindings/js/JSWorkerCustom.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/bindings/js/JSWorkerCustom.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/bindings/js/JSWorkerCustom.cpp')
-rw-r--r--Source/WebCore/bindings/js/JSWorkerCustom.cpp43
1 files changed, 18 insertions, 25 deletions
diff --git a/Source/WebCore/bindings/js/JSWorkerCustom.cpp b/Source/WebCore/bindings/js/JSWorkerCustom.cpp
index caa5318f1..84e07fe05 100644
--- a/Source/WebCore/bindings/js/JSWorkerCustom.cpp
+++ b/Source/WebCore/bindings/js/JSWorkerCustom.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008, 2009 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2008-2009, 2016 Apple Inc. All Rights Reserved.
* Copyright (C) 2011 Google Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,48 +25,41 @@
*/
#include "config.h"
-
#include "JSWorker.h"
#include "Document.h"
+#include "JSDOMConstructorBase.h"
+#include "JSDOMConvertStrings.h"
+#include "JSDOMExceptionHandling.h"
#include "JSDOMGlobalObject.h"
-#include "JSMessagePortCustom.h"
-#include "Worker.h"
#include "JSDOMWindowCustom.h"
+#include "Worker.h"
#include <runtime/Error.h>
using namespace JSC;
namespace WebCore {
-JSC::JSValue JSWorker::postMessage(JSC::ExecState* exec)
+EncodedJSValue JSC_HOST_CALL constructJSWorker(ExecState& state)
{
- return handlePostMessage(exec, &impl());
-}
+ VM& vm = state.vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
-EncodedJSValue JSC_HOST_CALL JSWorkerConstructor::constructJSWorker(ExecState* exec)
-{
- JSWorkerConstructor* jsConstructor = jsCast<JSWorkerConstructor*>(exec->callee());
+ ASSERT(jsCast<JSDOMConstructorBase*>(state.jsCallee()));
+ ASSERT(jsCast<JSDOMConstructorBase*>(state.jsCallee())->globalObject());
+ auto& globalObject = *jsCast<JSDOMConstructorBase*>(state.jsCallee())->globalObject();
- if (!exec->argumentCount())
- return throwVMError(exec, createNotEnoughArgumentsError(exec));
+ if (!state.argumentCount())
+ return throwVMError(&state, scope, createNotEnoughArgumentsError(&state));
- String scriptURL = exec->argument(0).toString(exec)->value(exec);
- if (exec->hadException())
- return JSValue::encode(JSValue());
+ auto scriptURL = convert<IDLDOMString>(state, state.uncheckedArgument(0));
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
- // See section 4.8.2 step 14 of WebWorkers for why this is the lexicalGlobalObject.
- DOMWindow& window = asJSDOMWindow(exec->lexicalGlobalObject())->impl();
+ // See section 4.8.2 step 14 of WebWorkers for why this is the lexicalGlobalObject.
+ auto& window = asJSDOMWindow(state.lexicalGlobalObject())->wrapped();
- ExceptionCode ec = 0;
ASSERT(window.document());
- RefPtr<Worker> worker = Worker::create(*window.document(), scriptURL, ec);
- if (ec) {
- setDOMException(exec, ec);
- return JSValue::encode(JSValue());
- }
-
- return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), worker.release())));
+ return JSValue::encode(toJSNewlyCreated<IDLInterface<Worker>>(state, globalObject, scope, Worker::create(*window.document(), scriptURL, globalObject.runtimeFlags())));
}
} // namespace WebCore