Flash of white when exiting full screen HTML5 video
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 May 2012 23:31:14 +0000 (23:31 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 May 2012 23:31:14 +0000 (23:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=85438

.:

Reviewed by Sam Weinig.

* ManualTests/fullscreen/full-screen-flash.html: Added.

Source/WebKit2:

Reviewed by Maciej Stachowiak.

Force a repaint before displaying the newly exited WebView window.  This gives the window
a chance to seamlessly repaint before enabling screen updates.

Also, send the WebProcess the didExitFullScreen and setAnimatingFullScreen(false) messages
after swapping the WebView back into its original window. Doing otherwise seems to cause
forceRepaint to paint a white frame.

* UIProcess/mac/WKFullScreenWindowController.mm:
(-[WKFullScreenWindowController finishedExitFullScreenAnimation:]):
(-[WKFullScreenWindowController completeFinishExitFullScreenAnimationAfterRepaint]):
(completeFinishExitFullScreenAnimationAfterRepaint):

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

ChangeLog
ManualTests/fullscreen/full-screen-flash.html [new file with mode: 0644]
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm

index 7088fa6..bad5b97 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2012-05-04  Jer Noble  <jer.noble@apple.com>
 
+        Flash of white when exiting full screen HTML5 video
+        https://bugs.webkit.org/show_bug.cgi?id=85438
+
+        Reviewed by Sam Weinig.
+
+        * ManualTests/fullscreen/full-screen-flash.html: Added.
+
+2012-05-04  Jer Noble  <jer.noble@apple.com>
+
         Taking a visibility:hidden element full screen causes full screen window to disappear.
         https://bugs.webkit.org/show_bug.cgi?id=85432
 
diff --git a/ManualTests/fullscreen/full-screen-flash.html b/ManualTests/fullscreen/full-screen-flash.html
new file mode 100644 (file)
index 0000000..982fe65
--- /dev/null
@@ -0,0 +1,28 @@
+<style>
+    body { background: green; color: white; }
+    document:-webkit-full-screen-document > body { background: red;  }
+    span { text-decoration: underline; cursor: hand; }
+    div {
+        background: blue;
+        width: 200px;
+        height: 100px;
+    }
+    div:-webkit-full-screen {
+        width: 100%;
+        height: 100%;
+    }
+</style>
+<script>
+function toggleFullScreen() {
+    if (document.webkitIsFullScreen)
+        document.webkitCancelFullScreen();
+    else
+        document.getElementsByTagName('div')[0].webkitRequestFullscreen();
+}
+</script>
+<body>
+    This tests that the page does not have a visible "flash" when finishing the exit full screen animation.
+    <span onclick="toggleFullScreen()">Click to toggle full screen.</span>
+    <div>
+    </div>
+</body>
\ No newline at end of file
index 9f38ffc..f19cf05 100644 (file)
@@ -1,3 +1,22 @@
+2012-05-02  Jer Noble  <jer.noble@apple.com>
+
+        Flash of white when exiting full screen HTML5 video
+        https://bugs.webkit.org/show_bug.cgi?id=85438
+
+        Reviewed by Maciej Stachowiak.
+
+        Force a repaint before displaying the newly exited WebView window.  This gives the window
+        a chance to seamlessly repaint before enabling screen updates.
+
+        Also, send the WebProcess the didExitFullScreen and setAnimatingFullScreen(false) messages
+        after swapping the WebView back into its original window. Doing otherwise seems to cause
+        forceRepaint to paint a white frame.
+
+        * UIProcess/mac/WKFullScreenWindowController.mm:
+        (-[WKFullScreenWindowController finishedExitFullScreenAnimation:]):
+        (-[WKFullScreenWindowController completeFinishExitFullScreenAnimationAfterRepaint]):
+        (completeFinishExitFullScreenAnimationAfterRepaint):
+
 2012-05-04  Anders Carlsson  <andersca@apple.com>
 
         Set the right device scale factor when creating the web page
index c282c9d..9b3c114 100644 (file)
@@ -338,6 +338,8 @@ static const NSTimeInterval DefaultWatchdogTimerInterval = 1;
     [self _startExitFullScreenAnimationWithDuration:defaultAnimationDuration];
 }
 
+static void completeFinishExitFullScreenAnimationAfterRepaint(WKErrorRef, void*);
+
 - (void)finishedExitFullScreenAnimation:(bool)completed
 {
     if (!_isExitingFullScreen)
@@ -346,11 +348,9 @@ static const NSTimeInterval DefaultWatchdogTimerInterval = 1;
 
     [self _updateMenuAndDockForFullScreen];
 
-    // Screen updates to be re-enabled ta the end of the current function.
+    // Screen updates to be re-enabled in completeFinishExitFullScreenAnimationAfterRepaint.
     NSDisableScreenUpdates();
-
-    [self _manager]->didExitFullScreen();
-    [self _manager]->setAnimatingFullScreen(false);
+    [[_webViewPlaceholder.get() window] setAutodisplay:NO];
 
     NSResponder *firstResponder = [[self window] firstResponder];
     [self _swapView:_webViewPlaceholder.get() with:_webView];
@@ -372,9 +372,24 @@ static const NSTimeInterval DefaultWatchdogTimerInterval = 1;
 
     [[_webView window] makeKeyAndOrderFront:self];
 
+    // These messages must be sent after the swap or flashing will occur during forceRepaint:
+    [self _manager]->didExitFullScreen();
+    [self _manager]->setAnimatingFullScreen(false);
+
+    [self _page]->forceRepaint(VoidCallback::create(self, completeFinishExitFullScreenAnimationAfterRepaint));
+}
+
+- (void)completeFinishExitFullScreenAnimationAfterRepaint
+{
+    [[_webView window] setAutodisplay:YES];
     NSEnableScreenUpdates();
 }
 
+static void completeFinishExitFullScreenAnimationAfterRepaint(WKErrorRef, void* _self)
+{
+    [(WKFullScreenWindowController*)_self completeFinishExitFullScreenAnimationAfterRepaint];
+}
+
 - (void)close
 {
     // We are being asked to close rapidly, most likely because the page