Changeset 223985 in webkit
- Timestamp:
- Oct 25, 2017 2:36:39 PM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 8 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r223984 r223985 1 2017-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 1 30 2017-10-25 Simon Fraser <simon.fraser@apple.com> 2 31 -
trunk/Source/WebCore/Sources.txt
r223973 r223985 404 404 bindings/js/JSSVGPathSegCustom.cpp 405 405 bindings/js/JSStyleSheetCustom.cpp 406 bindings/js/JSServiceWorkerClientCustom.cpp 406 407 bindings/js/JSTextCustom.cpp 407 408 bindings/js/JSTextTrackCueCustom.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r223981 r223985 10704 10704 83F570AD1C53268E007FD6CB /* JSXMLDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSXMLDocument.h; sourceTree = "<group>"; }; 10705 10705 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>"; }; 10706 10707 83FB33671F508A4E00986E54 /* FileSystemFileEntry.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = FileSystemFileEntry.idl; sourceTree = "<group>"; }; 10707 10708 83FB33681F508A4E00986E54 /* FileSystemEntry.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = FileSystemEntry.idl; sourceTree = "<group>"; }; … … 19611 19612 AD20B18C18E9D216005A8083 /* JSNodeListCustom.h */, 19612 19613 CB38FD551CD21D5B00592A3F /* JSPerformanceEntryCustom.cpp */, 19614 83F572941FA1066F003837BE /* JSServiceWorkerClientCustom.cpp */, 19613 19615 BC98A27C0C0C9950004BEBF7 /* JSStyleSheetCustom.cpp */, 19614 19616 AD726FEC16D9F4B9003A4E6D /* JSStyleSheetCustom.h */, -
trunk/Source/WebCore/bindings/js/JSServiceWorkerClientCustom.cpp
r223984 r223985 24 24 */ 25 25 26 # pragma once26 #include "config.h" 27 27 28 28 #if ENABLE(SERVICE_WORKER) 29 #include "JSServiceWorkerClient.h" 29 30 30 #include "ServiceWorkerClient.h" 31 #include "VisibilityState.h" 31 #include "JSServiceWorkerWindowClient.h" 32 32 33 33 namespace WebCore { 34 34 35 class DeferredPromise;35 using namespace JSC; 36 36 37 class ServiceWorkerWindowClient final : public ServiceWorkerClient { 38 public: 39 static Ref<ServiceWorkerWindowClient> create(ScriptExecutionContext& context)40 {41 return adoptRef(*new ServiceWorkerWindowClient(context));42 37 JSValue 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 } 43 43 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 }; 44 JSValue toJS(ExecState* state, JSDOMGlobalObject* globalObject, ServiceWorkerClient& client) 45 { 46 return wrap(state, globalObject, client); 47 } 53 48 54 49 } // namespace WebCore 55 50 56 #endif // ENABLE(SERVICE_WORKER)51 #endif -
trunk/Source/WebCore/workers/service/ServiceWorkerClient.cpp
r223973 r223985 31 31 namespace WebCore { 32 32 33 ServiceWorkerClient::ServiceWorkerClient(ScriptExecutionContext& context) 34 : ActiveDOMObject(&context) 33 ServiceWorkerClient::ServiceWorkerClient(ScriptExecutionContext& context, Type type) 34 : ContextDestructionObserver(&context) 35 , m_type(type) 35 36 { 36 suspendIfNeeded();37 }38 39 const char* ServiceWorkerClient::activeDOMObjectName() const40 {41 return "ServiceWorkerClient";42 }43 44 bool ServiceWorkerClient::canSuspendForDocumentSuspension() const45 {46 return !hasPendingActivity();47 37 } 48 38 … … 55 45 { 56 46 return FrameType::None; 57 }58 59 auto ServiceWorkerClient::type() const -> Type60 {61 return Type::Window;62 47 } 63 48 -
trunk/Source/WebCore/workers/service/ServiceWorkerClient.h
r223973 r223985 28 28 #if ENABLE(SERVICE_WORKER) 29 29 30 #include " ActiveDOMObject.h"30 #include "ContextDestructionObserver.h" 31 31 #include "ExceptionOr.h" 32 32 #include "ServiceWorkerClientType.h" … … 41 41 namespace WebCore { 42 42 43 class ServiceWorkerClient : public RefCounted<ServiceWorkerClient>, public ActiveDOMObject{43 class ServiceWorkerClient : public RefCounted<ServiceWorkerClient>, public ContextDestructionObserver { 44 44 public: 45 45 using Type = ServiceWorkerClientType; … … 51 51 }; 52 52 53 static Ref<ServiceWorkerClient> create(ScriptExecutionContext& context, Type type) 54 { 55 return adoptRef(*new ServiceWorkerClient(context, type)); 56 } 57 53 58 String url() const; 54 59 FrameType frameType() const; 55 Type type() const ;60 Type type() const { return m_type; } 56 61 String id() const; 57 62 … … 59 64 60 65 protected: 61 explicit ServiceWorkerClient(ScriptExecutionContext&);66 ServiceWorkerClient(ScriptExecutionContext&, Type); 62 67 63 // ActiveDOMObject. 64 const char* activeDOMObjectName() const final; 65 bool canSuspendForDocumentSuspension() const final; 68 Type m_type; 66 69 }; 67 70 -
trunk/Source/WebCore/workers/service/ServiceWorkerClient.idl
r223973 r223985 26 26 [ 27 27 Conditional=SERVICE_WORKER, 28 CustomToJSObject, 28 29 EnabledAtRuntime=ServiceWorker, 29 30 Exposed=ServiceWorker, -
trunk/Source/WebCore/workers/service/ServiceWorkerWindowClient.cpp
r223634 r223985 34 34 35 35 ServiceWorkerWindowClient::ServiceWorkerWindowClient(ScriptExecutionContext& context) 36 : ServiceWorkerClient(context )36 : ServiceWorkerClient(context, Type::Window) 37 37 { 38 38 } -
trunk/Source/WebCore/workers/service/ServiceWorkerWindowClient.h
r223634 r223985 54 54 } // namespace WebCore 55 55 56 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ServiceWorkerWindowClient) 57 static bool isType(const WebCore::ServiceWorkerClient& client) { return client.type() == WebCore::ServiceWorkerClientType::Window; } 58 SPECIALIZE_TYPE_TRAITS_END() 59 56 60 #endif // ENABLE(SERVICE_WORKER)
Note: See TracChangeset
for help on using the changeset viewer.