diff options
author | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-02 08:19:33 +0000 |
---|---|---|
committer | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-02 08:19:33 +0000 |
commit | f20cde9492f4431c27a55642c646af144c2001d1 (patch) | |
tree | 821b64e9545a120921fd9b3ac4523e6e65cf9493 /ash/shelf | |
parent | add820151028bef7148b7b5f2660f6c30e59e86b (diff) | |
download | chromium_src-f20cde9492f4431c27a55642c646af144c2001d1.zip chromium_src-f20cde9492f4431c27a55642c646af144c2001d1.tar.gz chromium_src-f20cde9492f4431c27a55642c646af144c2001d1.tar.bz2 |
If the user autohid the shelf, the shelf currently momentarily reveals when transitioning out of fullscreen.
The reason is that there are temporarily no visible windows which causes ShelfLayoutManager::CalculateAutoHideState() to return SHELF_AUTO_HIDE_SHOWN.
In particular, the following code in workspace_manager.cc causes this behavior:
ReparentWindow(child, desktop_workspace()->window(), NULL);
SetActiveWorkspace(desktop_workspace(), SWITCH_MAXIMIZED_OR_RESTORED, duration);
BUG=250918
TEST=Manual, see bug
Review URL: https://chromiumcodereview.appspot.com/16959021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209648 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/shelf')
-rw-r--r-- | ash/shelf/shelf_layout_manager.cc | 5 | ||||
-rw-r--r-- | ash/shelf/shelf_layout_manager.h | 2 | ||||
-rw-r--r-- | ash/shelf/shelf_layout_manager_unittest.cc | 28 |
3 files changed, 33 insertions, 2 deletions
diff --git a/ash/shelf/shelf_layout_manager.cc b/ash/shelf/shelf_layout_manager.cc index 9a6b912..c53da27 100644 --- a/ash/shelf/shelf_layout_manager.cc +++ b/ash/shelf/shelf_layout_manager.cc @@ -581,7 +581,6 @@ void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) { state_.auto_hide_state == SHELF_AUTO_HIDE_HIDDEN && state.visibility_state == SHELF_VISIBLE) ? BackgroundAnimator::CHANGE_IMMEDIATE : BackgroundAnimator::CHANGE_ANIMATE; - StopAnimating(); State old_state = state_; state_ = state; @@ -593,6 +592,8 @@ void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) { launcher_animation_setter.SetTransitionDuration( base::TimeDelta::FromMilliseconds(kWorkspaceSwitchTimeMS)); launcher_animation_setter.SetTweenType(ui::Tween::EASE_OUT); + launcher_animation_setter.SetPreemptionStrategy( + ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); GetLayer(shelf_)->SetBounds( target_bounds.shelf_bounds_in_root); GetLayer(shelf_)->SetOpacity(target_bounds.opacity); @@ -601,6 +602,8 @@ void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) { status_animation_setter.SetTransitionDuration( base::TimeDelta::FromMilliseconds(kWorkspaceSwitchTimeMS)); status_animation_setter.SetTweenType(ui::Tween::EASE_OUT); + status_animation_setter.SetPreemptionStrategy( + ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); // Delay updating the background when going from SHELF_AUTO_HIDE_SHOWN to // SHELF_AUTO_HIDE_HIDDEN until the shelf animates out. Otherwise during the diff --git a/ash/shelf/shelf_layout_manager.h b/ash/shelf/shelf_layout_manager.h index f113675..d49f42a 100644 --- a/ash/shelf/shelf_layout_manager.h +++ b/ash/shelf/shelf_layout_manager.h @@ -238,7 +238,7 @@ class ASH_EXPORT ShelfLayoutManager : // Sets the visibility of the shelf to |state|. void SetState(ShelfVisibilityState visibility_state); - // Stops any animations. + // Stops any animations and progresses them to the end. void StopAnimating(); // Returns the width (if aligned to the side) or height (if aligned to the diff --git a/ash/shelf/shelf_layout_manager_unittest.cc b/ash/shelf/shelf_layout_manager_unittest.cc index a0db945..20b5be0 100644 --- a/ash/shelf/shelf_layout_manager_unittest.cc +++ b/ash/shelf/shelf_layout_manager_unittest.cc @@ -33,6 +33,7 @@ #include "ui/base/animation/animation_container_element.h" #include "ui/compositor/layer.h" #include "ui/compositor/layer_animator.h" +#include "ui/compositor/scoped_animation_duration_scale_mode.h" #include "ui/gfx/display.h" #include "ui/gfx/screen.h" #include "ui/views/controls/label.h" @@ -659,6 +660,33 @@ TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { Shell::GetScreen()->GetPrimaryDisplay().bounds().bottom()); } +// Test that switching to a different visibility state does not restart the +// shelf show / hide animation if it is already running. (crbug.com/250918) +TEST_F(ShelfLayoutManagerTest, SetStateWhileAnimating) { + ShelfWidget* shelf = GetShelfWidget(); + SetState(shelf->shelf_layout_manager(), SHELF_VISIBLE); + gfx::Rect initial_shelf_bounds = shelf->GetWindowBoundsInScreen(); + gfx::Rect initial_status_bounds = + shelf->status_area_widget()->GetWindowBoundsInScreen(); + + ui::ScopedAnimationDurationScaleMode normal_animation_duration( + ui::ScopedAnimationDurationScaleMode::SLOW_DURATION); + SetState(shelf->shelf_layout_manager(), SHELF_HIDDEN); + SetState(shelf->shelf_layout_manager(), SHELF_VISIBLE); + + gfx::Rect current_shelf_bounds = shelf->GetWindowBoundsInScreen(); + gfx::Rect current_status_bounds = + shelf->status_area_widget()->GetWindowBoundsInScreen(); + + const int small_change = initial_shelf_bounds.height() / 2; + EXPECT_LE( + std::abs(initial_shelf_bounds.height() - current_shelf_bounds.height()), + small_change); + EXPECT_LE( + std::abs(initial_status_bounds.height() - current_status_bounds.height()), + small_change); +} + // Makes sure the launcher is sized when the status area changes size. TEST_F(ShelfLayoutManagerTest, LauncherUpdatedWhenStatusAreaChangesSize) { Launcher* launcher = Launcher::ForPrimaryDisplay(); |