Full screen video space can be resized to 1pt wide
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Jun 2015 21:06:23 +0000 (21:06 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Jun 2015 21:06:23 +0000 (21:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=145895
<rdar://problem/20907914>

Reviewed by Simon Fraser.

Prior to the upcoming OS X, full screen mode was not resizable. Now that it is,
we need to set a minimum window width that is large enough to hold the media
controls. This makes our full-screen video behave the same as the QuickTimeX player.

* UIProcess/mac/WKFullScreenWindowController.mm:
(-[WKFullScreenWindowController finishedEnterFullScreenAnimation:]): Active that new
kWKLayoutModeDynamicSizeWithMinimumViewSize style, and set the minimum view size to
be the width of our media controls, with 20 pixels of padding on either side.
(-[WKFullScreenWindowController finishedExitFullScreenAnimation:]): Set the layout
mode back to the default style.

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm

index 97ffd4b..91cb53d 100644 (file)
@@ -1,3 +1,22 @@
+2015-06-11  Brent Fulgham  <bfulgham@apple.com>
+
+        Full screen video space can be resized to 1pt wide
+        https://bugs.webkit.org/show_bug.cgi?id=145895
+        <rdar://problem/20907914>
+
+        Reviewed by Simon Fraser.
+
+        Prior to the upcoming OS X, full screen mode was not resizable. Now that it is,
+        we need to set a minimum window width that is large enough to hold the media
+        controls. This makes our full-screen video behave the same as the QuickTimeX player.
+
+        * UIProcess/mac/WKFullScreenWindowController.mm:
+        (-[WKFullScreenWindowController finishedEnterFullScreenAnimation:]): Active that new
+        kWKLayoutModeDynamicSizeWithMinimumViewSize style, and set the minimum view size to
+        be the width of our media controls, with 20 pixels of padding on either side.
+        (-[WKFullScreenWindowController finishedExitFullScreenAnimation:]): Set the layout
+        mode back to the default style.
+
 2015-06-11  Jon Lee  <jonlee@apple.com>
 
         Update media controls JS and CSS to use picture-in-picture
index 29e5e9c..3c835c9 100644 (file)
@@ -278,6 +278,8 @@ static RetainPtr<CGImageRef> createImageWithCopiedData(CGImageRef sourceImage)
     [[self window] enterFullScreenMode:self];
 }
 
+static const float minVideoWidth = 480 + 20 + 20; // Note: Keep in sync with mediaControlsApple.css (video:-webkit-full-screen::-webkit-media-controls-panel)
+
 - (void)finishedEnterFullScreenAnimation:(bool)completed
 {
     if (_fullScreenState != EnteringFullScreen)
@@ -298,6 +300,12 @@ static RetainPtr<CGImageRef> createImageWithCopiedData(CGImageRef sourceImage)
 
         [_webViewPlaceholder setExitWarningVisible:YES];
         [_webViewPlaceholder setTarget:self];
+
+        [_webView _setLayoutMode:kWKLayoutModeDynamicSizeWithMinimumViewSize];
+        
+        NSSize minContentSize = self.window.contentMinSize;
+        minContentSize.width = minVideoWidth;
+        self.window.contentMinSize = minContentSize;
     } else {
         // Transition to fullscreen failed. Clean up.
         _fullScreenState = NotInFullScreen;
@@ -384,6 +392,7 @@ static RetainPtr<CGImageRef> createImageWithCopiedData(CGImageRef sourceImage)
     makeResponderFirstResponderIfDescendantOfView(_webView.window, firstResponder, _webView);
 
     [[_webView window] makeKeyAndOrderFront:self];
+    [_webView _setLayoutMode:kWKLayoutModeViewSize];
 
     // These messages must be sent after the swap or flashing will occur during forceRepaint:
     [self _manager]->didExitFullScreen();