Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(690)

Unified Diff: chrome/browser/ui/cocoa/browser_window_fullscreen_transition.mm

Issue 1813693003: Fixed a fullscreen race condition on OSX (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/browser_window_fullscreen_transition.mm
diff --git a/chrome/browser/ui/cocoa/browser_window_fullscreen_transition.mm b/chrome/browser/ui/cocoa/browser_window_fullscreen_transition.mm
index 409c4222dacb9594279d7079241c83589e82102b..f83f139c35564fb54870398f4be9f4fb34c5cba4 100644
--- a/chrome/browser/ui/cocoa/browser_window_fullscreen_transition.mm
+++ b/chrome/browser/ui/cocoa/browser_window_fullscreen_transition.mm
@@ -22,8 +22,10 @@ NSString* const kSnapshotWindowAnimationID = @"SnapshotWindowAnimationID";
NSString* const kAnimationIDKey = @"AnimationIDKey";
// The fraction of the duration from AppKit's startCustomAnimation methods
-// that we want our animation to run in.
+// that we want our animation to run in. Yosemite's fraction is smaller
+// since its fullscreen transition is significantly slower.
CGFloat const kAnimationDurationFraction = 0.5;
+CGFloat const kAnimationDurationFractionYosemite = 0.3;
// This class has two simultaneous animations to resize and reposition layers.
// These animations must use the same timing function, otherwise there will be
@@ -131,6 +133,13 @@ class FrameAndStyleLock {
// Locks and unlocks the FullSizeContentWindow.
scoped_ptr<FrameAndStyleLock> lock_;
+
+ // Flag that indicates if the animation was completed. Sets to true at the
+ // end of the animation.
+ BOOL completedTransition_;
+
+ // Delegate that informs the state of the transition.
+ id<BrowserWindowFullscreenTransitionDelegate> delegate_; // weak
}
// Takes a snapshot of |primaryWindow_| and puts it in |snapshotLayer_|.
@@ -193,9 +202,11 @@ class FrameAndStyleLock {
return self;
}
-- (instancetype)initExitWithWindow:(FramedBrowserWindow*)window
- frame:(NSRect)frame
- tabStripBackgroundView:(NSView*)view {
+- (instancetype)
+ initExitWithWindow:(FramedBrowserWindow*)window
+ delegate:(id<BrowserWindowFullscreenTransitionDelegate>)delegate
+ frame:(NSRect)frame
+tabStripBackgroundView:(NSView*)view {
DCHECK(window);
DCHECK([self rootLayerOfWindow:window]);
if ((self = [super init])) {
@@ -204,6 +215,7 @@ class FrameAndStyleLock {
isEnteringFullscreen_ = NO;
finalFrame_ = frame;
initialFrame_ = [[primaryWindow_ screen] frame];
+ delegate_ = delegate;
lock_.reset(new FrameAndStyleLock(window));
}
@@ -216,8 +228,15 @@ class FrameAndStyleLock {
return @[ primaryWindow_.get(), snapshotWindow_.get() ];
}
+- (BOOL)isTransitionCompleted {
+ return completedTransition_;
+}
+
- (void)startCustomFullScreenAnimationWithDuration:(NSTimeInterval)duration {
- CGFloat animationDuration = duration * kAnimationDurationFraction;
+ CGFloat durationFraction = base::mac::IsOSYosemite()
+ ? kAnimationDurationFractionYosemite
+ : kAnimationDurationFraction;
+ CGFloat animationDuration = duration * durationFraction;
[self preparePrimaryWindowForAnimation];
[self animatePrimaryWindowWithDuration:animationDuration];
[self animateSnapshotWindowWithDuration:animationDuration];
@@ -502,6 +521,11 @@ class FrameAndStyleLock {
[root removeAnimationForKey:kPrimaryWindowAnimationID];
root.opacity = 1;
}
+
+ completedTransition_ = YES;
+
+ if (!isEnteringFullscreen_)
+ [delegate_ finishedExitingFullscreen];
}
- (CALayer*)rootLayerOfWindow:(NSWindow*)window {

Powered by Google App Engine
This is Rietveld 408576698