Diff
Modified: trunk/Source/WebCore/ChangeLog (223984 => 223985)
--- trunk/Source/WebCore/ChangeLog 2017-10-25 21:32:08 UTC (rev 223984)
+++ trunk/Source/WebCore/ChangeLog 2017-10-25 21:36:39 UTC (rev 223985)
@@ -1,3 +1,32 @@
+2017-10-25 Chris Dumez <[email protected]>
+
+ Make toJS() do the right thing for ServiceWorkerClient
+ https://bugs.webkit.org/show_bug.cgi?id=178816
+
+ Reviewed by Youenn Fablet.
+
+ Make toJS() do the right thing for ServiceWorkerClient. In particular,
+ it needs to construct a JSServiceWorkerWindowClient wrapper if the
+ implementation object is a ServiceWorkerWindowClient.
+
+ Also, ServiceWorkerClient does not need to be an ActiveDOMObject as
+ it does not have any long-running tasks. Make it a ContextDestructionObject
+ instead for now.
+
+ * CMakeLists.txt:
+ * DerivedSources.make:
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * workers/service/ServiceWorkerClient.cpp:
+ (WebCore::ServiceWorkerClient::postMessage):
+ * workers/service/ServiceWorkerClient.h:
+ (WebCore::ServiceWorkerClient::create):
+ * workers/service/ServiceWorkerClient.idl:
+ * workers/service/ServiceWorkerClientType.h: Copied from Source/WebCore/workers/service/ServiceWorkerClient.idl.
+ * workers/service/ServiceWorkerClientType.idl: Added.
+ * workers/service/ServiceWorkerClients.h:
+ * workers/service/ServiceWorkerClients.idl:
+
2017-10-25 Simon Fraser <[email protected]>
When navigating back to a page, compositing layers may not use accelerated drawing
Modified: trunk/Source/WebCore/Sources.txt (223984 => 223985)
--- trunk/Source/WebCore/Sources.txt 2017-10-25 21:32:08 UTC (rev 223984)
+++ trunk/Source/WebCore/Sources.txt 2017-10-25 21:36:39 UTC (rev 223985)
@@ -403,6 +403,7 @@
bindings/js/JSReadableStreamSourceCustom.cpp
bindings/js/JSSVGPathSegCustom.cpp
bindings/js/JSStyleSheetCustom.cpp
+bindings/js/JSServiceWorkerClientCustom.cpp
bindings/js/JSTextCustom.cpp
bindings/js/JSTextTrackCueCustom.cpp
bindings/js/JSTextTrackCustom.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (223984 => 223985)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-10-25 21:32:08 UTC (rev 223984)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-10-25 21:36:39 UTC (rev 223985)
@@ -10703,6 +10703,7 @@
83EE598C1F50958B003E8B30 /* JSErrorCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSErrorCallback.cpp; sourceTree = "<group>"; };
83F570AD1C53268E007FD6CB /* JSXMLDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSXMLDocument.h; sourceTree = "<group>"; };
83F570AE1C53268E007FD6CB /* JSXMLDocument.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSXMLDocument.cpp; sourceTree = "<group>"; };
+ 83F572941FA1066F003837BE /* JSServiceWorkerClientCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSServiceWorkerClientCustom.cpp; sourceTree = "<group>"; };
83FB33671F508A4E00986E54 /* FileSystemFileEntry.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = FileSystemFileEntry.idl; sourceTree = "<group>"; };
83FB33681F508A4E00986E54 /* FileSystemEntry.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = FileSystemEntry.idl; sourceTree = "<group>"; };
83FB33691F508A4E00986E54 /* FileSystemFileEntry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileSystemFileEntry.cpp; sourceTree = "<group>"; };
@@ -19610,6 +19611,7 @@
BCD9C2610C17AA67005C90A2 /* JSNodeListCustom.cpp */,
AD20B18C18E9D216005A8083 /* JSNodeListCustom.h */,
CB38FD551CD21D5B00592A3F /* JSPerformanceEntryCustom.cpp */,
+ 83F572941FA1066F003837BE /* JSServiceWorkerClientCustom.cpp */,
BC98A27C0C0C9950004BEBF7 /* JSStyleSheetCustom.cpp */,
AD726FEC16D9F4B9003A4E6D /* JSStyleSheetCustom.h */,
B2C96D8C0B3AF2B7005E80EC /* JSSVGPathSegCustom.cpp */,
Copied: trunk/Source/WebCore/bindings/js/JSServiceWorkerClientCustom.cpp (from rev 223984, trunk/Source/WebCore/workers/service/ServiceWorkerWindowClient.h) (0 => 223985)
--- trunk/Source/WebCore/bindings/js/JSServiceWorkerClientCustom.cpp (rev 0)
+++ trunk/Source/WebCore/bindings/js/JSServiceWorkerClientCustom.cpp 2017-10-25 21:36:39 UTC (rev 223985)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2017 Apple 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. AND ITS 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 APPLE INC. OR ITS 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"
+
+#if ENABLE(SERVICE_WORKER)
+#include "JSServiceWorkerClient.h"
+
+#include "JSServiceWorkerWindowClient.h"
+
+namespace WebCore {
+
+using namespace JSC;
+
+JSValue toJSNewlyCreated(ExecState*, JSDOMGlobalObject* globalObject, Ref<ServiceWorkerClient>&& client)
+{
+ if (is<ServiceWorkerWindowClient>(client))
+ return createWrapper<ServiceWorkerWindowClient>(globalObject, WTFMove(client));
+ return createWrapper<ServiceWorkerClient>(globalObject, WTFMove(client));
+}
+
+JSValue toJS(ExecState* state, JSDOMGlobalObject* globalObject, ServiceWorkerClient& client)
+{
+ return wrap(state, globalObject, client);
+}
+
+} // namespace WebCore
+
+#endif
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerClient.cpp (223984 => 223985)
--- trunk/Source/WebCore/workers/service/ServiceWorkerClient.cpp 2017-10-25 21:32:08 UTC (rev 223984)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerClient.cpp 2017-10-25 21:36:39 UTC (rev 223985)
@@ -30,22 +30,12 @@
namespace WebCore {
-ServiceWorkerClient::ServiceWorkerClient(ScriptExecutionContext& context)
- : ActiveDOMObject(&context)
+ServiceWorkerClient::ServiceWorkerClient(ScriptExecutionContext& context, Type type)
+ : ContextDestructionObserver(&context)
+ , m_type(type)
{
- suspendIfNeeded();
}
-const char* ServiceWorkerClient::activeDOMObjectName() const
-{
- return "ServiceWorkerClient";
-}
-
-bool ServiceWorkerClient::canSuspendForDocumentSuspension() const
-{
- return !hasPendingActivity();
-}
-
String ServiceWorkerClient::url() const
{
return { };
@@ -56,11 +46,6 @@
return FrameType::None;
}
-auto ServiceWorkerClient::type() const -> Type
-{
- return Type::Window;
-}
-
String ServiceWorkerClient::id() const
{
return { };
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerClient.h (223984 => 223985)
--- trunk/Source/WebCore/workers/service/ServiceWorkerClient.h 2017-10-25 21:32:08 UTC (rev 223984)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerClient.h 2017-10-25 21:36:39 UTC (rev 223985)
@@ -27,7 +27,7 @@
#if ENABLE(SERVICE_WORKER)
-#include "ActiveDOMObject.h"
+#include "ContextDestructionObserver.h"
#include "ExceptionOr.h"
#include "ServiceWorkerClientType.h"
#include <heap/Strong.h>
@@ -40,7 +40,7 @@
namespace WebCore {
-class ServiceWorkerClient : public RefCounted<ServiceWorkerClient>, public ActiveDOMObject {
+class ServiceWorkerClient : public RefCounted<ServiceWorkerClient>, public ContextDestructionObserver {
public:
using Type = ServiceWorkerClientType;
enum class FrameType {
@@ -50,19 +50,22 @@
None
};
+ static Ref<ServiceWorkerClient> create(ScriptExecutionContext& context, Type type)
+ {
+ return adoptRef(*new ServiceWorkerClient(context, type));
+ }
+
String url() const;
FrameType frameType() const;
- Type type() const;
+ Type type() const { return m_type; }
String id() const;
ExceptionOr<void> postMessage(JSC::ExecState&, JSC::JSValue message, Vector<JSC::Strong<JSC::JSObject>>&& transfer);
protected:
- explicit ServiceWorkerClient(ScriptExecutionContext&);
+ ServiceWorkerClient(ScriptExecutionContext&, Type);
- // ActiveDOMObject.
- const char* activeDOMObjectName() const final;
- bool canSuspendForDocumentSuspension() const final;
+ Type m_type;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerClient.idl (223984 => 223985)
--- trunk/Source/WebCore/workers/service/ServiceWorkerClient.idl 2017-10-25 21:32:08 UTC (rev 223984)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerClient.idl 2017-10-25 21:36:39 UTC (rev 223985)
@@ -25,6 +25,7 @@
[
Conditional=SERVICE_WORKER,
+ CustomToJSObject,
EnabledAtRuntime=ServiceWorker,
Exposed=ServiceWorker,
InterfaceName=Client,
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerWindowClient.cpp (223984 => 223985)
--- trunk/Source/WebCore/workers/service/ServiceWorkerWindowClient.cpp 2017-10-25 21:32:08 UTC (rev 223984)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerWindowClient.cpp 2017-10-25 21:36:39 UTC (rev 223985)
@@ -33,7 +33,7 @@
namespace WebCore {
ServiceWorkerWindowClient::ServiceWorkerWindowClient(ScriptExecutionContext& context)
- : ServiceWorkerClient(context)
+ : ServiceWorkerClient(context, Type::Window)
{
}
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerWindowClient.h (223984 => 223985)
--- trunk/Source/WebCore/workers/service/ServiceWorkerWindowClient.h 2017-10-25 21:32:08 UTC (rev 223984)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerWindowClient.h 2017-10-25 21:36:39 UTC (rev 223985)
@@ -53,4 +53,8 @@
} // namespace WebCore
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ServiceWorkerWindowClient)
+ static bool isType(const WebCore::ServiceWorkerClient& client) { return client.type() == WebCore::ServiceWorkerClientType::Window; }
+SPECIALIZE_TYPE_TRAITS_END()
+
#endif // ENABLE(SERVICE_WORKER)