| OLD | NEW |
| 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_drop_tracker.h" | 7 #include "ash/drag_drop/drag_drop_tracker.h" |
| 8 #include "ash/drag_drop/drag_image_view.h" | 8 #include "ash/drag_drop/drag_image_view.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 if (drag_window_ != drag_source_window_) | 256 if (drag_window_ != drag_source_window_) |
| 257 drag_window_->RemoveObserver(this); | 257 drag_window_->RemoveObserver(this); |
| 258 } | 258 } |
| 259 drag_window_ = target; | 259 drag_window_ = target; |
| 260 // We are already an observer of |drag_source_window_| so no need to add. | 260 // We are already an observer of |drag_source_window_| so no need to add. |
| 261 if (drag_window_ != drag_source_window_) | 261 if (drag_window_ != drag_source_window_) |
| 262 drag_window_->AddObserver(this); | 262 drag_window_->AddObserver(this); |
| 263 aura::client::DragDropDelegate* delegate = | 263 aura::client::DragDropDelegate* delegate = |
| 264 aura::client::GetDragDropDelegate(drag_window_); | 264 aura::client::GetDragDropDelegate(drag_window_); |
| 265 if (delegate) { | 265 if (delegate) { |
| 266 ui::DropTargetEvent e(*drag_data_, | 266 ui::DropTargetEvent e(*drag_data_, event.location_f(), |
| 267 event.location(), | 267 event.root_location_f(), drag_operation_); |
| 268 event.root_location(), | |
| 269 drag_operation_); | |
| 270 e.set_flags(event.flags()); | 268 e.set_flags(event.flags()); |
| 271 delegate->OnDragEntered(e); | 269 delegate->OnDragEntered(e); |
| 272 } | 270 } |
| 273 } else { | 271 } else { |
| 274 aura::client::DragDropDelegate* delegate = | 272 aura::client::DragDropDelegate* delegate = |
| 275 aura::client::GetDragDropDelegate(drag_window_); | 273 aura::client::GetDragDropDelegate(drag_window_); |
| 276 if (delegate) { | 274 if (delegate) { |
| 277 ui::DropTargetEvent e(*drag_data_, | 275 ui::DropTargetEvent e(*drag_data_, event.location_f(), |
| 278 event.location(), | 276 event.root_location_f(), drag_operation_); |
| 279 event.root_location(), | |
| 280 drag_operation_); | |
| 281 e.set_flags(event.flags()); | 277 e.set_flags(event.flags()); |
| 282 op = delegate->OnDragUpdated(e); | 278 op = delegate->OnDragUpdated(e); |
| 283 gfx::NativeCursor cursor = ui::kCursorNoDrop; | 279 gfx::NativeCursor cursor = ui::kCursorNoDrop; |
| 284 if (op & ui::DragDropTypes::DRAG_COPY) | 280 if (op & ui::DragDropTypes::DRAG_COPY) |
| 285 cursor = ui::kCursorCopy; | 281 cursor = ui::kCursorCopy; |
| 286 else if (op & ui::DragDropTypes::DRAG_LINK) | 282 else if (op & ui::DragDropTypes::DRAG_LINK) |
| 287 cursor = ui::kCursorAlias; | 283 cursor = ui::kCursorAlias; |
| 288 else if (op & ui::DragDropTypes::DRAG_MOVE) | 284 else if (op & ui::DragDropTypes::DRAG_MOVE) |
| 289 cursor = ui::kCursorGrabbing; | 285 cursor = ui::kCursorGrabbing; |
| 290 ash::Shell::GetInstance()->cursor_manager()->SetCursor(cursor); | 286 ash::Shell::GetInstance()->cursor_manager()->SetCursor(cursor); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 309 // We must guarantee that a target gets a OnDragEntered before Drop. WebKit | 305 // We must guarantee that a target gets a OnDragEntered before Drop. WebKit |
| 310 // depends on not getting a Drop without DragEnter. This behavior is | 306 // depends on not getting a Drop without DragEnter. This behavior is |
| 311 // consistent with drag/drop on other platforms. | 307 // consistent with drag/drop on other platforms. |
| 312 if (target != drag_window_) | 308 if (target != drag_window_) |
| 313 DragUpdate(target, event); | 309 DragUpdate(target, event); |
| 314 DCHECK(target == drag_window_); | 310 DCHECK(target == drag_window_); |
| 315 | 311 |
| 316 aura::client::DragDropDelegate* delegate = | 312 aura::client::DragDropDelegate* delegate = |
| 317 aura::client::GetDragDropDelegate(target); | 313 aura::client::GetDragDropDelegate(target); |
| 318 if (delegate) { | 314 if (delegate) { |
| 319 ui::DropTargetEvent e( | 315 ui::DropTargetEvent e(*drag_data_, event.location_f(), |
| 320 *drag_data_, event.location(), event.root_location(), drag_operation_); | 316 event.root_location_f(), drag_operation_); |
| 321 e.set_flags(event.flags()); | 317 e.set_flags(event.flags()); |
| 322 drag_operation_ = delegate->OnPerformDrop(e); | 318 drag_operation_ = delegate->OnPerformDrop(e); |
| 323 if (drag_operation_ == 0) | 319 if (drag_operation_ == 0) |
| 324 StartCanceledAnimation(kCancelAnimationDuration); | 320 StartCanceledAnimation(kCancelAnimationDuration); |
| 325 else | 321 else |
| 326 drag_image_.reset(); | 322 drag_image_.reset(); |
| 327 } else { | 323 } else { |
| 328 drag_image_.reset(); | 324 drag_image_.reset(); |
| 329 } | 325 } |
| 330 | 326 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 event->StopPropagation(); | 409 event->StopPropagation(); |
| 414 | 410 |
| 415 // If current drag session was not started by touch, dont process this event. | 411 // If current drag session was not started by touch, dont process this event. |
| 416 if (current_drag_event_source_ != ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH) | 412 if (current_drag_event_source_ != ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH) |
| 417 return; | 413 return; |
| 418 | 414 |
| 419 // Apply kTouchDragImageVerticalOffset to the location. | 415 // Apply kTouchDragImageVerticalOffset to the location. |
| 420 ui::GestureEvent touch_offset_event(*event, | 416 ui::GestureEvent touch_offset_event(*event, |
| 421 static_cast<aura::Window*>(NULL), | 417 static_cast<aura::Window*>(NULL), |
| 422 static_cast<aura::Window*>(NULL)); | 418 static_cast<aura::Window*>(NULL)); |
| 423 gfx::Point touch_offset_location = touch_offset_event.location(); | 419 gfx::PointF touch_offset_location = touch_offset_event.location_f(); |
| 424 gfx::Point touch_offset_root_location = touch_offset_event.root_location(); | 420 gfx::PointF touch_offset_root_location = touch_offset_event.root_location_f(); |
| 425 touch_offset_location.Offset(0, kTouchDragImageVerticalOffset); | 421 touch_offset_location.Offset(0, kTouchDragImageVerticalOffset); |
| 426 touch_offset_root_location.Offset(0, kTouchDragImageVerticalOffset); | 422 touch_offset_root_location.Offset(0, kTouchDragImageVerticalOffset); |
| 427 touch_offset_event.set_location(touch_offset_location); | 423 touch_offset_event.set_location(touch_offset_location); |
| 428 touch_offset_event.set_root_location(touch_offset_root_location); | 424 touch_offset_event.set_root_location(touch_offset_root_location); |
| 429 | 425 |
| 430 aura::Window* translated_target = | 426 aura::Window* translated_target = |
| 431 drag_drop_tracker_->GetTarget(touch_offset_event); | 427 drag_drop_tracker_->GetTarget(touch_offset_event); |
| 432 if (!translated_target) { | 428 if (!translated_target) { |
| 433 DragCancel(); | 429 DragCancel(); |
| 434 event->SetHandled(); | 430 event->SetHandled(); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 if (drag_window_) | 555 if (drag_window_) |
| 560 drag_window_->RemoveObserver(this); | 556 drag_window_->RemoveObserver(this); |
| 561 drag_window_ = NULL; | 557 drag_window_ = NULL; |
| 562 drag_data_ = NULL; | 558 drag_data_ = NULL; |
| 563 // Cleanup can be called again while deleting DragDropTracker, so delete | 559 // Cleanup can be called again while deleting DragDropTracker, so delete |
| 564 // the pointer with a local variable to avoid double free. | 560 // the pointer with a local variable to avoid double free. |
| 565 scoped_ptr<ash::DragDropTracker> holder = drag_drop_tracker_.Pass(); | 561 scoped_ptr<ash::DragDropTracker> holder = drag_drop_tracker_.Pass(); |
| 566 } | 562 } |
| 567 | 563 |
| 568 } // namespace ash | 564 } // namespace ash |
| OLD | NEW |