webkitfullscreenchange event not fired at the same time as :-webkit-full-screen pseud...
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Mar 2018 23:10:05 +0000 (23:10 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Mar 2018 23:10:05 +0000 (23:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=183383
<rdar://problem/38197028>

Reviewed by Eric Carlson.

Follow-up patch: now that the 'fullscreenchange' event is being fired slightly earlier, the
Fullscreen.TopContentInset tests triggers what appears to be an existing behavior: if you
exit in the middle of an enter fullscreen animation, the exit never happens, because the
NSWindow never starts the exit animation. The solution is to store the exit fullscreen
request, and only act upon it when the enter animation completes.

* UIProcess/mac/WKFullScreenWindowController.h:
* UIProcess/mac/WKFullScreenWindowController.mm:
(-[WKFullScreenWindowController finishedEnterFullScreenAnimation:]):
(-[WKFullScreenWindowController exitFullScreen]):

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/mac/WKFullScreenWindowController.h
Source/WebKit/UIProcess/mac/WKFullScreenWindowController.mm

index 24a07e8..e911567 100644 (file)
@@ -1,5 +1,24 @@
 2018-03-09  Jer Noble  <jer.noble@apple.com>
 
+        webkitfullscreenchange event not fired at the same time as :-webkit-full-screen pseudo selector changes; causes glitchiness
+        https://bugs.webkit.org/show_bug.cgi?id=183383
+        <rdar://problem/38197028>
+
+        Reviewed by Eric Carlson.
+
+        Follow-up patch: now that the 'fullscreenchange' event is being fired slightly earlier, the
+        Fullscreen.TopContentInset tests triggers what appears to be an existing behavior: if you
+        exit in the middle of an enter fullscreen animation, the exit never happens, because the
+        NSWindow never starts the exit animation. The solution is to store the exit fullscreen
+        request, and only act upon it when the enter animation completes.
+
+        * UIProcess/mac/WKFullScreenWindowController.h:
+        * UIProcess/mac/WKFullScreenWindowController.mm:
+        (-[WKFullScreenWindowController finishedEnterFullScreenAnimation:]):
+        (-[WKFullScreenWindowController exitFullScreen]):
+
+2018-03-09  Jer Noble  <jer.noble@apple.com>
+
         Unconditionalize more methods in VideoFullscreenInterface (and related classes)
         https://bugs.webkit.org/show_bug.cgi?id=183501
 
index 21308a7..35426d5 100644 (file)
@@ -54,6 +54,7 @@ typedef enum FullScreenState : NSInteger FullScreenState;
     RetainPtr<NSTimer> _watchdogTimer;
     RetainPtr<NSArray> _savedConstraints;
 
+    bool _requestedExitFullScreen;
     FullScreenState _fullScreenState;
 
     double _savedScale;
index e1446b2..aade974 100644 (file)
@@ -329,10 +329,24 @@ static const float minVideoWidth = 480 + 20 + 20; // Note: Keep in sync with med
     }
 
     NSEnableScreenUpdates();
+
+    if (_requestedExitFullScreen) {
+        _requestedExitFullScreen = NO;
+        [self exitFullScreen];
+    }
 }
 
 - (void)exitFullScreen
 {
+    if (_fullScreenState == EnteringFullScreen
+        || _fullScreenState == WaitingToEnterFullScreen) {
+        // Do not try to exit fullscreen during the enter animation; remember
+        // that exit was requested and perform the exit upon enter fullscreen
+        // animation complete.
+        _requestedExitFullScreen = YES;
+        return;
+    }
+
     if (_watchdogTimer) {
         [_watchdogTimer invalidate];
         _watchdogTimer.clear();