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

Patch by Jeremy Jones <jeremyj@apple.com> on 2017-08-04
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-04
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@220288 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 2b677b8..5e3197e 100644 (file)
@@ -1,3 +1,18 @@
+2017-08-04  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-04  Matt Baker  <mattbaker@apple.com>
 
         Web Inspector: REGRESSION (r220233): Check for null pointer passed to WebGLRenderingContextBase::deleteProgram
index 65a0144..f683543 100644 (file)
 #if USE(APPLE_INTERNAL_SDK)
 
 #import <MediaPlayer/MPAVRoutingController.h>
-#import <MediaPlayer/MPAVRoutingSheet.h>
-#import <MediaPlayer/MPAudioVideoRoutingPopoverController.h>
+#import <MediaPlayer/MPMediaControlsViewController.h>
 
 #else
 
-enum {
-    MPAVItemTypeUnknown = 0,
-    MPAVItemTypeAudio = 1,
-    MPAVItemTypeVideo = 2,
-};
-typedef NSUInteger MPAVItemType;
+NS_ASSUME_NONNULL_BEGIN
 
 enum {
     MPRouteDiscoveryModeDisabled = 0,
@@ -60,33 +54,11 @@ typedef NSInteger MPRouteDiscoveryMode;
 @property (nonatomic, assign) MPRouteDiscoveryMode discoveryMode;
 @end
 
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
-@interface MPAudioVideoRoutingPopoverController : UIPopoverController
-@end
-#pragma clang diagnostic pop
-
-@interface MPAudioVideoRoutingPopoverController ()
-- (id)initWithType:(MPAVItemType)avItemType;
-@end
-
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
-@interface MPAVRoutingSheet : UIView
+@interface MPMediaControlsViewController : UIViewController
+@property (nonatomic, copy, nullable) void (^didDismissHandler)(void);
 @end
-#pragma clang diagnostic pop
 
-@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
+NS_ASSUME_NONNULL_END
 
 #endif
 
index f11103a..d870d83 100644 (file)
@@ -1,3 +1,25 @@
+2017-08-04  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-04  Tim Horton  <timothy_horton@apple.com>
 
         viewport-fit changes during animated resize can cause layout size to get stuck
index 94ea374..8331043 100644 (file)
@@ -4000,8 +4000,8 @@ static bool isAssistableInputType(InputType type)
 - (void)_showPlaybackTargetPicker:(BOOL)hasVideo fromRect:(const IntRect&)elementRect
 {
     if (!_airPlayRoutePicker)
-        _airPlayRoutePicker = adoptNS([[WKAirPlayRoutePicker alloc] initWithView:self]);
-    [_airPlayRoutePicker show:hasVideo fromRect:elementRect];
+        _airPlayRoutePicker = adoptNS([[WKAirPlayRoutePicker alloc] init]);
+    [_airPlayRoutePicker showFromView:self];
 }
 
 - (void)_showRunOpenPanel:(API::OpenPanelParameters*)parameters resultListener:(WebOpenPanelResultListenerProxy*)listener
index 1795a16..4f02fe1 100644 (file)
 
 #if PLATFORM(IOS)
 
-#import <UIKit/UIPopoverController.h>
+#import <Foundation/Foundation.h>
 
 @class WKContentView;
 
-@interface WKAirPlayRoutePicker : UIView <UIPopoverControllerDelegate>
-- (instancetype)initWithView:(WKContentView *)view;
-- (void)show:(BOOL)hasVideo fromRect:(CGRect)elementRect;
+@interface WKAirPlayRoutePicker : NSObject
+- (void)showFromView:(WKContentView *)view;
 @end
 
 #endif // PLATFORM(IOS)
index 57597fe..e0a4316 100644 (file)
 
 #import "UIKitSPI.h"
 #import "WKContentView.h"
-#import "WKContentViewInteraction.h"
-#import "WebPageProxy.h"
 #import <WebCore/MediaPlayerSPI.h>
 #import <wtf/RetainPtr.h>
 #import <wtf/SoftLinking.h>
 
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
-
+#if !PLATFORM(WATCHOS) && !PLATFORM(APPLETV)
 SOFT_LINK_FRAMEWORK(MediaPlayer)
 SOFT_LINK_CLASS(MediaPlayer, MPAVRoutingController)
-SOFT_LINK_CLASS(MediaPlayer, MPAudioVideoRoutingPopoverController)
-SOFT_LINK_CLASS(MediaPlayer, MPAVRoutingSheet)
+SOFT_LINK_CLASS(MediaPlayer, MPMediaControlsViewController)
+#endif
 
 using namespace WebKit;
 
 @implementation WKAirPlayRoutePicker {
-    RetainPtr<MPAVRoutingController> _routingController;
-    RetainPtr<MPAudioVideoRoutingPopoverController> _popoverController;  // iPad
-    RetainPtr<MPAVRoutingSheet> _actionSheet; // iPhone
-    WKContentView* _view; // Weak reference.
-}
-
-- (instancetype)initWithView:(WKContentView *)view
-{
-    if (!(self = [super init]))
-        return nil;
-
-    _view = view;
-    return self;
+#if !PLATFORM(WATCHOS) && !PLATFORM(APPLETV)
+    RetainPtr<MPMediaControlsViewController> _actionSheet;
+#endif
 }
 
 - (void)dealloc
 {
-    // The ActionSheet's completion handler will release and clear the ActionSheet.
-    [_actionSheet dismiss];
-    [self _dismissAirPlayRoutePickerIPad];
-
+#if !PLATFORM(WATCHOS) && !PLATFORM(APPLETV)
+    [_actionSheet dismissViewControllerAnimated:0 completion:nil];
+#endif
     [super dealloc];
 }
 
-- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController
-{
-    if (popoverController != _popoverController)
-        return;
-
-    [self _dismissAirPlayRoutePickerIPad];
-}
-
-- (void)_presentAirPlayPopoverAnimated:(BOOL)animated fromRect:(CGRect)elementRect
-{
-    [_popoverController presentPopoverFromRect:elementRect inView:_view permittedArrowDirections:UIPopoverArrowDirectionAny animated:animated];
-}
-
-- (void)_windowWillRotate:(NSNotification *)notification
-{
-    [_popoverController dismissPopoverAnimated:NO];
-}
-
-- (void)_windowDidRotate:(NSNotification *)notification
-{
-    [self _dismissAirPlayRoutePickerIPad];
-}
-
-- (void)_dismissAirPlayRoutePickerIPad
-{
-    if (!_routingController)
-        return;
-
-    [_routingController setDiscoveryMode:MPRouteDiscoveryModeDisabled];
-    _routingController = nil;
-
-    if (!_popoverController)
-        return;
-
-    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
-    [center removeObserver:self name:UIWindowWillRotateNotification object:nil];
-    [center removeObserver:self name:UIWindowDidRotateNotification object:nil];
-
-    [_popoverController dismissPopoverAnimated:NO];
-    [_popoverController setDelegate:nil];
-    _popoverController = nil;
-}
-
-- (void)showAirPlayPickerIPad:(MPAVItemType)itemType fromRect:(CGRect)elementRect
-{
-    if (_popoverController)
-        return;
-
-    _popoverController = adoptNS([allocMPAudioVideoRoutingPopoverControllerInstance() initWithType:itemType]);
-    [_popoverController setDelegate:self];
-
-    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
-    [center addObserver:self selector:@selector(_windowWillRotate:) name:UIWindowWillRotateNotification object:nil];
-    [center addObserver:self selector:@selector(_windowDidRotate:) name:UIWindowDidRotateNotification object:nil];
-
-    [self _presentAirPlayPopoverAnimated:YES fromRect:elementRect];
-}
-
-- (void)showAirPlayPickerIPhone:(MPAVItemType)itemType
+- (void)showFromView:(WKContentView *)view
 {
+#if !PLATFORM(WATCHOS) && !PLATFORM(APPLETV)
     if (_actionSheet)
         return;
 
-    _actionSheet = adoptNS([allocMPAVRoutingSheetInstance() initWithAVItemType:itemType]);
+    __block RetainPtr<MPAVRoutingController> routingController = adoptNS([allocMPAVRoutingControllerInstance() initWithName:@"WebKit - HTML media element showing AirPlay route picker"]);
+    [routingController setDiscoveryMode:MPRouteDiscoveryModeDetailed];
 
-    [_actionSheet showInView:_view withCompletionHandler:^{
-        [_routingController setDiscoveryMode:MPRouteDiscoveryModeDisabled];
-        _routingController = nil;
+    _actionSheet = adoptNS([allocMPMediaControlsViewControllerInstance() init]);
+    _actionSheet.get().didDismissHandler = ^ {
+        [routingController setDiscoveryMode:MPRouteDiscoveryModeDisabled];
+        routingController = nil;
         _actionSheet = nil;
-    }];
-}
+    };
 
-- (void)show:(BOOL)hasVideo fromRect:(CGRect)elementRect
-{
-    _routingController = adoptNS([allocMPAVRoutingControllerInstance() initWithName:@"WebKit2 - HTML media element showing AirPlay route picker"]);
-    [_routingController setDiscoveryMode:MPRouteDiscoveryModeDetailed];
-
-    MPAVItemType itemType = hasVideo ? MPAVItemTypeVideo : MPAVItemTypeAudio;
-    if (UICurrentUserInterfaceIdiomIsPad())
-        [self showAirPlayPickerIPad:itemType fromRect:elementRect];
-    else
-        [self showAirPlayPickerIPhone:itemType];
+    UIViewController *viewControllerForPresentation = [UIViewController _viewControllerForFullScreenPresentationFromView:view];
+    [viewControllerForPresentation presentViewController:_actionSheet.get() animated:YES completion:nil];
+#else
+    UNUSED_PARAM(view);
+#endif
 }
 
 @end
 
-#pragma clang diagnostic pop
-
 #endif // PLATFORM(IOS)