Chromium Code Reviews| Index: content/browser/renderer_host/render_widget_host_input_event_router.cc |
| diff --git a/content/browser/renderer_host/render_widget_host_input_event_router.cc b/content/browser/renderer_host/render_widget_host_input_event_router.cc |
| index 355a358ade80a88eb141924d5faff5d6e2ddd2b5..7864c509c0f7e2595ba15dd18ba25be24cd8595b 100644 |
| --- a/content/browser/renderer_host/render_widget_host_input_event_router.cc |
| +++ b/content/browser/renderer_host/render_widget_host_input_event_router.cc |
| @@ -42,6 +42,17 @@ void RenderWidgetHostInputEventRouter::OnRenderWidgetHostViewBaseDestroyed( |
| current_touch_target_ = nullptr; |
| active_touches_ = 0; |
|
tdresser
2016/03/02 17:54:43
Let's clear the transforms here as well.
wjmaclean
2016/03/02 18:33:40
Done.
|
| } |
| + |
| + // If the target that's being destroyed is in the gesture target queue, we |
| + // replace it with nullptr so that we maintain the 1:1 correspondence between |
| + // queue entries and the touch sequences that underly them. |
| + for (size_t i = 0; i < gesture_target_queue_.size(); ++i) { |
| + if (gesture_target_queue_[i].target == view) |
| + gesture_target_queue_[i].target = nullptr; |
| + } |
| + |
| + if (view == current_gesture_target_) |
| + current_gesture_target_ = nullptr; |
| } |
| void RenderWidgetHostInputEventRouter::ClearAllObserverRegistrations() { |
| @@ -74,7 +85,9 @@ bool RenderWidgetHostInputEventRouter::HittestDelegate::AcceptHitTarget( |
| } |
| RenderWidgetHostInputEventRouter::RenderWidgetHostInputEventRouter() |
| - : current_touch_target_(nullptr), active_touches_(0) {} |
| + : current_touch_target_(nullptr), |
| + current_gesture_target_(nullptr), |
| + active_touches_(0) {} |
| RenderWidgetHostInputEventRouter::~RenderWidgetHostInputEventRouter() { |
| // We may be destroyed before some of the owners in the map, so we must |
| @@ -144,6 +157,33 @@ void RenderWidgetHostInputEventRouter::RouteMouseWheelEvent( |
| target->ProcessMouseWheelEvent(*event); |
| } |
| +void RenderWidgetHostInputEventRouter::RouteGestureEvent( |
| + RenderWidgetHostViewBase* root_view, |
| + blink::WebGestureEvent* event, |
| + const ui::LatencyInfo& latency) { |
| + // We use GestureTapDown to detect the start of a gesture sequence since there |
| + // is not WebGestureEvent equivalent for ET_GESTURE_BEGIN. Note that this |
|
tdresser
2016/03/02 17:54:43
is not -> is no
wjmaclean
2016/03/02 18:33:40
Done.
|
| + // means the GestureFlingCancel that always comes between ET_GESTURE_BEGIN and |
| + // GestureTapDown is sent to the previous target, but that is intentional. |
|
tdresser
2016/03/02 17:54:43
We should have a test for this case. We should sta
wjmaclean
2016/03/02 18:33:40
Hmmm, ok. I'm not sure I'm clear on what constitut
tdresser
2016/03/02 19:25:11
We should have a test where there are prior touch
|
| + if (event->type == blink::WebInputEvent::GestureTapDown) { |
| + if (!gesture_target_queue_.empty()) { |
| + GestureTargetData& data = gesture_target_queue_.front(); |
|
tdresser
2016/03/02 17:54:43
const?
wjmaclean
2016/03/02 18:33:40
Done.
|
| + current_gesture_target_ = data.target; |
| + gesture_delta_ = data.delta; |
| + gesture_target_queue_.pop_front(); |
| + } else { |
| + NOTIMPLEMENTED(); |
|
tdresser
2016/03/02 17:54:43
We should probably DCHECK that the queue isn't emp
wjmaclean
2016/03/02 18:33:40
Done.
|
| + } |
| + } |
| + |
| + if (!current_gesture_target_) |
| + return; |
| + |
| + event->x += gesture_delta_.x(); |
| + event->y += gesture_delta_.y(); |
| + current_gesture_target_->ProcessGestureEvent(*event, latency); |
| +} |
| + |
| void RenderWidgetHostInputEventRouter::RouteTouchEvent( |
| RenderWidgetHostViewBase* root_view, |
| blink::WebTouchEvent* event, |
| @@ -159,8 +199,6 @@ void RenderWidgetHostInputEventRouter::RouteTouchEvent( |
| event->touches[0].position.y); |
| current_touch_target_ = |
| FindEventTarget(root_view, original_point, &transformed_point); |
| - if (!current_touch_target_) |
| - return; |
| // TODO(wjmaclean): Instead of just computing a delta, we should extract |
| // the complete transform. We assume it doesn't change for the duration |
| @@ -168,6 +206,10 @@ void RenderWidgetHostInputEventRouter::RouteTouchEvent( |
| // might be to always transform each point to the current_touch_target_ |
| // for the duration of the sequence. |
|
tdresser
2016/03/02 17:54:43
Computing the transform each event seems more corr
wjmaclean
2016/03/02 18:33:40
Acknowledged.
As indicated in a previous comment,
tdresser
2016/03/02 19:25:11
Acknowledged.
|
| touch_delta_ = transformed_point - original_point; |
| + gesture_target_queue_.emplace_back(current_touch_target_, touch_delta_); |
| + |
| + if (!current_touch_target_) |
| + return; |
| } |
| ++active_touches_; |
| if (current_touch_target_) { |