Use MPAVRoutingController instead of deprecated versions.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Aug 2017 23:18:13 +0000 (23:18 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Aug 2017 23:18:13 +0000 (23:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=175063
Source/WebCore:

Patch by Jeremy Jones <jeremyj@apple.com> on 2017-08-09
Reviewed by Tim Horton.

No new tests because no behavior change. This uses a different platform class to present
an interface.

Remove deprecated MPAudioVideoRoutingPopoverController and MPAVRoutingSheet
Add MPMediaControlsViewController.

* platform/spi/ios/MediaPlayerSPI.h:

Source/WebKit:

rdar://problem/33301230

Patch by Jeremy Jones <jeremyj@apple.com> on 2017-08-09
Reviewed by Tim Horton.

Remove dependence on deprecated classes MPAVRoutingSheet and MPAudioVideoRoutingPopoverController.

* UIProcess/ios/forms/WKAirPlayRoutePicker.h:
* UIProcess/ios/forms/WKAirPlayRoutePicker.mm:
(-[WKAirPlayRoutePicker dealloc]):
(-[WKAirPlayRoutePicker show:fromRect:]):
(-[WKAirPlayRoutePicker popoverControllerDidDismissPopover:]): Deleted.
(-[WKAirPlayRoutePicker _presentAirPlayPopoverAnimated:fromRect:]): Deleted.
(-[WKAirPlayRoutePicker _windowWillRotate:]): Deleted.
(-[WKAirPlayRoutePicker _windowDidRotate:]): Deleted.
(-[WKAirPlayRoutePicker _dismissAirPlayRoutePickerIPad]): Deleted.
(-[WKAirPlayRoutePicker showAirPlayPickerIPad:fromRect:]): Deleted.
(-[WKAirPlayRoutePicker showAirPlayPickerIPhone:]): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220496 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/spi/ios/MediaPlayerSPI.h
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit/UIProcess/ios/forms/WKAirPlayRoutePicker.h
Source/WebKit/UIProcess/ios/forms/WKAirPlayRoutePicker.mm

index 555c547b0428081a8491411842b4111ae1885817..752bba7a0139fc0526abdb6c322ea13d6bb467a4 100644 (file)
@@ -1,3 +1,18 @@
+2017-08-09  Jeremy Jones  <jeremyj@apple.com>
+
+        Use MPAVRoutingController instead of deprecated versions.
+        https://bugs.webkit.org/show_bug.cgi?id=175063
+
+        Reviewed by Tim Horton.
+
+        No new tests because no behavior change. This uses a different platform class to present
+        an interface.
+
+        Remove deprecated MPAudioVideoRoutingPopoverController and MPAVRoutingSheet
+        Add MPMediaControlsViewController.
+
+        * platform/spi/ios/MediaPlayerSPI.h:
+
 2017-08-09  Myles C. Maxfield  <mmaxfield@apple.com>
 
         Mark font-display as in development
index 65a014447c9d71c57ada2544c4b543278428ba0a..dd87f93af7025bca6d133457b3f6b1206a0144f8 100644 (file)
 #if USE(APPLE_INTERNAL_SDK)
 
 #import <MediaPlayer/MPAVRoutingController.h>
+
+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000 && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV)
+#import <MediaPlayer/MPMediaControlsViewController.h>
+#else
 #import <MediaPlayer/MPAVRoutingSheet.h>
 #import <MediaPlayer/MPAudioVideoRoutingPopoverController.h>
+#endif
 
 #else
 
-enum {
-    MPAVItemTypeUnknown = 0,
-    MPAVItemTypeAudio = 1,
-    MPAVItemTypeVideo = 2,
-};
-typedef NSUInteger MPAVItemType;
+NS_ASSUME_NONNULL_BEGIN
 
 enum {
     MPRouteDiscoveryModeDisabled = 0,
@@ -60,6 +60,21 @@ typedef NSInteger MPRouteDiscoveryMode;
 @property (nonatomic, assign) MPRouteDiscoveryMode discoveryMode;
 @end
 
+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000 && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV)
+
+@interface MPMediaControlsViewController : UIViewController
+@property (nonatomic, copy, nullable) void (^didDismissHandler)(void);
+@end
+
+#else
+
+enum {
+    MPAVItemTypeUnknown = 0,
+    MPAVItemTypeAudio = 1,
+    MPAVItemTypeVideo = 2,
+};
+typedef NSUInteger MPAVItemType;
+
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
 @interface MPAudioVideoRoutingPopoverController : UIPopoverController
@@ -78,16 +93,16 @@ typedef NSInteger MPRouteDiscoveryMode;
 
 @interface MPAVRoutingSheet ()
 @property (nonatomic, assign, setter=setAVItemType:) MPAVItemType avItemType;
-
 @property (nonatomic, assign) BOOL mirroringOnly;
-
 - (id)initWithAVItemType:(MPAVItemType)avItemType;
-
 - (void)showInView:(UIView *)view withCompletionHandler:(void (^)(void))completionHandler;
-
 - (void)dismiss;
 @end
 
 #endif
 
+NS_ASSUME_NONNULL_END
+
 #endif
+
+#endif // PLATFORM(IOS)
index bb2023e56e5f9a539252246f3f8c12ee070fa159..34ad9790c1d4f1ab7a3656cb89ebaa9de84cb30b 100644 (file)
@@ -1,3 +1,25 @@
+2017-08-09  Jeremy Jones  <jeremyj@apple.com>
+
+        Use MPAVRoutingController instead of deprecated versions.
+        https://bugs.webkit.org/show_bug.cgi?id=175063
+        rdar://problem/33301230
+
+        Reviewed by Tim Horton.
+
+        Remove dependence on deprecated classes MPAVRoutingSheet and MPAudioVideoRoutingPopoverController.
+
+        * UIProcess/ios/forms/WKAirPlayRoutePicker.h:
+        * UIProcess/ios/forms/WKAirPlayRoutePicker.mm:
+        (-[WKAirPlayRoutePicker dealloc]):
+        (-[WKAirPlayRoutePicker show:fromRect:]):
+        (-[WKAirPlayRoutePicker popoverControllerDidDismissPopover:]): Deleted.
+        (-[WKAirPlayRoutePicker _presentAirPlayPopoverAnimated:fromRect:]): Deleted.
+        (-[WKAirPlayRoutePicker _windowWillRotate:]): Deleted.
+        (-[WKAirPlayRoutePicker _windowDidRotate:]): Deleted.
+        (-[WKAirPlayRoutePicker _dismissAirPlayRoutePickerIPad]): Deleted.
+        (-[WKAirPlayRoutePicker showAirPlayPickerIPad:fromRect:]): Deleted.
+        (-[WKAirPlayRoutePicker showAirPlayPickerIPhone:]): Deleted.
+
 2017-08-09  Sam Weinig  <sam@webkit.org>
 
         WTF::Function does not allow for reference / non-default constructible return types
index 63b7eee21cc0705545bbf70dafb76da2ac75eecd..04f8b6df8f4816bcd0a62b008337de9162289890 100644 (file)
@@ -4000,9 +4000,15 @@ static bool isAssistableInputType(InputType type)
 
 - (void)_showPlaybackTargetPicker:(BOOL)hasVideo fromRect:(const IntRect&)elementRect
 {
+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000 && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV)
+    if (!_airPlayRoutePicker)
+        _airPlayRoutePicker = adoptNS([[WKAirPlayRoutePicker alloc] init]);
+    [_airPlayRoutePicker showFromView:self];
+#else
     if (!_airPlayRoutePicker)
         _airPlayRoutePicker = adoptNS([[WKAirPlayRoutePicker alloc] initWithView:self]);
     [_airPlayRoutePicker show:hasVideo fromRect:elementRect];
+#endif
 }
 
 - (void)_showRunOpenPanel:(API::OpenPanelParameters*)parameters resultListener:(WebOpenPanelResultListenerProxy*)listener
index 1795a1657ba2c7fbf3639aa14a6a0a2f5ca4b1ab..d2be77768e27834f79bc183bc7079a8797326c9d 100644 (file)
 
 #if PLATFORM(IOS)
 
+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000 && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV)
+
+#import <Foundation/Foundation.h>
+
+@class UIView;
+
+@interface WKAirPlayRoutePicker : NSObject
+- (void)showFromView:(UIView *)view;
+@end
+
+#else
+
 #import <UIKit/UIPopoverController.h>
 
 @class WKContentView;
@@ -34,5 +46,7 @@
 - (void)show:(BOOL)hasVideo fromRect:(CGRect)elementRect;
 @end
 
+#endif
+
 #endif // PLATFORM(IOS)
 
index 57597fe33ec13165d30c021285ed4777a70dfaba..43500e370655a4187664ff2271cbb1410f6850dd 100644 (file)
 #if PLATFORM(IOS)
 
 #import "UIKitSPI.h"
-#import "WKContentView.h"
-#import "WKContentViewInteraction.h"
-#import "WebPageProxy.h"
 #import <WebCore/MediaPlayerSPI.h>
 #import <wtf/RetainPtr.h>
 #import <wtf/SoftLinking.h>
 
+#if __IPHONE_OS_VERSION_MIN_REQUIRED < 110000 || PLATFORM(WATCHOS) || PLATFORM(APPLETV)
+#import "WKContentView.h"
+#import "WKContentViewInteraction.h"
+#import "WebPageProxy.h"
+
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
 
@@ -159,4 +161,43 @@ using namespace WebKit;
 
 #pragma clang diagnostic pop
 
+#else 
+
+SOFT_LINK_FRAMEWORK(MediaPlayer)
+SOFT_LINK_CLASS(MediaPlayer, MPAVRoutingController)
+SOFT_LINK_CLASS(MediaPlayer, MPMediaControlsViewController)
+
+@implementation WKAirPlayRoutePicker {
+    RetainPtr<MPMediaControlsViewController> _actionSheet;
+}
+
+- (void)dealloc
+{
+    [_actionSheet dismissViewControllerAnimated:0 completion:nil];
+    [super dealloc];
+}
+
+- (void)showFromView:(UIView *)view
+{
+    if (_actionSheet)
+        return;
+
+    __block RetainPtr<MPAVRoutingController> routingController = adoptNS([allocMPAVRoutingControllerInstance() initWithName:@"WebKit - HTML media element showing AirPlay route picker"]);
+    [routingController setDiscoveryMode:MPRouteDiscoveryModeDetailed];
+
+    _actionSheet = adoptNS([allocMPMediaControlsViewControllerInstance() init]);
+    _actionSheet.get().didDismissHandler = ^ {
+        [routingController setDiscoveryMode:MPRouteDiscoveryModeDisabled];
+        routingController = nil;
+        _actionSheet = nil;
+    };
+
+    UIViewController *viewControllerForPresentation = [UIViewController _viewControllerForFullScreenPresentationFromView:view];
+    [viewControllerForPresentation presentViewController:_actionSheet.get() animated:YES completion:nil];
+}
+
+@end
+
+#endif
+
 #endif // PLATFORM(IOS)