diff options
author | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-29 16:58:12 +0000 |
---|---|---|
committer | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-29 16:58:12 +0000 |
commit | 72ed5eb362404c825be0db3b8549ddd2e5348b1a (patch) | |
tree | 741b2d385a3a5b7a1ad06a9ba9c5374d53326e97 /ui/base | |
parent | fd69f25fa093e5a4581a9c617f99302d88d7155e (diff) | |
download | chromium_src-72ed5eb362404c825be0db3b8549ddd2e5348b1a.zip chromium_src-72ed5eb362404c825be0db3b8549ddd2e5348b1a.tar.gz chromium_src-72ed5eb362404c825be0db3b8549ddd2e5348b1a.tar.bz2 |
Add ability for EventGenerator to generate Scroll events asynchronously
This has been split out from https://codereview.chromium.org/11881042
BUG=124830
TEST=None
Review URL: https://codereview.chromium.org/12088015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179348 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base')
-rw-r--r-- | ui/base/events/event.cc | 14 | ||||
-rw-r--r-- | ui/base/events/event.h | 33 |
2 files changed, 28 insertions, 19 deletions
diff --git a/ui/base/events/event.cc b/ui/base/events/event.cc index cffc21f..c06b604 100644 --- a/ui/base/events/event.cc +++ b/ui/base/events/event.cc @@ -640,12 +640,16 @@ ScrollEvent::ScrollEvent(const base::NativeEvent& native_event) ScrollEvent::ScrollEvent(EventType type, const gfx::Point& location, + base::TimeDelta time_stamp, int flags, float x_offset, - float y_offset) + float y_offset, + int finger_count) : MouseEvent(type, location, location, flags), x_offset_(x_offset), - y_offset_(y_offset) { + y_offset_(y_offset), + finger_count_(finger_count) { + set_time_stamp(time_stamp); CHECK(IsScrollEvent()); } @@ -664,7 +668,11 @@ GestureEvent::GestureEvent(EventType type, base::TimeDelta time_stamp, const GestureEventDetails& details, unsigned int touch_ids_bitfield) - : LocatedEvent(type, gfx::Point(x, y), gfx::Point(x, y), time_stamp, flags), + : LocatedEvent(type, + gfx::Point(x, y), + gfx::Point(x, y), + time_stamp, + flags | EF_FROM_TOUCH), details_(details), touch_ids_bitfield_(touch_ids_bitfield) { } diff --git a/ui/base/events/event.h b/ui/base/events/event.h index 574cb7f..b691118 100644 --- a/ui/base/events/event.h +++ b/ui/base/events/event.h @@ -53,7 +53,7 @@ class UI_EXPORT Event { public: explicit TestApi(Event* event) : event_(event) {} - void set_time_stamp(const base::TimeDelta& time_stamp) { + void set_time_stamp(base::TimeDelta time_stamp) { event_->time_stamp_ = time_stamp; } @@ -141,9 +141,9 @@ class UI_EXPORT Event { case ET_SCROLL_FLING_CANCEL: case ET_SCROLL_FLING_START: - // These can be ScrollEvents too. But for ScrollEvents have valid native - // events. No gesture events have native events. - return !HasNativeEvent(); + // These can be ScrollEvents too. EF_FROM_TOUCH determines if they're + // Gesture or Scroll events. + return (flags_ & EF_FROM_TOUCH) == EF_FROM_TOUCH; default: break; @@ -152,9 +152,12 @@ class UI_EXPORT Event { } bool IsScrollEvent() const { + // Flings can be GestureEvents too. EF_FROM_TOUCH determins if they're + // Gesture or Scroll events. return type_ == ET_SCROLL || ((type_ == ET_SCROLL_FLING_START || - type_ == ET_SCROLL_FLING_CANCEL) && HasNativeEvent()); + type_ == ET_SCROLL_FLING_CANCEL) && + !(flags() & EF_FROM_TOUCH)); } bool IsScrollGestureEvent() const { @@ -199,6 +202,10 @@ class UI_EXPORT Event { dispatch_to_hidden_targets_ = dispatch_to_hidden_targets; } + void set_time_stamp(const base::TimeDelta& time_stamp) { + time_stamp_ = time_stamp; + } + void set_name(const std::string& name) { name_ = name; } private: @@ -512,8 +519,6 @@ class UI_EXPORT TouchEvent : public LocatedEvent { // Force (pressure) of the touch. Normalized to be [0, 1]. Default to be 0.0. float force_; - - DISALLOW_COPY_AND_ASSIGN(TouchEvent); }; class UI_EXPORT KeyEvent : public Event { @@ -564,8 +569,6 @@ class UI_EXPORT KeyEvent : public Event { uint16 character_; uint16 unmodified_character_; - - DISALLOW_COPY_AND_ASSIGN(KeyEvent); }; // A key event which is translated by an input method (IME). @@ -615,10 +618,8 @@ class UI_EXPORT ScrollEvent : public MouseEvent { template <class T> ScrollEvent(const ScrollEvent& model, T* source, - T* target, - EventType type, - int flags) - : MouseEvent(model, source, target, type, flags), + T* target) + : MouseEvent(model, source, target), x_offset_(model.x_offset_), y_offset_(model.y_offset_), finger_count_(model.finger_count_){ @@ -627,9 +628,11 @@ class UI_EXPORT ScrollEvent : public MouseEvent { // Used for tests. ScrollEvent(EventType type, const gfx::Point& location, + base::TimeDelta time_stamp, int flags, float x_offset, - float y_offset); + float y_offset, + int finger_count); // Scale the scroll event's offset value. // This is useful in the multi-monitor setup where it needs to be scaled @@ -644,8 +647,6 @@ class UI_EXPORT ScrollEvent : public MouseEvent { float x_offset_; float y_offset_; int finger_count_; - - DISALLOW_COPY_AND_ASSIGN(ScrollEvent); }; class UI_EXPORT GestureEvent : public LocatedEvent { |