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

Side by Side 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: Gardening Created 8 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/drag_drop/drag_drop_controller.h" 5 #include "ash/drag_drop/drag_drop_controller.h"
6 6
7 #include "ash/drag_drop/drag_image_view.h" 7 #include "ash/drag_drop/drag_image_view.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "ui/aura/client/drag_drop_delegate.h" 10 #include "ui/aura/client/drag_drop_delegate.h"
(...skipping 10 matching lines...) Expand all
21 21
22 namespace ash { 22 namespace ash {
23 namespace internal { 23 namespace internal {
24 24
25 using aura::RootWindow; 25 using aura::RootWindow;
26 26
27 namespace { 27 namespace {
28 const gfx::Point kDragDropWidgetOffset(0, 0); 28 const gfx::Point kDragDropWidgetOffset(0, 0);
29 const base::TimeDelta kDragDropAnimationDuration = 29 const base::TimeDelta kDragDropAnimationDuration =
30 base::TimeDelta::FromMilliseconds(250); 30 base::TimeDelta::FromMilliseconds(250);
31 } 31 } // namespace
32 32
33 //////////////////////////////////////////////////////////////////////////////// 33 ////////////////////////////////////////////////////////////////////////////////
34 // DragDropController, public: 34 // DragDropController, public:
35 35
36 DragDropController::DragDropController() 36 DragDropController::DragDropController()
37 : aura::EventFilter(RootWindow::GetInstance()), 37 : aura::EventFilter(RootWindow::GetInstance()),
38 drag_image_(NULL), 38 drag_image_(NULL),
39 drag_data_(NULL), 39 drag_data_(NULL),
40 drag_operation_(0), 40 drag_operation_(0),
41 dragged_window_(NULL), 41 dragged_window_(NULL),
42 drag_drop_in_progress_(false), 42 drag_drop_in_progress_(false),
43 should_block_during_drag_drop_(true) { 43 should_block_during_drag_drop_(true) {
44 Shell::GetInstance()->AddRootWindowEventFilter(this); 44 Shell::GetInstance()->AddRootWindowEventFilter(this);
45 aura::client::SetDragDropClient(this); 45 aura::client::SetDragDropClient(this);
46 } 46 }
47 47
48 DragDropController::~DragDropController() { 48 DragDropController::~DragDropController() {
49 Shell::GetInstance()->RemoveRootWindowEventFilter(this); 49 Shell::GetInstance()->RemoveRootWindowEventFilter(this);
50 Cleanup(); 50 Cleanup();
51 if (drag_image_.get()) { 51 if (drag_image_.get())
52 aura::Window* window = drag_image_->GetWidget()->GetNativeView();
53 window->layer()->GetAnimator()->RemoveObserver(this);
54 drag_image_.reset(); 52 drag_image_.reset();
55 }
56 } 53 }
57 54
58 int DragDropController::StartDragAndDrop(const ui::OSExchangeData& data, 55 int DragDropController::StartDragAndDrop(const ui::OSExchangeData& data,
59 int operation) { 56 int operation) {
60 DCHECK(!drag_drop_in_progress_); 57 DCHECK(!drag_drop_in_progress_);
61 aura::Window* capture_window = RootWindow::GetInstance()->capture_window(); 58 aura::Window* capture_window = RootWindow::GetInstance()->capture_window();
62 if (capture_window) 59 if (capture_window)
63 RootWindow::GetInstance()->ReleaseCapture(capture_window); 60 RootWindow::GetInstance()->ReleaseCapture(capture_window);
64 drag_drop_in_progress_ = true; 61 drag_drop_in_progress_ = true;
65 62
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 197
201 ui::GestureStatus DragDropController::PreHandleGestureEvent( 198 ui::GestureStatus DragDropController::PreHandleGestureEvent(
202 aura::Window* target, 199 aura::Window* target,
203 aura::GestureEvent* event) { 200 aura::GestureEvent* event) {
204 return ui::GESTURE_STATUS_UNKNOWN; 201 return ui::GESTURE_STATUS_UNKNOWN;
205 } 202 }
206 203
207 //////////////////////////////////////////////////////////////////////////////// 204 ////////////////////////////////////////////////////////////////////////////////
208 // DragDropController, private: 205 // DragDropController, private:
209 206
210 void DragDropController::OnLayerAnimationEnded( 207 void DragDropController::OnImplicitAnimationsCompleted() OVERRIDE {
211 const ui::LayerAnimationSequence* sequence) {
212 DCHECK(drag_image_.get()); 208 DCHECK(drag_image_.get());
213 drag_image_.reset(); 209 drag_image_.reset();
214 } 210 }
215
216 void DragDropController::OnLayerAnimationAborted(
217 const ui::LayerAnimationSequence* sequence) {
218 DCHECK(drag_image_.get());
219 drag_image_.reset();
220 }
221 211
222 void DragDropController::StartCanceledAnimation() { 212 void DragDropController::StartCanceledAnimation() {
223 aura::Window* window = drag_image_->GetWidget()->GetNativeView(); 213 aura::Window* window = drag_image_->GetWidget()->GetNativeView();
224 ui::LayerAnimator* animator = window->layer()->GetAnimator(); 214 ui::LayerAnimator* animator = window->layer()->GetAnimator();
225 animator->set_preemption_strategy( 215 animator->set_preemption_strategy(
226 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 216 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
227 animator->AddObserver(this); 217
218 // Stop waiting for any as yet unfinished implicit animations.
219 SetActive(false);
220 animator->RemoveObserver(this);
221
228 ui::ScopedLayerAnimationSettings animation_setter(animator); 222 ui::ScopedLayerAnimationSettings animation_setter(animator);
229 animation_setter.SetTransitionDuration(kDragDropAnimationDuration); 223 animation_setter.SetTransitionDuration(kDragDropAnimationDuration);
224 animation_setter.AddObserver(this);
230 window->SetBounds(gfx::Rect(drag_start_location_, window->bounds().size())); 225 window->SetBounds(gfx::Rect(drag_start_location_, window->bounds().size()));
231 } 226 }
232 227
233 void DragDropController::Cleanup() { 228 void DragDropController::Cleanup() {
234 drag_data_ = NULL; 229 drag_data_ = NULL;
235 drag_drop_in_progress_ = false; 230 drag_drop_in_progress_ = false;
236 } 231 }
237 232
238 } // namespace internal 233 } // namespace internal
239 } // namespace ash 234 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698