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

Unified Diff: ash/drag_drop/drag_drop_controller.cc

Issue 9222018: reland -- Disable animations during aura tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address reviewer comments. Created 8 years, 11 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: ash/drag_drop/drag_drop_controller.cc
diff --git a/ash/drag_drop/drag_drop_controller.cc b/ash/drag_drop/drag_drop_controller.cc
index 42a58abba8d6c4448c4c8ddc1a6d8851a3f0c86b..637ff0fba1661676a8a850d030c3783e4b08f053 100644
--- a/ash/drag_drop/drag_drop_controller.cc
+++ b/ash/drag_drop/drag_drop_controller.cc
@@ -28,7 +28,25 @@ namespace {
const gfx::Point kDragDropWidgetOffset(0, 0);
const base::TimeDelta kDragDropAnimationDuration =
base::TimeDelta::FromMilliseconds(250);
-}
+
+class DragDropAnimationObserver : public ui::ImplicitAnimationObserver {
+ public:
+ DragDropAnimationObserver(DragDropAnimationObserverClient* client)
+ : client_(client) {}
+ virtual ~DragDropAnimationObserver() {}
+
+ private:
+ // Implementation of ImplicitAnimationObserver
+ virtual void OnImplicitAnimationsCompleted() OVERRIDE {
+ client_->OnDragDropAnimationsCompleted(this);
+ }
+
+ DragDropAnimationObserverClient* client_;
+
+ DISALLOW_COPY_AND_ASSIGN(DragDropAnimationObserver);
+};
+
+} // namespace
////////////////////////////////////////////////////////////////////////////////
// DragDropController, public:
@@ -46,13 +64,16 @@ DragDropController::DragDropController()
}
DragDropController::~DragDropController() {
+ if (drag_image_.get() && active_observer_.get()) {
sky 2012/01/27 17:54:10 Why do you need to explicitly remove the animation
+ aura::Window* window = drag_image_->GetWidget()->GetNativeView();
+ ui::LayerAnimator* animator = window->layer()->GetAnimator();
+ animator->RemoveObserver(active_observer_.get());
+ }
+
Shell::GetInstance()->RemoveRootWindowEventFilter(this);
Cleanup();
- if (drag_image_.get()) {
- aura::Window* window = drag_image_->GetWidget()->GetNativeView();
- window->layer()->GetAnimator()->RemoveObserver(this);
+ if (drag_image_.get())
drag_image_.reset();
- }
}
int DragDropController::StartDragAndDrop(const ui::OSExchangeData& data,
@@ -203,14 +224,10 @@ ui::GestureStatus DragDropController::PreHandleGestureEvent(
////////////////////////////////////////////////////////////////////////////////
// DragDropController, private:
-void DragDropController::OnLayerAnimationEnded(
- const ui::LayerAnimationSequence* sequence) {
- DCHECK(drag_image_.get());
- drag_image_.reset();
-}
-
-void DragDropController::OnLayerAnimationAborted(
- const ui::LayerAnimationSequence* sequence) {
+void DragDropController::OnDragDropAnimationsCompleted(
+ ui::ImplicitAnimationObserver* observer) {
+ DCHECK_EQ(active_observer_.get(), observer);
+ active_observer_.reset(NULL);
DCHECK(drag_image_.get());
drag_image_.reset();
}
@@ -220,9 +237,10 @@ void DragDropController::StartCanceledAnimation() {
ui::LayerAnimator* animator = window->layer()->GetAnimator();
animator->set_preemption_strategy(
ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
- animator->AddObserver(this);
ui::ScopedLayerAnimationSettings animation_setter(animator);
animation_setter.SetTransitionDuration(kDragDropAnimationDuration);
+ active_observer_.reset(new DragDropAnimationObserver(this));
+ animation_setter.AddObserver(active_observer_.get());
window->SetBounds(gfx::Rect(drag_start_location_, window->bounds().size()));
}

Powered by Google App Engine
This is Rietveld 408576698