Diff
Modified: trunk/Source/WebKit2/ChangeLog (207819 => 207820)
--- trunk/Source/WebKit2/ChangeLog 2016-10-25 15:52:10 UTC (rev 207819)
+++ trunk/Source/WebKit2/ChangeLog 2016-10-25 15:52:25 UTC (rev 207820)
@@ -1,3 +1,48 @@
+2016-10-19 Jer Noble <[email protected]>
+
+ Add WKWebView fullscreen delegate SPI
+ https://bugs.webkit.org/show_bug.cgi?id=163674
+
+ Reviewed by Anders Carlsson.
+
+ Add a new SPI property to WKWebView allowing clients to be notified when fullscreen mode enters and exits.
+
+ * UIProcess/API/APIFullscreenClient.h: Added.
+ (API::FullscreenClient::~FullscreenClient):
+ (API::FullscreenClient::willEnterFullscreen):
+ (API::FullscreenClient::didEnterFullscreen):
+ (API::FullscreenClient::willExitFullscreen):
+ (API::FullscreenClient::didExitFullscreen):
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _initializeWithConfiguration:]):
+ (-[WKWebView _setFullscreenDelegate:]):
+ (-[WKWebView _fullscreenDelegate]):
+ (-[WKWebView _isInFullscreen]):
+ * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+ * UIProcess/API/Cocoa/_WKFullscreenDelegate.h: Added.
+ * UIProcess/Cocoa/FullscreenClient.h: Added.
+ (WebKit::FullscreenClient::~FullscreenClient):
+ * UIProcess/Cocoa/FullscreenClient.mm: Added.
+ (WebKit::FullscreenClient::FullscreenClient):
+ (WebKit::FullscreenClient::delegate):
+ (WebKit::FullscreenClient::setDelegate):
+ (WebKit::FullscreenClient::willEnterFullscreen):
+ (WebKit::FullscreenClient::didEnterFullscreen):
+ (WebKit::FullscreenClient::willExitFullscreen):
+ (WebKit::FullscreenClient::didExitFullscreen):
+ * UIProcess/WebFullScreenManagerProxy.cpp:
+ (WebKit::WebFullScreenManagerProxy::willEnterFullScreen):
+ (WebKit::WebFullScreenManagerProxy::didEnterFullScreen):
+ (WebKit::WebFullScreenManagerProxy::willExitFullScreen):
+ (WebKit::WebFullScreenManagerProxy::didExitFullScreen):
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::WebPageProxy):
+ (WebKit::WebPageProxy::setFullscreenClient):
+ (WebKit::WebPageProxy::fullScreenManager): Deleted.
+ * UIProcess/WebPageProxy.h:
+ (WebKit::WebPageProxy::fullscreenClient):
+ * WebKit2.xcodeproj/project.pbxproj:
+
2016-10-25 Carlos Garcia Campos <[email protected]>
Unreviewed. Fix timeouts in 12 GTK+ unit tests after r207812.
Added: trunk/Source/WebKit2/UIProcess/API/APIFullscreenClient.h (0 => 207820)
--- trunk/Source/WebKit2/UIProcess/API/APIFullscreenClient.h (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/APIFullscreenClient.h 2016-10-25 15:52:25 UTC (rev 207820)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#pragma once
+
+namespace WebKit {
+class WebPageProxy;
+}
+
+namespace API {
+
+class FullscreenClient {
+public:
+ virtual ~FullscreenClient() { }
+
+ virtual void willEnterFullscreen(WebKit::WebPageProxy*) { }
+ virtual void didEnterFullscreen(WebKit::WebPageProxy*) { }
+ virtual void willExitFullscreen(WebKit::WebPageProxy*) { }
+ virtual void didExitFullscreen(WebKit::WebPageProxy*) { }
+};
+
+} // namespace API
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (207819 => 207820)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2016-10-25 15:52:10 UTC (rev 207819)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2016-10-25 15:52:25 UTC (rev 207820)
@@ -34,6 +34,7 @@
#import "CompletionHandlerCallChecker.h"
#import "DiagnosticLoggingClient.h"
#import "FindClient.h"
+#import "FullscreenClient.h"
#import "LegacySessionStateCoding.h"
#import "Logging.h"
#import "NavigationState.h"
@@ -67,6 +68,7 @@
#import "WebBackForwardList.h"
#import "WebCertificateInfo.h"
#import "WebFormSubmissionListenerProxy.h"
+#import "WebFullScreenManagerProxy.h"
#import "WebKitSystemInterface.h"
#import "WebPageGroup.h"
#import "WebPageProxy.h"
@@ -77,6 +79,7 @@
#import "_WKDiagnosticLoggingDelegate.h"
#import "_WKFindDelegate.h"
#import "_WKFrameHandleInternal.h"
+#import "_WKFullscreenDelegate.h"
#import "_WKHitTestResultInternal.h"
#import "_WKInputDelegate.h"
#import "_WKRemoteObjectRegistryInternal.h"
@@ -550,6 +553,10 @@
_page->setFindClient(std::make_unique<WebKit::FindClient>(self));
_page->setDiagnosticLoggingClient(std::make_unique<WebKit::DiagnosticLoggingClient>(self));
+#if ENABLE(FULLSCREEN_API)
+ _page->setFullscreenClient(std::make_unique<WebKit::FullscreenClient>(self));
+#endif
+
pageToViewMap().add(_page.get(), self);
}
@@ -3922,6 +3929,31 @@
return _page->process().responsivenessTimer().isResponsive();
}
+- (void)_setFullscreenDelegate:(id<_WKFullscreenDelegate>)delegate
+{
+#if ENABLE(FULLSCREEN_API)
+ static_cast<WebKit::FullscreenClient&>(_page->fullscreenClient()).setDelegate(delegate);
+#endif
+}
+
+- (id<_WKFullscreenDelegate>)_fullscreenDelegate
+{
+#if ENABLE(FULLSCREEN_API)
+ return static_cast<WebKit::FullscreenClient&>(_page->fullscreenClient()).delegate().autorelease());
+#else
+ return nullptr;
+#endif
+}
+
+- (BOOL)_isInFullscreen
+{
+#if ENABLE(FULLSCREEN_API)
+ return _page->fullScreenManager() && _page->fullScreenManager()->isFullScreen();
+#else
+ return false;
+#endif
+}
+
#pragma mark iOS-specific methods
#if PLATFORM(IOS)
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h (207819 => 207820)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h 2016-10-25 15:52:10 UTC (rev 207819)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h 2016-10-25 15:52:25 UTC (rev 207820)
@@ -63,6 +63,7 @@
@protocol _WKDiagnosticLoggingDelegate;
@protocol _WKFindDelegate;
@protocol _WKInputDelegate;
+@protocol _WKFullscreenDelegate;
@interface WKWebView (WKPrivate)
@@ -244,6 +245,9 @@
@property (nonatomic, readonly) BOOL _webProcessIsResponsive WK_API_AVAILABLE(macosx(10.12), ios(10.0));
+@property (nonatomic, setter=_setFullscreenDelegate:) id<_WKFullscreenDelegate> _fullscreenDelegate WK_API_AVAILABLE(macos(10.13));
+@property (nonatomic, readonly) BOOL _isInFullscreen WK_API_AVAILABLE(macos(WK_MAC_TBA));
+
@end
#if !TARGET_OS_IPHONE
Added: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKFullscreenDelegate.h (0 => 207820)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKFullscreenDelegate.h (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKFullscreenDelegate.h 2016-10-25 15:52:25 UTC (rev 207820)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#import <WebKit/WKFoundation.h>
+
+#if WK_API_ENABLED
+
+@protocol _WKFullscreenDelegate <NSObject>
+
+@optional
+
+- (void)_webViewWillEnterFullscreen:(WKWebView *)webView;
+- (void)_webViewDidEnterFullscreen:(WKWebView *)webView;
+- (void)_webViewWillExitFullscreen:(WKWebView *)webView;
+- (void)_webViewDidExitFullscreen:(WKWebView *)webView;
+
+@end
+
+#endif
Added: trunk/Source/WebKit2/UIProcess/Cocoa/FullscreenClient.h (0 => 207820)
--- trunk/Source/WebKit2/UIProcess/Cocoa/FullscreenClient.h (rev 0)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/FullscreenClient.h 2016-10-25 15:52:25 UTC (rev 207820)
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#pragma once
+
+#import "WKFoundation.h"
+
+#if WK_API_ENABLED
+
+#import "APIFullscreenClient.h"
+#import "WeakObjCPtr.h"
+#import <wtf/RetainPtr.h>
+
+@class WKWebView;
+@protocol _WKFullscreenDelegate;
+
+namespace WebKit {
+
+class FullscreenClient : public API::FullscreenClient {
+public:
+ explicit FullscreenClient(WKWebView *);
+ ~FullscreenClient() { };
+
+ RetainPtr<id<_WKFullscreenDelegate>> delegate();
+ void setDelegate(id<_WKFullscreenDelegate>);
+
+ void willEnterFullscreen(WebPageProxy*) override;
+ void didEnterFullscreen(WebPageProxy*) override;
+ void willExitFullscreen(WebPageProxy*) override;
+ void didExitFullscreen(WebPageProxy*) override;
+
+private:
+ WKWebView *m_webView;
+ WeakObjCPtr<id <_WKFullscreenDelegate> > m_delegate;
+
+ struct {
+ bool webViewWillEnterFullscreen : 1;
+ bool webViewDidEnterFullscreen : 1;
+ bool webViewWillExitFullscreen : 1;
+ bool webViewDidExitFullscreen : 1;
+ } m_delegateMethods;
+};
+
+} // namespace WebKit
+
+#endif // WK_API_ENABLED
Added: trunk/Source/WebKit2/UIProcess/Cocoa/FullscreenClient.mm (0 => 207820)
--- trunk/Source/WebKit2/UIProcess/Cocoa/FullscreenClient.mm (rev 0)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/FullscreenClient.mm 2016-10-25 15:52:25 UTC (rev 207820)
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#import "config.h"
+#import "FullscreenClient.h"
+
+#if WK_API_ENABLED
+
+#import "_WKFullscreenDelegate.h"
+
+namespace WebKit {
+
+FullscreenClient::FullscreenClient(WKWebView *webView)
+ : m_webView(webView)
+{
+}
+
+RetainPtr<id <_WKFullscreenDelegate>> FullscreenClient::delegate()
+{
+ return m_delegate.get();
+}
+
+void FullscreenClient::setDelegate(id <_WKFullscreenDelegate> delegate)
+{
+ m_delegate = delegate;
+
+ m_delegateMethods.webViewWillEnterFullscreen = [delegate respondsToSelector:@selector(_webViewWillEnterFullscreen:)];
+ m_delegateMethods.webViewDidEnterFullscreen = [delegate respondsToSelector:@selector(_webViewDidEnterFullscreen:)];
+ m_delegateMethods.webViewWillExitFullscreen = [delegate respondsToSelector:@selector(_webViewWillExitFullscreen:)];
+ m_delegateMethods.webViewDidExitFullscreen = [delegate respondsToSelector:@selector(_webViewDidExitFullscreen:)];
+}
+
+void FullscreenClient::willEnterFullscreen(WebPageProxy*)
+{
+ if (m_delegateMethods.webViewWillEnterFullscreen)
+ [m_delegate.get() _webViewWillEnterFullscreen:m_webView];
+}
+
+void FullscreenClient::didEnterFullscreen(WebPageProxy*)
+{
+ if (m_delegateMethods.webViewDidEnterFullscreen)
+ [m_delegate.get() _webViewDidEnterFullscreen:m_webView];
+}
+
+void FullscreenClient::willExitFullscreen(WebPageProxy*)
+{
+ if (m_delegateMethods.webViewWillExitFullscreen)
+ [m_delegate.get() _webViewWillExitFullscreen:m_webView];
+}
+
+void FullscreenClient::didExitFullscreen(WebPageProxy*)
+{
+ if (m_delegateMethods.webViewDidExitFullscreen)
+ [m_delegate.get() _webViewDidExitFullscreen:m_webView];
+}
+
+} // namespace WebKit
+
+#endif // WK_API_ENABLED
Modified: trunk/Source/WebKit2/UIProcess/WebFullScreenManagerProxy.cpp (207819 => 207820)
--- trunk/Source/WebKit2/UIProcess/WebFullScreenManagerProxy.cpp 2016-10-25 15:52:10 UTC (rev 207819)
+++ trunk/Source/WebKit2/UIProcess/WebFullScreenManagerProxy.cpp 2016-10-25 15:52:25 UTC (rev 207820)
@@ -28,6 +28,7 @@
#if ENABLE(FULLSCREEN_API)
+#include "APIFullscreenClient.h"
#include "WebFullScreenManagerMessages.h"
#include "WebFullScreenManagerProxyMessages.h"
#include "WebPageProxy.h"
@@ -56,21 +57,25 @@
void WebFullScreenManagerProxy::willEnterFullScreen()
{
+ m_page->fullscreenClient().willEnterFullscreen(m_page);
m_page->process().send(Messages::WebFullScreenManager::WillEnterFullScreen(), m_page->pageID());
}
void WebFullScreenManagerProxy::didEnterFullScreen()
{
+ m_page->fullscreenClient().didEnterFullscreen(m_page);
m_page->process().send(Messages::WebFullScreenManager::DidEnterFullScreen(), m_page->pageID());
}
void WebFullScreenManagerProxy::willExitFullScreen()
{
+ m_page->fullscreenClient().willExitFullscreen(m_page);
m_page->process().send(Messages::WebFullScreenManager::WillExitFullScreen(), m_page->pageID());
}
void WebFullScreenManagerProxy::didExitFullScreen()
{
+ m_page->fullscreenClient().didExitFullscreen(m_page);
m_page->process().send(Messages::WebFullScreenManager::DidExitFullScreen(), m_page->pageID());
}
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (207819 => 207820)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2016-10-25 15:52:10 UTC (rev 207819)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2016-10-25 15:52:25 UTC (rev 207820)
@@ -33,6 +33,7 @@
#include "APIFindMatchesClient.h"
#include "APIFormClient.h"
#include "APIFrameInfo.h"
+#include "APIFullscreenClient.h"
#include "APIGeometry.h"
#include "APIHistoryClient.h"
#include "APIHitTestResult.h"
@@ -340,6 +341,9 @@
, m_mainFrame(nullptr)
, m_userAgent(standardUserAgent())
, m_treatsSHA1CertificatesAsInsecure(m_configuration->treatsSHA1SignedCertificatesAsInsecure())
+#if ENABLE(FULLSCREEN_API)
+ , m_fullscreenClient(std::make_unique<API::FullscreenClient>())
+#endif
#if PLATFORM(IOS)
, m_hasReceivedLayerTreeTransactionAfterDidCommitLoad(true)
, m_firstLayerTreeTransactionIdAfterDidCommitLoad(0)
@@ -4271,6 +4275,11 @@
{
return m_fullScreenManager.get();
}
+
+void WebPageProxy::setFullscreenClient(std::unique_ptr<API::FullscreenClient> client)
+{
+ m_fullscreenClient = WTFMove(client);
+}
#endif
#if (PLATFORM(IOS) && HAVE(AVKIT)) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (207819 => 207820)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2016-10-25 15:52:10 UTC (rev 207819)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2016-10-25 15:52:25 UTC (rev 207820)
@@ -127,6 +127,7 @@
class FindClient;
class FindMatchesClient;
class FormClient;
+class FullscreenClient;
class HistoryClient;
class LoaderClient;
class Navigation;
@@ -329,6 +330,9 @@
#if ENABLE(FULLSCREEN_API)
WebFullScreenManagerProxy* fullScreenManager();
+
+ API::FullscreenClient& fullscreenClient() const { return *m_fullscreenClient; }
+ void setFullscreenClient(std::unique_ptr<API::FullscreenClient>);
#endif
#if (PLATFORM(IOS) && HAVE(AVKIT)) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
WebPlaybackSessionManagerProxy* playbackSessionManager();
@@ -1605,6 +1609,7 @@
#if ENABLE(FULLSCREEN_API)
RefPtr<WebFullScreenManagerProxy> m_fullScreenManager;
+ std::unique_ptr<API::FullscreenClient> m_fullscreenClient;
#endif
#if (PLATFORM(IOS) && HAVE(AVKIT)) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
RefPtr<WebPlaybackSessionManagerProxy> m_playbackSessionManager;
Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (207819 => 207820)
--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2016-10-25 15:52:10 UTC (rev 207819)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2016-10-25 15:52:25 UTC (rev 207820)
@@ -1759,6 +1759,10 @@
CD73BA47131ACC9A00EEDED2 /* WebFullScreenManagerProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD73BA45131ACC8800EEDED2 /* WebFullScreenManagerProxyMessageReceiver.cpp */; };
CD73BA4E131ACDB700EEDED2 /* WebFullScreenManagerMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD73BA48131ACD8E00EEDED2 /* WebFullScreenManagerMessageReceiver.cpp */; };
CD73BA53131B645B00EEDED2 /* WebFullScreenManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD73BA37131A29FE00EEDED2 /* WebFullScreenManager.cpp */; };
+ CD78E1141DB7D7ED0014A2DE /* FullscreenClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD78E1121DB7D7ED0014A2DE /* FullscreenClient.mm */; };
+ CD78E1151DB7D7ED0014A2DE /* FullscreenClient.h in Headers */ = {isa = PBXBuildFile; fileRef = CD78E1131DB7D7ED0014A2DE /* FullscreenClient.h */; };
+ CD78E1171DB7DC0A0014A2DE /* APIFullscreenClient.h in Headers */ = {isa = PBXBuildFile; fileRef = CD78E1161DB7DC0A0014A2DE /* APIFullscreenClient.h */; };
+ CD78E1191DB7E5AD0014A2DE /* _WKFullscreenDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = CD78E1181DB7E5AD0014A2DE /* _WKFullscreenDelegate.h */; settings = {ATTRIBUTES = (Private, ); }; };
CDA041F41ACE2105004A13EC /* BackBoardServicesSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA041F31ACE2105004A13EC /* BackBoardServicesSPI.h */; };
CDA29A1A1CBDBF4100901CCF /* WebPlaybackSessionManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDA29A181CBDBF4100901CCF /* WebPlaybackSessionManager.mm */; };
CDA29A1B1CBDBF4100901CCF /* WebPlaybackSessionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA29A191CBDBF4100901CCF /* WebPlaybackSessionManager.h */; };
@@ -3901,6 +3905,10 @@
CD73BA48131ACD8E00EEDED2 /* WebFullScreenManagerMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebFullScreenManagerMessageReceiver.cpp; sourceTree = "<group>"; };
CD73BA49131ACD8E00EEDED2 /* WebFullScreenManagerMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebFullScreenManagerMessages.h; sourceTree = "<group>"; };
CD73BA4A131ACD8F00EEDED2 /* WebFullScreenManagerProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebFullScreenManagerProxyMessages.h; sourceTree = "<group>"; };
+ CD78E1121DB7D7ED0014A2DE /* FullscreenClient.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FullscreenClient.mm; sourceTree = "<group>"; };
+ CD78E1131DB7D7ED0014A2DE /* FullscreenClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FullscreenClient.h; sourceTree = "<group>"; };
+ CD78E1161DB7DC0A0014A2DE /* APIFullscreenClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIFullscreenClient.h; sourceTree = "<group>"; };
+ CD78E1181DB7E5AD0014A2DE /* _WKFullscreenDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKFullscreenDelegate.h; sourceTree = "<group>"; };
CDA041F31ACE2105004A13EC /* BackBoardServicesSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BackBoardServicesSPI.h; sourceTree = "<group>"; };
CDA29A181CBDBF4100901CCF /* WebPlaybackSessionManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebPlaybackSessionManager.mm; sourceTree = "<group>"; };
CDA29A191CBDBF4100901CCF /* WebPlaybackSessionManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPlaybackSessionManager.h; sourceTree = "<group>"; };
@@ -4802,6 +4810,8 @@
A1DF631018E0B7C8003A3E2A /* DownloadClient.mm */,
00B9661818E25AE100CE1F88 /* FindClient.h */,
00B9661718E25AE100CE1F88 /* FindClient.mm */,
+ CD78E1121DB7D7ED0014A2DE /* FullscreenClient.mm */,
+ CD78E1131DB7D7ED0014A2DE /* FullscreenClient.h */,
0F0C365918C0555800F607D7 /* LayerRepresentation.h */,
1ABC3DF41899E437004F0626 /* NavigationState.h */,
1ABC3DF31899E437004F0626 /* NavigationState.mm */,
@@ -5183,6 +5193,7 @@
2DEAC5CE1AC368BB00A195D8 /* _WKFindOptions.h */,
2E7A94491BBD95C600945547 /* _WKFocusedElementInfo.h */,
37A64E5618F38F4600EB30F1 /* _WKFormInputSession.h */,
+ CD78E1181DB7E5AD0014A2DE /* _WKFullscreenDelegate.h */,
37A64E5418F38E3C00EB30F1 /* _WKInputDelegate.h */,
2D790A9C1AD7050D00AB90B3 /* _WKLayoutMode.h */,
9323611D1B015DA800FA9232 /* _WKOverlayScrollbarStyle.h */,
@@ -6254,6 +6265,7 @@
37E25D6D18FDE5D6005D3A00 /* APIFormClient.h */,
2DF9EEE31A781FB400B6CFBE /* APIFrameInfo.cpp */,
2DF9EEE41A781FB400B6CFBE /* APIFrameInfo.h */,
+ CD78E1161DB7DC0A0014A2DE /* APIFullscreenClient.h */,
2DABA7751A82B42100EF0F1A /* APIHistoryClient.h */,
93A88B421BC8828C00ABA5C2 /* APIHitTestResult.cpp */,
93A88B431BC8828C00ABA5C2 /* APIHitTestResult.h */,
@@ -7528,6 +7540,7 @@
1AFB4C721ADF155D00B33339 /* _WKWebsiteDataStore.h in Headers */,
1A4A93B71AEB08EA00150E9C /* _WKWebsiteDataStoreInternal.h in Headers */,
A115DC72191D82DA00DA8072 /* _WKWebViewPrintFormatter.h in Headers */,
+ CD78E1191DB7E5AD0014A2DE /* _WKFullscreenDelegate.h in Headers */,
A19DD3C01D07D16800AC823B /* _WKWebViewPrintFormatterInternal.h in Headers */,
A182D5B51BE6BD250087A7CC /* AccessibilityIOS.h in Headers */,
A7D792D81767CCA300881CBE /* ActivityAssertion.h in Headers */,
@@ -8275,6 +8288,7 @@
8372DB251A674C8F00C697C5 /* WKPageDiagnosticLoggingClient.h in Headers */,
1AB8A1F418400B8F00E9AE69 /* WKPageFindClient.h in Headers */,
1AB8A1F618400B9D00E9AE69 /* WKPageFindMatchesClient.h in Headers */,
+ CD78E1151DB7D7ED0014A2DE /* FullscreenClient.h in Headers */,
1AB8A1F018400B0000E9AE69 /* WKPageFormClient.h in Headers */,
BC7B633712A45ABA00D174A4 /* WKPageGroup.h in Headers */,
2D9EA30D1A96CB59002D2807 /* WKPageInjectedBundleClient.h in Headers */,
@@ -8306,6 +8320,7 @@
9391074F1BF6BC65008C17AD /* WKPreviewElementInfoInternal.h in Headers */,
0FCB4E6618BBE3D9000FCFC9 /* WKPrintingView.h in Headers */,
BCBAACEB145225E30053F82F /* WKProcessGroup.h in Headers */,
+ CD78E1171DB7DC0A0014A2DE /* APIFullscreenClient.h in Headers */,
BCBAACED145225E30053F82F /* WKProcessGroupPrivate.h in Headers */,
1A15841A189044F50017616C /* WKProcessPool.h in Headers */,
1A3CC16918907EB0001E6ED8 /* WKProcessPoolInternal.h in Headers */,
@@ -9213,6 +9228,7 @@
E4436ECD1A0D040B00EAD204 /* NetworkCacheKey.cpp in Sources */,
831EEBBE1BD85C4300BB64C3 /* NetworkCacheSpeculativeLoad.cpp in Sources */,
832AE2531BE2E8CD00FAAE10 /* NetworkCacheSpeculativeLoadManager.cpp in Sources */,
+ CD78E1141DB7D7ED0014A2DE /* FullscreenClient.mm in Sources */,
83BDCCB91AC5FDB6003F6441 /* NetworkCacheStatistics.cpp in Sources */,
E4436ED01A0D040B00EAD204 /* NetworkCacheStorage.cpp in Sources */,
8310428C1BD6B66F00A715E4 /* NetworkCacheSubresourcesEntry.cpp in Sources */,
Modified: trunk/Tools/ChangeLog (207819 => 207820)
--- trunk/Tools/ChangeLog 2016-10-25 15:52:10 UTC (rev 207819)
+++ trunk/Tools/ChangeLog 2016-10-25 15:52:25 UTC (rev 207820)
@@ -1,3 +1,20 @@
+2016-10-19 Jer Noble <[email protected]>
+
+ Add WKWebView fullscreen delegate SPI
+ https://bugs.webkit.org/show_bug.cgi?id=163674
+
+ Reviewed by Anders Carlsson.
+
+ Add a new API test which verifies that the fullscreen delegate receives notifications.
+
+ * TestWebKitAPI/Tests/WebKit2Cocoa/FullscreenDelegate.mm:
+ (-[FullscreenDelegateMessageHandler userContentController:didReceiveScriptMessage:]):
+ (-[FullscreenDelegateMessageHandler _webViewWillEnterFullscreen:]):
+ (-[FullscreenDelegateMessageHandler _webViewDidEnterFullscreen:]):
+ (-[FullscreenDelegateMessageHandler _webViewWillExitFullscreen:]):
+ (-[FullscreenDelegateMessageHandler _webViewDidExitFullscreen:]):
+ (TestWebKitAPI::TEST):
+
2016-10-24 Alex Christensen <[email protected]>
URLParser should match old URL::parse with %2E in path
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (207819 => 207820)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2016-10-25 15:52:10 UTC (rev 207819)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2016-10-25 15:52:25 UTC (rev 207820)
@@ -473,6 +473,8 @@
C5E1AFFE16B221F1006CC1F2 /* execCopy.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C5E1AFFD16B22179006CC1F2 /* execCopy.html */; };
CD59F53419E9110D00CF1835 /* file-with-mse.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD59F53219E910AA00CF1835 /* file-with-mse.html */; };
CD59F53519E9110D00CF1835 /* test-mse.mp4 in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD59F53319E910BC00CF1835 /* test-mse.mp4 */; };
+ CD78E11D1DB7EA660014A2DE /* FullscreenDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD78E11A1DB7EA360014A2DE /* FullscreenDelegate.mm */; };
+ CD78E11E1DB7EE2A0014A2DE /* FullscreenDelegate.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD78E11B1DB7EA360014A2DE /* FullscreenDelegate.html */; };
CD9E292E1C90C33F000BB800 /* audio-only.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD9E292D1C90C1BA000BB800 /* audio-only.html */; };
CDBFCC451A9FF45300A7B691 /* FullscreenZoomInitialFrame.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDBFCC431A9FF44800A7B691 /* FullscreenZoomInitialFrame.mm */; };
CDBFCC461A9FF49E00A7B691 /* FullscreenZoomInitialFrame.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CDBFCC421A9FF44800A7B691 /* FullscreenZoomInitialFrame.html */; };
@@ -567,6 +569,7 @@
8349D3C41DB9728E004A9F65 /* link-with-download-attribute.html in Copy Resources */,
AD57AC221DA7466E00FF1BDE /* many-iframes.html in Copy Resources */,
F415086D1DA040C50044BE9B /* play-audio-on-click.html in Copy Resources */,
+ CD78E11E1DB7EE2A0014A2DE /* FullscreenDelegate.html in Copy Resources */,
F4F137921D9B683E002BEC57 /* large-video-test-now-playing.html in Copy Resources */,
837A35F11D9A1E7D00663C57 /* DownloadRequestBlobURL.html in Copy Resources */,
2E9896151D8F093800739892 /* text-and-password-inputs.html in Copy Resources */,
@@ -1187,6 +1190,8 @@
CD59F53219E910AA00CF1835 /* file-with-mse.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "file-with-mse.html"; sourceTree = "<group>"; };
CD59F53319E910BC00CF1835 /* test-mse.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = "test-mse.mp4"; sourceTree = "<group>"; };
CD773F711C5057DB0002257C /* FeatureDefines.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = FeatureDefines.xcconfig; sourceTree = "<group>"; };
+ CD78E11A1DB7EA360014A2DE /* FullscreenDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FullscreenDelegate.mm; sourceTree = "<group>"; };
+ CD78E11B1DB7EA360014A2DE /* FullscreenDelegate.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = FullscreenDelegate.html; sourceTree = "<group>"; };
CD89D0381C4EDB2A00040A04 /* WebCoreNSURLSession.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreNSURLSession.mm; sourceTree = "<group>"; };
CD9E292B1C90A71F000BB800 /* RequiresUserActionForPlayback.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RequiresUserActionForPlayback.mm; sourceTree = "<group>"; };
CD9E292D1C90C1BA000BB800 /* audio-only.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "audio-only.html"; sourceTree = "<group>"; };
@@ -1393,6 +1398,7 @@
A1A4FE5D18DD3DB700B5EA8A /* Download.mm */,
2D8104CB1BEC13E70020DA46 /* FindInPage.mm */,
2D1FE0AF1AD465C1006CD9E6 /* FixedLayoutSize.mm */,
+ CD78E11A1DB7EA360014A2DE /* FullscreenDelegate.mm */,
3F1B52681D3D7129008D60C4 /* FullscreenLayoutConstraints.mm */,
CDE195B31CFE0ADE0053D256 /* FullscreenTopContentInset.mm */,
510477751D298E03009747EB /* IDBDeleteRecovery.mm */,
@@ -1552,6 +1558,7 @@
9984FACD1CFFB038008D198C /* editable-body.html */,
93575C551D30366E000D604D /* focus-inputs.html */,
F4F405BA1D4C0CF8007A9707 /* full-size-autoplaying-video-with-audio.html */,
+ CD78E11B1DB7EA360014A2DE /* FullscreenDelegate.html */,
3FBD1B491D39D1DB00E6D6FA /* FullscreenLayoutConstraints.html */,
CDE195B21CFE0ADE0053D256 /* FullscreenTopContentInset.html */,
510477761D298E57009747EB /* IDBDeleteRecovery.html */,
@@ -2540,6 +2547,7 @@
51714EB81CF8CA17004723C4 /* WebProcessKillIDBCleanup.mm in Sources */,
536770341CC8022800D425B1 /* WebScriptObjectDescription.mm in Sources */,
7CCE7ED41A411A7E00447C4C /* WebViewCanPasteURL.mm in Sources */,
+ CD78E11D1DB7EA660014A2DE /* FullscreenDelegate.mm in Sources */,
7C83E0421D0A63FD00FEBCF3 /* WebViewCloseInsideDidFinishLoadForFrame.mm in Sources */,
7CCE7ED51A411A7E00447C4C /* WebViewDidCreateJavaScriptContext.mm in Sources */,
7CCE7ED61A411A7E00447C4C /* WebViewDidRemoveFrameFromHierarchy.mm in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/FullscreenDelegate.html (0 => 207820)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/FullscreenDelegate.html (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/FullscreenDelegate.html 2016-10-25 15:52:25 UTC (rev 207820)
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script>
+ function load() {
+ window.webkit.messageHandlers.fullscreenChangeHandler.postMessage('load');
+ }
+ document.addEventListener('webkitfullscreenchange', function(event) {
+ window.webkit.messageHandlers.fullscreenChangeHandler.postMessage('fullscreenchange');
+ });
+ document.addEventListener('mousedown', function(event) {
+ // Toggle fullscreen
+ var target = document.getElementById('target');
+ if (document.webkitFullscreenElement == target)
+ document.webkitExitFullscreen();
+ else
+ target.webkitRequestFullScreen();
+ });
+ </script>
+ <style>
+ #target {
+ background-color: red;
+ width: 150px;
+ height: 150px;
+ }
+ </style>
+</head>
+<body _onload_="load()">
+ <div id="target"></div>
+</body>
+</html>
\ No newline at end of file
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/FullscreenDelegate.mm (0 => 207820)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/FullscreenDelegate.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/FullscreenDelegate.mm 2016-10-25 15:52:25 UTC (rev 207820)
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2016 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 WK_API_ENABLED && PLATFORM(MAC)
+
+#import "PlatformUtilities.h"
+#import <WebKit/WKPreferencesPrivate.h>
+#import <WebKit/WKWebViewConfigurationPrivate.h>
+#import <WebKit/WKWebViewPrivate.h>
+#import <WebKit/_WKFullscreenDelegate.h>
+#import <wtf/RetainPtr.h>
+
+static bool receivedLoadedMessage;
+static bool receivedWillEnterFullscreenMessage;
+static bool receivedDidEnterFullscreenMessage;
+static bool receivedWillExitFullscreenMessage;
+static bool receivedDidExitFullscreenMessage;
+
+@interface FullscreenDelegateMessageHandler : NSObject <WKScriptMessageHandler, _WKFullscreenDelegate>
+@end
+
+@implementation FullscreenDelegateMessageHandler
+- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message
+{
+ NSString *bodyString = (NSString *)[message body];
+ if ([bodyString isEqualToString:@"load"])
+ receivedLoadedMessage = true;
+}
+
+- (void)_webViewWillEnterFullscreen:(WKWebView *)view
+{
+ receivedWillEnterFullscreenMessage = true;
+}
+
+- (void)_webViewDidEnterFullscreen:(WKWebView *)view
+{
+ receivedDidEnterFullscreenMessage = true;
+}
+
+- (void)_webViewWillExitFullscreen:(WKWebView *)view
+{
+ receivedWillExitFullscreenMessage = true;
+}
+
+- (void)_webViewDidExitFullscreen:(WKWebView *)view
+{
+ receivedDidExitFullscreenMessage = true;
+}
+@end
+
+namespace TestWebKitAPI {
+
+TEST(Fullscreen, Delegate)
+{
+ RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]);
+ [configuration preferences]._fullScreenEnabled = YES;
+ RetainPtr<FullscreenDelegateMessageHandler> handler = adoptNS([[FullscreenDelegateMessageHandler alloc] init]);
+ [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"fullscreenChangeHandler"];
+ [webView _setFullscreenDelegate:handler.get()];
+
+ RetainPtr<NSWindow> window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]);
+ [[window contentView] addSubview:webView.get()];
+
+ NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"FullscreenDelegate" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
+ [webView loadRequest:request];
+ TestWebKitAPI::Util::run(&receivedLoadedMessage);
+
+ NSEvent *event = [NSEvent mouseEventWithType:NSLeftMouseDown location:NSMakePoint(5, 5) modifierFlags:0 timestamp:0 windowNumber:window.get().windowNumber context:0 eventNumber:0 clickCount:0 pressure:0];
+ [webView mouseDown:event];
+
+ ASSERT_FALSE([webView _isInFullscreen]);
+ TestWebKitAPI::Util::run(&receivedWillEnterFullscreenMessage);
+ TestWebKitAPI::Util::run(&receivedDidEnterFullscreenMessage);
+
+ ASSERT_TRUE([webView _isInFullscreen]);
+ [webView mouseDown:event];
+ TestWebKitAPI::Util::run(&receivedWillExitFullscreenMessage);
+ TestWebKitAPI::Util::run(&receivedDidExitFullscreenMessage);
+
+ ASSERT_FALSE([webView _isInFullscreen]);
+}
+
+} // namespace TestWebKitAPI
+
+#endif