Changeset 256531 in webkit


Ignore:
Timestamp:
Feb 13, 2020 12:22:05 PM (4 years ago)
Author:
pvollan@apple.com
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):

Location:
trunk
Files:
13 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r256530 r256531  
     12020-02-13  Per Arne Vollan  <pvollan@apple.com>
     2
     3        [iOS] Check if PIP is supported in the UI process
     4        https://bugs.webkit.org/show_bug.cgi?id=207406
     5
     6        Reviewed by Brent Fulgham.
     7
     8        This is currently being checked in the WebProcess, but since this check is initiating communication with the frontboard
     9        service which will be blocked, this check should be moved to the UI process. In the UI process, this is checked when
     10        starting a new WebContent process, and sent to the WebContent process as part of the process creation parameters. The
     11        WebContent is storing the received value.
     12
     13        API test: WebKit.PictureInPictureSupport
     14
     15        * platform/PictureInPictureSupport.h:
     16        * platform/ios/VideoFullscreenInterfaceAVKit.mm:
     17        (WebCore::setSupportsPictureInPicture):
     18        (WebCore::supportsPictureInPicture):
     19        * testing/Internals.cpp:
     20        (WebCore::Internals::supportsPictureInPicture):
     21        * testing/Internals.h:
     22        * testing/Internals.idl:
     23
    1242020-02-13  Benjamin Nham  <nham@apple.com>
    225
  • trunk/Source/WebCore/platform/PictureInPictureSupport.h

    r251834 r256531  
    2929
    3030#if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
     31WEBCORE_EXPORT void setSupportsPictureInPicture(bool);
    3132WEBCORE_EXPORT bool supportsPictureInPicture();
    3233#else
  • trunk/Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm

    r254512 r256531  
    15041504#endif // HAVE(AVKIT)
    15051505
     1506static Optional<bool> isPictureInPictureSupported;
     1507
     1508void WebCore::setSupportsPictureInPicture(bool isSupported)
     1509{
     1510    isPictureInPictureSupported = isSupported;
     1511}
     1512
    15061513bool WebCore::supportsPictureInPicture()
    15071514{
    15081515#if PLATFORM(IOS_FAMILY) && HAVE(AVKIT) && !PLATFORM(WATCHOS)
     1516    if (isPictureInPictureSupported.hasValue())
     1517        return *isPictureInPictureSupported;
    15091518    return [getAVPictureInPictureControllerClass() isPictureInPictureSupported];
    15101519#else
  • trunk/Source/WebCore/testing/Internals.cpp

    r255957 r256531  
    139139#include "PageOverlay.h"
    140140#include "PathUtilities.h"
     141#include "PictureInPictureSupport.h"
    141142#include "PlatformKeyboardEvent.h"
    142143#include "PlatformMediaSessionManager.h"
     
    54675468}
    54685469
     5470bool Internals::supportsPictureInPicture()
     5471{
     5472    return WebCore::supportsPictureInPicture();
     5473}
     5474
    54695475String Internals::focusRingColor()
    54705476{
  • trunk/Source/WebCore/testing/Internals.h

    r255875 r256531  
    936936    String mediaMIMETypeForExtension(const String& extension);
    937937
     938    bool supportsPictureInPicture();
     939
    938940    String focusRingColor();
    939941
  • trunk/Source/WebCore/testing/Internals.idl

    r255875 r256531  
    844844
    845845    DOMString mediaMIMETypeForExtension(DOMString extension);
    846 };
     846   
     847    boolean supportsPictureInPicture();
     848};
  • trunk/Source/WebKit/ChangeLog

    r256530 r256531  
     12020-02-13  Per Arne Vollan  <pvollan@apple.com>
     2
     3        [iOS] Check if PIP is supported in the UI process
     4        https://bugs.webkit.org/show_bug.cgi?id=207406
     5
     6        Reviewed by Brent Fulgham.
     7
     8        When starting a new WebContent process, check if PIP is supported, and pass the results to the newly created
     9        WebContent process.
     10
     11        * Shared/WebProcessCreationParameters.cpp:
     12        (WebKit::WebProcessCreationParameters::encode const):
     13        (WebKit::WebProcessCreationParameters::decode):
     14        * Shared/WebProcessCreationParameters.h:
     15        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
     16        (WebKit::WebProcessPool::platformInitializeWebProcess):
     17        * WebProcess/cocoa/WebProcessCocoa.mm:
     18        (WebKit::WebProcess::platformInitializeWebProcess):
     19
    1202020-02-13  Benjamin Nham  <nham@apple.com>
    221
  • trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp

    r255457 r256531  
    173173#if PLATFORM(IOS_FAMILY)
    174174    encoder << currentUserInterfaceIdiomIsPad;
     175    encoder << supportsPictureInPicture;
    175176    encoder << cssValueToSystemColorMap;
    176177    encoder << focusRingColor;
     
    455456        return false;
    456457
     458    if (!decoder.decode(parameters.supportsPictureInPicture))
     459        return false;
     460
    457461    Optional<WebCore::RenderThemeIOS::CSSValueToSystemColorMap> cssValueToSystemColorMap;
    458462    decoder >> cssValueToSystemColorMap;
  • trunk/Source/WebKit/Shared/WebProcessCreationParameters.h

    r255457 r256531  
    215215#if PLATFORM(IOS_FAMILY)
    216216    bool currentUserInterfaceIdiomIsPad { false };
     217    bool supportsPictureInPicture { false };
    217218    WebCore::RenderThemeIOS::CSSValueToSystemColorMap cssValueToSystemColorMap;
    218219    WebCore::Color focusRingColor;
  • trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm

    r256530 r256531  
    361361#if PLATFORM(IOS_FAMILY)
    362362    parameters.currentUserInterfaceIdiomIsPad = currentUserInterfaceIdiomIsPad();
     363    parameters.supportsPictureInPicture = supportsPictureInPicture();
    363364    parameters.cssValueToSystemColorMap = RenderThemeIOS::cssValueToSystemColorMap();
    364365    parameters.focusRingColor = RenderTheme::singleton().focusRingColor(OptionSet<StyleColor::Options>());
  • trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm

    r255881 r256531  
    6464#import <WebCore/NSScrollerImpDetails.h>
    6565#import <WebCore/PerformanceLogging.h>
     66#import <WebCore/PictureInPictureSupport.h>
    6667#import <WebCore/RuntimeApplicationChecks.h>
    6768#import <WebCore/SWContextManager.h>
     
    198199#if PLATFORM(IOS_FAMILY)
    199200    setCurrentUserInterfaceIdiomIsPad(parameters.currentUserInterfaceIdiomIsPad);
     201    setSupportsPictureInPicture(parameters.supportsPictureInPicture);
    200202#endif
    201203
  • trunk/Tools/ChangeLog

    r256528 r256531  
     12020-02-13  Per Arne Vollan  <pvollan@apple.com>
     2
     3        [iOS] Check if PIP is supported in the UI process
     4        https://bugs.webkit.org/show_bug.cgi?id=207406
     5
     6        Reviewed by Brent Fulgham.
     7
     8        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     9        * TestWebKitAPI/Tests/WebKit/PictureInPictureSupport.mm: Added.
     10        (TEST):
     11
    1122020-02-13  Jonathan Bedard  <jbedard@apple.com>
    213
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r256234 r256531  
    991991                E194E1BD177E53C7009C4D4E /* StopLoadingFromDidReceiveResponse.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E194E1BC177E534A009C4D4E /* StopLoadingFromDidReceiveResponse.html */; };
    992992                E324A6F02041C82000A76593 /* UniqueArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E398BC0F2041C76300387136 /* UniqueArray.cpp */; };
     993                E325C90723E3870200BC7D3B /* PictureInPictureSupport.mm in Sources */ = {isa = PBXBuildFile; fileRef = E325C90623E3870200BC7D3B /* PictureInPictureSupport.mm */; };
    993994                E32B549222810AC4008AD702 /* Packed.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E32B549122810AC0008AD702 /* Packed.cpp */; };
    994995                E35FC7B222B82A7300F32F98 /* JSLockTakesWebThreadLock.mm in Sources */ = {isa = PBXBuildFile; fileRef = E35FC7B122B82A6D00F32F98 /* JSLockTakesWebThreadLock.mm */; };
     
    25652566                E194E1BA177E5145009C4D4E /* StopLoadingFromDidReceiveResponse.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StopLoadingFromDidReceiveResponse.mm; sourceTree = "<group>"; };
    25662567                E194E1BC177E534A009C4D4E /* StopLoadingFromDidReceiveResponse.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = StopLoadingFromDidReceiveResponse.html; sourceTree = "<group>"; };
     2568                E325C90623E3870200BC7D3B /* PictureInPictureSupport.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PictureInPictureSupport.mm; sourceTree = "<group>"; };
    25672569                E32B549122810AC0008AD702 /* Packed.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Packed.cpp; sourceTree = "<group>"; };
    25682570                E35FC7B122B82A6D00F32F98 /* JSLockTakesWebThreadLock.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = JSLockTakesWebThreadLock.mm; sourceTree = "<group>"; };
     
    28722874                                E394AE6E23F2303E005B4936 /* GrantAccessToMobileAssets.mm */,
    28732875                                C145CC0B23DA5A0F003A5EEB /* MimeTypes.mm */,
     2876                                E325C90623E3870200BC7D3B /* PictureInPictureSupport.mm */,
    28742877                                0F139E751A423A5300F590F5 /* WeakObjCPtr.mm */,
    28752878                        );
     
    49184921                                7C83E0531D0A643A00FEBCF3 /* PendingAPIRequestURL.cpp in Sources */,
    49194922                                3FCC4FE51EC4E8520076E37C /* PictureInPictureDelegate.mm in Sources */,
     4923                                E325C90723E3870200BC7D3B /* PictureInPictureSupport.mm in Sources */,
    49204924                                7CCE7EA61A411A0F00447C4C /* PlatformUtilitiesMac.mm in Sources */,
    49214925                                7CCE7EA71A411A1300447C4C /* PlatformWebViewMac.mm in Sources */,
  • trunk/Tools/TestWebKitAPI/Tests/WebKit/PictureInPictureSupport.mm

    r256530 r256531  
    11/*
    2  * Copyright (C) 2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #pragma once
     26#include "config.h"
    2727
    28 namespace WebCore {
     28#if WK_HAVE_C_SPI
    2929
    30 #if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
    31 WEBCORE_EXPORT bool supportsPictureInPicture();
    32 #else
    33 constexpr bool supportsPictureInPicture() { return false; }
    34 #endif
     30#import "PlatformUtilities.h"
     31#import "TestWKWebView.h"
     32#import <WebCore/PictureInPictureSupport.h>
    3533
     34TEST(WebKit, PictureInPictureSupport)
     35{
     36    auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
     37    WKRetainPtr<WKContextRef> context = adoptWK(TestWebKitAPI::Util::createContextForInjectedBundleTest("InternalsInjectedBundleTest"));
     38    configuration.get().processPool = (WKProcessPool *)context.get();
     39    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get() addToWindow:YES]);
     40
     41    auto supportsPictureInPicture = [&] {
     42        return [webView stringByEvaluatingJavaScript:@"window.internals.supportsPictureInPicture()"].boolValue;
     43    };
     44
     45    ASSERT_TRUE(supportsPictureInPicture() == WebCore::supportsPictureInPicture());
    3646}
     47
     48#endif // WK_HAVE_C_SPI
Note: See TracChangeset for help on using the changeset viewer.