diff options
author | varunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-06 21:46:44 +0000 |
---|---|---|
committer | varunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-06 21:46:44 +0000 |
commit | c086babf8788773e9f632c0c8a7623d7f85cbf13 (patch) | |
tree | 518f7c21e8d01380410efba7853819a5a9179802 /ash/drag_drop | |
parent | fdfb270bc229a55c2a5042139f03f9d8a5438fef (diff) | |
download | chromium_src-c086babf8788773e9f632c0c8a7623d7f85cbf13.zip chromium_src-c086babf8788773e9f632c0c8a7623d7f85cbf13.tar.gz chromium_src-c086babf8788773e9f632c0c8a7623d7f85cbf13.tar.bz2 |
Change ordering of Shell event handlers:
crrev.com/14184010 made the DragDropController to be the first handler everytime
a drag starts. That was done under the assumption that once we are in a drag
drop session, no other handler needs to see the event. This assumption turned
out to be false because the MouseCursorEventFilter needs to handle events even
during a drag drop session so that the cursor can move across displays (causing
the bug listed below). Hence, we make the DragDropController the second event
handler while MouseCursorEvedntFilter becomes the first.
BUG=244508
Review URL: https://chromiumcodereview.appspot.com/16463002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@204612 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/drag_drop')
-rw-r--r-- | ash/drag_drop/drag_drop_controller.cc | 8 | ||||
-rw-r--r-- | ash/drag_drop/drag_drop_controller_unittest.cc | 100 |
2 files changed, 1 insertions, 107 deletions
diff --git a/ash/drag_drop/drag_drop_controller.cc b/ash/drag_drop/drag_drop_controller.cc index 98e41d9..40c7cec 100644 --- a/ash/drag_drop/drag_drop_controller.cc +++ b/ash/drag_drop/drag_drop_controller.cc @@ -148,7 +148,7 @@ DragDropController::DragDropController() drag_drop_window_delegate_(new DragDropTrackerDelegate(this)), current_drag_event_source_(ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE), weak_factory_(this) { - Shell::GetInstance()->AddPreTargetHandler(this); + Shell::GetInstance()->PrependPreTargetHandler(this); } DragDropController::~DragDropController() { @@ -226,12 +226,6 @@ int DragDropController::StartDragAndDrop( if (cancel_animation_) cancel_animation_->End(); - // Become the first event handler since we should get first shot at handling - // any events during the drag drop session. - Shell::GetInstance()->RemovePreTargetHandler(this); - Shell::GetInstance()->PrependPreTargetHandler(this); - - #if !defined(OS_MACOSX) if (should_block_during_drag_drop_) { base::RunLoop run_loop(aura::Env::GetInstance()->GetDispatcher()); diff --git a/ash/drag_drop/drag_drop_controller_unittest.cc b/ash/drag_drop/drag_drop_controller_unittest.cc index 91cb67c..e27f19c 100644 --- a/ash/drag_drop/drag_drop_controller_unittest.cc +++ b/ash/drag_drop/drag_drop_controller_unittest.cc @@ -1108,105 +1108,5 @@ TEST_F(DragDropControllerTest, MAYBE_DragCancelAcrossDisplays) { } } -class SimpleEventHandler : public ui::EventHandler { - public: - SimpleEventHandler() - : handled_event_received_(false), - unhandled_event_received_(false) { - ash::Shell::GetInstance()->PrependPreTargetHandler(this); - } - - virtual ~SimpleEventHandler() { - ash::Shell::GetInstance()->RemovePreTargetHandler(this); - } - - bool handled_event_received() { return handled_event_received_; } - bool unhandled_event_received() { return unhandled_event_received_; } - - void Reset() { - handled_event_received_ = false; - unhandled_event_received_ = false; - } - - private: - // Overridden from ui::EventHandler. - virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { - if (event->handled()) - handled_event_received_ = true; - else - unhandled_event_received_ = true; - } - - bool handled_event_received_; - bool unhandled_event_received_; - - DISALLOW_COPY_AND_ASSIGN(SimpleEventHandler); -}; - -TEST_F(DragDropControllerTest, - DragDropControllerReceivesAllEventsDuringDragDrop) { - CommandLine::ForCurrentProcess()->AppendSwitch( - switches::kEnableTouchDragDrop); - scoped_ptr<views::Widget> widget(CreateNewWidget()); - DragTestView* drag_view = new DragTestView; - AddViewToWidgetAndResize(widget.get(), drag_view); - aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), - widget->GetNativeView()); - ui::OSExchangeData data; - data.SetString(UTF8ToUTF16("I am being dragged")); - SimpleEventHandler handler; - - // Since we are not in drag/drop, |handler| should receive unhandled events. - generator.PressTouch(); - gfx::Point point = gfx::Rect(drag_view->bounds()).CenterPoint(); - handler.Reset(); - DispatchGesture(ui::ET_GESTURE_LONG_PRESS, point); - EXPECT_TRUE(handler.unhandled_event_received()); - EXPECT_FALSE(handler.handled_event_received()); - - EXPECT_TRUE(drag_drop_controller_->drag_start_received_); - - // Since dragging has started, |handler| should not receive unhandled events. - UpdateDragData(&data); - gfx::Point gesture_location = point; - int num_drags = drag_view->width(); - for (int i = 0; i < num_drags; ++i) { - gesture_location.Offset(1, 0); - handler.Reset(); - DispatchGesture(ui::ET_GESTURE_SCROLL_UPDATE, gesture_location); - EXPECT_FALSE(handler.handled_event_received()); - EXPECT_FALSE(handler.unhandled_event_received()); - - // Execute any scheduled draws to process deferred mouse events. - RunAllPendingInMessageLoop(); - } - - // Handler should not receive any other gestures that DragDropController - // does not care about. - std::set<ui::EventType> drag_drop_gestures; - drag_drop_gestures.insert(ui::ET_GESTURE_SCROLL_UPDATE); - drag_drop_gestures.insert(ui::ET_GESTURE_SCROLL_END); - drag_drop_gestures.insert(ui::ET_GESTURE_LONG_TAP); - drag_drop_gestures.insert(ui::ET_SCROLL_FLING_START); - for (ui::EventType type = ui::ET_UNKNOWN; type < ui::ET_LAST; - type = static_cast<ui::EventType>(type + 1)) { - if (!IsGestureEventType(type) || - drag_drop_gestures.find(type) != drag_drop_gestures.end()) - continue; - - handler.Reset(); - DispatchGesture(ui::ET_GESTURE_SCROLL_UPDATE, gesture_location); - EXPECT_FALSE(handler.handled_event_received()); - EXPECT_FALSE(handler.unhandled_event_received()); - - // Execute any scheduled draws to process deferred mouse events. - RunAllPendingInMessageLoop(); - } - - // End dragging. - DispatchGesture(ui::ET_GESTURE_SCROLL_END, gesture_location); - EXPECT_TRUE(drag_drop_controller_->drop_received_); -} - } // namespace test } // namespace aura |