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

Side by Side Diff: content/browser/renderer_host/render_widget_host_input_event_router.cc

Issue 2193033003: Cancel browser process scroll bubbling when new gestures start (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed indent Created 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/site_per_process_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 FindEventTarget(root_view, original_point, &transformed_point); 203 FindEventTarget(root_view, original_point, &transformed_point);
204 204
205 // TODO(wjmaclean): Instead of just computing a delta, we should extract 205 // TODO(wjmaclean): Instead of just computing a delta, we should extract
206 // the complete transform. We assume it doesn't change for the duration 206 // the complete transform. We assume it doesn't change for the duration
207 // of the touch sequence, though this could be wrong; a better approach 207 // of the touch sequence, though this could be wrong; a better approach
208 // might be to always transform each point to the |touch_target_.target| 208 // might be to always transform each point to the |touch_target_.target|
209 // for the duration of the sequence. 209 // for the duration of the sequence.
210 touch_target_.delta = transformed_point - original_point; 210 touch_target_.delta = transformed_point - original_point;
211 touchscreen_gesture_target_queue_.push_back(touch_target_); 211 touchscreen_gesture_target_queue_.push_back(touch_target_);
212 212
213 if (!touch_target_.target) 213 if (!touch_target_.target) {
214 return; 214 return;
215 } else if (touch_target_.target ==
216 bubbling_gesture_scroll_target_.target) {
217 SendGestureScrollEnd(bubbling_gesture_scroll_target_.target,
218 blink::WebGestureEvent());
219 CancelScrollBubbling(bubbling_gesture_scroll_target_.target);
220 }
215 } 221 }
222
216 ++active_touches_; 223 ++active_touches_;
217 if (touch_target_.target) { 224 if (touch_target_.target) {
218 TransformEventTouchPositions(event, touch_target_.delta); 225 TransformEventTouchPositions(event, touch_target_.delta);
219 touch_target_.target->ProcessTouchEvent(*event, latency); 226 touch_target_.target->ProcessTouchEvent(*event, latency);
220 } 227 }
221 break; 228 break;
222 } 229 }
223 case blink::WebInputEvent::TouchMove: 230 case blink::WebInputEvent::TouchMove:
224 if (touch_target_.target) { 231 if (touch_target_.target) {
225 TransformEventTouchPositions(event, touch_target_.delta); 232 TransformEventTouchPositions(event, touch_target_.delta);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 if (target_view == bubbling_gesture_scroll_target_.target) { 290 if (target_view == bubbling_gesture_scroll_target_.target) {
284 bubbling_gesture_scroll_target_.target->ProcessGestureEvent( 291 bubbling_gesture_scroll_target_.target->ProcessGestureEvent(
285 event, ui::LatencyInfo()); 292 event, ui::LatencyInfo());
286 return; 293 return;
287 } 294 }
288 295
289 // If target_view has unrelated gesture events in progress, do 296 // If target_view has unrelated gesture events in progress, do
290 // not proceed. This could cause confusion between independent 297 // not proceed. This could cause confusion between independent
291 // scrolls. 298 // scrolls.
292 if (target_view == touchscreen_gesture_target_.target || 299 if (target_view == touchscreen_gesture_target_.target ||
293 target_view == touchpad_gesture_target_.target) 300 target_view == touchpad_gesture_target_.target ||
301 target_view == touch_target_.target)
294 return; 302 return;
295 303
296 // This accounts for bubbling through nested OOPIFs. A gesture scroll has 304 // This accounts for bubbling through nested OOPIFs. A gesture scroll has
297 // been bubbled but the target has sent back a gesture scroll event ack with 305 // been bubbled but the target has sent back a gesture scroll event ack with
298 // unused scroll delta, and so another level of bubbling is needed. This 306 // unused scroll delta, and so another level of bubbling is needed. This
299 // requires a GestureScrollEnd be sent to the last view, which will no 307 // requires a GestureScrollEnd be sent to the last view, which will no
300 // longer be the scroll target. 308 // longer be the scroll target.
301 if (bubbling_gesture_scroll_target_.target) 309 if (bubbling_gesture_scroll_target_.target)
302 SendGestureScrollEnd(bubbling_gesture_scroll_target_.target, event); 310 SendGestureScrollEnd(bubbling_gesture_scroll_target_.target, event);
303 else 311 else
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 // Ignore this gesture sequence as no target is available. 405 // Ignore this gesture sequence as no target is available.
398 // TODO(wjmaclean): this only happens on Windows, and should not happen. 406 // TODO(wjmaclean): this only happens on Windows, and should not happen.
399 // https://crbug.com/595422 407 // https://crbug.com/595422
400 touchscreen_gesture_target_.target = nullptr; 408 touchscreen_gesture_target_.target = nullptr;
401 base::debug::DumpWithoutCrashing(); 409 base::debug::DumpWithoutCrashing();
402 return; 410 return;
403 } 411 }
404 412
405 touchscreen_gesture_target_ = touchscreen_gesture_target_queue_.front(); 413 touchscreen_gesture_target_ = touchscreen_gesture_target_queue_.front();
406 touchscreen_gesture_target_queue_.pop_front(); 414 touchscreen_gesture_target_queue_.pop_front();
415
416 // Abort any scroll bubbling in progress to avoid double entry.
417 if (touchscreen_gesture_target_.target &&
418 touchscreen_gesture_target_.target ==
419 bubbling_gesture_scroll_target_.target) {
420 SendGestureScrollEnd(bubbling_gesture_scroll_target_.target,
421 blink::WebGestureEvent());
422 CancelScrollBubbling(bubbling_gesture_scroll_target_.target);
423 }
407 } 424 }
408 425
409 if (!touchscreen_gesture_target_.target) 426 if (!touchscreen_gesture_target_.target)
410 return; 427 return;
411 428
412 // TODO(mohsen): Add tests to check event location. 429 // TODO(mohsen): Add tests to check event location.
413 event->x += touchscreen_gesture_target_.delta.x(); 430 event->x += touchscreen_gesture_target_.delta.x();
414 event->y += touchscreen_gesture_target_.delta.y(); 431 event->y += touchscreen_gesture_target_.delta.y();
415 touchscreen_gesture_target_.target->ProcessGestureEvent(*event, latency); 432 touchscreen_gesture_target_.target->ProcessGestureEvent(*event, latency);
416 } 433 }
417 434
418 void RenderWidgetHostInputEventRouter::RouteTouchpadGestureEvent( 435 void RenderWidgetHostInputEventRouter::RouteTouchpadGestureEvent(
419 RenderWidgetHostViewBase* root_view, 436 RenderWidgetHostViewBase* root_view,
420 blink::WebGestureEvent* event, 437 blink::WebGestureEvent* event,
421 const ui::LatencyInfo& latency) { 438 const ui::LatencyInfo& latency) {
422 DCHECK_EQ(blink::WebGestureDeviceTouchpad, event->sourceDevice); 439 DCHECK_EQ(blink::WebGestureDeviceTouchpad, event->sourceDevice);
423 440
424 if (event->type == blink::WebInputEvent::GesturePinchBegin || 441 if (event->type == blink::WebInputEvent::GesturePinchBegin ||
425 event->type == blink::WebInputEvent::GestureFlingStart) { 442 event->type == blink::WebInputEvent::GestureFlingStart) {
426 gfx::Point transformed_point; 443 gfx::Point transformed_point;
427 gfx::Point original_point(event->x, event->y); 444 gfx::Point original_point(event->x, event->y);
428 touchpad_gesture_target_.target = 445 touchpad_gesture_target_.target =
429 FindEventTarget(root_view, original_point, &transformed_point); 446 FindEventTarget(root_view, original_point, &transformed_point);
430 // TODO(mohsen): Instead of just computing a delta, we should extract the 447 // TODO(mohsen): Instead of just computing a delta, we should extract the
431 // complete transform. We assume it doesn't change for the duration of the 448 // complete transform. We assume it doesn't change for the duration of the
432 // touchpad gesture sequence, though this could be wrong; a better approach 449 // touchpad gesture sequence, though this could be wrong; a better approach
433 // might be to always transform each point to the 450 // might be to always transform each point to the
434 // |touchpad_gesture_target_.target| for the duration of the sequence. 451 // |touchpad_gesture_target_.target| for the duration of the sequence.
435 touchpad_gesture_target_.delta = transformed_point - original_point; 452 touchpad_gesture_target_.delta = transformed_point - original_point;
453
454 // Abort any scroll bubbling in progress to avoid double entry.
455 if (touchpad_gesture_target_.target &&
456 touchpad_gesture_target_.target ==
457 bubbling_gesture_scroll_target_.target) {
458 SendGestureScrollEnd(bubbling_gesture_scroll_target_.target,
459 blink::WebGestureEvent());
460 CancelScrollBubbling(bubbling_gesture_scroll_target_.target);
461 }
436 } 462 }
437 463
438 if (!touchpad_gesture_target_.target) 464 if (!touchpad_gesture_target_.target)
439 return; 465 return;
440 466
441 // TODO(mohsen): Add tests to check event location. 467 // TODO(mohsen): Add tests to check event location.
442 event->x += touchpad_gesture_target_.delta.x(); 468 event->x += touchpad_gesture_target_.delta.x();
443 event->y += touchpad_gesture_target_.delta.y(); 469 event->y += touchpad_gesture_target_.delta.y();
444 touchpad_gesture_target_.target->ProcessGestureEvent(*event, latency); 470 touchpad_gesture_target_.target->ProcessGestureEvent(*event, latency);
445 } 471 }
446 472
447 } // namespace content 473 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/site_per_process_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698