summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-20 15:31:19 +0000
committerpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-20 15:31:19 +0000
commit0d316250465743d53a9b886b44497c768e0d0c4c (patch)
tree570837e676177ef471aac8b62dc759deefd00b43
parent6d4b66c1480ea3c09a50e25377a89fbc1e7d5db0 (diff)
downloadchromium_src-0d316250465743d53a9b886b44497c768e0d0c4c.zip
chromium_src-0d316250465743d53a9b886b44497c768e0d0c4c.tar.gz
chromium_src-0d316250465743d53a9b886b44497c768e0d0c4c.tar.bz2
Revert https://codereview.chromium.org/105673008/ because the CL was causing a crash (http://crbug.com/335068)
BUG=335068 TEST=Crash stops occuring TBR=pkotwicz Review URL: https://codereview.chromium.org/130413004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245913 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/system/tray/tray_background_view.cc2
-rw-r--r--ash/wm/dock/docked_window_layout_manager.cc42
-rw-r--r--ash/wm/dock/docked_window_layout_manager.h2
-rw-r--r--ash/wm/window_animations.cc26
-rw-r--r--ash/wm/window_animations_unittest.cc103
-rw-r--r--chrome/browser/chromeos/login/login_display_host_impl.cc2
-rw-r--r--ui/compositor/layer_animator.cc11
-rw-r--r--ui/compositor/layer_animator.h14
-rw-r--r--ui/compositor/scoped_layer_animation_settings.cc14
-rw-r--r--ui/compositor/scoped_layer_animation_settings.h7
-rw-r--r--ui/views/corewm/window_animations.cc75
-rw-r--r--ui/views/corewm/window_animations.h20
-rw-r--r--ui/views/touchui/touch_selection_controller_impl.cc17
13 files changed, 206 insertions, 129 deletions
diff --git a/ash/system/tray/tray_background_view.cc b/ash/system/tray/tray_background_view.cc
index 0ad7431..765b2a2 100644
--- a/ash/system/tray/tray_background_view.cc
+++ b/ash/system/tray/tray_background_view.cc
@@ -501,7 +501,7 @@ void TrayBackgroundView::InitializeBubbleAnimations(
views::corewm::SetWindowVisibilityAnimationTransition(
bubble_widget->GetNativeWindow(),
views::corewm::ANIMATE_HIDE);
- views::corewm::SetWindowHideAnimationDuration(
+ views::corewm::SetWindowVisibilityAnimationDuration(
bubble_widget->GetNativeWindow(),
base::TimeDelta::FromMilliseconds(kAnimationDurationForPopupMS));
}
diff --git a/ash/wm/dock/docked_window_layout_manager.cc b/ash/wm/dock/docked_window_layout_manager.cc
index 4540b2c..323275f 100644
--- a/ash/wm/dock/docked_window_layout_manager.cc
+++ b/ash/wm/dock/docked_window_layout_manager.cc
@@ -522,9 +522,6 @@ void DockedWindowLayoutManager::FinishDragging(DockedAction action,
wm::GetWindowState(dragged_window_)->RemoveObserver(this);
if (last_active_window_ == dragged_window_)
last_active_window_ = NULL;
-
- views::corewm::SetWindowShowAnimationDuration(dragged_window_,
- base::TimeDelta());
} else {
// If this is the first window that got docked by a move update alignment.
if (alignment_ == DOCKED_ALIGNMENT_NONE)
@@ -534,9 +531,6 @@ void DockedWindowLayoutManager::FinishDragging(DockedAction action,
// the only opportunity we will have to enforce a window
// count limit so do it here.
MaybeMinimizeChildrenExcept(dragged_window_);
-
- views::corewm::SetWindowShowAnimationDuration(dragged_window_,
- base::TimeDelta::FromMilliseconds(kFadeDurationMs));
}
dragged_window_ = NULL;
dragged_bounds_ = gfx::Rect();
@@ -673,8 +667,6 @@ void DockedWindowLayoutManager::OnWindowAddedToLayout(aura::Window* child) {
wm::GetWindowState(child)->AddObserver(this);
Relayout();
UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED);
- views::corewm::SetWindowShowAnimationDuration(child,
- base::TimeDelta::FromMilliseconds(kFadeDurationMs));
}
void DockedWindowLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) {
@@ -696,7 +688,6 @@ void DockedWindowLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) {
wm::GetWindowState(child)->RemoveObserver(this);
Relayout();
UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED);
- views::corewm::SetWindowShowAnimationDuration(child, base::TimeDelta());
}
void DockedWindowLayoutManager::OnChildWindowVisibilityChanged(
@@ -835,6 +826,21 @@ void DockedWindowLayoutManager::OnWindowBoundsChanged(
Relayout();
}
+void DockedWindowLayoutManager::OnWindowVisibilityChanging(
+ aura::Window* window, bool visible) {
+ if (IsPopupOrTransient(window))
+ return;
+ int animation_type = views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT;
+ if (visible) {
+ animation_type = views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_DROP;
+ views::corewm::SetWindowVisibilityAnimationDuration(
+ window, base::TimeDelta::FromMilliseconds(kFadeDurationMs));
+ } else if (wm::GetWindowState(window)->IsMinimized()) {
+ animation_type = WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE;
+ }
+ views::corewm::SetWindowVisibilityAnimationType(window, animation_type);
+}
+
void DockedWindowLayoutManager::OnWindowDestroying(aura::Window* window) {
if (dragged_window_ == window) {
FinishDragging(DOCKED_ACTION_NONE, DOCKED_ACTION_SOURCE_UNKNOWN);
@@ -893,25 +899,21 @@ void DockedWindowLayoutManager::MaybeMinimizeChildrenExcept(
if (available_room > room_needed) {
available_room -= room_needed;
} else {
- // Slow down the minimize animation.
- views::corewm::SetWindowHideAnimationDuration(
- window,
+ // Slow down minimizing animations. Lock duration so that it is not
+ // overridden by other ScopedLayerAnimationSettings down the stack.
+ ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
+ settings.SetTransitionDuration(
base::TimeDelta::FromMilliseconds(kMinimizeDurationMs));
+ settings.LockTransitionDuration();
wm::GetWindowState(window)->Minimize();
- views::corewm::SetWindowHideAnimationDuration(window, base::TimeDelta());
}
}
}
void DockedWindowLayoutManager::MinimizeDockedWindow(
wm::WindowState* window_state) {
- aura::Window* window = window_state->window();
- DCHECK(!IsPopupOrTransient(window));
- views::corewm::SetWindowVisibilityAnimationType(window,
- ash::WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE);
- window->Hide();
- views::corewm::SetWindowVisibilityAnimationType(window,
- views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT);
+ DCHECK(!IsPopupOrTransient(window_state->window()));
+ window_state->window()->Hide();
if (window_state->IsActive())
window_state->Deactivate();
RecordUmaAction(DOCKED_ACTION_MINIMIZE, DOCKED_ACTION_SOURCE_UNKNOWN);
diff --git a/ash/wm/dock/docked_window_layout_manager.h b/ash/wm/dock/docked_window_layout_manager.h
index 8401ab9..088ebd2 100644
--- a/ash/wm/dock/docked_window_layout_manager.h
+++ b/ash/wm/dock/docked_window_layout_manager.h
@@ -166,6 +166,8 @@ class ASH_EXPORT DockedWindowLayoutManager
virtual void OnWindowBoundsChanged(aura::Window* window,
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) OVERRIDE;
+ virtual void OnWindowVisibilityChanging(aura::Window* window,
+ bool visible) OVERRIDE;
virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
// aura::client::ActivationChangeObserver:
diff --git a/ash/wm/window_animations.cc b/ash/wm/window_animations.cc
index 5aecb06..aad40c9 100644
--- a/ash/wm/window_animations.cc
+++ b/ash/wm/window_animations.cc
@@ -71,9 +71,7 @@ int64 Round64(float f) {
const int kCrossFadeDurationMS = 200;
-void AddLayerAnimationsForMinimize(aura::Window* window,
- const base::TimeDelta& duration,
- bool show) {
+void AddLayerAnimationsForMinimize(aura::Window* window, bool show) {
// Recalculate the transform at restore time since the launcher item may have
// moved while the window was minimized.
gfx::Rect bounds = window->bounds();
@@ -107,6 +105,9 @@ void AddLayerAnimationsForMinimize(aura::Window* window,
rotation_about_pivot->SetReversed(show);
+ base::TimeDelta duration = window->layer()->GetAnimator()->
+ GetTransitionDuration();
+
scoped_ptr<ui::LayerAnimationElement> transition(
ui::LayerAnimationElement::CreateInterpolatedTransformElement(
rotation_about_pivot.release(), duration));
@@ -136,11 +137,10 @@ void AnimateShowWindow_Minimize(aura::Window* window) {
window->layer()->set_delegate(window);
window->layer()->SetOpacity(kWindowAnimation_HideOpacity);
ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
- base::TimeDelta duration = views::corewm::GetWindowShowAnimationDuration(
- window,
- base::TimeDelta::FromMilliseconds(kLayerAnimationsForMinimizeDurationMS));
+ base::TimeDelta duration = base::TimeDelta::FromMilliseconds(
+ kLayerAnimationsForMinimizeDurationMS);
settings.SetTransitionDuration(duration);
- AddLayerAnimationsForMinimize(window, duration, true);
+ AddLayerAnimationsForMinimize(window, true);
// Now that the window has been restored, we need to clear its animation style
// to default so that normal animation applies.
@@ -153,15 +153,14 @@ void AnimateHideWindow_Minimize(aura::Window* window) {
// Property sets within this scope will be implicitly animated.
ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
- base::TimeDelta duration = views::corewm::GetWindowHideAnimationDuration(
- window,
- base::TimeDelta::FromMilliseconds(kLayerAnimationsForMinimizeDurationMS));
+ base::TimeDelta duration = base::TimeDelta::FromMilliseconds(
+ kLayerAnimationsForMinimizeDurationMS);
settings.SetTransitionDuration(duration);
settings.AddObserver(
views::corewm::CreateHidingWindowAnimationObserver(window));
window->layer()->SetVisible(false);
- AddLayerAnimationsForMinimize(window, duration, false);
+ AddLayerAnimationsForMinimize(window, false);
}
void AnimateShowHideWindowCommon_BrightnessGrayscale(aura::Window* window,
@@ -184,11 +183,8 @@ void AnimateShowHideWindowCommon_BrightnessGrayscale(aura::Window* window,
window->layer()->SetVisible(true);
}
- base::TimeDelta default_duration =
+ base::TimeDelta duration =
base::TimeDelta::FromMilliseconds(kBrightnessGrayscaleFadeDurationMs);
- base::TimeDelta duration = show ?
- views::corewm::GetWindowShowAnimationDuration(window, default_duration) :
- views::corewm::GetWindowHideAnimationDuration(window, default_duration);
ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
settings.SetTransitionDuration(duration);
diff --git a/ash/wm/window_animations_unittest.cc b/ash/wm/window_animations_unittest.cc
index efc9a5d..eeeb120 100644
--- a/ash/wm/window_animations_unittest.cc
+++ b/ash/wm/window_animations_unittest.cc
@@ -36,6 +36,37 @@ class WindowAnimationsTest : public ash::test::AshTestBase {
DISALLOW_COPY_AND_ASSIGN(WindowAnimationsTest);
};
+// Listens to animation scheduled notifications. Remembers the transition
+// duration of the first sequence.
+class MinimizeAnimationObserver : public ui::LayerAnimationObserver {
+ public:
+ explicit MinimizeAnimationObserver(ui::LayerAnimator* animator)
+ : animator_(animator) {
+ animator_->AddObserver(this);
+ // RemoveObserver is called when the first animation is scheduled and so
+ // there should be no need for now to remove it in destructor.
+ };
+ base::TimeDelta duration() { return duration_; }
+
+ protected:
+ // ui::LayerAnimationObserver:
+ virtual void OnLayerAnimationScheduled(
+ ui::LayerAnimationSequence* sequence) OVERRIDE {
+ duration_ = animator_->GetTransitionDuration();
+ animator_->RemoveObserver(this);
+ }
+ virtual void OnLayerAnimationEnded(
+ ui::LayerAnimationSequence* sequence) OVERRIDE {}
+ virtual void OnLayerAnimationAborted(
+ ui::LayerAnimationSequence* sequence) OVERRIDE {}
+
+ private:
+ ui::LayerAnimator* animator_;
+ base::TimeDelta duration_;
+
+ DISALLOW_COPY_AND_ASSIGN(MinimizeAnimationObserver);
+};
+
TEST_F(WindowAnimationsTest, HideShowBrightnessGrayscaleAnimation) {
scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0));
window->Show();
@@ -136,5 +167,77 @@ TEST_F(WindowAnimationsTest, CrossFadeToBounds) {
Step(base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1));
}
+TEST_F(WindowAnimationsTest, LockAnimationDuration) {
+ ui::ScopedAnimationDurationScaleMode normal_duration_mode(
+ ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION);
+
+ scoped_ptr<Window> window(CreateTestWindowInShellWithId(0));
+ Layer* layer = window->layer();
+ window->SetBounds(gfx::Rect(5, 10, 320, 240));
+ window->Show();
+
+ // Test that it is possible to override transition duration when it is not
+ // locked.
+ {
+ ui::ScopedLayerAnimationSettings settings1(layer->GetAnimator());
+ settings1.SetTransitionDuration(base::TimeDelta::FromMilliseconds(1000));
+ {
+ ui::ScopedLayerAnimationSettings settings2(layer->GetAnimator());
+ // Duration is not locked so it gets overridden.
+ settings2.SetTransitionDuration(base::TimeDelta::FromMilliseconds(50));
+ wm::GetWindowState(window.get())->Minimize();
+ EXPECT_TRUE(layer->GetAnimator()->is_animating());
+ // Expect duration from the inner scope
+ EXPECT_EQ(50,
+ layer->GetAnimator()->GetTransitionDuration().InMilliseconds());
+ }
+ window->Show();
+ layer->GetAnimator()->StopAnimating();
+ }
+
+ // Test that it is possible to lock transition duration
+ {
+ ui::ScopedLayerAnimationSettings settings1(layer->GetAnimator());
+ settings1.SetTransitionDuration(base::TimeDelta::FromMilliseconds(1000));
+ // Duration is locked in outer scope.
+ settings1.LockTransitionDuration();
+ {
+ ui::ScopedLayerAnimationSettings settings2(layer->GetAnimator());
+ // Transition duration setting is ignored.
+ settings2.SetTransitionDuration(base::TimeDelta::FromMilliseconds(50));
+ wm::GetWindowState(window.get())->Minimize();
+ EXPECT_TRUE(layer->GetAnimator()->is_animating());
+ // Expect duration from the outer scope
+ EXPECT_EQ(1000,
+ layer->GetAnimator()->GetTransitionDuration().InMilliseconds());
+ }
+ window->Show();
+ layer->GetAnimator()->StopAnimating();
+ }
+
+ // Test that duration respects default.
+ {
+ // Query default duration.
+ MinimizeAnimationObserver observer(layer->GetAnimator());
+ wm::GetWindowState(window.get())->Minimize();
+ EXPECT_TRUE(layer->GetAnimator()->is_animating());
+ base::TimeDelta default_duration(observer.duration());
+ window->Show();
+ layer->GetAnimator()->StopAnimating();
+
+ ui::ScopedLayerAnimationSettings settings(layer->GetAnimator());
+ settings.LockTransitionDuration();
+ // Setting transition duration is ignored since duration is locked
+ settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(1000));
+ wm::GetWindowState(window.get())->Minimize();
+ EXPECT_TRUE(layer->GetAnimator()->is_animating());
+ // Expect default duration (200ms for stock ash minimizing animation).
+ EXPECT_EQ(default_duration.InMilliseconds(),
+ layer->GetAnimator()->GetTransitionDuration().InMilliseconds());
+ window->Show();
+ layer->GetAnimator()->StopAnimating();
+ }
+}
+
} // namespace internal
} // namespace ash
diff --git a/chrome/browser/chromeos/login/login_display_host_impl.cc b/chrome/browser/chromeos/login/login_display_host_impl.cc
index 9314bf0..e4f96b8 100644
--- a/chrome/browser/chromeos/login/login_display_host_impl.cc
+++ b/chrome/browser/chromeos/login/login_display_host_impl.cc
@@ -979,7 +979,7 @@ void LoginDisplayHostImpl::InitLoginWindowAndView() {
if (login_view_->webui_visible())
OnLoginPromptVisible();
- views::corewm::SetWindowHideAnimationDuration(
+ views::corewm::SetWindowVisibilityAnimationDuration(
login_window_->GetNativeView(),
base::TimeDelta::FromMilliseconds(kLoginFadeoutTransitionDurationMs));
views::corewm::SetWindowVisibilityAnimationTransition(
diff --git a/ui/compositor/layer_animator.cc b/ui/compositor/layer_animator.cc
index f878897..0454152 100644
--- a/ui/compositor/layer_animator.cc
+++ b/ui/compositor/layer_animator.cc
@@ -55,6 +55,7 @@ gfx::AnimationContainer* GetAnimationContainer() {
LayerAnimator::LayerAnimator(base::TimeDelta transition_duration)
: delegate_(NULL),
preemption_strategy_(IMMEDIATELY_SET_NEW_TARGET),
+ is_transition_duration_locked_(false),
transition_duration_(transition_duration),
tween_type_(gfx::Tween::LINEAR),
is_started_(false),
@@ -118,6 +119,10 @@ ANIMATED_PROPERTY(float, BRIGHTNESS, Brightness, float, brightness);
ANIMATED_PROPERTY(float, GRAYSCALE, Grayscale, float, grayscale);
ANIMATED_PROPERTY(SkColor, COLOR, Color, SkColor, color);
+base::TimeDelta LayerAnimator::GetTransitionDuration() const {
+ return transition_duration_;
+}
+
void LayerAnimator::SetDelegate(LayerAnimationDelegate* delegate) {
delegate_ = delegate;
}
@@ -798,8 +803,10 @@ void LayerAnimator::OnScheduled(LayerAnimationSequence* sequence) {
sequence->OnScheduled();
}
-base::TimeDelta LayerAnimator::GetTransitionDuration() const {
- return transition_duration_;
+void LayerAnimator::SetTransitionDuration(base::TimeDelta duration) {
+ if (is_transition_duration_locked_)
+ return;
+ transition_duration_ = duration;
}
void LayerAnimator::ClearAnimationsInternal() {
diff --git a/ui/compositor/layer_animator.h b/ui/compositor/layer_animator.h
index 4704456..a1e0ad2 100644
--- a/ui/compositor/layer_animator.h
+++ b/ui/compositor/layer_animator.h
@@ -88,6 +88,10 @@ class COMPOSITOR_EXPORT LayerAnimator
virtual void SetColor(SkColor color);
SkColor GetTargetColor() const;
+ // Returns the default length of animations, including adjustment for slow
+ // animation mode if set.
+ base::TimeDelta GetTransitionDuration() const;
+
// Sets the layer animation delegate the animator is associated with. The
// animator does not own the delegate. The layer animator expects a non-NULL
// delegate for most of its operations, so do not call any methods without
@@ -293,11 +297,7 @@ class COMPOSITOR_EXPORT LayerAnimator
// starting the animation or adding to the queue.
void OnScheduled(LayerAnimationSequence* sequence);
- // Returns the default length of animations, including adjustment for slow
- // animation mode if set.
- base::TimeDelta GetTransitionDuration() const;
-
- // Sets |transition_duration_|.
+ // Sets |transition_duration_| unless |is_transition_duration_locked_| is set.
void SetTransitionDuration(base::TimeDelta duration);
// Clears the animation queues and notifies any running animations that they
@@ -319,6 +319,10 @@ class COMPOSITOR_EXPORT LayerAnimator
// Determines how animations are replaced.
PreemptionStrategy preemption_strategy_;
+ // Whether the length of animations is locked. While it is locked
+ // SetTransitionDuration does not set |transition_duration_|.
+ bool is_transition_duration_locked_;
+
// The default length of animations.
base::TimeDelta transition_duration_;
diff --git a/ui/compositor/scoped_layer_animation_settings.cc b/ui/compositor/scoped_layer_animation_settings.cc
index a4fd17d..9ab0673 100644
--- a/ui/compositor/scoped_layer_animation_settings.cc
+++ b/ui/compositor/scoped_layer_animation_settings.cc
@@ -81,7 +81,9 @@ class InvertingObserver : public ImplicitAnimationObserver {
ScopedLayerAnimationSettings::ScopedLayerAnimationSettings(
LayerAnimator* animator)
: animator_(animator),
- old_transition_duration_(animator->transition_duration_),
+ old_is_transition_duration_locked_(
+ animator->is_transition_duration_locked_),
+ old_transition_duration_(animator->GetTransitionDuration()),
old_tween_type_(animator->tween_type()),
old_preemption_strategy_(animator->preemption_strategy()),
inverse_observer_(new InvertingObserver()) {
@@ -90,7 +92,9 @@ ScopedLayerAnimationSettings::ScopedLayerAnimationSettings(
}
ScopedLayerAnimationSettings::~ScopedLayerAnimationSettings() {
- animator_->transition_duration_ = old_transition_duration_;
+ animator_->is_transition_duration_locked_ =
+ old_is_transition_duration_locked_;
+ animator_->SetTransitionDuration(old_transition_duration_);
animator_->set_tween_type(old_tween_type_);
animator_->set_preemption_strategy(old_preemption_strategy_);
@@ -113,7 +117,11 @@ void ScopedLayerAnimationSettings::AddObserver(
void ScopedLayerAnimationSettings::SetTransitionDuration(
base::TimeDelta duration) {
- animator_->transition_duration_ = duration;
+ animator_->SetTransitionDuration(duration);
+}
+
+void ScopedLayerAnimationSettings::LockTransitionDuration() {
+ animator_->is_transition_duration_locked_ = true;
}
base::TimeDelta ScopedLayerAnimationSettings::GetTransitionDuration() const {
diff --git a/ui/compositor/scoped_layer_animation_settings.h b/ui/compositor/scoped_layer_animation_settings.h
index e36b853..e8a1b46 100644
--- a/ui/compositor/scoped_layer_animation_settings.h
+++ b/ui/compositor/scoped_layer_animation_settings.h
@@ -34,6 +34,12 @@ class COMPOSITOR_EXPORT ScopedLayerAnimationSettings {
void SetTransitionDuration(base::TimeDelta duration);
base::TimeDelta GetTransitionDuration() const;
+ // Locks transition duration in |animator_|. When transition duration
+ // is locked any subsequent changes to it are ignored until the
+ // ScopedLayerAnimationSettings object that has locked the duration goes out
+ // of scope.
+ void LockTransitionDuration();
+
void SetTweenType(gfx::Tween::Type tween_type);
gfx::Tween::Type GetTweenType() const;
@@ -50,6 +56,7 @@ class COMPOSITOR_EXPORT ScopedLayerAnimationSettings {
private:
LayerAnimator* animator_;
+ bool old_is_transition_duration_locked_;
base::TimeDelta old_transition_duration_;
gfx::Tween::Type old_tween_type_;
LayerAnimator::PreemptionStrategy old_preemption_strategy_;
diff --git a/ui/views/corewm/window_animations.cc b/ui/views/corewm/window_animations.cc
index d4262ff..1f90b40 100644
--- a/ui/views/corewm/window_animations.cc
+++ b/ui/views/corewm/window_animations.cc
@@ -56,8 +56,7 @@ const float kWindowAnimation_Vertical_TranslateY = 15.f;
DEFINE_WINDOW_PROPERTY_KEY(int,
kWindowVisibilityAnimationTypeKey,
WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT);
-DEFINE_WINDOW_PROPERTY_KEY(int, kWindowShowAnimationDurationKey, 0);
-DEFINE_WINDOW_PROPERTY_KEY(int, kWindowHideAnimationDurationKey, 0);
+DEFINE_WINDOW_PROPERTY_KEY(int, kWindowVisibilityAnimationDurationKey, 0);
DEFINE_WINDOW_PROPERTY_KEY(WindowVisibilityAnimationTransition,
kWindowVisibilityAnimationTransitionKey,
ANIMATE_BOTH);
@@ -67,7 +66,6 @@ DEFINE_WINDOW_PROPERTY_KEY(float,
namespace {
-const int kDefaultAnimationDurationMS = 200;
const int kDefaultAnimationDurationForMenuMS = 150;
const float kWindowAnimation_HideOpacity = 0.f;
@@ -86,11 +84,14 @@ const float kWindowAnimation_Bounce_Scale = 1.02f;
const int kWindowAnimation_Bounce_DurationMS = 180;
const int kWindowAnimation_Bounce_GrowShrinkDurationPercent = 40;
-base::TimeDelta GetDefaultWindowVisibilityAnimationDuration(
- aura::Window* window) {
- int duration_ms = (window->type() == ui::wm::WINDOW_TYPE_MENU) ?
- kDefaultAnimationDurationForMenuMS : kDefaultAnimationDurationMS;
- return base::TimeDelta::FromMilliseconds(duration_ms);
+base::TimeDelta GetWindowVisibilityAnimationDuration(aura::Window* window) {
+ int duration =
+ window->GetProperty(kWindowVisibilityAnimationDurationKey);
+ if (duration == 0 && window->type() == ui::wm::WINDOW_TYPE_MENU) {
+ return base::TimeDelta::FromMilliseconds(
+ kDefaultAnimationDurationForMenuMS);
+ }
+ return TimeDelta::FromInternalValue(duration);
}
// Gets/sets the WindowVisibilityAnimationType associated with a window.
@@ -254,9 +255,9 @@ void AnimateShowWindowCommon(aura::Window* window,
{
// Property sets within this scope will be implicitly animated.
ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
- base::TimeDelta duration = GetWindowShowAnimationDuration(window,
- GetDefaultWindowVisibilityAnimationDuration(window));
- settings.SetTransitionDuration(duration);
+ base::TimeDelta duration = GetWindowVisibilityAnimationDuration(window);
+ if (duration.ToInternalValue() > 0)
+ settings.SetTransitionDuration(duration);
window->layer()->SetTransform(end_transform);
window->layer()->SetOpacity(kWindowAnimation_ShowOpacity);
@@ -272,10 +273,11 @@ void AnimateHideWindowCommon(aura::Window* window,
// Property sets within this scope will be implicitly animated.
ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
- settings.AddObserver(CreateHidingWindowAnimationObserver(window));
- base::TimeDelta duration = GetWindowHideAnimationDuration(window,
- GetDefaultWindowVisibilityAnimationDuration(window));
- settings.SetTransitionDuration(duration);
+ settings.AddObserver(new HidingWindowAnimationObserver(window));
+
+ base::TimeDelta duration = GetWindowVisibilityAnimationDuration(window);
+ if (duration.ToInternalValue() > 0)
+ settings.SetTransitionDuration(duration);
window->layer()->SetOpacity(kWindowAnimation_HideOpacity);
window->layer()->SetTransform(end_transform);
@@ -368,26 +370,17 @@ void AnimateBounce(aura::Window* window) {
void AddLayerAnimationsForRotate(aura::Window* window, bool show) {
window->layer()->set_delegate(window);
- if (show) {
+ if (show)
window->layer()->SetOpacity(kWindowAnimation_HideOpacity);
- window->layer()->SetVisible(true);
- }
- base::TimeDelta default_duration = base::TimeDelta::FromMilliseconds(
+ base::TimeDelta duration = base::TimeDelta::FromMilliseconds(
kWindowAnimation_Rotate_DurationMS);
- base::TimeDelta duration = show ?
- GetWindowShowAnimationDuration(window, default_duration) :
- GetWindowHideAnimationDuration(window, default_duration);
-
- ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
- settings.SetTransitionDuration(duration);
if (!show) {
- settings.AddObserver(CreateHidingWindowAnimationObserver(window));
+ new HidingWindowAnimationObserver(window);
window->layer()->GetAnimator()->SchedulePauseForProperties(
duration * (100 - kWindowAnimation_Rotate_OpacityDurationPercent) / 100,
ui::LayerAnimationElement::OPACITY);
- window->layer()->SetVisible(false);
}
scoped_ptr<ui::LayerAnimationElement> opacity(
ui::LayerAnimationElement::CreateOpacityElement(
@@ -529,34 +522,12 @@ bool HasWindowVisibilityAnimationTransition(
return (prop & transition) != 0;
}
-void SetWindowShowAnimationDuration(aura::Window* window,
- const base::TimeDelta& duration) {
- window->SetProperty(kWindowShowAnimationDurationKey,
+void SetWindowVisibilityAnimationDuration(aura::Window* window,
+ const TimeDelta& duration) {
+ window->SetProperty(kWindowVisibilityAnimationDurationKey,
static_cast<int>(duration.ToInternalValue()));
}
-void SetWindowHideAnimationDuration(aura::Window* window,
- const base::TimeDelta& duration) {
- window->SetProperty(kWindowHideAnimationDurationKey,
- static_cast<int>(duration.ToInternalValue()));
-}
-
-base::TimeDelta GetWindowShowAnimationDuration(
- aura::Window* window,
- const base::TimeDelta& default_duration) {
- int duration = window->GetProperty(kWindowShowAnimationDurationKey);
- return (duration == 0) ?
- default_duration : base::TimeDelta::FromInternalValue(duration);
-}
-
-base::TimeDelta GetWindowHideAnimationDuration(
- aura::Window* window,
- const base::TimeDelta& default_duration) {
- int duration = window->GetProperty(kWindowHideAnimationDurationKey);
- return (duration == 0) ?
- default_duration : base::TimeDelta::FromInternalValue(duration);
-}
-
void SetWindowVisibilityAnimationVerticalPosition(aura::Window* window,
float position) {
window->SetProperty(kWindowVisibilityAnimationVerticalPositionKey, position);
diff --git a/ui/views/corewm/window_animations.h b/ui/views/corewm/window_animations.h
index 4a0a30b..996c215 100644
--- a/ui/views/corewm/window_animations.h
+++ b/ui/views/corewm/window_animations.h
@@ -70,28 +70,10 @@ VIEWS_EXPORT bool HasWindowVisibilityAnimationTransition(
aura::Window* window,
WindowVisibilityAnimationTransition transition);
-// Sets the duration of |window|'s show animation.
-VIEWS_EXPORT void SetWindowShowAnimationDuration(
+VIEWS_EXPORT void SetWindowVisibilityAnimationDuration(
aura::Window* window,
const base::TimeDelta& duration);
-// Sets the duration of |window|'s hide animation.
-VIEWS_EXPORT void SetWindowHideAnimationDuration(
- aura::Window* window,
- const base::TimeDelta& duration);
-
-// Returns the duration of |window|'s show animation if it is set and
-// |default_duration| otherwise.
-VIEWS_EXPORT base::TimeDelta GetWindowShowAnimationDuration(
- aura::Window* window,
- const base::TimeDelta& default_duration);
-
-// Returns the duration of |window|'s hide animation duration if it is set and
-// |default_duration| otherwise.
-VIEWS_EXPORT base::TimeDelta GetWindowHideAnimationDuration(
- aura::Window* window,
- const base::TimeDelta& default_duration);
-
VIEWS_EXPORT void SetWindowVisibilityAnimationVerticalPosition(
aura::Window* window,
float position);
diff --git a/ui/views/touchui/touch_selection_controller_impl.cc b/ui/views/touchui/touch_selection_controller_impl.cc
index c87eb82..f30be9e 100644
--- a/ui/views/touchui/touch_selection_controller_impl.cc
+++ b/ui/views/touchui/touch_selection_controller_impl.cc
@@ -235,19 +235,14 @@ class TouchSelectionControllerImpl::EditingHandleView
void SetWidgetVisible(bool visible, bool quick) {
if (widget_->IsVisible() == visible)
return;
- if (visible) {
- corewm::SetWindowShowAnimationDuration(
- widget_->GetNativeView(),
- base::TimeDelta::FromMilliseconds(
- quick ? kSelectionHandleQuickFadeDurationMs : 0));
+ corewm::SetWindowVisibilityAnimationDuration(
+ widget_->GetNativeView(),
+ base::TimeDelta::FromMilliseconds(
+ quick ? kSelectionHandleQuickFadeDurationMs : 0));
+ if (visible)
widget_->Show();
- } else {
- corewm::SetWindowHideAnimationDuration(
- widget_->GetNativeView(),
- base::TimeDelta::FromMilliseconds(
- quick ? kSelectionHandleQuickFadeDurationMs : 0));
+ else
widget_->Hide();
- }
}
void SetSelectionRectInScreen(const gfx::Rect& rect) {