| Index: ui/events/gestures/gesture_provider_impl.cc
|
| diff --git a/ui/events/gestures/gesture_provider_impl.cc b/ui/events/gestures/gesture_provider_impl.cc
|
| index 58862d1ccb1e3872ae5cd764ae90fbe490048d12..33c46f0b55add8b33d13baefe6660087f6647eef 100644
|
| --- a/ui/events/gestures/gesture_provider_impl.cc
|
| +++ b/ui/events/gestures/gesture_provider_impl.cc
|
| @@ -7,61 +7,46 @@
|
| #include "base/auto_reset.h"
|
| #include "base/logging.h"
|
| #include "ui/events/event.h"
|
| -#include "ui/events/gesture_detection/gesture_config_helper.h"
|
| +#include "ui/events/gesture_detection/gesture_configuration.h"
|
| #include "ui/events/gesture_detection/gesture_event_data.h"
|
| -#include "ui/events/gestures/gesture_configuration.h"
|
| +#include "ui/events/gesture_detection/gesture_provider_config_helper.h"
|
|
|
| namespace ui {
|
|
|
| GestureProviderImpl::GestureProviderImpl(GestureProviderImplClient* client)
|
| : client_(client),
|
| - filtered_gesture_provider_(ui::DefaultGestureProviderConfig(), this),
|
| + filtered_gesture_provider_(
|
| + GetGestureProviderConfig(GestureProviderConfigType::CURRENT_PLATFORM),
|
| + this),
|
| handling_event_(false) {
|
| filtered_gesture_provider_.SetDoubleTapSupportForPlatformEnabled(false);
|
| }
|
|
|
| -GestureProviderImpl::~GestureProviderImpl() {
|
| -}
|
| -
|
| -bool GestureProviderImpl::OnTouchEvent(const TouchEvent& event) {
|
| - int index = pointer_state_.FindPointerIndexOfId(event.touch_id());
|
| - bool pointer_id_is_active = index != -1;
|
| +GestureProviderImpl::~GestureProviderImpl() {}
|
|
|
| - if (event.type() == ET_TOUCH_PRESSED && pointer_id_is_active) {
|
| - // Ignore touch press events if we already believe the pointer is down.
|
| +bool GestureProviderImpl::OnTouchEvent(TouchEvent* event) {
|
| + if (!pointer_state_.OnTouch(*event))
|
| return false;
|
| - } else if (event.type() != ET_TOUCH_PRESSED && !pointer_id_is_active) {
|
| - // We could have an active touch stream transfered to us, resulting in touch
|
| - // move or touch up events without associated touch down events. Ignore
|
| - // them.
|
| - return false;
|
| - }
|
|
|
| - // If this is a touchmove event, and it isn't different from the last
|
| - // event, ignore it.
|
| - if (event.type() == ET_TOUCH_MOVED &&
|
| - event.x() == pointer_state_.GetX(index) &&
|
| - event.y() == pointer_state_.GetY(index)) {
|
| + auto result = filtered_gesture_provider_.OnTouchEvent(pointer_state_);
|
| + if (!result.succeeded)
|
| return false;
|
| - }
|
| -
|
| - last_touch_event_latency_info_ = *event.latency();
|
| - pointer_state_.OnTouch(event);
|
|
|
| - bool result = filtered_gesture_provider_.OnTouchEvent(pointer_state_);
|
| - pointer_state_.CleanupRemovedTouchPoints(event);
|
| - return result;
|
| + event->set_may_cause_scrolling(result.did_generate_scroll);
|
| + pointer_state_.CleanupRemovedTouchPoints(*event);
|
| + return true;
|
| }
|
|
|
| -void GestureProviderImpl::OnTouchEventAck(bool event_consumed) {
|
| +void GestureProviderImpl::OnTouchEventAck(uint32 unique_event_id,
|
| + bool event_consumed) {
|
| DCHECK(pending_gestures_.empty());
|
| DCHECK(!handling_event_);
|
| base::AutoReset<bool> handling_event(&handling_event_, true);
|
| - filtered_gesture_provider_.OnTouchEventAck(event_consumed);
|
| - last_touch_event_latency_info_.Clear();
|
| + filtered_gesture_provider_.OnTouchEventAck(unique_event_id, event_consumed);
|
| }
|
|
|
| -void GestureProviderImpl::OnGestureEvent(const GestureEventData& gesture) {
|
| +void GestureProviderImpl::OnGestureEvent(
|
| + const GestureEventData& gesture) {
|
| GestureEventDetails details = gesture.details;
|
| details.set_oldest_touch_id(gesture.motion_event_id);
|
|
|
| @@ -80,25 +65,18 @@ void GestureProviderImpl::OnGestureEvent(const GestureEventData& gesture) {
|
| }
|
|
|
| scoped_ptr<ui::GestureEvent> event(
|
| - new ui::GestureEvent(gesture.x, gesture.y, gesture.flags,
|
| - gesture.time - base::TimeTicks(), details));
|
| -
|
| - ui::LatencyInfo* gesture_latency = event->latency();
|
| -
|
| - gesture_latency->CopyLatencyFrom(last_touch_event_latency_info_,
|
| - ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT);
|
| - gesture_latency->CopyLatencyFrom(last_touch_event_latency_info_,
|
| - ui::INPUT_EVENT_LATENCY_UI_COMPONENT);
|
| - gesture_latency->CopyLatencyFrom(
|
| - last_touch_event_latency_info_,
|
| - ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT);
|
| + new ui::GestureEvent(gesture.x,
|
| + gesture.y,
|
| + gesture.flags,
|
| + gesture.time - base::TimeTicks(),
|
| + details));
|
|
|
| if (!handling_event_) {
|
| // Dispatching event caused by timer.
|
| client_->OnGestureEvent(event.get());
|
| } else {
|
| // Memory managed by ScopedVector pending_gestures_.
|
| - pending_gestures_.push_back(event.release());
|
| + pending_gestures_.push_back(event.Pass());
|
| }
|
| }
|
|
|
| @@ -117,12 +95,14 @@ bool GestureProviderImpl::IsConsideredDoubleTap(
|
| const GestureEventData& current_tap) const {
|
| if (current_tap.time - previous_tap.time >
|
| base::TimeDelta::FromMilliseconds(
|
| - ui::GestureConfiguration::max_time_between_double_click_in_ms())) {
|
| + GestureConfiguration::GetInstance()
|
| + ->max_time_between_double_click_in_ms())) {
|
| return false;
|
| }
|
|
|
| float double_tap_slop_square =
|
| - GestureConfiguration::max_distance_between_taps_for_double_tap();
|
| + GestureConfiguration::GetInstance()
|
| + ->max_distance_between_taps_for_double_tap();
|
| double_tap_slop_square *= double_tap_slop_square;
|
| const float delta_x = previous_tap.x - current_tap.x;
|
| const float delta_y = previous_tap.y - current_tap.y;
|
|
|