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

Unified Diff: ui/aura/window_event_dispatcher.cc

Issue 2933353003: Mark the ET_MOUSE_MOVED created from a pointer grab as synthesized. (Closed)
Patch Set: Investigate use-after-free. Created 3 years, 6 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/aura/window_event_dispatcher.cc
diff --git a/ui/aura/window_event_dispatcher.cc b/ui/aura/window_event_dispatcher.cc
index dc286d0826545413afb7ddb91314056bf84d439d..7f0d85105b6adf9a7174ea4a1ee2d489807c1edb 100644
--- a/ui/aura/window_event_dispatcher.cc
+++ b/ui/aura/window_event_dispatcher.cc
@@ -226,6 +226,8 @@ gfx::Point WindowEventDispatcher::GetLastMouseLocationInRoot() const {
void WindowEventDispatcher::OnHostLostMouseGrab() {
mouse_pressed_handler_ = NULL;
+ LOG(ERROR) << "mouse_moved_handler_ = NULL (was " << mouse_moved_handler_
+ << ")";
mouse_moved_handler_ = NULL;
}
@@ -327,8 +329,11 @@ void WindowEventDispatcher::OnWindowHidden(Window* invisible,
// longer receive mouse events.
if (invisible->Contains(mouse_pressed_handler_))
mouse_pressed_handler_ = NULL;
- if (invisible->Contains(mouse_moved_handler_))
+ if (invisible->Contains(mouse_moved_handler_)) {
+ LOG(ERROR) << "mouse_moved_handler_ = NULL (was " << mouse_moved_handler_
+ << ")";
mouse_moved_handler_ = NULL;
+ }
// If events are being dispatched from a nested message-loop, and the target
// of the outer loop is hidden or moved to another dispatcher during
@@ -376,8 +381,11 @@ void WindowEventDispatcher::UpdateCapture(Window* old_capture,
// |mouse_moved_handler_| may have been set to a Window in a different root
// (see below). Clear it here to ensure we don't end up referencing a stale
// Window.
- if (mouse_moved_handler_ && !window()->Contains(mouse_moved_handler_))
+ if (mouse_moved_handler_ && !window()->Contains(mouse_moved_handler_)) {
+ LOG(ERROR) << "mouse_moved_handler_ = NULL (was " << mouse_moved_handler_
+ << ")";
mouse_moved_handler_ = NULL;
+ }
if (old_capture && old_capture->GetRootWindow() == window() &&
old_capture->delegate()) {
@@ -396,8 +404,11 @@ void WindowEventDispatcher::UpdateCapture(Window* old_capture,
if (new_capture) {
// Make all subsequent mouse events go to the capture window. We shouldn't
// need to send an event here as OnCaptureLost() should take care of that.
- if (mouse_moved_handler_ || Env::GetInstance()->IsMouseButtonDown())
+ if (mouse_moved_handler_ || Env::GetInstance()->IsMouseButtonDown()) {
+ LOG(ERROR) << "mouse_moved_handler_ = " << new_capture << " (was "
+ << mouse_moved_handler_ << ")";
mouse_moved_handler_ = new_capture;
+ }
} else {
// Make sure mouse_moved_handler gets updated.
DispatchDetails details = SynthesizeMouseMoveEvent();
@@ -426,6 +437,8 @@ void WindowEventDispatcher::OnOtherRootGotCapture() {
}
#endif
+ LOG(ERROR) << "mouse_moved_handler_ = NULL (was " << mouse_moved_handler_
+ << ")";
mouse_moved_handler_ = NULL;
mouse_pressed_handler_ = NULL;
}
@@ -810,10 +823,13 @@ DispatchDetails WindowEventDispatcher::PreDispatchMouseEvent(
// We allow synthesized mouse exit events through even if mouse events are
// disabled. This ensures that hover state, etc on controls like buttons is
// cleared.
+ if (cursor_client)
+ LOG(ERROR) << cursor_client->IsMouseEventsEnabled();
if (cursor_client &&
!cursor_client->IsMouseEventsEnabled() &&
(event->flags() & ui::EF_IS_SYNTHESIZED) &&
(event->type() != ui::ET_MOUSE_EXITED)) {
+ LOG(ERROR) << "drop";
event->SetHandled();
return DispatchDetails();
}
@@ -824,6 +840,7 @@ DispatchDetails WindowEventDispatcher::PreDispatchMouseEvent(
if (IsEventCandidateForHold(*event) && !dispatching_held_event_) {
if (move_hold_count_) {
held_move_event_.reset(new ui::MouseEvent(*event, target, window()));
+ LOG(ERROR) << "drop";
event->SetHandled();
return DispatchDetails();
} else {
@@ -843,6 +860,8 @@ DispatchDetails WindowEventDispatcher::PreDispatchMouseEvent(
event->SetHandled();
return details;
}
+ LOG(ERROR) << "mouse_moved_handler_ = NULL (was "
+ << mouse_moved_handler_ << ")";
mouse_moved_handler_ = NULL;
}
break;
@@ -862,22 +881,28 @@ DispatchDetails WindowEventDispatcher::PreDispatchMouseEvent(
DispatchDetails target_details = details;
target_details.target_destroyed = !live_window.Contains(target);
if (details.dispatcher_destroyed) {
+ LOG(ERROR) << "drop";
event->SetHandled();
return target_details;
}
// If the |mouse_moved_handler_| changes out from under us, assume a
// nested run loop ran and we don't need to do anything.
if (mouse_moved_handler_ != old_mouse_moved_handler) {
+ LOG(ERROR) << "drop";
event->SetHandled();
return target_details;
}
if (details.target_destroyed || target_details.target_destroyed) {
+ LOG(ERROR) << "mouse_moved_handler_ = NULL (was "
+ << mouse_moved_handler_ << ")";
mouse_moved_handler_ = NULL;
event->SetHandled();
return target_details;
}
live_window.Remove(target);
+ LOG(ERROR) << "mouse_moved_handler_ = " << target << " (was "
+ << mouse_moved_handler_ << ")";
mouse_moved_handler_ = target;
details =
DispatchMouseEnterOrExit(target, *event, ui::ET_MOUSE_ENTERED);

Powered by Google App Engine
This is Rietveld 408576698