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

Unified Diff: ui/base/events/event_dispatcher.h

Issue 11415238: events: Allow retrieving the current event being dispatched from EventDispatcher. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 1 month 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
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.cc ('k') | ui/base/events/event_dispatcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/events/event_dispatcher.h
diff --git a/ui/base/events/event_dispatcher.h b/ui/base/events/event_dispatcher.h
index ec5d2b14144b76f650ba1579d957796d8427128e..42d208c474b1706f1e95ffff09385fa1aa841134 100644
--- a/ui/base/events/event_dispatcher.h
+++ b/ui/base/events/event_dispatcher.h
@@ -5,7 +5,6 @@
#ifndef UI_BASE_EVENTS_EVENT_DISPATCHER_H_
#define UI_BASE_EVENTS_EVENT_DISPATCHER_H_
-#include "base/auto_reset.h"
#include "ui/base/events/event.h"
#include "ui/base/events/event_constants.h"
#include "ui/base/events/event_target.h"
@@ -62,6 +61,9 @@ class UI_EXPORT EventDispatcher {
return result;
}
+ const Event* current_event() const { return current_event_; }
+ Event* current_event() { return current_event_; }
+
private:
class UI_EXPORT ScopedDispatchHelper : public NON_EXPORTED_BASE(
Event::DispatcherApi) {
@@ -96,11 +98,19 @@ class UI_EXPORT EventDispatcher {
return ui::ER_CONSUMED;
bool destroyed = false;
set_on_destroy_ = &destroyed;
+
+ // Do not use base::AutoReset for |current_event_|. The EventDispatcher can
+ // be destroyed by the event-handler during the event-dispatch. That would
+ // cause invalid memory-write when AutoReset tries to restore the value.
+ Event* old_event = current_event_;
+ current_event_ = event;
int result = DispatchEventToSingleHandler(handler, event);
- if (destroyed)
+ if (destroyed) {
result |= ui::ER_CONSUMED;
- else
+ } else {
+ current_event_ = old_event;
set_on_destroy_ = NULL;
+ }
return result;
}
@@ -120,6 +130,8 @@ class UI_EXPORT EventDispatcher {
// middle of dispatching an event.
bool* set_on_destroy_;
+ Event* current_event_;
+
DISALLOW_COPY_AND_ASSIGN(EventDispatcher);
};
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.cc ('k') | ui/base/events/event_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698