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

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

Issue 15889009: ash: Stop propagation of gesture events when drag drop is in progress. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch Created 7 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
« no previous file with comments | « no previous file | ash/drag_drop/drag_drop_controller_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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 "ash/wm/coordinate_conversion.h" 10 #include "ash/wm/coordinate_conversion.h"
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 return; 399 return;
400 400
401 if (event->type() == ui::ET_TOUCH_CANCELLED) 401 if (event->type() == ui::ET_TOUCH_CANCELLED)
402 DragCancel(); 402 DragCancel();
403 } 403 }
404 404
405 void DragDropController::OnGestureEvent(ui::GestureEvent* event) { 405 void DragDropController::OnGestureEvent(ui::GestureEvent* event) {
406 if (!IsDragDropInProgress()) 406 if (!IsDragDropInProgress())
407 return; 407 return;
408 408
409 // If current drag session was not started by touch, dont process this touch 409 // No one else should handle gesture events when in drag drop. Note that it is
410 // event, but consume it so it does not interfere with current drag session. 410 // not enough to just set ER_HANDLED because the dispatcher only stops
411 if (current_drag_event_source_ != 411 // dispatching when the event has ER_CONSUMED. If we just set ER_HANDLED, the
412 ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH) { 412 // event will still be dispatched to other handlers and we depend on
413 event->StopPropagation(); 413 // individual handlers' kindness to not touch events marked ER_HANDLED (not
414 // all handlers are so kind and may cause bugs like crbug.com/236493).
415 event->StopPropagation();
416
417 // If current drag session was not started by touch, dont process this event.
418 if (current_drag_event_source_ != ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH)
414 return; 419 return;
415 }
416 420
417 // Apply kTouchDragImageVerticalOffset to the location. 421 // Apply kTouchDragImageVerticalOffset to the location.
418 ui::GestureEvent touch_offset_event(*event, 422 ui::GestureEvent touch_offset_event(*event,
419 static_cast<aura::Window*>(NULL), 423 static_cast<aura::Window*>(NULL),
420 static_cast<aura::Window*>(NULL)); 424 static_cast<aura::Window*>(NULL));
421 gfx::Point touch_offset_location = touch_offset_event.location(); 425 gfx::Point touch_offset_location = touch_offset_event.location();
422 gfx::Point touch_offset_root_location = touch_offset_event.root_location(); 426 gfx::Point touch_offset_root_location = touch_offset_event.root_location();
423 touch_offset_location.Offset(0, kTouchDragImageVerticalOffset); 427 touch_offset_location.Offset(0, kTouchDragImageVerticalOffset);
424 touch_offset_root_location.Offset(0, kTouchDragImageVerticalOffset); 428 touch_offset_root_location.Offset(0, kTouchDragImageVerticalOffset);
425 touch_offset_event.set_location(touch_offset_location); 429 touch_offset_event.set_location(touch_offset_location);
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 drag_window_->RemoveObserver(this); 565 drag_window_->RemoveObserver(this);
562 drag_window_ = NULL; 566 drag_window_ = NULL;
563 drag_data_ = NULL; 567 drag_data_ = NULL;
564 // Cleanup can be called again while deleting DragDropTracker, so use Pass 568 // Cleanup can be called again while deleting DragDropTracker, so use Pass
565 // instead of reset to avoid double free. 569 // instead of reset to avoid double free.
566 drag_drop_tracker_.Pass(); 570 drag_drop_tracker_.Pass();
567 } 571 }
568 572
569 } // namespace internal 573 } // namespace internal
570 } // namespace ash 574 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/drag_drop/drag_drop_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698