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

Unified Diff: ui/views/controls/menu/menu_controller.cc

Issue 1565013002: Don't send touch events to windows like menus when the touch occurs outside the menu bounds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build redness Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/controls/menu/menu_controller.cc
diff --git a/ui/views/controls/menu/menu_controller.cc b/ui/views/controls/menu/menu_controller.cc
index cae826f46607a06da30b946d49b0ec98578cb9e4..e057ab26c28f96acc64b364a242c642583451674 100644
--- a/ui/views/controls/menu/menu_controller.cc
+++ b/ui/views/controls/menu/menu_controller.cc
@@ -679,6 +679,15 @@ void MenuController::OnGestureEvent(SubmenuView* source,
part.submenu->OnGestureEvent(event);
}
+void MenuController::OnTouchEvent(SubmenuView* source, ui::TouchEvent* event) {
+ if (event->type() == ui::ET_TOUCH_PRESSED) {
+ MenuPart part = GetMenuPart(source, event->location());
+ if (part.type == MenuPart::NONE) {
+ RepostEvent(source, *event);
sky 2016/01/12 21:16:42 If you repostevent don't you need to stop propagat
ananta 2016/01/13 01:21:24 Done.
+ }
+ }
+}
+
View* MenuController::GetTooltipHandlerForPoint(SubmenuView* source,
const gfx::Point& point) {
MenuHostRootView* root_view = GetRootView(source, point);
@@ -970,8 +979,9 @@ void MenuController::SetSelection(MenuItemView* menu_item,
}
}
+template<class EventType>
void MenuController::SetSelectionOnPointerDown(SubmenuView* source,
- const ui::LocatedEvent& event) {
+ const EventType& event) {
if (!blocking_run_)
return;
@@ -2182,9 +2192,10 @@ void MenuController::SelectByChar(base::char16 character) {
}
}
+template<class EventType>
void MenuController::RepostEvent(SubmenuView* source,
- const ui::LocatedEvent& event) {
- if (!event.IsMouseEvent()) {
+ const EventType& event) {
+ if (!event.IsMouseEvent() && !event.IsTouchEvent()) {
// TODO(rbyers): Gesture event repost is tricky to get right
// crbug.com/170987.
DCHECK(event.IsGestureEvent());
@@ -2218,8 +2229,8 @@ void MenuController::RepostEvent(SubmenuView* source,
// coordinates to be in pixels.
// PostMessage() to metro windows isn't allowed (access will be denied). Don't
// try to repost with Win32 if the window under the mouse press is in metro.
- if (!ViewsDelegate::GetInstance() ||
- !ViewsDelegate::GetInstance()->IsWindowInMetro(window)) {
+ if (event.IsMouseEvent() && (!ViewsDelegate::GetInstance() ||
+ !ViewsDelegate::GetInstance()->IsWindowInMetro(window))) {
gfx::Point screen_loc_pixels = gfx::win::DIPToScreenPoint(screen_loc);
HWND target_window = window ? HWNDForNativeWindow(window) :
WindowFromPoint(screen_loc_pixels.ToPOINT());
@@ -2275,7 +2286,16 @@ void MenuController::RepostEvent(SubmenuView* source,
if (!window)
return;
- MenuMessageLoop::RepostEventToWindow(event, window, screen_loc);
+ if (event.IsTouchEvent()) {
+ // Handle touch events in a posted task, as we don't want them to get
+ // dispatched in the context of the menu message pump.
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&MenuMessageLoop::RepostEventToWindow<EventType>,
sky 2016/01/12 21:16:42 RepostEventtoWindow() should post after a delay. Y
ananta 2016/01/13 01:21:24 Done.
+ event, window, screen_loc));
+ } else {
+ MenuMessageLoop::RepostEventToWindow(event, window, screen_loc);
+ }
}
void MenuController::SetDropMenuItem(

Powered by Google App Engine
This is Rietveld 408576698