[WebIDL] Remove need for custom binding for Worker constructor
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 13 May 2017 06:39:30 +0000 (06:39 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 13 May 2017 06:39:30 +0000 (06:39 +0000)
https://bugs.webkit.org/show_bug.cgi?id=172050

Patch by Sam Weinig <sam@webkit.org> on 2017-05-12
Reviewed by Chris Dumez.

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSWorkerCustom.cpp: Removed.
Remove JSWorkerCustom.cpp

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateCallWith):
* bindings/scripts/IDLAttributes.json:
Add RuntimeFlags as a new option for the ConstructorCallWith extended attribute.

* workers/Worker.cpp:
(WebCore::Worker::create):
* workers/Worker.h:
Update order of arguments to appease the generator.

* workers/Worker.idl:
Add extended attributes for the constructor.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@216819 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSBindingsAllInOne.cpp
Source/WebCore/bindings/js/JSWorkerCustom.cpp [deleted file]
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/IDLAttributes.json
Source/WebCore/workers/Worker.cpp
Source/WebCore/workers/Worker.h
Source/WebCore/workers/Worker.idl

index 37110c6..b9a9dbf 100644 (file)
@@ -1226,7 +1226,6 @@ set(WebCore_SOURCES
     bindings/js/JSWebGPURenderPassAttachmentDescriptorCustom.cpp
     bindings/js/JSWebGPURenderingContextCustom.cpp
     bindings/js/JSWebKitSubtleCryptoCustom.cpp
-    bindings/js/JSWorkerCustom.cpp
     bindings/js/JSWorkerGlobalScopeBase.cpp
     bindings/js/JSWorkerGlobalScopeCustom.cpp
     bindings/js/JSXMLDocumentCustom.cpp
index 787863c..e4b3706 100644 (file)
@@ -1,3 +1,28 @@
+2017-05-12  Sam Weinig  <sam@webkit.org>
+
+        [WebIDL] Remove need for custom binding for Worker constructor
+        https://bugs.webkit.org/show_bug.cgi?id=172050
+
+        Reviewed by Chris Dumez.
+
+        * CMakeLists.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSWorkerCustom.cpp: Removed.
+        Remove JSWorkerCustom.cpp
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateCallWith):
+        * bindings/scripts/IDLAttributes.json:
+        Add RuntimeFlags as a new option for the ConstructorCallWith extended attribute.
+
+        * workers/Worker.cpp:
+        (WebCore::Worker::create):
+        * workers/Worker.h:
+        Update order of arguments to appease the generator.
+
+        * workers/Worker.idl:
+        Add extended attributes for the constructor.
+
 2017-05-12  Simon Fraser  <simon.fraser@apple.com>
 
         The rects returned by Element/Range.getClientRects() should not be rounded
index a353cd8..610b539 100644 (file)
                E1C657271816F9FE00256CDD /* CryptoAlgorithmParametersDeprecated.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C657261816F9FE00256CDD /* CryptoAlgorithmParametersDeprecated.h */; };
                E1C8BE5D0E8BD15A0064CB7D /* JSWorker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1C8BE5C0E8BD15A0064CB7D /* JSWorker.cpp */; };
                E1C94AF9191303F000D5A893 /* BlobPart.h in Headers */ = {isa = PBXBuildFile; fileRef = E1C94AF7191303F000D5A893 /* BlobPart.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               E1CA5CBC0E8CDCAF00E8EF90 /* JSWorkerCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1CA5CBB0E8CDCAF00E8EF90 /* JSWorkerCustom.cpp */; };
                E1CAA5C60E8BD23600A73ECA /* JSWorker.h in Headers */ = {isa = PBXBuildFile; fileRef = E1CAA5C50E8BD23600A73ECA /* JSWorker.h */; };
                E1CDE92015018ED000862CC5 /* AsyncFileStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1CDE91F15018ED000862CC5 /* AsyncFileStream.cpp */; };
                E1CDE9221501916900862CC5 /* AsyncFileStream.h in Headers */ = {isa = PBXBuildFile; fileRef = E1CDE9211501916900862CC5 /* AsyncFileStream.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E1C6CFC21746D293007B87A1 /* DOMWindowConstructors.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = DOMWindowConstructors.idl; sourceTree = "<group>"; };
                E1C8BE5C0E8BD15A0064CB7D /* JSWorker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWorker.cpp; sourceTree = "<group>"; };
                E1C94AF7191303F000D5A893 /* BlobPart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BlobPart.h; sourceTree = "<group>"; };
-               E1CA5CBB0E8CDCAF00E8EF90 /* JSWorkerCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWorkerCustom.cpp; sourceTree = "<group>"; };
                E1CAA5C50E8BD23600A73ECA /* JSWorker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWorker.h; sourceTree = "<group>"; };
                E1CDE91F15018ED000862CC5 /* AsyncFileStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AsyncFileStream.cpp; sourceTree = "<group>"; };
                E1CDE9211501916900862CC5 /* AsyncFileStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AsyncFileStream.h; sourceTree = "<group>"; };
                                49EED14C1051971A00099FAB /* JSWebGLRenderingContextCustom.cpp */,
                                38850C521E964C1100C60753 /* JSWebGPUCommandBufferCustom.cpp */,
                                E1FF8F661807460800132674 /* JSWebKitSubtleCryptoCustom.cpp */,
-                               E1CA5CBB0E8CDCAF00E8EF90 /* JSWorkerCustom.cpp */,
                                E18258AB0EF3CD7000933242 /* JSWorkerGlobalScopeCustom.cpp */,
                                BC348BBD0DB7F531004ABAB9 /* JSXMLHttpRequestCustom.cpp */,
                        );
                                5DA5E0FC102B953800088CF9 /* JSWebSocket.cpp in Sources */,
                                65DF320509D1CC60000BE325 /* JSWheelEvent.cpp in Sources */,
                                E1C8BE5D0E8BD15A0064CB7D /* JSWorker.cpp in Sources */,
-                               E1CA5CBC0E8CDCAF00E8EF90 /* JSWorkerCustom.cpp in Sources */,
                                E182568F0EF2B02D00933242 /* JSWorkerGlobalScope.cpp in Sources */,
                                E1C36D340EB0A094007410BC /* JSWorkerGlobalScopeBase.cpp in Sources */,
                                E18258AC0EF3CD7000933242 /* JSWorkerGlobalScopeCustom.cpp in Sources */,
index 06288de..2604d05 100644 (file)
 #include "JSTreeWalkerCustom.cpp"
 #include "JSVideoTrackCustom.cpp"
 #include "JSVideoTrackListCustom.cpp"
-#include "JSWorkerCustom.cpp"
 #include "JSWorkerGlobalScopeBase.cpp"
 #include "JSWorkerGlobalScopeCustom.cpp"
 #include "JSXMLDocumentCustom.cpp"
diff --git a/Source/WebCore/bindings/js/JSWorkerCustom.cpp b/Source/WebCore/bindings/js/JSWorkerCustom.cpp
deleted file mode 100644 (file)
index 84e07fe..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * 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 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
- * 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. 
- */
-
-#include "config.h"
-#include "JSWorker.h"
-
-#include "Document.h"
-#include "JSDOMConstructorBase.h"
-#include "JSDOMConvertStrings.h"
-#include "JSDOMExceptionHandling.h"
-#include "JSDOMGlobalObject.h"
-#include "JSDOMWindowCustom.h"
-#include "Worker.h"
-#include <runtime/Error.h>
-
-using namespace JSC;
-
-namespace WebCore {
-
-EncodedJSValue JSC_HOST_CALL constructJSWorker(ExecState& state)
-{
-    VM& vm = state.vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    ASSERT(jsCast<JSDOMConstructorBase*>(state.jsCallee()));
-    ASSERT(jsCast<JSDOMConstructorBase*>(state.jsCallee())->globalObject());
-    auto& globalObject = *jsCast<JSDOMConstructorBase*>(state.jsCallee())->globalObject();
-
-    if (!state.argumentCount())
-        return throwVMError(&state, scope, createNotEnoughArgumentsError(&state));
-
-    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.
-    auto& window = asJSDOMWindow(state.lexicalGlobalObject())->wrapped();
-
-    ASSERT(window.document());
-    return JSValue::encode(toJSNewlyCreated<IDLInterface<Worker>>(state, globalObject, scope, Worker::create(*window.document(), scriptURL, globalObject.runtimeFlags())));
-}
-
-} // namespace WebCore
index 5358fa4..02a9541 100644 (file)
@@ -4659,6 +4659,9 @@ sub GenerateCallWith
         $implIncludes{"JSDOMWindowBase.h"} = 1;
         push(@callWithArgs, "incumbentDOMWindow($statePointer)");
     }
+    if ($codeGenerator->ExtendedAttributeContains($callWith, "RuntimeFlags")) {
+        push(@callWithArgs, "${globalObject}->runtimeFlags()");
+    }
 
     return @callWithArgs;
 }
index 1f5e0fe..bba518a 100644 (file)
@@ -66,7 +66,7 @@
         },
         "ConstructorCallWith": {
             "contextsAllowed": ["interface"],
-            "values": ["Document", "ScriptExecutionContext", "ScriptState"]
+            "values": ["Document", "RuntimeFlags", "ScriptExecutionContext", "ScriptState"]
         },
         "ConstructorMayThrowException": {
             "contextsAllowed": ["interface"]
index 51348c2..9c9875f 100644 (file)
@@ -66,7 +66,7 @@ inline Worker::Worker(ScriptExecutionContext& context, JSC::RuntimeFlags runtime
     ASSERT_UNUSED(addResult, addResult.isNewEntry);
 }
 
-ExceptionOr<Ref<Worker>> Worker::create(ScriptExecutionContext& context, const String& url, JSC::RuntimeFlags runtimeFlags)
+ExceptionOr<Ref<Worker>> Worker::create(ScriptExecutionContext& context, JSC::RuntimeFlags runtimeFlags, const String& url)
 {
     ASSERT(isMainThread());
 
index 44d86f8..855c7e6 100644 (file)
@@ -49,7 +49,7 @@ class WorkerScriptLoader;
 
 class Worker final : public AbstractWorker, public ActiveDOMObject, private WorkerScriptLoaderClient {
 public:
-    static ExceptionOr<Ref<Worker>> create(ScriptExecutionContext&, const String& url, JSC::RuntimeFlags);
+    static ExceptionOr<Ref<Worker>> create(ScriptExecutionContext&, JSC::RuntimeFlags, const String& url);
     virtual ~Worker();
 
     ExceptionOr<void> postMessage(JSC::ExecState&, JSC::JSValue message, Vector<JSC::Strong<JSC::JSObject>>&&);
index 16481a3..6c51778 100644 (file)
@@ -26,7 +26,9 @@
 
 [
     ActiveDOMObject,
-    CustomConstructor(USVString scriptUrl),
+    Constructor(USVString scriptUrl),
+    ConstructorCallWith=ScriptExecutionContext&RuntimeFlags,
+    ConstructorMayThrowException
 ] interface Worker : EventTarget {
     void terminate();