Chromium Code Reviews| 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 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. | 5 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. |
| 6 | 6 |
| 7 #include "ui/views/view.h" | 7 #include "ui/views/view.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 class PostEventDispatchHandler : public ui::EventHandler { | 94 class PostEventDispatchHandler : public ui::EventHandler { |
| 95 public: | 95 public: |
| 96 explicit PostEventDispatchHandler(View* owner) | 96 explicit PostEventDispatchHandler(View* owner) |
| 97 : owner_(owner), | 97 : owner_(owner), |
| 98 touch_dnd_enabled_(switches::IsTouchDragDropEnabled()) { | 98 touch_dnd_enabled_(switches::IsTouchDragDropEnabled()) { |
| 99 } | 99 } |
| 100 virtual ~PostEventDispatchHandler() {} | 100 virtual ~PostEventDispatchHandler() {} |
| 101 | 101 |
| 102 private: | 102 private: |
| 103 // Overridden from ui::EventHandler: | 103 // Overridden from ui::EventHandler: |
| 104 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { | 104 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { |
|
tdanderson
2014/05/22 14:40:37
In response to Sadrul's suggestion, I actually don
sadrul
2014/05/22 14:50:53
But the event is going to be retargeted to A if B
tdanderson
2014/05/22 16:08:20
Wouldn't the early return when owner_ != event->ta
sadrul
2014/05/22 16:26:22
Consider the case of B: whether or not the context
tdanderson
2014/05/22 18:35:10
OK, so your concern here is specific to context me
| |
| 105 DCHECK_EQ(ui::EP_POSTTARGET, event->phase()); | 105 DCHECK_EQ(ui::EP_POSTTARGET, event->phase()); |
| 106 if (event->handled()) | 106 if (event->handled()) |
| 107 return; | 107 return; |
| 108 | 108 |
| 109 if (touch_dnd_enabled_) { | 109 if (touch_dnd_enabled_) { |
| 110 if (event->type() == ui::ET_GESTURE_LONG_PRESS && | 110 if (event->type() == ui::ET_GESTURE_LONG_PRESS) { |
| 111 (!owner_->drag_controller() || | 111 gfx::Point location(event->location()); |
| 112 owner_->drag_controller()->CanStartDragForView( | 112 View::ConvertPointToTarget(static_cast<View*>(event->target()), |
| 113 owner_, event->location(), event->location()))) { | 113 owner_, &location); |
| 114 if (owner_->DoDrag(*event, event->location(), | 114 if (!owner_->drag_controller() || |
| 115 ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH)) { | 115 owner_->drag_controller()->CanStartDragForView( |
| 116 event->StopPropagation(); | 116 owner_, location, location)) { |
| 117 return; | 117 if (owner_->DoDrag(*event, location, |
| 118 ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH)) { | |
| 119 event->StopPropagation(); | |
| 120 return; | |
| 121 } | |
| 118 } | 122 } |
| 119 } | 123 } |
| 120 } | 124 } |
| 121 | 125 |
| 122 if (owner_->context_menu_controller() && | 126 if (owner_->context_menu_controller() && |
| 123 (event->type() == ui::ET_GESTURE_LONG_PRESS || | 127 (event->type() == ui::ET_GESTURE_LONG_PRESS || |
| 124 event->type() == ui::ET_GESTURE_LONG_TAP || | 128 event->type() == ui::ET_GESTURE_LONG_TAP || |
| 125 event->type() == ui::ET_GESTURE_TWO_FINGER_TAP)) { | 129 event->type() == ui::ET_GESTURE_TWO_FINGER_TAP)) { |
| 126 gfx::Point location(event->location()); | 130 gfx::Point location(event->location()); |
| 127 View::ConvertPointToScreen(owner_, &location); | 131 View::ConvertPointToScreen( |
| 132 static_cast<View*>(event->target()), &location); | |
| 128 owner_->ShowContextMenu(location, ui::MENU_SOURCE_TOUCH); | 133 owner_->ShowContextMenu(location, ui::MENU_SOURCE_TOUCH); |
| 129 event->StopPropagation(); | 134 event->StopPropagation(); |
| 130 } | 135 } |
| 131 } | 136 } |
| 132 | 137 |
| 133 View* owner_; | 138 View* owner_; |
| 134 bool touch_dnd_enabled_; | 139 bool touch_dnd_enabled_; |
| 135 | 140 |
| 136 DISALLOW_COPY_AND_ASSIGN(PostEventDispatchHandler); | 141 DISALLOW_COPY_AND_ASSIGN(PostEventDispatchHandler); |
| 137 }; | 142 }; |
| (...skipping 2397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2535 // Message the RootView to do the drag and drop. That way if we're removed | 2540 // Message the RootView to do the drag and drop. That way if we're removed |
| 2536 // the RootView can detect it and avoid calling us back. | 2541 // the RootView can detect it and avoid calling us back. |
| 2537 gfx::Point widget_location(event.location()); | 2542 gfx::Point widget_location(event.location()); |
| 2538 ConvertPointToWidget(this, &widget_location); | 2543 ConvertPointToWidget(this, &widget_location); |
| 2539 widget->RunShellDrag(this, data, widget_location, drag_operations, source); | 2544 widget->RunShellDrag(this, data, widget_location, drag_operations, source); |
| 2540 // WARNING: we may have been deleted. | 2545 // WARNING: we may have been deleted. |
| 2541 return true; | 2546 return true; |
| 2542 } | 2547 } |
| 2543 | 2548 |
| 2544 } // namespace views | 2549 } // namespace views |
| OLD | NEW |