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

Side by Side Diff: ash/drag_drop/drag_drop_controller.cc

Issue 10377119: Plumb event flags (shift/alt/ctrl modifiers) for drag/drop events to WebKit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 delegate->OnDragExited(); 97 delegate->OnDragExited();
98 drag_window_->RemoveObserver(this); 98 drag_window_->RemoveObserver(this);
99 } 99 }
100 drag_window_ = target; 100 drag_window_ = target;
101 drag_window_->AddObserver(this); 101 drag_window_->AddObserver(this);
102 if ((delegate = aura::client::GetDragDropDelegate(drag_window_))) { 102 if ((delegate = aura::client::GetDragDropDelegate(drag_window_))) {
103 aura::DropTargetEvent e(*drag_data_, 103 aura::DropTargetEvent e(*drag_data_,
104 event.location(), 104 event.location(),
105 event.root_location(), 105 event.root_location(),
106 drag_operation_); 106 drag_operation_);
107 e.set_flags(event.flags());
107 delegate->OnDragEntered(e); 108 delegate->OnDragEntered(e);
108 } 109 }
109 } else { 110 } else {
110 if ((delegate = aura::client::GetDragDropDelegate(drag_window_))) { 111 if ((delegate = aura::client::GetDragDropDelegate(drag_window_))) {
111 aura::DropTargetEvent e(*drag_data_, 112 aura::DropTargetEvent e(*drag_data_,
112 event.location(), 113 event.location(),
113 event.root_location(), 114 event.root_location(),
114 drag_operation_); 115 drag_operation_);
116 e.set_flags(event.flags());
115 int op = delegate->OnDragUpdated(e); 117 int op = delegate->OnDragUpdated(e);
116 gfx::NativeCursor cursor = (op == ui::DragDropTypes::DRAG_NONE)? 118 gfx::NativeCursor cursor = (op == ui::DragDropTypes::DRAG_NONE)?
117 ui::kCursorMove : ui::kCursorHand; 119 ui::kCursorMove : ui::kCursorHand;
118 Shell::GetRootWindow()->SetCursor(cursor); 120 Shell::GetRootWindow()->SetCursor(cursor);
119 } 121 }
120 } 122 }
121 123
122 DCHECK(drag_image_.get()); 124 DCHECK(drag_image_.get());
123 if (drag_image_->visible()) { 125 if (drag_image_->visible()) {
124 drag_image_->SetScreenPosition( 126 drag_image_->SetScreenPosition(
125 event.root_location().Subtract(drag_image_offset_)); 127 event.root_location().Subtract(drag_image_offset_));
126 } 128 }
127 } 129 }
128 130
129 void DragDropController::Drop(aura::Window* target, 131 void DragDropController::Drop(aura::Window* target,
130 const aura::LocatedEvent& event) { 132 const aura::LocatedEvent& event) {
131 Shell::GetRootWindow()->SetCursor(ui::kCursorPointer); 133 Shell::GetRootWindow()->SetCursor(ui::kCursorPointer);
132 aura::client::DragDropDelegate* delegate = NULL; 134 aura::client::DragDropDelegate* delegate = NULL;
133 135
134 // |drag_window_| can be NULL if we have just started the drag and have not 136 // |drag_window_| can be NULL if we have just started the drag and have not
135 // received any DragUpdates, or, if the |drag_window_| gets destroyed during 137 // received any DragUpdates, or, if the |drag_window_| gets destroyed during
136 // a drag/drop. Otherwise, target should be equal to the |drag_window_|. 138 // a drag/drop. Otherwise, target should be equal to the |drag_window_|.
137 DCHECK(target == drag_window_ || !drag_window_); 139 DCHECK(target == drag_window_ || !drag_window_);
138 if ((delegate = aura::client::GetDragDropDelegate(target))) { 140 if ((delegate = aura::client::GetDragDropDelegate(target))) {
139 aura::DropTargetEvent e( 141 aura::DropTargetEvent e(
140 *drag_data_, event.location(), event.root_location(), drag_operation_); 142 *drag_data_, event.location(), event.root_location(), drag_operation_);
143 e.set_flags(event.flags());
141 drag_operation_ = delegate->OnPerformDrop(e); 144 drag_operation_ = delegate->OnPerformDrop(e);
142 if (drag_operation_ == 0) 145 if (drag_operation_ == 0)
143 StartCanceledAnimation(); 146 StartCanceledAnimation();
144 else 147 else
145 drag_image_.reset(); 148 drag_image_.reset();
146 } else { 149 } else {
147 drag_image_.reset(); 150 drag_image_.reset();
148 } 151 }
149 152
150 Cleanup(); 153 Cleanup();
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 void DragDropController::Cleanup() { 267 void DragDropController::Cleanup() {
265 if (drag_window_) 268 if (drag_window_)
266 drag_window_->RemoveObserver(this); 269 drag_window_->RemoveObserver(this);
267 drag_window_ = NULL; 270 drag_window_ = NULL;
268 drag_data_ = NULL; 271 drag_data_ = NULL;
269 drag_drop_in_progress_ = false; 272 drag_drop_in_progress_ = false;
270 } 273 }
271 274
272 } // namespace internal 275 } // namespace internal
273 } // namespace ash 276 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698