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;