[iOS] allow host application to opt-out of alternate fullscreen
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Nov 2014 14:07:04 +0000 (14:07 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Nov 2014 14:07:04 +0000 (14:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=138787

Reviewed by Darin Adler.

Source/WebCore:

* Modules/mediacontrols/MediaControlsHost.cpp:
(WebCore::MediaControlsHost::optimizedFullscreenSupported): Check mediaSession().allowsAlternateFullscreen.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::enterFullscreenOptimized): Do nothing if
    mediaSession().allowsAlternateFullscreen says it isn't allowed.

* html/HTMLMediaSession.cpp:
(WebCore::HTMLMediaSession::allowsAlternateFullscreen): New, check settings.
* html/HTMLMediaSession.h:

* page/Settings.cpp: Add allowsAlternateFullscreen.
* page/Settings.in: Ditto.

Source/WebKit/mac:

* WebView/WebPreferenceKeysPrivate.h:
* WebView/WebPreferences.mm:
(+[WebPreferences initialize]):
(-[WebPreferences allowsAlternateFullscreen]):
(-[WebPreferences setAllowsAlternateFullscreen:]):
* WebView/WebPreferencesPrivate.h:
* WebView/WebView.mm:
(-[WebView _preferencesChanged:]):

Source/WebKit2:

* Shared/WebPreferencesDefinitions.h:
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetAllowsAlternateFullscreen):
(WKPreferencesGetAllowsAlternateFullscreen):
* UIProcess/API/C/WKPreferencesRefPrivate.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView initWithFrame:configuration:]):
* UIProcess/API/Cocoa/WKWebViewConfiguration.h:
* UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
(-[WKWebViewConfiguration init]):
(-[WKWebViewConfiguration copyWithZone:]):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):

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

20 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediacontrols/MediaControlsHost.cpp
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaSession.cpp
Source/WebCore/html/HTMLMediaSession.h
Source/WebCore/page/Settings.cpp
Source/WebCore/page/Settings.in
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h
Source/WebKit/mac/WebView/WebPreferences.mm
Source/WebKit/mac/WebView/WebPreferencesPrivate.h
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebPreferencesDefinitions.h
Source/WebKit2/UIProcess/API/C/WKPreferences.cpp
Source/WebKit2/UIProcess/API/C/WKPreferencesRefPrivate.h
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.h
Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm
Source/WebKit2/WebProcess/WebPage/WebPage.cpp

index b583f43..3bf0675 100644 (file)
@@ -1,3 +1,24 @@
+2014-11-17  Eric Carlson  <eric.carlson@apple.com>
+
+        [iOS] allow host application to opt-out of alternate fullscreen
+        https://bugs.webkit.org/show_bug.cgi?id=138787
+
+        Reviewed by Darin Adler.
+
+        * Modules/mediacontrols/MediaControlsHost.cpp:
+        (WebCore::MediaControlsHost::optimizedFullscreenSupported): Check mediaSession().allowsAlternateFullscreen.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::enterFullscreenOptimized): Do nothing if
+            mediaSession().allowsAlternateFullscreen says it isn't allowed.
+
+        * html/HTMLMediaSession.cpp:
+        (WebCore::HTMLMediaSession::allowsAlternateFullscreen): New, check settings.
+        * html/HTMLMediaSession.h:
+
+        * page/Settings.cpp: Add allowsAlternateFullscreen.
+        * page/Settings.in: Ditto.
+
 2014-11-16  Zan Dobersek  <zdobersek@igalia.com>
 
         Replace RenderSVGResource::cast<T>() with downcast<T>()
index cad7baa..a0cc4d7 100644 (file)
@@ -198,10 +198,11 @@ void MediaControlsHost::enterFullscreenOptimized()
 bool MediaControlsHost::optimizedFullscreenSupported()
 {
 #if PLATFORM(IOS)
-    return wkIsOptimizedFullscreenSupported();
-#else
-    return false;
+    if (!wkIsOptimizedFullscreenSupported())
+        return false;
 #endif
+
+    return m_mediaElement->mediaSession().allowsAlternateFullscreen(*m_mediaElement);
 }
 
 void MediaControlsHost::updateCaptionDisplaySizes()
index d47d64a..ca5f0ae 100644 (file)
@@ -4960,7 +4960,8 @@ void HTMLMediaElement::exitFullscreen()
 
 void HTMLMediaElement::enterFullscreenOptimized()
 {
-    enterFullscreen(VideoFullscreenModeOptimized);
+    if (m_mediaSession->allowsAlternateFullscreen(*this))
+        enterFullscreen(VideoFullscreenModeOptimized);
 }
 
 void HTMLMediaElement::didBecomeFullscreenElement()
index b4c777f..da1a53a 100644 (file)
@@ -301,6 +301,12 @@ void HTMLMediaSession::applyMediaPlayerRestrictions(const HTMLMediaElement& elem
     
 }
 
+bool HTMLMediaSession::allowsAlternateFullscreen(const HTMLMediaElement& element) const
+{
+    Settings* settings = element.document().settings();
+    return settings && settings->allowsAlternateFullscreen();
+}
+
 #if ENABLE(MEDIA_SOURCE)
 const unsigned fiveMinutesOf1080PVideo = 290 * 1024 * 1024; // 290 MB is approximately 5 minutes of 8Mbps (1080p) content.
 const unsigned fiveMinutesStereoAudio = 14 * 1024 * 1024; // 14 MB is approximately 5 minutes of 384kbps content.
index 31d7d34..d42eda5 100644 (file)
@@ -61,6 +61,7 @@ public:
     void setHasPlaybackTargetAvailabilityListeners(const HTMLMediaElement&, bool);
 #endif
     bool requiresFullscreenForVideoPlayback(const HTMLMediaElement&) const;
+    bool allowsAlternateFullscreen(const HTMLMediaElement&) const;
     MediaPlayer::Preload effectivePreloadForElement(const HTMLMediaElement&) const;
 
     void applyMediaPlayerRestrictions(const HTMLMediaElement&);
index b55f967..7d75e02 100644 (file)
@@ -145,6 +145,8 @@ static const bool defaultImageSubsamplingEnabled = false;
 static const bool defaultScrollingTreeIncludesFrames = false;
 #endif
 
+static const bool defaultAllowsAlternateFullscreen = true;
+
 static const double defaultIncrementalRenderingSuppressionTimeoutInSeconds = 5;
 #if USE(UNIFIED_TEXT_CHECKING)
 static const bool defaultUnifiedTextCheckerEnabled = true;
index 8aff84d..4983e33 100644 (file)
@@ -125,6 +125,7 @@ allowDisplayOfInsecureContent initial=true
 allowRunningOfInsecureContent initial=true
 mediaPlaybackRequiresUserGesture initial=defaultMediaPlaybackRequiresUserGesture
 mediaPlaybackAllowsInline initial=defaultMediaPlaybackAllowsInline
+allowsAlternateFullscreen initial=defaultAllowsAlternateFullscreen
 passwordEchoEnabled initial=false
 suppressesIncrementalRendering initial=false
 incrementalRenderingSuppressionTimeoutInSeconds type=double, initial=defaultIncrementalRenderingSuppressionTimeoutInSeconds
index b131a4e..e7582b1 100644 (file)
@@ -1,3 +1,19 @@
+2014-11-17  Eric Carlson  <eric.carlson@apple.com>
+
+        [iOS] allow host application to opt-out of alternate fullscreen
+        https://bugs.webkit.org/show_bug.cgi?id=138787
+
+        Reviewed by Darin Adler.
+
+        * WebView/WebPreferenceKeysPrivate.h:
+        * WebView/WebPreferences.mm:
+        (+[WebPreferences initialize]):
+        (-[WebPreferences allowsAlternateFullscreen]):
+        (-[WebPreferences setAllowsAlternateFullscreen:]):
+        * WebView/WebPreferencesPrivate.h:
+        * WebView/WebView.mm:
+        (-[WebView _preferencesChanged:]):
+
 2014-11-16  Tim Horton  <timothy_horton@apple.com>
 
         Use TextIndicator instead of the built in Lookup highlight
index 34a2fcf..106631a 100644 (file)
 #define WebKitHixie76WebSocketProtocolEnabledKey @"WebKitHixie76WebSocketProtocolEnabled"
 #define WebKitMediaPlaybackRequiresUserGesturePreferenceKey @"WebKitMediaPlaybackRequiresUserGesture"
 #define WebKitMediaPlaybackAllowsInlinePreferenceKey @"WebKitMediaPlaybackAllowsInline"
+#define WebKitAllowsAlternateFullscreenPreferenceKey @"WebKitAllowsAlternateFullscreen"
 #define WebKitMockScrollbarsEnabledPreferenceKey @"WebKitMockScrollbarsEnabled"
 #define WebKitShouldDisplaySubtitlesPreferenceKey @"WebKitShouldDisplaySubtitles"
 #define WebKitShouldDisplayCaptionsPreferenceKey @"WebKitShouldDisplayCaptions"
index 8196971..04ca54a 100644 (file)
@@ -538,6 +538,7 @@ public:
 
         [NSNumber numberWithBool:YES],   WebKitShouldRespectImageOrientationKey,
 #endif // PLATFORM(IOS)
+        [NSNumber numberWithBool:YES],  WebKitAllowsAlternateFullscreenPreferenceKey,
         [NSNumber numberWithBool:YES],  WebKitRequestAnimationFrameEnabledPreferenceKey,
         [NSNumber numberWithBool:NO],   WebKitWantsBalancedSetDefersLoadingBehaviorKey,
         [NSNumber numberWithBool:NO],   WebKitDiagnosticLoggingEnabledKey,
@@ -2162,6 +2163,16 @@ static NSString *classIBCreatorID = nil;
     [self _setBoolValue:flag forKey:WebKitMediaPlaybackAllowsInlinePreferenceKey];
 }
 
+- (BOOL)allowsAlternateFullscreen
+{
+    return [self _boolValueForKey:WebKitAllowsAlternateFullscreenPreferenceKey];
+}
+
+- (void)setAllowsAlternateFullscreen:(BOOL)flag
+{
+    [self _setBoolValue:flag forKey:WebKitAllowsAlternateFullscreenPreferenceKey];
+}
+
 - (BOOL)mockScrollbarsEnabled
 {
     return [self _boolValueForKey:WebKitMockScrollbarsEnabledPreferenceKey];
index ddae855..0e69d3e 100644 (file)
@@ -238,6 +238,9 @@ extern NSString *WebPreferencesCacheModelChangedInternalNotification;
 - (void)setMediaPlaybackAllowsInline:(BOOL)flag;
 - (BOOL)mediaPlaybackAllowsInline;
 
+- (void)setAllowsAlternateFullscreen:(BOOL)flag;
+- (BOOL)allowsAlternateFullscreen;
+
 - (NSString *)pictographFontFamily;
 - (void)setPictographFontFamily:(NSString *)family;
 
index 4848711..c402696 100644 (file)
@@ -2257,6 +2257,7 @@ static bool needsSelfRetainWhileLoadingQuirk()
 
     settings.setMediaPlaybackRequiresUserGesture([preferences mediaPlaybackRequiresUserGesture]);
     settings.setMediaPlaybackAllowsInline([preferences mediaPlaybackAllowsInline]);
+    settings.setAllowsAlternateFullscreen([preferences allowsAlternateFullscreen]);
     settings.setSuppressesIncrementalRendering([preferences suppressesIncrementalRendering]);
     settings.setBackspaceKeyNavigationEnabled([preferences backspaceKeyNavigationEnabled]);
     settings.setWantsBalancedSetDefersLoadingBehavior([preferences wantsBalancedSetDefersLoadingBehavior]);
index 4c6fabf..b0942b6 100644 (file)
@@ -1,3 +1,24 @@
+2014-11-17  Eric Carlson  <eric.carlson@apple.com>
+
+        [iOS] allow host application to opt-out of alternate fullscreen
+        https://bugs.webkit.org/show_bug.cgi?id=138787
+
+        Reviewed by Darin Adler.
+
+        * Shared/WebPreferencesDefinitions.h:
+        * UIProcess/API/C/WKPreferences.cpp:
+        (WKPreferencesSetAllowsAlternateFullscreen):
+        (WKPreferencesGetAllowsAlternateFullscreen):
+        * UIProcess/API/C/WKPreferencesRefPrivate.h:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView initWithFrame:configuration:]):
+        * UIProcess/API/Cocoa/WKWebViewConfiguration.h:
+        * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
+        (-[WKWebViewConfiguration init]):
+        (-[WKWebViewConfiguration copyWithZone:]):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences):
+
 2014-11-16  Benjamin Poulain  <bpoulain@apple.com>
 
         Start cleaning up minimal UI from WKWebView
index c708823..93ac2b4 100644 (file)
     macro(AVFoundationEnabled, isAVFoundationEnabled, Bool, bool, true) \
     macro(MediaPlaybackRequiresUserGesture, mediaPlaybackRequiresUserGesture, Bool, bool, DEFAULT_MEDIA_PLAYBACK_REQUIRES_USER_GESTURE) \
     macro(MediaPlaybackAllowsInline, mediaPlaybackAllowsInline, Bool, bool, DEFAULT_MEDIA_PLAYBACK_ALLOWS_INLINE) \
+    macro(AllowsAlternateFullscreen, allowsAlternateFullscreen, Bool, bool, true) \
     macro(MediaPlaybackAllowsAirPlay, mediaPlaybackAllowsAirPlay, Bool, bool, true) \
     macro(InspectorStartsAttached, inspectorStartsAttached, Bool, bool, true) \
     macro(ShowsToolTipOverTruncatedText, showsToolTipOverTruncatedText, Bool, bool, false) \
index b8b7ffa..44add1d 100644 (file)
@@ -738,6 +738,16 @@ bool WKPreferencesGetMediaPlaybackAllowsInline(WKPreferencesRef preferencesRef)
     return toImpl(preferencesRef)->mediaPlaybackAllowsInline();
 }
 
+void WKPreferencesSetAllowsAlternateFullscreen(WKPreferencesRef preferencesRef, bool flag)
+{
+    toImpl(preferencesRef)->setAllowsAlternateFullscreen(flag);
+}
+
+bool WKPreferencesGetAllowsAlternateFullscreen(WKPreferencesRef preferencesRef)
+{
+    return toImpl(preferencesRef)->allowsAlternateFullscreen();
+}
+
 void WKPreferencesSetShowsToolTipOverTruncatedText(WKPreferencesRef preferencesRef, bool flag)
 {
     toImpl(preferencesRef)->setShowsToolTipOverTruncatedText(flag);
index 3af6eec..e38322d 100644 (file)
@@ -164,6 +164,10 @@ WK_EXPORT bool WKPreferencesGetMediaPlaybackRequiresUserGesture(WKPreferencesRef
 WK_EXPORT void WKPreferencesSetMediaPlaybackAllowsInline(WKPreferencesRef preferencesRef, bool flag);
 WK_EXPORT bool WKPreferencesGetMediaPlaybackAllowsInline(WKPreferencesRef preferencesRef);
 
+// Defaults to true.
+WK_EXPORT void WKPreferencesSetAllowsAlternateFullscreen(WKPreferencesRef preferencesRef, bool flag);
+WK_EXPORT bool WKPreferencesGetAllowsAlternateFullscreen(WKPreferencesRef preferencesRef);
+
 // Defaults to false.
 WK_EXPORT void WKPreferencesSetShowsToolTipOverTruncatedText(WKPreferencesRef preferencesRef, bool flag);
 WK_EXPORT bool WKPreferencesGetShowsToolTipOverTruncatedText(WKPreferencesRef preferencesRef);
index a931b68..ab3f2e3 100644 (file)
@@ -289,6 +289,7 @@ static int32_t deviceOrientation()
 
 #if PLATFORM(IOS)
     webPageConfiguration.preferenceValues.set(WebKit::WebPreferencesKey::mediaPlaybackAllowsInlineKey(), WebKit::WebPreferencesStore::Value(!![_configuration allowsInlineMediaPlayback]));
+    webPageConfiguration.preferenceValues.set(WebKit::WebPreferencesKey::allowsAlternateFullscreenKey(), WebKit::WebPreferencesStore::Value(!![_configuration allowsAlternateFullscreen]));
     webPageConfiguration.preferenceValues.set(WebKit::WebPreferencesKey::mediaPlaybackRequiresUserGestureKey(), WebKit::WebPreferencesStore::Value(!![_configuration mediaPlaybackRequiresUserAction]));
     webPageConfiguration.preferenceValues.set(WebKit::WebPreferencesKey::mediaPlaybackAllowsAirPlayKey(), WebKit::WebPreferencesStore::Value(!![_configuration mediaPlaybackAllowsAirPlay]));
 #endif
index 6063540..19166b5 100644 (file)
@@ -102,6 +102,11 @@ WK_CLASS_AVAILABLE(10_10, 8_0)
  */
 @property (nonatomic) WKSelectionGranularity selectionGranularity;
 
+/*! @abstract A Boolean value indicating whether alternate fullscreen mode is allowed.
+ @discussion The default value is YES.
+ */
+@property (nonatomic) BOOL allowsAlternateFullscreen;
+
 #endif
 
 @end
index 304a485..415883b 100644 (file)
@@ -88,6 +88,7 @@ private:
 #if PLATFORM(IOS)
     _mediaPlaybackRequiresUserAction = YES;
     _mediaPlaybackAllowsAirPlay = YES;
+    _allowsAlternateFullscreen = YES;
 #endif
     
     return self;
@@ -116,6 +117,7 @@ private:
     configuration->_suppressesIncrementalRendering = self->_suppressesIncrementalRendering;
 #if PLATFORM(IOS)
     configuration->_allowsInlineMediaPlayback = self->_allowsInlineMediaPlayback;
+    configuration->_allowsAlternateFullscreen = self->_allowsAlternateFullscreen;
     configuration->_mediaPlaybackRequiresUserAction = self->_mediaPlaybackRequiresUserAction;
     configuration->_mediaPlaybackAllowsAirPlay = self->_mediaPlaybackAllowsAirPlay;
     configuration->_selectionGranularity = self->_selectionGranularity;
index 60c2e47..3e75c29 100644 (file)
@@ -2709,6 +2709,7 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
     settings.setAccelerated2dCanvasEnabled(store.getBoolValueForKey(WebPreferencesKey::accelerated2dCanvasEnabledKey()));
     settings.setMediaPlaybackRequiresUserGesture(store.getBoolValueForKey(WebPreferencesKey::mediaPlaybackRequiresUserGestureKey()));
     settings.setMediaPlaybackAllowsInline(store.getBoolValueForKey(WebPreferencesKey::mediaPlaybackAllowsInlineKey()));
+    settings.setAllowsAlternateFullscreen(store.getBoolValueForKey(WebPreferencesKey::allowsAlternateFullscreenKey()));
     settings.setMockScrollbarsEnabled(store.getBoolValueForKey(WebPreferencesKey::mockScrollbarsEnabledKey()));
     settings.setHyperlinkAuditingEnabled(store.getBoolValueForKey(WebPreferencesKey::hyperlinkAuditingEnabledKey()));
     settings.setRequestAnimationFrameEnabled(store.getBoolValueForKey(WebPreferencesKey::requestAnimationFrameEnabledKey()));