Title: [262322] trunk/Source/WebKit
Revision
262322
Author
[email protected]
Date
2020-05-29 16:03:46 -0700 (Fri, 29 May 2020)

Log Message

[Mac,WK2] Fullscreen animation missing a few frames at beginning
https://bugs.webkit.org/show_bug.cgi?id=212156
<rdar://problem/54799415>

Reviewed by Eric Carlson.

When starting the enter fullscreen animation, ensure that the fullscreen window is ordered front, and on top
of the content, as well as having all the animations configured so that their starting state is in place before
calling -[NSWindow enterFullscreenMode:]. Move all the window creation code into
-beganEnterFullScreenWithInitialFrame:finalFrame: from _startEnterFullScreenAnimationWithDuration:. Re-use the
existing zoomAnimation() and maskAnimation() utility methods, but give the animations a very long duration
(since there is no explicit way to start and stop a CAAnimation). This initial animation will be replaced with
the final one inside -_startEnterFullScreenAnimationWithDuration:. Separately, explictly disable implicit
animations of the fullscreen window during -orderIn: and -orderOut:.

* UIProcess/mac/WKFullScreenWindowController.mm:
(-[WKFullScreenWindowController initWithWindow:webView:page:impl:]):
(-[WKFullScreenWindowController beganEnterFullScreenWithInitialFrame:finalFrame:]):
(-[WKFullScreenWindowController _startEnterFullScreenAnimationWithDuration:]):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (262321 => 262322)


--- trunk/Source/WebKit/ChangeLog	2020-05-29 22:35:27 UTC (rev 262321)
+++ trunk/Source/WebKit/ChangeLog	2020-05-29 23:03:46 UTC (rev 262322)
@@ -1,3 +1,25 @@
+2020-05-29  Jer Noble  <[email protected]>
+
+        [Mac,WK2] Fullscreen animation missing a few frames at beginning
+        https://bugs.webkit.org/show_bug.cgi?id=212156
+        <rdar://problem/54799415>
+
+        Reviewed by Eric Carlson.
+
+        When starting the enter fullscreen animation, ensure that the fullscreen window is ordered front, and on top
+        of the content, as well as having all the animations configured so that their starting state is in place before
+        calling -[NSWindow enterFullscreenMode:]. Move all the window creation code into
+        -beganEnterFullScreenWithInitialFrame:finalFrame: from _startEnterFullScreenAnimationWithDuration:. Re-use the
+        existing zoomAnimation() and maskAnimation() utility methods, but give the animations a very long duration
+        (since there is no explicit way to start and stop a CAAnimation). This initial animation will be replaced with
+        the final one inside -_startEnterFullScreenAnimationWithDuration:. Separately, explictly disable implicit
+        animations of the fullscreen window during -orderIn: and -orderOut:.
+
+        * UIProcess/mac/WKFullScreenWindowController.mm:
+        (-[WKFullScreenWindowController initWithWindow:webView:page:impl:]):
+        (-[WKFullScreenWindowController beganEnterFullScreenWithInitialFrame:finalFrame:]):
+        (-[WKFullScreenWindowController _startEnterFullScreenAnimationWithDuration:]):
+
 2020-05-29  Jan-Michael Brummer  <[email protected]>
 
         [GTK][WPE] API for WebView audio mute support

Modified: trunk/Source/WebKit/UIProcess/mac/WKFullScreenWindowController.mm (262321 => 262322)


--- trunk/Source/WebKit/UIProcess/mac/WKFullScreenWindowController.mm	2020-05-29 22:35:27 UTC (rev 262321)
+++ trunk/Source/WebKit/UIProcess/mac/WKFullScreenWindowController.mm	2020-05-29 23:03:46 UTC (rev 262322)
@@ -128,6 +128,7 @@
 
     // Hide the titlebar during the animation to full screen so that only the WKWebView content is visible.
     window.titlebarAlphaValue = 0;
+    window.animationBehavior = NSWindowAnimationBehaviorNone;
 
     NSView *contentView = [window contentView];
     contentView.hidden = YES;
@@ -313,8 +314,34 @@
     _initialFrame = initialFrame;
     _finalFrame = finalFrame;
 
-    [self.window orderBack: self]; // Make sure the full screen window is part of the correct Space.
-    [[self window] enterFullScreenMode:self];
+    [CATransaction begin];
+    [CATransaction setDisableActions:YES];
+
+    auto clipLayer = _clipView.get().layer;
+    NSView *contentView = [[self window] contentView];
+
+    // Give the initial animations a speed of "0". We want the animations in place when we order in
+    // the window, but to not start animating until we get the callback from AppKit with the required
+    // animation duration. These animations will be replaced with the final animations in
+    // -_startEnterFullScreenAnimationWithDuration:
+    [clipLayer addAnimation:zoomAnimation(_initialFrame, _finalFrame, self.window.screen.frame, 1, 0, AnimateIn) forKey:@"fullscreen"];
+    clipLayer.mask = createMask(contentView.bounds);
+    [clipLayer.mask addAnimation:maskAnimation(_initialFrame, _finalFrame, self.window.screen.frame, 1, 0, AnimateIn) forKey:@"fullscreen"];
+    contentView.hidden = NO;
+
+    NSWindow* window = self.window;
+    NSWindowCollectionBehavior behavior = [window collectionBehavior];
+    [window setCollectionBehavior:(behavior | NSWindowCollectionBehaviorCanJoinAllSpaces)];
+    [window makeKeyAndOrderFront:self];
+    [window setCollectionBehavior:behavior];
+    [window makeFirstResponder:_webView];
+
+    _page->setSuppressVisibilityUpdates(false);
+    [[self window] displayIfNeeded];
+
+    [CATransaction commit];
+
+    [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)
@@ -694,7 +721,7 @@
 }
 
 enum AnimationDirection { AnimateIn, AnimateOut };
-static CAAnimation *zoomAnimation(const WebCore::FloatRect& initialFrame, const WebCore::FloatRect& finalFrame, const WebCore::FloatRect& screenFrame, CFTimeInterval duration, AnimationDirection direction)
+static CAAnimation *zoomAnimation(const WebCore::FloatRect& initialFrame, const WebCore::FloatRect& finalFrame, const WebCore::FloatRect& screenFrame, CFTimeInterval duration, float speed, AnimationDirection direction)
 {
     CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];
     WebCore::FloatRect scaleRect = smallestRectWithAspectRatioAroundRect(finalFrame.size().aspectRatio(), initialFrame);
@@ -726,7 +753,7 @@
     return maskLayer;
 }
 
-static CAAnimation *maskAnimation(const WebCore::FloatRect& initialFrame, const WebCore::FloatRect& finalFrame, const WebCore::FloatRect& screenFrame, CFTimeInterval duration, AnimationDirection direction)
+static CAAnimation *maskAnimation(const WebCore::FloatRect& initialFrame, const WebCore::FloatRect& finalFrame, const WebCore::FloatRect& screenFrame, CFTimeInterval duration, float speed, AnimationDirection direction)
 {
     CABasicAnimation *boundsAnimation = [CABasicAnimation animationWithKeyPath:@"bounds"];
     WebCore::FloatRect boundsRect = largestRectWithAspectRatioInsideRect(initialFrame.size().aspectRatio(), finalFrame);
@@ -768,31 +795,15 @@
 
 - (void)_startEnterFullScreenAnimationWithDuration:(NSTimeInterval)duration
 {
-    NSView* contentView = [[self window] contentView];
+    [CATransaction begin];
+    [CATransaction setDisableActions:YES];
 
-    [[_clipView layer] addAnimation:zoomAnimation(_initialFrame, _finalFrame, self.window.screen.frame, duration, AnimateIn) forKey:@"fullscreen"];
-    CALayer *maskLayer = createMask(contentView.bounds);
-    [maskLayer addAnimation:maskAnimation(_initialFrame, _finalFrame, self.window.screen.frame, duration, AnimateIn) forKey:@"fullscreen"];
-    [_clipView layer].mask = maskLayer;
-
-    contentView.hidden = NO;
+    auto clipLayer = _clipView.get().layer;
+    [clipLayer addAnimation:zoomAnimation(_initialFrame, _finalFrame, self.window.screen.frame, duration, 1, AnimateIn) forKey:@"fullscreen"];
+    [clipLayer.mask addAnimation:maskAnimation(_initialFrame, _finalFrame, self.window.screen.frame, duration, 1, AnimateIn) forKey:@"fullscreen"];
     [_backgroundView.get().layer addAnimation:fadeAnimation(duration, AnimateIn) forKey:@"fullscreen"];
 
-    NSWindow* window = [self window];
-    NSWindowCollectionBehavior behavior = [window collectionBehavior];
-    [window setCollectionBehavior:(behavior | NSWindowCollectionBehaviorCanJoinAllSpaces)];
-    [window makeKeyAndOrderFront:self];
-    [window setCollectionBehavior:behavior];
-    [window makeFirstResponder:_webView];
-
-    _page->setSuppressVisibilityUpdates(false);
-    ALLOW_DEPRECATED_DECLARATIONS_BEGIN
-    [[self window] setAutodisplay:YES];
-    ALLOW_DEPRECATED_DECLARATIONS_END
-    [[self window] displayIfNeeded];
-    ALLOW_DEPRECATED_DECLARATIONS_BEGIN
-    NSEnableScreenUpdates();
-    ALLOW_DEPRECATED_DECLARATIONS_END
+    [CATransaction commit];
 }
 
 - (void)_startExitFullScreenAnimationWithDuration:(NSTimeInterval)duration
@@ -805,10 +816,10 @@
         _fullScreenState = ExitingFullScreen;
     }
 
-    [[_clipView layer] addAnimation:zoomAnimation(_initialFrame, _finalFrame, self.window.screen.frame, duration, AnimateOut) forKey:@"fullscreen"];
+    [[_clipView layer] addAnimation:zoomAnimation(_initialFrame, _finalFrame, self.window.screen.frame, duration, 1, AnimateOut) forKey:@"fullscreen"];
     NSView* contentView = [[self window] contentView];
     CALayer *maskLayer = createMask(contentView.bounds);
-    [maskLayer addAnimation:maskAnimation(_initialFrame, _finalFrame, self.window.screen.frame, duration, AnimateOut) forKey:@"fullscreen"];
+    [maskLayer addAnimation:maskAnimation(_initialFrame, _finalFrame, self.window.screen.frame, duration, 1, AnimateOut) forKey:@"fullscreen"];
     [_clipView layer].mask = maskLayer;
 
     contentView.hidden = NO;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to