Changeset 223985 in webkit


Ignore:
Timestamp:
Oct 25, 2017 2:36:39 PM (6 years ago)
Author:
Chris Dumez
Message:

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:
Location:
trunk/Source/WebCore
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r223984 r223985  
     12017-10-25  Chris Dumez  <cdumez@apple.com>
     2
     3        Make toJS() do the right thing for ServiceWorkerClient
     4        https://bugs.webkit.org/show_bug.cgi?id=178816
     5
     6        Reviewed by Youenn Fablet.
     7
     8        Make toJS() do the right thing for ServiceWorkerClient. In particular,
     9        it needs to construct a JSServiceWorkerWindowClient wrapper if the
     10        implementation object is a ServiceWorkerWindowClient.
     11
     12        Also, ServiceWorkerClient does not need to be an ActiveDOMObject as
     13        it does not have any long-running tasks. Make it a ContextDestructionObject
     14        instead for now.
     15
     16        * CMakeLists.txt:
     17        * DerivedSources.make:
     18        * Sources.txt:
     19        * WebCore.xcodeproj/project.pbxproj:
     20        * workers/service/ServiceWorkerClient.cpp:
     21        (WebCore::ServiceWorkerClient::postMessage):
     22        * workers/service/ServiceWorkerClient.h:
     23        (WebCore::ServiceWorkerClient::create):
     24        * workers/service/ServiceWorkerClient.idl:
     25        * workers/service/ServiceWorkerClientType.h: Copied from Source/WebCore/workers/service/ServiceWorkerClient.idl.
     26        * workers/service/ServiceWorkerClientType.idl: Added.
     27        * workers/service/ServiceWorkerClients.h:
     28        * workers/service/ServiceWorkerClients.idl:
     29
    1302017-10-25  Simon Fraser  <simon.fraser@apple.com>
    231
  • trunk/Source/WebCore/Sources.txt

    r223973 r223985  
    404404bindings/js/JSSVGPathSegCustom.cpp
    405405bindings/js/JSStyleSheetCustom.cpp
     406bindings/js/JSServiceWorkerClientCustom.cpp
    406407bindings/js/JSTextCustom.cpp
    407408bindings/js/JSTextTrackCueCustom.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r223981 r223985  
    1070410704                83F570AD1C53268E007FD6CB /* JSXMLDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSXMLDocument.h; sourceTree = "<group>"; };
    1070510705                83F570AE1C53268E007FD6CB /* JSXMLDocument.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSXMLDocument.cpp; sourceTree = "<group>"; };
     10706                83F572941FA1066F003837BE /* JSServiceWorkerClientCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSServiceWorkerClientCustom.cpp; sourceTree = "<group>"; };
    1070610707                83FB33671F508A4E00986E54 /* FileSystemFileEntry.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = FileSystemFileEntry.idl; sourceTree = "<group>"; };
    1070710708                83FB33681F508A4E00986E54 /* FileSystemEntry.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = FileSystemEntry.idl; sourceTree = "<group>"; };
     
    1961119612                                AD20B18C18E9D216005A8083 /* JSNodeListCustom.h */,
    1961219613                                CB38FD551CD21D5B00592A3F /* JSPerformanceEntryCustom.cpp */,
     19614                                83F572941FA1066F003837BE /* JSServiceWorkerClientCustom.cpp */,
    1961319615                                BC98A27C0C0C9950004BEBF7 /* JSStyleSheetCustom.cpp */,
    1961419616                                AD726FEC16D9F4B9003A4E6D /* JSStyleSheetCustom.h */,
  • trunk/Source/WebCore/bindings/js/JSServiceWorkerClientCustom.cpp

    r223984 r223985  
    2424 */
    2525
    26 #pragma once
     26#include "config.h"
    2727
    2828#if ENABLE(SERVICE_WORKER)
     29#include "JSServiceWorkerClient.h"
    2930
    30 #include "ServiceWorkerClient.h"
    31 #include "VisibilityState.h"
     31#include "JSServiceWorkerWindowClient.h"
    3232
    3333namespace WebCore {
    3434
    35 class DeferredPromise;
     35using namespace JSC;
    3636
    37 class ServiceWorkerWindowClient final : public ServiceWorkerClient {
    38 public:
    39     static Ref<ServiceWorkerWindowClient> create(ScriptExecutionContext& context)
    40     {
    41         return adoptRef(*new ServiceWorkerWindowClient(context));
    42     }
     37JSValue toJSNewlyCreated(ExecState*, JSDOMGlobalObject* globalObject, Ref<ServiceWorkerClient>&& client)
     38{
     39    if (is<ServiceWorkerWindowClient>(client))
     40        return createWrapper<ServiceWorkerWindowClient>(globalObject, WTFMove(client));
     41    return createWrapper<ServiceWorkerClient>(globalObject, WTFMove(client));
     42}
    4343
    44     VisibilityState visibilityState() const;
    45     bool isFocused() const;
    46 
    47     void focus(Ref<DeferredPromise>&&);
    48     void navigate(const String& url, Ref<DeferredPromise>&&);
    49 
    50 private:
    51     explicit ServiceWorkerWindowClient(ScriptExecutionContext&);
    52 };
     44JSValue toJS(ExecState* state, JSDOMGlobalObject* globalObject, ServiceWorkerClient& client)
     45{
     46    return wrap(state, globalObject, client);
     47}
    5348
    5449} // namespace WebCore
    5550
    56 #endif // ENABLE(SERVICE_WORKER)
     51#endif
  • trunk/Source/WebCore/workers/service/ServiceWorkerClient.cpp

    r223973 r223985  
    3131namespace WebCore {
    3232
    33 ServiceWorkerClient::ServiceWorkerClient(ScriptExecutionContext& context)
    34     : ActiveDOMObject(&context)
     33ServiceWorkerClient::ServiceWorkerClient(ScriptExecutionContext& context, Type type)
     34    : ContextDestructionObserver(&context)
     35    , m_type(type)
    3536{
    36     suspendIfNeeded();
    37 }
    38 
    39 const char* ServiceWorkerClient::activeDOMObjectName() const
    40 {
    41     return "ServiceWorkerClient";
    42 }
    43 
    44 bool ServiceWorkerClient::canSuspendForDocumentSuspension() const
    45 {
    46     return !hasPendingActivity();
    4737}
    4838
     
    5545{
    5646    return FrameType::None;
    57 }
    58 
    59 auto ServiceWorkerClient::type() const -> Type
    60 {
    61     return Type::Window;
    6247}
    6348
  • trunk/Source/WebCore/workers/service/ServiceWorkerClient.h

    r223973 r223985  
    2828#if ENABLE(SERVICE_WORKER)
    2929
    30 #include "ActiveDOMObject.h"
     30#include "ContextDestructionObserver.h"
    3131#include "ExceptionOr.h"
    3232#include "ServiceWorkerClientType.h"
     
    4141namespace WebCore {
    4242
    43 class ServiceWorkerClient : public RefCounted<ServiceWorkerClient>, public ActiveDOMObject {
     43class ServiceWorkerClient : public RefCounted<ServiceWorkerClient>, public ContextDestructionObserver {
    4444public:
    4545    using Type = ServiceWorkerClientType;
     
    5151    };
    5252
     53    static Ref<ServiceWorkerClient> create(ScriptExecutionContext& context, Type type)
     54    {
     55        return adoptRef(*new ServiceWorkerClient(context, type));
     56    }
     57
    5358    String url() const;
    5459    FrameType frameType() const;
    55     Type type() const;
     60    Type type() const { return m_type; }
    5661    String id() const;
    5762
     
    5964
    6065protected:
    61     explicit ServiceWorkerClient(ScriptExecutionContext&);
     66    ServiceWorkerClient(ScriptExecutionContext&, Type);
    6267
    63     // ActiveDOMObject.
    64     const char* activeDOMObjectName() const final;
    65     bool canSuspendForDocumentSuspension() const final;
     68    Type m_type;
    6669};
    6770
  • trunk/Source/WebCore/workers/service/ServiceWorkerClient.idl

    r223973 r223985  
    2626[
    2727    Conditional=SERVICE_WORKER,
     28    CustomToJSObject,
    2829    EnabledAtRuntime=ServiceWorker,
    2930    Exposed=ServiceWorker,
  • trunk/Source/WebCore/workers/service/ServiceWorkerWindowClient.cpp

    r223634 r223985  
    3434
    3535ServiceWorkerWindowClient::ServiceWorkerWindowClient(ScriptExecutionContext& context)
    36     : ServiceWorkerClient(context)
     36    : ServiceWorkerClient(context, Type::Window)
    3737{
    3838}
  • trunk/Source/WebCore/workers/service/ServiceWorkerWindowClient.h

    r223634 r223985  
    5454} // namespace WebCore
    5555
     56SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ServiceWorkerWindowClient)
     57    static bool isType(const WebCore::ServiceWorkerClient& client) { return client.type() == WebCore::ServiceWorkerClientType::Window; }
     58SPECIALIZE_TYPE_TRAITS_END()
     59
    5660#endif // ENABLE(SERVICE_WORKER)
Note: See TracChangeset for help on using the changeset viewer.