Title: [256531] trunk
Revision
256531
Author
[email protected]
Date
2020-02-13 12:22:05 -0800 (Thu, 13 Feb 2020)

Log Message

[iOS] Check if PIP is supported in the UI process
https://bugs.webkit.org/show_bug.cgi?id=207406

Reviewed by Brent Fulgham.

Source/WebCore:

This is currently being checked in the WebProcess, but since this check is initiating communication with the frontboard
service which will be blocked, this check should be moved to the UI process. In the UI process, this is checked when
starting a new WebContent process, and sent to the WebContent process as part of the process creation parameters. The
WebContent is storing the received value.

API test: WebKit.PictureInPictureSupport

* platform/PictureInPictureSupport.h:
* platform/ios/VideoFullscreenInterfaceAVKit.mm:
(WebCore::setSupportsPictureInPicture):
(WebCore::supportsPictureInPicture):
* testing/Internals.cpp:
(WebCore::Internals::supportsPictureInPicture):
* testing/Internals.h:
* testing/Internals.idl:

Source/WebKit:

When starting a new WebContent process, check if PIP is supported, and pass the results to the newly created
WebContent process.

* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::encode const):
(WebKit::WebProcessCreationParameters::decode):
* Shared/WebProcessCreationParameters.h:
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitializeWebProcess):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::platformInitializeWebProcess):

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit/PictureInPictureSupport.mm: Added.
(TEST):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (256530 => 256531)


--- trunk/Source/WebCore/ChangeLog	2020-02-13 19:47:29 UTC (rev 256530)
+++ trunk/Source/WebCore/ChangeLog	2020-02-13 20:22:05 UTC (rev 256531)
@@ -1,3 +1,26 @@
+2020-02-13  Per Arne Vollan  <[email protected]>
+
+        [iOS] Check if PIP is supported in the UI process
+        https://bugs.webkit.org/show_bug.cgi?id=207406
+
+        Reviewed by Brent Fulgham.
+
+        This is currently being checked in the WebProcess, but since this check is initiating communication with the frontboard
+        service which will be blocked, this check should be moved to the UI process. In the UI process, this is checked when
+        starting a new WebContent process, and sent to the WebContent process as part of the process creation parameters. The
+        WebContent is storing the received value.
+
+        API test: WebKit.PictureInPictureSupport
+
+        * platform/PictureInPictureSupport.h:
+        * platform/ios/VideoFullscreenInterfaceAVKit.mm:
+        (WebCore::setSupportsPictureInPicture):
+        (WebCore::supportsPictureInPicture):
+        * testing/Internals.cpp:
+        (WebCore::Internals::supportsPictureInPicture):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2020-02-13  Benjamin Nham  <[email protected]>
 
         Allow use of proxies in MiniBrowser

Modified: trunk/Source/WebCore/platform/PictureInPictureSupport.h (256530 => 256531)


--- trunk/Source/WebCore/platform/PictureInPictureSupport.h	2020-02-13 19:47:29 UTC (rev 256530)
+++ trunk/Source/WebCore/platform/PictureInPictureSupport.h	2020-02-13 20:22:05 UTC (rev 256531)
@@ -28,6 +28,7 @@
 namespace WebCore {
 
 #if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
+WEBCORE_EXPORT void setSupportsPictureInPicture(bool);
 WEBCORE_EXPORT bool supportsPictureInPicture();
 #else
 constexpr bool supportsPictureInPicture() { return false; }

Modified: trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm (256530 => 256531)


--- trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm	2020-02-13 19:47:29 UTC (rev 256530)
+++ trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm	2020-02-13 20:22:05 UTC (rev 256531)
@@ -1503,9 +1503,18 @@
 
 #endif // HAVE(AVKIT)
 
+static Optional<bool> isPictureInPictureSupported;
+
+void WebCore::setSupportsPictureInPicture(bool isSupported)
+{
+    isPictureInPictureSupported = isSupported;
+}
+
 bool WebCore::supportsPictureInPicture()
 {
 #if PLATFORM(IOS_FAMILY) && HAVE(AVKIT) && !PLATFORM(WATCHOS)
+    if (isPictureInPictureSupported.hasValue())
+        return *isPictureInPictureSupported;
     return [getAVPictureInPictureControllerClass() isPictureInPictureSupported];
 #else
     return false;

Modified: trunk/Source/WebCore/testing/Internals.cpp (256530 => 256531)


--- trunk/Source/WebCore/testing/Internals.cpp	2020-02-13 19:47:29 UTC (rev 256530)
+++ trunk/Source/WebCore/testing/Internals.cpp	2020-02-13 20:22:05 UTC (rev 256531)
@@ -138,6 +138,7 @@
 #include "Page.h"
 #include "PageOverlay.h"
 #include "PathUtilities.h"
+#include "PictureInPictureSupport.h"
 #include "PlatformKeyboardEvent.h"
 #include "PlatformMediaSessionManager.h"
 #include "PlatformScreen.h"
@@ -5466,6 +5467,11 @@
     return MIMETypeRegistry::getMediaMIMETypeForExtension(extension);
 }
 
+bool Internals::supportsPictureInPicture()
+{
+    return WebCore::supportsPictureInPicture();
+}
+
 String Internals::focusRingColor()
 {
     OptionSet<StyleColor::Options> options;

Modified: trunk/Source/WebCore/testing/Internals.h (256530 => 256531)


--- trunk/Source/WebCore/testing/Internals.h	2020-02-13 19:47:29 UTC (rev 256530)
+++ trunk/Source/WebCore/testing/Internals.h	2020-02-13 20:22:05 UTC (rev 256531)
@@ -935,6 +935,8 @@
 
     String mediaMIMETypeForExtension(const String& extension);
 
+    bool supportsPictureInPicture();
+
     String focusRingColor();
 
 private:

Modified: trunk/Source/WebCore/testing/Internals.idl (256530 => 256531)


--- trunk/Source/WebCore/testing/Internals.idl	2020-02-13 19:47:29 UTC (rev 256530)
+++ trunk/Source/WebCore/testing/Internals.idl	2020-02-13 20:22:05 UTC (rev 256531)
@@ -843,4 +843,6 @@
     boolean systemHasBattery();
 
     DOMString mediaMIMETypeForExtension(DOMString extension);
+    
+    boolean supportsPictureInPicture();
 };

Modified: trunk/Source/WebKit/ChangeLog (256530 => 256531)


--- trunk/Source/WebKit/ChangeLog	2020-02-13 19:47:29 UTC (rev 256530)
+++ trunk/Source/WebKit/ChangeLog	2020-02-13 20:22:05 UTC (rev 256531)
@@ -1,3 +1,22 @@
+2020-02-13  Per Arne Vollan  <[email protected]>
+
+        [iOS] Check if PIP is supported in the UI process
+        https://bugs.webkit.org/show_bug.cgi?id=207406
+
+        Reviewed by Brent Fulgham.
+
+        When starting a new WebContent process, check if PIP is supported, and pass the results to the newly created
+        WebContent process.
+
+        * Shared/WebProcessCreationParameters.cpp:
+        (WebKit::WebProcessCreationParameters::encode const):
+        (WebKit::WebProcessCreationParameters::decode):
+        * Shared/WebProcessCreationParameters.h:
+        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+        (WebKit::WebProcessPool::platformInitializeWebProcess):
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::platformInitializeWebProcess):
+
 2020-02-13  Benjamin Nham  <[email protected]>
 
         Allow use of proxies in MiniBrowser

Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp (256530 => 256531)


--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp	2020-02-13 19:47:29 UTC (rev 256530)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp	2020-02-13 20:22:05 UTC (rev 256531)
@@ -172,6 +172,7 @@
 
 #if PLATFORM(IOS_FAMILY)
     encoder << currentUserInterfaceIdiomIsPad;
+    encoder << supportsPictureInPicture;
     encoder << cssValueToSystemColorMap;
     encoder << focusRingColor;
 #endif
@@ -454,6 +455,9 @@
     if (!decoder.decode(parameters.currentUserInterfaceIdiomIsPad))
         return false;
 
+    if (!decoder.decode(parameters.supportsPictureInPicture))
+        return false;
+
     Optional<WebCore::RenderThemeIOS::CSSValueToSystemColorMap> cssValueToSystemColorMap;
     decoder >> cssValueToSystemColorMap;
     if (!cssValueToSystemColorMap)

Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.h (256530 => 256531)


--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.h	2020-02-13 19:47:29 UTC (rev 256530)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.h	2020-02-13 20:22:05 UTC (rev 256531)
@@ -214,6 +214,7 @@
 
 #if PLATFORM(IOS_FAMILY)
     bool currentUserInterfaceIdiomIsPad { false };
+    bool supportsPictureInPicture { false };
     WebCore::RenderThemeIOS::CSSValueToSystemColorMap cssValueToSystemColorMap;
     WebCore::Color focusRingColor;
 #endif

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (256530 => 256531)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2020-02-13 19:47:29 UTC (rev 256530)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2020-02-13 20:22:05 UTC (rev 256531)
@@ -360,6 +360,7 @@
     
 #if PLATFORM(IOS_FAMILY)
     parameters.currentUserInterfaceIdiomIsPad = currentUserInterfaceIdiomIsPad();
+    parameters.supportsPictureInPicture = supportsPictureInPicture();
     parameters.cssValueToSystemColorMap = RenderThemeIOS::cssValueToSystemColorMap();
     parameters.focusRingColor = RenderTheme::singleton().focusRingColor(OptionSet<StyleColor::Options>());
 #endif

Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (256530 => 256531)


--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2020-02-13 19:47:29 UTC (rev 256530)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2020-02-13 20:22:05 UTC (rev 256531)
@@ -63,6 +63,7 @@
 #import <WebCore/MemoryRelease.h>
 #import <WebCore/NSScrollerImpDetails.h>
 #import <WebCore/PerformanceLogging.h>
+#import <WebCore/PictureInPictureSupport.h>
 #import <WebCore/RuntimeApplicationChecks.h>
 #import <WebCore/SWContextManager.h>
 #import <algorithm>
@@ -197,6 +198,7 @@
 
 #if PLATFORM(IOS_FAMILY)
     setCurrentUserInterfaceIdiomIsPad(parameters.currentUserInterfaceIdiomIsPad);
+    setSupportsPictureInPicture(parameters.supportsPictureInPicture);
 #endif
 
 #if USE(APPKIT)

Modified: trunk/Tools/ChangeLog (256530 => 256531)


--- trunk/Tools/ChangeLog	2020-02-13 19:47:29 UTC (rev 256530)
+++ trunk/Tools/ChangeLog	2020-02-13 20:22:05 UTC (rev 256531)
@@ -1,3 +1,14 @@
+2020-02-13  Per Arne Vollan  <[email protected]>
+
+        [iOS] Check if PIP is supported in the UI process
+        https://bugs.webkit.org/show_bug.cgi?id=207406
+
+        Reviewed by Brent Fulgham.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit/PictureInPictureSupport.mm: Added.
+        (TEST):
+
 2020-02-13  Jonathan Bedard  <[email protected]>
 
         TestWebKitAPI: Conditionalize fullscreen tests on fullscreen API

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (256530 => 256531)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2020-02-13 19:47:29 UTC (rev 256530)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2020-02-13 20:22:05 UTC (rev 256531)
@@ -990,6 +990,7 @@
 		E1220DCA155B28AA0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E1220DC9155B287D0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html */; };
 		E194E1BD177E53C7009C4D4E /* StopLoadingFromDidReceiveResponse.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E194E1BC177E534A009C4D4E /* StopLoadingFromDidReceiveResponse.html */; };
 		E324A6F02041C82000A76593 /* UniqueArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E398BC0F2041C76300387136 /* UniqueArray.cpp */; };
+		E325C90723E3870200BC7D3B /* PictureInPictureSupport.mm in Sources */ = {isa = PBXBuildFile; fileRef = E325C90623E3870200BC7D3B /* PictureInPictureSupport.mm */; };
 		E32B549222810AC4008AD702 /* Packed.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E32B549122810AC0008AD702 /* Packed.cpp */; };
 		E35FC7B222B82A7300F32F98 /* JSLockTakesWebThreadLock.mm in Sources */ = {isa = PBXBuildFile; fileRef = E35FC7B122B82A6D00F32F98 /* JSLockTakesWebThreadLock.mm */; };
 		E373D7911F2CF35200C6FAAF /* Signals.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3953F951F2CF32100A76A2E /* Signals.cpp */; };
@@ -2564,6 +2565,7 @@
 		E1220DC9155B287D0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = MemoryCacheDisableWithinResourceLoadDelegate.html; sourceTree = "<group>"; };
 		E194E1BA177E5145009C4D4E /* StopLoadingFromDidReceiveResponse.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StopLoadingFromDidReceiveResponse.mm; sourceTree = "<group>"; };
 		E194E1BC177E534A009C4D4E /* StopLoadingFromDidReceiveResponse.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = StopLoadingFromDidReceiveResponse.html; sourceTree = "<group>"; };
+		E325C90623E3870200BC7D3B /* PictureInPictureSupport.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PictureInPictureSupport.mm; sourceTree = "<group>"; };
 		E32B549122810AC0008AD702 /* Packed.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Packed.cpp; sourceTree = "<group>"; };
 		E35FC7B122B82A6D00F32F98 /* JSLockTakesWebThreadLock.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = JSLockTakesWebThreadLock.mm; sourceTree = "<group>"; };
 		E388887020C9098100E632BC /* WorkerPool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkerPool.cpp; sourceTree = "<group>"; };
@@ -2871,6 +2873,7 @@
 				C1692DC923D10DAE006E88F7 /* Battery.mm */,
 				E394AE6E23F2303E005B4936 /* GrantAccessToMobileAssets.mm */,
 				C145CC0B23DA5A0F003A5EEB /* MimeTypes.mm */,
+				E325C90623E3870200BC7D3B /* PictureInPictureSupport.mm */,
 				0F139E751A423A5300F590F5 /* WeakObjCPtr.mm */,
 			);
 			name = cocoa;
@@ -4917,6 +4920,7 @@
 				516281272325C19800BB7E42 /* PDFSnapshot.mm in Sources */,
 				7C83E0531D0A643A00FEBCF3 /* PendingAPIRequestURL.cpp in Sources */,
 				3FCC4FE51EC4E8520076E37C /* PictureInPictureDelegate.mm in Sources */,
+				E325C90723E3870200BC7D3B /* PictureInPictureSupport.mm in Sources */,
 				7CCE7EA61A411A0F00447C4C /* PlatformUtilitiesMac.mm in Sources */,
 				7CCE7EA71A411A1300447C4C /* PlatformWebViewMac.mm in Sources */,
 				83BAEE8D1EF4625500DDE894 /* PluginLoadClientPolicies.mm in Sources */,

Copied: trunk/Tools/TestWebKitAPI/Tests/WebKit/PictureInPictureSupport.mm (from rev 256530, trunk/Source/WebCore/platform/PictureInPictureSupport.h) (0 => 256531)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit/PictureInPictureSupport.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit/PictureInPictureSupport.mm	2020-02-13 20:22:05 UTC (rev 256531)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2020 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_HAVE_C_SPI
+
+#import "PlatformUtilities.h"
+#import "TestWKWebView.h"
+#import <WebCore/PictureInPictureSupport.h>
+
+TEST(WebKit, PictureInPictureSupport)
+{
+    auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    WKRetainPtr<WKContextRef> context = adoptWK(TestWebKitAPI::Util::createContextForInjectedBundleTest("InternalsInjectedBundleTest"));
+    configuration.get().processPool = (WKProcessPool *)context.get();
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get() addToWindow:YES]);
+
+    auto supportsPictureInPicture = [&] {
+        return [webView stringByEvaluatingJavaScript:@"window.internals.supportsPictureInPicture()"].boolValue;
+    };
+
+    ASSERT_TRUE(supportsPictureInPicture() == WebCore::supportsPictureInPicture());
+}
+
+#endif // WK_HAVE_C_SPI
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to