diff options
author | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-31 22:46:23 +0000 |
---|---|---|
committer | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-31 22:46:23 +0000 |
commit | 8bc061ff0bb46a286dc61af8c28891a801b8492f (patch) | |
tree | d173a5bda02d31a42591deeb065c00a3fc15ffba /chrome/browser | |
parent | 19ccd3f535aa51f092644169f18181f82d55834f (diff) | |
download | chromium_src-8bc061ff0bb46a286dc61af8c28891a801b8492f.zip chromium_src-8bc061ff0bb46a286dc61af8c28891a801b8492f.tar.gz chromium_src-8bc061ff0bb46a286dc61af8c28891a801b8492f.tar.bz2 |
Remove Animation When "Resuming" Window in Lion
Adds signal to browser that session restore is in progress. When Mac window shows it inhibits animation during session restore.
BUG=92984
TEST=Manual. Enable session restore, launch Chrome, observe lack of swoosh animation on Mac.
Review URL: http://codereview.chromium.org/7809013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99067 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/sessions/session_restore.cc | 3 | ||||
-rw-r--r-- | chrome/browser/ui/browser.cc | 1 | ||||
-rw-r--r-- | chrome/browser/ui/browser.h | 12 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/browser_window_cocoa.mm | 42 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.mm | 10 |
5 files changed, 42 insertions, 26 deletions
diff --git a/chrome/browser/sessions/session_restore.cc b/chrome/browser/sessions/session_restore.cc index c4c5b29..b18eb7b 100644 --- a/chrome/browser/sessions/session_restore.cc +++ b/chrome/browser/sessions/session_restore.cc @@ -714,6 +714,7 @@ class SessionRestoreImpl : public NotificationObserver { Browser* browser = new Browser(type, profile_); browser->set_override_bounds(bounds); browser->set_show_state(show_state); + browser->set_is_session_restore(true); browser->InitBrowserWindow(); return browser; } @@ -731,6 +732,8 @@ class SessionRestoreImpl : public NotificationObserver { return; browser->window()->Show(); + browser->set_is_session_restore(false); + // TODO(jcampan): http://crbug.com/8123 we should not need to set the // initial focus explicitly. browser->GetSelectedTabContents()->view()->SetInitialFocus(); diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 886eaf2..85e858e 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -258,6 +258,7 @@ Browser::Browser(Type type, Profile* profile) is_attempting_to_close_browser_(false), cancel_download_confirmation_state_(NOT_PROMPTED), show_state_(ui::SHOW_STATE_DEFAULT), + is_session_restore_(false), method_factory_(this), block_command_execution_(false), last_blocked_command_id_(-1), diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h index df08d1e5..6963963 100644 --- a/chrome/browser/ui/browser.h +++ b/chrome/browser/ui/browser.h @@ -168,6 +168,15 @@ class Browser : public TabHandlerDelegate, bool bounds_overridden() const { return !override_bounds_.IsEmpty(); } + // Set indicator that this browser is being created via session restore. + // This is used on the Mac (only) to determine animation style when the + // browser window is shown. + void set_is_session_restore(bool is_session_restore) { + is_session_restore_ = is_session_restore; + } + bool is_session_restore() const { + return is_session_restore_; + } // Creates the Browser Window. Prefer to use the static helpers above where // possible. This does not show the window. You need to call window()->Show() @@ -1317,6 +1326,9 @@ class Browser : public TabHandlerDelegate, gfx::Rect override_bounds_; ui::WindowShowState show_state_; + // Tracks when this browser is being created by session restore. + bool is_session_restore_; + // The following factory is used to close the frame at a later time. ScopedRunnableMethodFactory<Browser> method_factory_; diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa.mm b/chrome/browser/ui/cocoa/browser_window_cocoa.mm index cf51c3f..ea410b2 100644 --- a/chrome/browser/ui/cocoa/browser_window_cocoa.mm +++ b/chrome/browser/ui/cocoa/browser_window_cocoa.mm @@ -92,31 +92,31 @@ void BrowserWindowCocoa::Show() { // the previous browser instead if we don't explicitly set it here. BrowserList::SetLastActive(browser_); - ui::WindowShowState show_state = browser_->GetSavedWindowShowState(); - if (show_state == ui::SHOW_STATE_MINIMIZED) { - // Turn off swishing when restoring minimized windows. When creating - // windows from nibs it is necessary to |orderFront:| prior to |orderOut:| - // then |miniaturize:| when restoring windows in the minimized state. - NSWindowAnimationBehavior savedAnimationBehavior = 0; - if ([window() respondsToSelector:@selector(animationBehavior)] && - [window() respondsToSelector:@selector(setAnimationBehavior:)]) { - savedAnimationBehavior = [window() animationBehavior]; - [window() setAnimationBehavior:NSWindowAnimationBehaviorNone]; - } - - [window() makeKeyAndOrderFront:controller_]; + bool is_session_restore = browser_->is_session_restore(); + NSWindowAnimationBehavior saved_animation_behavior; + bool did_save_animation_behavior = false; + // Turn off swishing when restoring windows. + if (is_session_restore && + [window() respondsToSelector:@selector(animationBehavior)] && + [window() respondsToSelector:@selector(setAnimationBehavior:)]) { + did_save_animation_behavior = true; + saved_animation_behavior = [window() animationBehavior]; + [window() setAnimationBehavior:NSWindowAnimationBehaviorNone]; + } + + [window() makeKeyAndOrderFront:controller_]; + // When creating windows from nibs it is necessary to |makeKeyAndOrderFront:| + // prior to |orderOut:| then |miniaturize:| when restoring windows in the + // minimized state. + if (browser_->GetSavedWindowShowState() == ui::SHOW_STATE_MINIMIZED) { [window() orderOut:controller_]; [window() miniaturize:controller_]; - - // Restore window animation behavior. - if ([window() respondsToSelector:@selector(animationBehavior)] && - [window() respondsToSelector:@selector(setAnimationBehavior:)]) { - [window() setAnimationBehavior:savedAnimationBehavior]; - } - } else { - [window() makeKeyAndOrderFront:controller_]; } + + // Restore window animation behavior. + if (did_save_animation_behavior) + [window() setAnimationBehavior:saved_animation_behavior]; } void BrowserWindowCocoa::ShowInactive() { diff --git a/chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.mm b/chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.mm index 1a92665..25ee897 100644 --- a/chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.mm +++ b/chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.mm @@ -264,9 +264,11 @@ const NSTimeInterval kTearDuration = 0.333; // Disable window animation before calling |orderFront:| when detatching // to a new window. - NSWindowAnimationBehavior savedAnimationBehavior = 0; + NSWindowAnimationBehavior savedAnimationBehavior; + bool didSaveAnimationBehavior = false; if ([dragWindow_ respondsToSelector:@selector(animationBehavior)] && [dragWindow_ respondsToSelector:@selector(setAnimationBehavior:)]) { + didSaveAnimationBehavior = true; savedAnimationBehavior = [dragWindow_ animationBehavior]; [dragWindow_ setAnimationBehavior:NSWindowAnimationBehaviorNone]; } @@ -285,11 +287,9 @@ const NSTimeInterval kTearDuration = 0.333; tearTime_ = [NSDate timeIntervalSinceReferenceDate]; tearOrigin_ = sourceWindowFrame_.origin; - // Restore window animation behavior - if ([dragWindow_ respondsToSelector:@selector(animationBehavior)] && - [dragWindow_ respondsToSelector:@selector(setAnimationBehavior:)]) { + // Restore window animation behavior. + if (didSaveAnimationBehavior) [dragWindow_ setAnimationBehavior:savedAnimationBehavior]; - } } // TODO(pinkerton): http://crbug.com/25682 demonstrates a way to get here by |