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

Side by Side Diff: ui/aura/window_event_dispatcher.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: Restore DCHECK 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/aura/window_event_dispatcher.h" 5 #include "ui/aura/window_event_dispatcher.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 ui::GestureRecognizer::Get()->AddGestureEventHelper(this); 93 ui::GestureRecognizer::Get()->AddGestureEventHelper(this);
94 Env::GetInstance()->AddObserver(this); 94 Env::GetInstance()->AddObserver(this);
95 } 95 }
96 96
97 WindowEventDispatcher::~WindowEventDispatcher() { 97 WindowEventDispatcher::~WindowEventDispatcher() {
98 TRACE_EVENT0("shutdown", "WindowEventDispatcher::Destructor"); 98 TRACE_EVENT0("shutdown", "WindowEventDispatcher::Destructor");
99 Env::GetInstance()->RemoveObserver(this); 99 Env::GetInstance()->RemoveObserver(this);
100 ui::GestureRecognizer::Get()->RemoveGestureEventHelper(this); 100 ui::GestureRecognizer::Get()->RemoveGestureEventHelper(this);
101 } 101 }
102 102
103 void WindowEventDispatcher::RepostEvent(const ui::LocatedEvent& event) { 103 void WindowEventDispatcher::RepostEvent(const ui::LocatedEvent* event) {
104 DCHECK(event.type() == ui::ET_MOUSE_PRESSED || 104 DCHECK(event->type() == ui::ET_MOUSE_PRESSED ||
105 event.type() == ui::ET_GESTURE_TAP_DOWN); 105 event->type() == ui::ET_GESTURE_TAP_DOWN ||
106 event->type() == ui::ET_TOUCH_PRESSED);
106 // We allow for only one outstanding repostable event. This is used 107 // We allow for only one outstanding repostable event. This is used
107 // in exiting context menus. A dropped repost request is allowed. 108 // in exiting context menus. A dropped repost request is allowed.
108 if (event.type() == ui::ET_MOUSE_PRESSED) { 109 if (event->type() == ui::ET_MOUSE_PRESSED) {
109 held_repostable_event_.reset( 110 held_repostable_event_.reset(
110 new ui::MouseEvent( 111 new ui::MouseEvent(
111 static_cast<const ui::MouseEvent&>(event), 112 static_cast<const ui::MouseEvent&>(*event),
112 static_cast<aura::Window*>(event.target()), 113 static_cast<aura::Window*>(event->target()),
113 window())); 114 window()));
115 } else if (event->type() == ui::ET_TOUCH_PRESSED) {
116 held_repostable_event_.reset(
117 new ui::TouchEvent(static_cast<const ui::TouchEvent&>(*event)));
118 } else {
119 DCHECK(event->type() == ui::ET_GESTURE_TAP_DOWN);
120 held_repostable_event_.reset();
121 // TODO(rbyers): Reposing of gestures is tricky to get
122 // right, so it's not yet supported. crbug.com/170987.
123 }
124
125 if (held_repostable_event_) {
114 base::MessageLoop::current()->PostNonNestableTask( 126 base::MessageLoop::current()->PostNonNestableTask(
115 FROM_HERE, base::Bind( 127 FROM_HERE, base::Bind(
116 base::IgnoreResult(&WindowEventDispatcher::DispatchHeldEvents), 128 base::IgnoreResult(&WindowEventDispatcher::DispatchHeldEvents),
117 repost_event_factory_.GetWeakPtr())); 129 repost_event_factory_.GetWeakPtr()));
118 } else {
119 DCHECK(event.type() == ui::ET_GESTURE_TAP_DOWN);
120 held_repostable_event_.reset();
121 // TODO(rbyers): Reposing of gestures is tricky to get
122 // right, so it's not yet supported. crbug.com/170987.
123 } 130 }
124 } 131 }
125 132
126 void WindowEventDispatcher::OnMouseEventsEnableStateChanged(bool enabled) { 133 void WindowEventDispatcher::OnMouseEventsEnableStateChanged(bool enabled) {
127 // Send entered / exited so that visual state can be updated to match 134 // Send entered / exited so that visual state can be updated to match
128 // mouse events state. 135 // mouse events state.
129 PostSynthesizeMouseMove(); 136 PostSynthesizeMouseMove();
130 // TODO(mazda): Add code to disable mouse events when |enabled| == false. 137 // TODO(mazda): Add code to disable mouse events when |enabled| == false.
131 } 138 }
132 139
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 // WindowEventDispatcher, private: 666 // WindowEventDispatcher, private:
660 667
661 ui::EventDispatchDetails WindowEventDispatcher::DispatchHeldEvents() { 668 ui::EventDispatchDetails WindowEventDispatcher::DispatchHeldEvents() {
662 if (!held_repostable_event_ && !held_move_event_) 669 if (!held_repostable_event_ && !held_move_event_)
663 return DispatchDetails(); 670 return DispatchDetails();
664 671
665 CHECK(!dispatching_held_event_); 672 CHECK(!dispatching_held_event_);
666 673
667 DispatchDetails dispatch_details; 674 DispatchDetails dispatch_details;
668 if (held_repostable_event_) { 675 if (held_repostable_event_) {
669 if (held_repostable_event_->type() == ui::ET_MOUSE_PRESSED) { 676 if (held_repostable_event_->type() == ui::ET_MOUSE_PRESSED ||
670 scoped_ptr<ui::MouseEvent> mouse_event( 677 held_repostable_event_->type() == ui::ET_TOUCH_PRESSED) {
671 static_cast<ui::MouseEvent*>(held_repostable_event_.release())); 678 scoped_ptr<ui::LocatedEvent> event = std::move(held_repostable_event_);
672 dispatching_held_event_ = mouse_event.get(); 679 dispatching_held_event_ = event.get();
673 dispatch_details = OnEventFromSource(mouse_event.get()); 680 dispatch_details = OnEventFromSource(event.get());
674 } else { 681 } else {
675 // TODO(rbyers): GESTURE_TAP_DOWN not yet supported: crbug.com/170987. 682 // TODO(rbyers): GESTURE_TAP_DOWN not yet supported: crbug.com/170987.
676 NOTREACHED(); 683 NOTREACHED();
677 } 684 }
678 if (dispatch_details.dispatcher_destroyed) 685 if (dispatch_details.dispatcher_destroyed)
679 return dispatch_details; 686 return dispatch_details;
680 } 687 }
681 688
682 if (held_move_event_) { 689 if (held_move_event_) {
683 // If a mouse move has been synthesized, the target location is suspect, 690 // If a mouse move has been synthesized, the target location is suspect,
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 } 915 }
909 916
910 // This flag is set depending on the gestures recognized in the call above, 917 // This flag is set depending on the gestures recognized in the call above,
911 // and needs to propagate with the forwarded event. 918 // and needs to propagate with the forwarded event.
912 event->set_may_cause_scrolling(orig_event.may_cause_scrolling()); 919 event->set_may_cause_scrolling(orig_event.may_cause_scrolling());
913 920
914 return PreDispatchLocatedEvent(target, event); 921 return PreDispatchLocatedEvent(target, event);
915 } 922 }
916 923
917 } // namespace aura 924 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698