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

Unified Diff: ui/events/event.h

Issue 519113002: Do not mutate ui::Event properties during nested event processing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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
« no previous file with comments | « no previous file | ui/events/event.cc » ('j') | ui/events/event_processor.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/event.h
diff --git a/ui/events/event.h b/ui/events/event.h
index 7257f625f40299b32510fb80850b4259db5f00c0..b55eeae84e563d70513e7fc725b03fa785fa51c8 100644
--- a/ui/events/event.h
+++ b/ui/events/event.h
@@ -215,6 +215,9 @@ class EVENTS_EXPORT Event {
void SetHandled();
bool handled() const { return result_ != ER_UNHANDLED; }
+ // Used to create a copy of |this|.
+ virtual scoped_ptr<Event> Clone() const = 0;
sadrul 2014/08/29 21:12:17 Can we have a static Event::Clone(const Event& eve
tdanderson 2014/09/02 22:57:09 Done.
+
protected:
Event(EventType type, base::TimeDelta time_stamp, int flags);
Event(const base::NativeEvent& native_event, EventType type, int flags);
@@ -255,6 +258,9 @@ class EVENTS_EXPORT CancelModeEvent : public Event {
public:
CancelModeEvent();
virtual ~CancelModeEvent();
+
+ // Event:
+ virtual scoped_ptr<Event> Clone() const OVERRIDE;
};
class EVENTS_EXPORT LocatedEvent : public Event {
@@ -294,6 +300,9 @@ class EVENTS_EXPORT LocatedEvent : public Event {
location_= location_ - diff;
}
+ // Event:
+ virtual scoped_ptr<Event> Clone() const OVERRIDE;
+
protected:
friend class LocatedEventTestApi;
explicit LocatedEvent(const base::NativeEvent& native_event);
@@ -401,6 +410,9 @@ class EVENTS_EXPORT MouseEvent : public LocatedEvent {
// Set the click count for a mousedown message. Can be 1, 2 or 3.
void SetClickCount(int click_count);
+ // Event:
+ virtual scoped_ptr<Event> Clone() const OVERRIDE;
+
// Identifies the button that changed. During a press this corresponds to the
// button that was pressed and during a release this corresponds to the button
// that was released.
@@ -470,6 +482,9 @@ class EVENTS_EXPORT MouseWheelEvent : public MouseEvent {
virtual void UpdateForRootTransform(
const gfx::Transform& inverted_root_transform) OVERRIDE;
+ // Event:
+ virtual scoped_ptr<Event> Clone() const OVERRIDE;
+
private:
gfx::Vector2d offset_;
};
@@ -522,6 +537,9 @@ class EVENTS_EXPORT TouchEvent : public LocatedEvent {
virtual void UpdateForRootTransform(
const gfx::Transform& inverted_root_transform) OVERRIDE;
+ // Event:
+ virtual scoped_ptr<Event> Clone() const OVERRIDE;
+
protected:
void set_radius(float radius_x, float radius_y) {
radius_x_ = radius_x;
@@ -664,6 +682,9 @@ class EVENTS_EXPORT KeyEvent : public Event {
// Marks this key event as translated or not translated.
void SetTranslated(bool translated);
+ // Event:
+ virtual scoped_ptr<Event> Clone() const OVERRIDE;
+
protected:
friend class KeyEventTestApi;
@@ -737,6 +758,9 @@ class EVENTS_EXPORT ScrollEvent : public MouseEvent {
// to provide a consistent user experience.
void Scale(const float factor);
+ // Event:
+ virtual scoped_ptr<Event> Clone() const OVERRIDE;
+
float x_offset() const { return x_offset_; }
float y_offset() const { return y_offset_; }
float x_offset_ordinal() const { return x_offset_ordinal_; }
@@ -773,6 +797,9 @@ class EVENTS_EXPORT GestureEvent : public LocatedEvent {
virtual ~GestureEvent();
+ // Event:
+ virtual scoped_ptr<Event> Clone() const OVERRIDE;
+
const GestureEventDetails& details() const { return details_; }
private:
« no previous file with comments | « no previous file | ui/events/event.cc » ('j') | ui/events/event_processor.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698