Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" | 5 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" |
| 6 | 6 |
| 7 #include "base/debug/dump_without_crashing.h" | 7 #include "base/debug/dump_without_crashing.h" |
| 8 #include "cc/quads/surface_draw_quad.h" | 8 #include "cc/quads/surface_draw_quad.h" |
| 9 #include "cc/surfaces/surface_id_allocator.h" | 9 #include "cc/surfaces/surface_id_allocator.h" |
| 10 #include "cc/surfaces/surface_manager.h" | 10 #include "cc/surfaces/surface_manager.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 bool RenderWidgetHostInputEventRouter::HittestDelegate::AcceptHitTarget( | 88 bool RenderWidgetHostInputEventRouter::HittestDelegate::AcceptHitTarget( |
| 89 const cc::SurfaceDrawQuad* surface_quad, | 89 const cc::SurfaceDrawQuad* surface_quad, |
| 90 const gfx::Point& point_in_quad_space) { | 90 const gfx::Point& point_in_quad_space) { |
| 91 auto it = hittest_data_.find(surface_quad->surface_id); | 91 auto it = hittest_data_.find(surface_quad->surface_id); |
| 92 if (it != hittest_data_.end() && !it->second.ignored_for_hittest) | 92 if (it != hittest_data_.end() && !it->second.ignored_for_hittest) |
| 93 return true; | 93 return true; |
| 94 return false; | 94 return false; |
| 95 } | 95 } |
| 96 | 96 |
| 97 RenderWidgetHostInputEventRouter::RenderWidgetHostInputEventRouter() | 97 RenderWidgetHostInputEventRouter::RenderWidgetHostInputEventRouter() |
| 98 : active_touches_(0) {} | 98 : active_touches_(0), in_touchscreen_gesture_pinch_(false) {} |
| 99 | 99 |
| 100 RenderWidgetHostInputEventRouter::~RenderWidgetHostInputEventRouter() { | 100 RenderWidgetHostInputEventRouter::~RenderWidgetHostInputEventRouter() { |
| 101 // We may be destroyed before some of the owners in the map, so we must | 101 // We may be destroyed before some of the owners in the map, so we must |
| 102 // remove ourself from their observer lists. | 102 // remove ourself from their observer lists. |
| 103 ClearAllObserverRegistrations(); | 103 ClearAllObserverRegistrations(); |
| 104 } | 104 } |
| 105 | 105 |
| 106 RenderWidgetHostViewBase* RenderWidgetHostInputEventRouter::FindEventTarget( | 106 RenderWidgetHostViewBase* RenderWidgetHostInputEventRouter::FindEventTarget( |
| 107 RenderWidgetHostViewBase* root_view, | 107 RenderWidgetHostViewBase* root_view, |
| 108 const gfx::Point& point, | 108 const gfx::Point& point, |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 305 | 305 |
| 306 bubbling_gesture_scroll_target_.target = target_view; | 306 bubbling_gesture_scroll_target_.target = target_view; |
| 307 | 307 |
| 308 SendGestureScrollBegin(target_view, event); | 308 SendGestureScrollBegin(target_view, event); |
| 309 target_view->ProcessGestureEvent(event, ui::LatencyInfo()); | 309 target_view->ProcessGestureEvent(event, ui::LatencyInfo()); |
| 310 } | 310 } |
| 311 | 311 |
| 312 void RenderWidgetHostInputEventRouter::SendGestureScrollBegin( | 312 void RenderWidgetHostInputEventRouter::SendGestureScrollBegin( |
| 313 RenderWidgetHostViewBase* view, | 313 RenderWidgetHostViewBase* view, |
| 314 const blink::WebGestureEvent& event) { | 314 const blink::WebGestureEvent& event) { |
| 315 DCHECK(event.type == blink::WebInputEvent::GestureScrollUpdate); | 315 DCHECK(event.type == blink::WebInputEvent::GestureScrollUpdate || |
| 316 event.type == blink::WebInputEvent::GesturePinchBegin); | |
| 316 blink::WebGestureEvent scroll_begin(event); | 317 blink::WebGestureEvent scroll_begin(event); |
| 317 scroll_begin.type = blink::WebInputEvent::GestureScrollBegin; | 318 scroll_begin.type = blink::WebInputEvent::GestureScrollBegin; |
| 318 scroll_begin.data.scrollBegin.deltaXHint = event.data.scrollUpdate.deltaX; | 319 scroll_begin.data.scrollBegin.deltaXHint = event.data.scrollUpdate.deltaX; |
| 319 scroll_begin.data.scrollBegin.deltaYHint = event.data.scrollUpdate.deltaY; | 320 scroll_begin.data.scrollBegin.deltaYHint = event.data.scrollUpdate.deltaY; |
| 320 scroll_begin.data.scrollBegin.deltaHintUnits = | 321 scroll_begin.data.scrollBegin.deltaHintUnits = |
| 321 event.data.scrollUpdate.deltaUnits; | 322 event.data.scrollUpdate.deltaUnits; |
| 322 view->ProcessGestureEvent(scroll_begin, ui::LatencyInfo()); | 323 view->ProcessGestureEvent(scroll_begin, ui::LatencyInfo()); |
| 323 } | 324 } |
| 324 | 325 |
| 325 void RenderWidgetHostInputEventRouter::SendGestureScrollEnd( | 326 void RenderWidgetHostInputEventRouter::SendGestureScrollEnd( |
| 326 RenderWidgetHostViewBase* view, | 327 RenderWidgetHostViewBase* view, |
| 327 const blink::WebGestureEvent& event) { | 328 const blink::WebGestureEvent& event) { |
| 328 DCHECK(event.type == blink::WebInputEvent::GestureScrollUpdate); | 329 DCHECK(event.type == blink::WebInputEvent::GestureScrollUpdate || |
| 330 event.type == blink::WebInputEvent::GesturePinchEnd); | |
| 329 blink::WebGestureEvent scroll_end(event); | 331 blink::WebGestureEvent scroll_end(event); |
| 330 scroll_end.type = blink::WebInputEvent::GestureScrollEnd; | 332 scroll_end.type = blink::WebInputEvent::GestureScrollEnd; |
| 331 scroll_end.timeStampSeconds = | 333 scroll_end.timeStampSeconds = |
| 332 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(); | 334 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(); |
| 333 scroll_end.data.scrollEnd.inertialPhase = | 335 scroll_end.data.scrollEnd.inertialPhase = |
| 334 event.data.scrollUpdate.inertialPhase; | 336 event.data.scrollUpdate.inertialPhase; |
| 335 scroll_end.data.scrollEnd.deltaUnits = event.data.scrollUpdate.deltaUnits; | 337 scroll_end.data.scrollEnd.deltaUnits = event.data.scrollUpdate.deltaUnits; |
| 336 view->ProcessGestureEvent(scroll_end, ui::LatencyInfo()); | 338 view->ProcessGestureEvent(scroll_end, ui::LatencyInfo()); |
| 337 } | 339 } |
| 338 | 340 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 379 data.ignored_for_hittest = params.ignored_for_hittest; | 381 data.ignored_for_hittest = params.ignored_for_hittest; |
| 380 hittest_data_[params.surface_id] = data; | 382 hittest_data_[params.surface_id] = data; |
| 381 } | 383 } |
| 382 | 384 |
| 383 void RenderWidgetHostInputEventRouter::RouteTouchscreenGestureEvent( | 385 void RenderWidgetHostInputEventRouter::RouteTouchscreenGestureEvent( |
| 384 RenderWidgetHostViewBase* root_view, | 386 RenderWidgetHostViewBase* root_view, |
| 385 blink::WebGestureEvent* event, | 387 blink::WebGestureEvent* event, |
| 386 const ui::LatencyInfo& latency) { | 388 const ui::LatencyInfo& latency) { |
| 387 DCHECK_EQ(blink::WebGestureDeviceTouchscreen, event->sourceDevice); | 389 DCHECK_EQ(blink::WebGestureDeviceTouchscreen, event->sourceDevice); |
| 388 | 390 |
| 391 if (event->type == blink::WebInputEvent::GesturePinchBegin) { | |
| 392 in_touchscreen_gesture_pinch_ = true; | |
| 393 // If the root view wasn't already receiving the gesture stream, then we | |
| 394 // need to wrap the diverted pinch events in a GestureScrollBegin/End. | |
| 395 // TODO(wjmaclean,kenrb,tdresser): When scroll latching lands, we can | |
| 396 // revisit how this code should work. | |
|
kenrb
2016/07/27 21:49:49
nit: Add the bug number that this depends on, 5264
wjmaclean
2016/07/28 13:22:11
Done.
| |
| 397 if (root_view != touchscreen_gesture_target_.target) | |
| 398 SendGestureScrollBegin(root_view, *event); | |
| 399 } | |
| 400 | |
| 401 if (in_touchscreen_gesture_pinch_) { | |
| 402 root_view->ProcessGestureEvent(*event, latency); | |
| 403 if (event->type == blink::WebInputEvent::GesturePinchEnd) { | |
| 404 in_touchscreen_gesture_pinch_ = false; | |
| 405 // If the root view wasn't already receiving the gesture stream, then we | |
| 406 // need to wrap the diverted pinch events in a GestureScrollBegin/End. | |
| 407 if (root_view != touchscreen_gesture_target_.target) | |
| 408 SendGestureScrollEnd(root_view, *event); | |
| 409 } | |
| 410 return; | |
| 411 } | |
| 412 | |
| 389 // We use GestureTapDown to detect the start of a gesture sequence since there | 413 // We use GestureTapDown to detect the start of a gesture sequence since there |
| 390 // is no WebGestureEvent equivalent for ET_GESTURE_BEGIN. Note that this | 414 // is no WebGestureEvent equivalent for ET_GESTURE_BEGIN. Note that this |
| 391 // means the GestureFlingCancel that always comes between ET_GESTURE_BEGIN and | 415 // means the GestureFlingCancel that always comes between ET_GESTURE_BEGIN and |
| 392 // GestureTapDown is sent to the previous target, in case it is still in a | 416 // GestureTapDown is sent to the previous target, in case it is still in a |
| 393 // fling. | 417 // fling. |
| 394 if (event->type == blink::WebInputEvent::GestureTapDown) { | 418 if (event->type == blink::WebInputEvent::GestureTapDown) { |
| 395 if (touchscreen_gesture_target_queue_.empty()) { | 419 if (touchscreen_gesture_target_queue_.empty()) { |
| 396 LOG(ERROR) << "Gesture sequence start detected with no target available."; | 420 LOG(ERROR) << "Gesture sequence start detected with no target available."; |
| 397 // Ignore this gesture sequence as no target is available. | 421 // Ignore this gesture sequence as no target is available. |
| 398 // TODO(wjmaclean): this only happens on Windows, and should not happen. | 422 // TODO(wjmaclean): this only happens on Windows, and should not happen. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 438 if (!touchpad_gesture_target_.target) | 462 if (!touchpad_gesture_target_.target) |
| 439 return; | 463 return; |
| 440 | 464 |
| 441 // TODO(mohsen): Add tests to check event location. | 465 // TODO(mohsen): Add tests to check event location. |
| 442 event->x += touchpad_gesture_target_.delta.x(); | 466 event->x += touchpad_gesture_target_.delta.x(); |
| 443 event->y += touchpad_gesture_target_.delta.y(); | 467 event->y += touchpad_gesture_target_.delta.y(); |
| 444 touchpad_gesture_target_.target->ProcessGestureEvent(*event, latency); | 468 touchpad_gesture_target_.target->ProcessGestureEvent(*event, latency); |
| 445 } | 469 } |
| 446 | 470 |
| 447 } // namespace content | 471 } // namespace content |
| OLD | NEW |