Fix macros for wireless playback
authorjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 May 2015 07:27:13 +0000 (07:27 +0000)
committerjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 May 2015 07:27:13 +0000 (07:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=145239
rdar://problem/21049541

Reviewed by Anders Carlsson.

Encompass the logic within ENABLE(WIRELESS_TARGET_PLAYBACK). Update property name.

Source/WebKit/mac:

* WebView/WebPreferenceKeysPrivate.h:
* WebView/WebPreferences.h:
* WebView/WebPreferences.mm:
(+[WebPreferences initialize]): Wrap in ENABLE.
(-[WebPreferences allowsAirPlayForMediaPlayback]): Ditto.
(-[WebPreferences setAllowsAirPlayForMediaPlayback:]): Ditto.
* WebView/WebView.mm:
(-[WebView _preferencesChanged:]): Ditto.

Source/WebKit2:

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView initWithFrame:configuration:]):
* UIProcess/API/Cocoa/WKWebViewConfiguration.h: Update names. Add a WKDeprecated
category section.
* UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
(-[WKWebViewConfiguration init]): Update name of variables to reflect new property names.
(-[WKWebViewConfiguration copyWithZone:]): Ditto.
(-[WKWebViewConfiguration mediaPlaybackAllowsAirPlay]): Get and set off of the new
variable.
(-[WKWebViewConfiguration setMediaPlaybackAllowsAirPlay:]): Ditto.
(-[WKWebViewConfiguration mediaPlaybackRequiresUserAction]): Ditto.
(-[WKWebViewConfiguration setMediaPlaybackRequiresUserAction:]): Ditto.

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

Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h
Source/WebKit/mac/WebView/WebPreferences.h
Source/WebKit/mac/WebView/WebPreferences.mm
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.h
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm

index df02aa3..86fef86 100644 (file)
@@ -1,3 +1,22 @@
+2015-05-22  Jon Lee  <jonlee@apple.com>
+
+        Fix macros for wireless playback
+        https://bugs.webkit.org/show_bug.cgi?id=145239
+        rdar://problem/21049541
+
+        Reviewed by Anders Carlsson.
+
+        Encompass the logic within ENABLE(WIRELESS_TARGET_PLAYBACK). Update property name.
+
+        * WebView/WebPreferenceKeysPrivate.h:
+        * WebView/WebPreferences.h:
+        * WebView/WebPreferences.mm:
+        (+[WebPreferences initialize]): Wrap in ENABLE.
+        (-[WebPreferences allowsAirPlayForMediaPlayback]): Ditto.
+        (-[WebPreferences setAllowsAirPlayForMediaPlayback:]): Ditto.
+        * WebView/WebView.mm:
+        (-[WebView _preferencesChanged:]): Ditto.
+
 2015-05-27  Dean Jackson  <dino@apple.com>
 
         img.currentSrc problem in strict mode with old picturefill
index 7592f9a..d0a9aa4 100644 (file)
 #define WebKitRequiresUserGestureForMediaPlaybackPreferenceKey @"WebKitMediaPlaybackRequiresUserGesture"
 #define WebKitAllowsInlineMediaPlaybackPreferenceKey @"WebKitMediaPlaybackAllowsInline"
 #define WebKitAllowsAlternateFullscreenPreferenceKey @"WebKitAllowsAlternateFullscreen"
+#define WebKitAllowsAirPlayForMediaPlaybackPreferenceKey @"WebKitMediaPlaybackAllowsAirPlay"
 #define WebKitMockScrollbarsEnabledPreferenceKey @"WebKitMockScrollbarsEnabled"
 #define WebKitShouldDisplaySubtitlesPreferenceKey @"WebKitShouldDisplaySubtitles"
 #define WebKitShouldDisplayCaptionsPreferenceKey @"WebKitShouldDisplayCaptions"
 #define WebKitSuppressesIncrementalRenderingKey @"WebKitSuppressesIncrementalRendering"
 #define WebKitSubpixelCSSOMElementMetricsEnabledPreferenceKey @"WebKitSubpixelCSSOMElementMetricsEnabled"
 #if TARGET_OS_IPHONE
-#define WebKitAllowsAirPlayForMediaPlaybackPreferenceKey @"WebKitMediaPlaybackAllowsAirPlay"
 #define WebKitAudioSessionCategoryOverride @"WebKitAudioSessionCategoryOverride"
 #define WebKitAVKitEnabled @"WebKitAVKitEnabled"
 #endif
index 33c0be8..248da77 100644 (file)
@@ -267,4 +267,9 @@ extern NSString *WebPreferencesChangedNotification;
 */
 @property (nonatomic) BOOL suppressesIncrementalRendering;
 
+/*!
+    @property allowsAirPlayForMediaPlayback
+ */
+@property (nonatomic) BOOL allowsAirPlayForMediaPlayback;
+
 @end
index ea484c8..97eb6bc 100644 (file)
@@ -529,7 +529,6 @@ public:
 #else
         [NSNumber numberWithBool:YES],  WebKitRequiresUserGestureForMediaPlaybackPreferenceKey,
         [NSNumber numberWithBool:NO],   WebKitAllowsInlineMediaPlaybackPreferenceKey,
-        [NSNumber numberWithBool:YES],  WebKitAllowsAirPlayForMediaPlaybackPreferenceKey,
         [NSNumber numberWithUnsignedInt:AudioSession::None],  WebKitAudioSessionCategoryOverride,
 #if HAVE(AVKIT)
         [NSNumber numberWithBool:YES],  WebKitAVKitEnabled,
@@ -545,6 +544,9 @@ public:
 
         [NSNumber numberWithBool:YES],   WebKitShouldRespectImageOrientationKey,
 #endif // PLATFORM(IOS)
+#if ENABLE(WIRELESS_TARGET_PLAYBACK)
+        [NSNumber numberWithBool:YES],  WebKitAllowsAirPlayForMediaPlaybackPreferenceKey,
+#endif
         [NSNumber numberWithBool:YES],  WebKitAllowsAlternateFullscreenPreferenceKey,
         [NSNumber numberWithBool:YES],  WebKitRequestAnimationFrameEnabledPreferenceKey,
         [NSNumber numberWithBool:NO],   WebKitWantsBalancedSetDefersLoadingBehaviorKey,
@@ -2076,6 +2078,22 @@ static NSString *classIBCreatorID = nil;
     [self _setBoolValue:flag forKey: WebKitEnableInheritURIQueryComponentPreferenceKey];
 }
 
+- (BOOL)allowsAirPlayForMediaPlayback
+{
+#if ENABLE(WIRELESS_TARGET_PLAYBACK)
+    return [self _boolValueForKey:WebKitAllowsAirPlayForMediaPlaybackPreferenceKey];
+#else
+    return false;
+#endif
+}
+
+- (void)setAllowsAirPlayForMediaPlayback:(BOOL)flag
+{
+#if ENABLE(WIRELESS_TARGET_PLAYBACK)
+    [self _setBoolValue:flag forKey:WebKitAllowsAirPlayForMediaPlaybackPreferenceKey];
+#endif
+}
+
 #if PLATFORM(IOS)
 - (BOOL)mediaPlaybackAllowsAirPlay
 {
index 3fe7b7b..68886cf 100644 (file)
@@ -2343,6 +2343,9 @@ static bool needsSelfRetainWhileLoadingQuirk()
     settings.setRubberBandingForSubScrollableRegionsEnabled(false);
 #endif
 
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+    settings.setAllowsAirPlayForMediaPlayback([preferences allowsAirPlayForMediaPlayback]);
+#endif
 #if PLATFORM(IOS)
     settings.setStandalone([preferences _standalone]);
     settings.setTelephoneNumberParsingEnabled([preferences _telephoneNumberParsingEnabled]);
@@ -2350,7 +2353,6 @@ static bool needsSelfRetainWhileLoadingQuirk()
     settings.setLayoutInterval(std::chrono::milliseconds([preferences _layoutInterval]));
     settings.setMaxParseDuration([preferences _maxParseDuration]);
     settings.setAlwaysUseAcceleratedOverflowScroll([preferences _alwaysUseAcceleratedOverflowScroll]);
-    settings.setAllowsAirPlayForMediaPlayback([preferences mediaPlaybackAllowsAirPlay]);
     settings.setAudioSessionCategoryOverride([preferences audioSessionCategoryOverride]);
     settings.setNetworkDataUsageTrackingEnabled([preferences networkDataUsageTrackingEnabled]);
     settings.setNetworkInterfaceName([preferences networkInterfaceName]);
index d71a207..7b8ca8a 100644 (file)
@@ -1,3 +1,26 @@
+2015-05-22  Jon Lee  <jonlee@apple.com>
+
+        Fix macros for wireless playback
+        https://bugs.webkit.org/show_bug.cgi?id=145239
+        rdar://problem/21049541
+
+        Reviewed by Anders Carlsson.
+
+        Encompass the logic within ENABLE(WIRELESS_TARGET_PLAYBACK). Update property name.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView initWithFrame:configuration:]):
+        * UIProcess/API/Cocoa/WKWebViewConfiguration.h: Update names. Add a WKDeprecated
+        category section.
+        * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
+        (-[WKWebViewConfiguration init]): Update name of variables to reflect new property names.
+        (-[WKWebViewConfiguration copyWithZone:]): Ditto.
+        (-[WKWebViewConfiguration mediaPlaybackAllowsAirPlay]): Get and set off of the new
+        variable.
+        (-[WKWebViewConfiguration setMediaPlaybackAllowsAirPlay:]): Ditto.
+        (-[WKWebViewConfiguration mediaPlaybackRequiresUserAction]): Ditto.
+        (-[WKWebViewConfiguration setMediaPlaybackRequiresUserAction:]): Ditto.
+
 2015-05-27  Brady Eidson  <beidson@apple.com>
 
         Add a "should open urls externally" flag to DocumentLoader.
index bbe4c4a..2fe41c5 100644 (file)
@@ -322,8 +322,10 @@ static bool shouldAllowAlternateFullscreen()
 #if PLATFORM(IOS)
     webPageConfiguration.preferenceValues.set(WebKit::WebPreferencesKey::allowsInlineMediaPlaybackKey(), WebKit::WebPreferencesStore::Value(!![_configuration allowsInlineMediaPlayback]));
     webPageConfiguration.preferenceValues.set(WebKit::WebPreferencesKey::allowsAlternateFullscreenKey(), WebKit::WebPreferencesStore::Value(!![_configuration _allowsAlternateFullscreen] && shouldAllowAlternateFullscreen()));
-    webPageConfiguration.preferenceValues.set(WebKit::WebPreferencesKey::requiresUserGestureForMediaPlaybackKey(), WebKit::WebPreferencesStore::Value(!![_configuration mediaPlaybackRequiresUserAction]));
-    webPageConfiguration.preferenceValues.set(WebKit::WebPreferencesKey::allowsAirPlayForMediaPlaybackKey(), WebKit::WebPreferencesStore::Value(!![_configuration mediaPlaybackAllowsAirPlay]));
+    webPageConfiguration.preferenceValues.set(WebKit::WebPreferencesKey::requiresUserGestureForMediaPlaybackKey(), WebKit::WebPreferencesStore::Value(!![_configuration requiresUserActionForMediaPlayback]));
+#endif
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+    webPageConfiguration.preferenceValues.set(WebKit::WebPreferencesKey::allowsAirPlayForMediaPlaybackKey(), WebKit::WebPreferencesStore::Value(!![_configuration allowsAirPlayForMediaPlayback]));
 #endif
 
 #if PLATFORM(IOS)
index 34b7b96..2c414fa 100644 (file)
@@ -88,6 +88,11 @@ WK_CLASS_AVAILABLE(10_10, 8_0)
 */
 @property (WK_NULLABLE_PROPERTY nonatomic, copy) NSString *applicationNameForUserAgent WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
 
+/*! @abstract A Boolean value indicating whether AirPlay is allowed.
+ @discussion The default value is YES.
+ */
+@property (nonatomic) BOOL allowsAirPlayForMediaPlayback WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
+
 #if TARGET_OS_IPHONE
 /*! @abstract A Boolean value indicating whether HTML5 videos play inline
  (YES) or use the native full-screen controller (NO).
@@ -99,12 +104,7 @@ WK_CLASS_AVAILABLE(10_10, 8_0)
  user to start playing them (YES) or can play automatically (NO).
  @discussion The default value is YES.
  */
-@property (nonatomic) BOOL mediaPlaybackRequiresUserAction;
-
-/*! @abstract A Boolean value indicating whether AirPlay is allowed.
- @discussion The default value is YES.
- */
-@property (nonatomic) BOOL mediaPlaybackAllowsAirPlay;
+@property (nonatomic) BOOL requiresUserActionForMediaPlayback WK_AVAILABLE(NA, WK_IOS_TBA);
 
 /*! @abstract The level of granularity with which the user can interactively
  select content in the web view.
@@ -117,6 +117,15 @@ WK_CLASS_AVAILABLE(10_10, 8_0)
 
 @end
 
+@interface WKWebViewConfiguration (WKDeprecated)
+
+#if TARGET_OS_IPHONE
+@property (nonatomic) BOOL mediaPlaybackRequiresUserAction WK_DEPRECATED(NA, NA, 8_0, WK_IOS_TBA, "Please use requiresUserActionForMediaPlayback");
+@property (nonatomic) BOOL mediaPlaybackAllowsAirPlay WK_DEPRECATED(NA, NA, 8_0, WK_IOS_TBA, "Please use allowsAirPlayForMediaPlayback");
+#endif
+
+@end
+
 WK_ASSUME_NONNULL_END
 
 #endif
index 9be9a6e..b5772a3 100644 (file)
@@ -103,11 +103,13 @@ private:
         return nil;
     
 #if PLATFORM(IOS)
-    _mediaPlaybackRequiresUserAction = YES;
-    _mediaPlaybackAllowsAirPlay = YES;
+    _requiresUserActionForMediaPlayback = YES;
     _allowsAlternateFullscreen = YES;
 #endif
-    
+#if ENABLE(WIRELESS_TARGET_PLAYBACK)
+    _allowsAirPlayForMediaPlayback = YES;
+#endif
+
     return self;
 }
 
@@ -138,10 +140,12 @@ private:
 #if PLATFORM(IOS)
     configuration->_allowsInlineMediaPlayback = self->_allowsInlineMediaPlayback;
     configuration->_allowsAlternateFullscreen = self->_allowsAlternateFullscreen;
-    configuration->_mediaPlaybackRequiresUserAction = self->_mediaPlaybackRequiresUserAction;
-    configuration->_mediaPlaybackAllowsAirPlay = self->_mediaPlaybackAllowsAirPlay;
+    configuration->_requiresUserActionForMediaPlayback = self->_requiresUserActionForMediaPlayback;
     configuration->_selectionGranularity = self->_selectionGranularity;
 #endif
+#if ENABLE(WIRELESS_TARGET_PLAYBACK)
+    configuration->_allowsAirPlayForMediaPlayback = self->_allowsAirPlayForMediaPlayback;
+#endif
 
     return configuration;
 }
@@ -323,4 +327,30 @@ static NSString *defaultApplicationNameForUserAgent()
 
 @end
 
+@implementation WKWebViewConfiguration (WKDeprecated)
+
+#if PLATFORM(IOS)
+- (BOOL)mediaPlaybackAllowsAirPlay
+{
+    return self.allowsAirPlayForMediaPlayback;
+}
+
+- (void)setMediaPlaybackAllowsAirPlay:(BOOL)allowed
+{
+    self.allowsAirPlayForMediaPlayback = allowed;
+}
+
+- (BOOL)mediaPlaybackRequiresUserAction
+{
+    return self.requiresUserActionForMediaPlayback;
+}
+
+- (void)setMediaPlaybackRequiresUserAction:(BOOL)required
+{
+    self.requiresUserActionForMediaPlayback = required;
+}
+#endif // PLATFORM(IOS)
+
+@end
+
 #endif // WK_API_ENABLED