summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Ross <jonross@chromium.org>2014-09-29 11:07:41 -0400
committerJonathan Ross <jonross@chromium.org>2014-09-29 15:08:43 +0000
commit66d0c092b3eea6f40b23dcea1b7a7afaf8ed2b4b (patch)
tree5a463559932d1a195b6f9abd31ea324062a79c7a
parent1fe136f6746a392c8f30191afb6857be5553614b (diff)
downloadchromium_src-66d0c092b3eea6f40b23dcea1b7a7afaf8ed2b4b.zip
chromium_src-66d0c092b3eea6f40b23dcea1b7a7afaf8ed2b4b.tar.gz
chromium_src-66d0c092b3eea6f40b23dcea1b7a7afaf8ed2b4b.tar.bz2
Merge Status Tray Flicker fix to M-38
Status Trays delayed visibility Change the shelf visibility animation so that the status area is visible before animating any properties. This way it is rendering for the full animation. TEST=ShelfLayoutManagerTest.SetAutoHideBehavior BUG=416618 Review URL: https://codereview.chromium.org/596863003 Cr-Commit-Position: refs/heads/master@{#296307} (cherry picked from commit 50e36d1cd3e1d2706214b42f959563d301911cd7) TBR=skuhne@chromium.org, flackr@chromium.org Review URL: https://codereview.chromium.org/611583003 Cr-Commit-Position: refs/branch-heads/2125@{#514} Cr-Branched-From: b68026d94bda36dd106a3d91a098719f952a9477-refs/heads/master@{#290040}
-rw-r--r--ash/shelf/shelf_layout_manager.cc133
-rw-r--r--ash/shelf/shelf_layout_manager_unittest.cc7
2 files changed, 77 insertions, 63 deletions
diff --git a/ash/shelf/shelf_layout_manager.cc b/ash/shelf/shelf_layout_manager.cc
index 0d6713b15..887c6fc 100644
--- a/ash/shelf/shelf_layout_manager.cc
+++ b/ash/shelf/shelf_layout_manager.cc
@@ -651,71 +651,78 @@ void ShelfLayoutManager::UpdateBoundsAndOpacity(
bool animate,
ui::ImplicitAnimationObserver* observer) {
base::AutoReset<bool> auto_reset_updating_bounds(&updating_bounds_, true);
-
- ui::ScopedLayerAnimationSettings shelf_animation_setter(
- GetLayer(shelf_)->GetAnimator());
- ui::ScopedLayerAnimationSettings status_animation_setter(
- GetLayer(shelf_->status_area_widget())->GetAnimator());
- if (animate) {
- int duration = duration_override_in_ms_ ? duration_override_in_ms_ :
- kCrossFadeDurationMS;
- shelf_animation_setter.SetTransitionDuration(
- base::TimeDelta::FromMilliseconds(duration));
- shelf_animation_setter.SetTweenType(gfx::Tween::EASE_OUT);
- shelf_animation_setter.SetPreemptionStrategy(
- ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
- status_animation_setter.SetTransitionDuration(
- base::TimeDelta::FromMilliseconds(duration));
- status_animation_setter.SetTweenType(gfx::Tween::EASE_OUT);
- status_animation_setter.SetPreemptionStrategy(
- ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
- } else {
- StopAnimating();
- shelf_animation_setter.SetTransitionDuration(base::TimeDelta());
- status_animation_setter.SetTransitionDuration(base::TimeDelta());
- }
- if (observer)
- status_animation_setter.AddObserver(observer);
-
- GetLayer(shelf_)->SetOpacity(target_bounds.opacity);
- shelf_->SetBounds(ScreenUtil::ConvertRectToScreen(
- shelf_->GetNativeView()->parent(),
- target_bounds.shelf_bounds_in_root));
-
- GetLayer(shelf_->status_area_widget())->SetOpacity(
- target_bounds.status_opacity);
-
- // Having a window which is visible but does not have an opacity is an illegal
- // state. We therefore show / hide the shelf here if required.
- if (!target_bounds.status_opacity)
- shelf_->status_area_widget()->Hide();
- else if (target_bounds.status_opacity)
- shelf_->status_area_widget()->Show();
-
- // TODO(harrym): Once status area widget is a child view of shelf
- // this can be simplified.
- gfx::Rect status_bounds = target_bounds.status_bounds_in_shelf;
- status_bounds.set_x(status_bounds.x() +
- target_bounds.shelf_bounds_in_root.x());
- status_bounds.set_y(status_bounds.y() +
- target_bounds.shelf_bounds_in_root.y());
- shelf_->status_area_widget()->SetBounds(
- ScreenUtil::ConvertRectToScreen(
- shelf_->status_area_widget()->GetNativeView()->parent(),
- status_bounds));
- SessionStateDelegate* session_state_delegate =
- Shell::GetInstance()->session_state_delegate();
- if (!state_.is_screen_locked) {
- gfx::Insets insets;
- // If user session is blocked (login to new user session or add user to
- // the existing session - multi-profile) then give 100% of work area only if
- // keyboard is not shown.
- if (!session_state_delegate->IsUserSessionBlocked() ||
- !keyboard_bounds_.IsEmpty()) {
- insets = target_bounds.work_area_insets;
+ {
+ ui::ScopedLayerAnimationSettings shelf_animation_setter(
+ GetLayer(shelf_)->GetAnimator());
+ ui::ScopedLayerAnimationSettings status_animation_setter(
+ GetLayer(shelf_->status_area_widget())->GetAnimator());
+ if (animate) {
+ int duration = duration_override_in_ms_ ? duration_override_in_ms_ :
+ kCrossFadeDurationMS;
+ shelf_animation_setter.SetTransitionDuration(
+ base::TimeDelta::FromMilliseconds(duration));
+ shelf_animation_setter.SetTweenType(gfx::Tween::EASE_OUT);
+ shelf_animation_setter.SetPreemptionStrategy(
+ ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
+ status_animation_setter.SetTransitionDuration(
+ base::TimeDelta::FromMilliseconds(duration));
+ status_animation_setter.SetTweenType(gfx::Tween::EASE_OUT);
+ status_animation_setter.SetPreemptionStrategy(
+ ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
+ } else {
+ StopAnimating();
+ shelf_animation_setter.SetTransitionDuration(base::TimeDelta());
+ status_animation_setter.SetTransitionDuration(base::TimeDelta());
+ }
+ if (observer)
+ status_animation_setter.AddObserver(observer);
+
+ GetLayer(shelf_)->SetOpacity(target_bounds.opacity);
+ shelf_->SetBounds(ScreenUtil::ConvertRectToScreen(
+ shelf_->GetNativeView()->parent(),
+ target_bounds.shelf_bounds_in_root));
+
+ GetLayer(shelf_->status_area_widget())->SetOpacity(
+ target_bounds.status_opacity);
+
+ // Having a window which is visible but does not have an opacity is an
+ // illegal state. We therefore hide the shelf here if required.
+ if (!target_bounds.status_opacity)
+ shelf_->status_area_widget()->Hide();
+ // Setting visibility during an animation causes the visibility property to
+ // animate. Override the animation settings to immediately set the
+ // visibility property. Opacity will still animate.
+
+ // TODO(harrym): Once status area widget is a child view of shelf
+ // this can be simplified.
+ gfx::Rect status_bounds = target_bounds.status_bounds_in_shelf;
+ status_bounds.set_x(status_bounds.x() +
+ target_bounds.shelf_bounds_in_root.x());
+ status_bounds.set_y(status_bounds.y() +
+ target_bounds.shelf_bounds_in_root.y());
+ shelf_->status_area_widget()->SetBounds(
+ ScreenUtil::ConvertRectToScreen(
+ shelf_->status_area_widget()->GetNativeView()->parent(),
+ status_bounds));
+ SessionStateDelegate* session_state_delegate =
+ Shell::GetInstance()->session_state_delegate();
+ if (!state_.is_screen_locked) {
+ gfx::Insets insets;
+ // If user session is blocked (login to new user session or add user to
+ // the existing session - multi-profile) then give 100% of work area only
+ // if keyboard is not shown.
+ if (!session_state_delegate->IsUserSessionBlocked() ||
+ !keyboard_bounds_.IsEmpty()) {
+ insets = target_bounds.work_area_insets;
+ }
+ Shell::GetInstance()->SetDisplayWorkAreaInsets(root_window_, insets);
}
- Shell::GetInstance()->SetDisplayWorkAreaInsets(root_window_, insets);
}
+
+ // Setting visibility during an animation causes the visibility property to
+ // animate. Set the visibility property without an animation.
+ if (target_bounds.status_opacity)
+ shelf_->status_area_widget()->Show();
}
void ShelfLayoutManager::StopAnimating() {
diff --git a/ash/shelf/shelf_layout_manager_unittest.cc b/ash/shelf/shelf_layout_manager_unittest.cc
index 58c712a..03640c0 100644
--- a/ash/shelf/shelf_layout_manager_unittest.cc
+++ b/ash/shelf/shelf_layout_manager_unittest.cc
@@ -1074,7 +1074,14 @@ TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) {
window).work_area().bottom(),
widget->GetWorkAreaBoundsInScreen().bottom());
+ ui::ScopedAnimationDurationScaleMode animation_duration(
+ ui::ScopedAnimationDurationScaleMode::SLOW_DURATION);
+
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
+ ShelfWidget* shelf_widget = GetShelfWidget();
+ EXPECT_TRUE(shelf_widget->status_area_widget()->IsVisible());
+ StepWidgetLayerAnimatorToEnd(shelf_widget);
+ StepWidgetLayerAnimatorToEnd(shelf_widget->status_area_widget());
EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
EXPECT_EQ(Shell::GetScreen()->GetDisplayNearestWindow(
window).work_area().bottom(),