Skip to content

Commit a2dbce6

Browse files
author
Sahel Sharify
committed
Reland "Fling bubbles from OOPIF properly" without the tests.
This cl relands the following cl after excluding the added tests. https://chromium-review.googlesource.com/c/chromium/src/+/1278963 This gives the solution more time to bake on ToT without getting reverted due to flaky tests. Meanwhile I will work on the tests to deflake them. [email protected],[email protected] Bug: 884728, 249063 Change-Id: Icc1e32ffe493f85d0ee74b0aff37ccdf078d0e8f Reviewed-on: https://chromium-review.googlesource.com/c/1281687 Commit-Queue: Charlie Reis <[email protected]> Reviewed-by: Kevin McNee <[email protected]> Reviewed-by: Charlie Reis <[email protected]> Cr-Original-Commit-Position: refs/heads/master@{#599781}(cherry picked from commit abad218) Reviewed-on: https://chromium-review.googlesource.com/c/1284066 Reviewed-by: Sahel Sharify <[email protected]> Cr-Commit-Position: refs/branch-heads/3578@{#55} Cr-Branched-From: 4226ddf-refs/heads/master@{#599034}
1 parent f39c9f7 commit a2dbce6

File tree

4 files changed

+61
-4
lines changed

4 files changed

+61
-4
lines changed

content/browser/frame_host/cross_process_frame_connector.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,8 @@ void CrossProcessFrameConnector::BubbleScrollEvent(
279279
DCHECK(event.GetType() == blink::WebInputEvent::kGestureScrollBegin ||
280280
event.GetType() == blink::WebInputEvent::kGestureScrollUpdate ||
281281
event.GetType() == blink::WebInputEvent::kGestureScrollEnd ||
282-
event.GetType() == blink::WebInputEvent::kGestureFlingStart);
282+
event.GetType() == blink::WebInputEvent::kGestureFlingStart ||
283+
event.GetType() == blink::WebInputEvent::kGestureFlingCancel);
283284
auto* parent_view = GetParentRenderWidgetHostView();
284285

285286
if (!parent_view)
@@ -302,7 +303,9 @@ void CrossProcessFrameConnector::BubbleScrollEvent(
302303
if (event.GetType() == blink::WebInputEvent::kGestureScrollBegin) {
303304
event_router->BubbleScrollEvent(parent_view, resent_gesture_event, view_);
304305
is_scroll_bubbling_ = true;
305-
} else if (is_scroll_bubbling_) {
306+
} else if (is_scroll_bubbling_ ||
307+
event.GetType() == blink::WebInputEvent::kGestureFlingCancel) {
308+
// For GFC events the router decides whether to bubble them or not.
306309
event_router->BubbleScrollEvent(parent_view, resent_gesture_event, view_);
307310
}
308311
if (event.GetType() == blink::WebInputEvent::kGestureScrollEnd ||

content/browser/renderer_host/render_widget_host_input_event_router.cc

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,9 @@ void RenderWidgetHostInputEventRouter::OnRenderWidgetHostViewBaseDestroyed(
293293
if (view == last_fling_start_target_)
294294
last_fling_start_target_ = nullptr;
295295

296+
if (view == last_fling_start_bubbled_target_)
297+
last_fling_start_bubbled_target_ = nullptr;
298+
296299
event_targeter_->ViewWillBeDestroyed(view);
297300
}
298301

@@ -1001,7 +1004,8 @@ void RenderWidgetHostInputEventRouter::BubbleScrollEvent(
10011004
DCHECK(event.GetType() == blink::WebInputEvent::kGestureScrollBegin ||
10021005
event.GetType() == blink::WebInputEvent::kGestureScrollUpdate ||
10031006
event.GetType() == blink::WebInputEvent::kGestureScrollEnd ||
1004-
event.GetType() == blink::WebInputEvent::kGestureFlingStart);
1007+
event.GetType() == blink::WebInputEvent::kGestureFlingStart ||
1008+
event.GetType() == blink::WebInputEvent::kGestureFlingCancel);
10051009

10061010
ui::LatencyInfo latency_info =
10071011
ui::WebInputEventTraits::CreateLatencyInfoForWebGestureEvent(event);
@@ -1030,7 +1034,26 @@ void RenderWidgetHostInputEventRouter::BubbleScrollEvent(
10301034
}
10311035

10321036
bubbling_gesture_scroll_target_.target = target_view;
1037+
} else if (event.GetType() == blink::WebInputEvent::kGestureFlingCancel) {
1038+
// TODO(828422): Remove once this issue no longer occurs.
1039+
if (resending_view == last_fling_start_bubbled_target_) {
1040+
ReportBubblingScrollToSameView(event, resending_view);
1041+
last_fling_start_bubbled_target_ = nullptr;
1042+
return;
1043+
}
1044+
// GFC event must get bubbled to the same target view that the last GFS has
1045+
// been bubbled.
1046+
if (last_fling_start_bubbled_target_) {
1047+
last_fling_start_bubbled_target_->ProcessGestureEvent(
1048+
GestureEventInTarget(event, last_fling_start_bubbled_target_),
1049+
latency_info);
1050+
last_fling_start_bubbled_target_ = nullptr;
1051+
}
1052+
return;
10331053
} else { // !(event.GetType() == blink::WebInputEvent::kGestureScrollBegin)
1054+
// && !(event.GetType() ==
1055+
// blink::WebInputEvent::kGestureFlingCancel)
1056+
10341057
if (!bubbling_gesture_scroll_target_.target) {
10351058
// The GestureScrollBegin event is not bubbled, don't bubble the rest of
10361059
// the scroll events.
@@ -1062,6 +1085,12 @@ void RenderWidgetHostInputEventRouter::BubbleScrollEvent(
10621085
bubbling_gesture_scroll_target_.target->ProcessGestureEvent(
10631086
GestureEventInTarget(event, bubbling_gesture_scroll_target_.target),
10641087
latency_info);
1088+
1089+
// The GFC should be sent to the view that handles the GFS.
1090+
if (event.GetType() == blink::WebInputEvent::kGestureFlingStart) {
1091+
last_fling_start_bubbled_target_ = bubbling_gesture_scroll_target_.target;
1092+
}
1093+
10651094
if (event.GetType() == blink::WebInputEvent::kGestureScrollEnd ||
10661095
event.GetType() == blink::WebInputEvent::kGestureFlingStart) {
10671096
first_bubbling_scroll_target_.target = nullptr;

content/browser/renderer_host/render_widget_host_input_event_router.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,12 @@ class CONTENT_EXPORT RenderWidgetHostInputEventRouter
308308
// Tracked for the purpose of targeting subsequent fling cancel events.
309309
RenderWidgetHostViewBase* last_fling_start_target_ = nullptr;
310310

311+
// During scroll bubbling we bubble the GFS to the target view so that its
312+
// fling controller takes care of flinging. In this case we should also send
313+
// the GFC to the bubbling target so that the fling controller currently in
314+
// charge of the fling progress could handle the fling cancellelation as well.
315+
RenderWidgetHostViewBase* last_fling_start_bubbled_target_ = nullptr;
316+
311317
// Tracked for the purpose of providing a root_view when dispatching emulated
312318
// touch/gesture events.
313319
RenderWidgetHostViewBase* last_emulated_event_root_view_;

content/browser/renderer_host/render_widget_host_view_child_frame.cc

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,24 @@ void RenderWidgetHostViewChildFrame::GestureEventAck(
527527
ack_result == INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS ||
528528
ack_result == INPUT_EVENT_ACK_STATE_CONSUMED_SHOULD_BUBBLE;
529529

530+
// The inertial events on Mac should still get bubbled since there is no GFS to
531+
// bubble and the inertial events are received from the OS.
532+
#if !defined(OS_MACOSX)
533+
// When a GFS is bubbled, we still send it to the fling controller of the
534+
// child view to finish the scroll sequence. However the GSU and GSE events
535+
// that are generated by the child view's fling controller do not need to get
536+
// bubbled since the GFS event itself is bubbled and the target's fling
537+
// controller will take care of flinging.
538+
if ((event.GetType() == blink::WebInputEvent::kGestureScrollEnd &&
539+
event.data.scroll_end.inertial_phase ==
540+
blink::WebGestureEvent::kMomentumPhase) ||
541+
(event.GetType() == blink::WebInputEvent::kGestureScrollUpdate &&
542+
event.data.scroll_update.inertial_phase ==
543+
blink::WebGestureEvent::kMomentumPhase)) {
544+
return;
545+
}
546+
#endif // defined(OS_MACOSX)
547+
530548
if ((event.GetType() == blink::WebInputEvent::kGestureScrollBegin) &&
531549
should_bubble) {
532550
DCHECK(!is_scroll_sequence_bubbling_);
@@ -545,7 +563,8 @@ void RenderWidgetHostViewChildFrame::GestureEventAck(
545563
should_bubble) ||
546564
event.GetType() == blink::WebInputEvent::kGestureScrollUpdate ||
547565
event.GetType() == blink::WebInputEvent::kGestureScrollEnd ||
548-
event.GetType() == blink::WebInputEvent::kGestureFlingStart) {
566+
event.GetType() == blink::WebInputEvent::kGestureFlingStart ||
567+
event.GetType() == blink::WebInputEvent::kGestureFlingCancel) {
549568
frame_connector_->BubbleScrollEvent(event);
550569
}
551570
}

0 commit comments

Comments
 (0)