From 52a1e4ddb266e1b84a4cef1cc3f5fac39d6a9ffb Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Thu, 14 Jul 2022 02:19:11 +0000 Subject: [PATCH] Bug 1774537 - Call SetState with WEEL_SCROLL or KEYBOARD_SCROLL in the case of instant scoll. r=botond It will ensure an APZ:TransformEnd notification. Differential Revision: https://phabricator.services.mozilla.com/D149495 --- gfx/layers/apz/src/AsyncPanZoomController.cpp | 13 +++++ .../mochitest/apz_test_native_event_utils.js | 12 +++++ ...lper_transform_end_on_keyboard_scroll.html | 48 +++++++++++++++++++ .../helper_transform_end_on_wheel_scroll.html | 28 +++++++++++ .../test/mochitest/test_group_keyboard.html | 2 + .../mochitest/test_group_wheelevents.html | 2 + 6 files changed, 105 insertions(+) create mode 100644 gfx/layers/apz/test/mochitest/helper_transform_end_on_keyboard_scroll.html create mode 100644 gfx/layers/apz/test/mochitest/helper_transform_end_on_wheel_scroll.html diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index 4e4fa24f07e7..fdf67ff10146 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -2006,6 +2006,12 @@ nsEventStatus AsyncPanZoomController::OnKeyboard(const KeyboardInput& aEvent) { distance, ScrollSource::Keyboard); CallDispatchScroll(startPoint, endPoint, handoffState); + ParentLayerPoint remainingDelta = endPoint - startPoint; + if (remainingDelta != delta) { + // If any scrolling happened, set KEYBOARD_SCROLL explicitly so that it + // will trigger a TransformEnd notification. + SetState(KEYBOARD_SCROLL); + } SetState(NOTHING); @@ -2426,7 +2432,14 @@ nsEventStatus AsyncPanZoomController::OnScrollWheel( ParentLayerPoint startPoint = aEvent.mLocalOrigin; ParentLayerPoint endPoint = aEvent.mLocalOrigin - delta; RecordScrollPayload(aEvent.mTimeStamp); + CallDispatchScroll(startPoint, endPoint, handoffState); + ParentLayerPoint remainingDelta = endPoint - startPoint; + if (remainingDelta != delta) { + // If any scrolling happened, set KEYBOARD_SCROLL explicitly so that it + // will trigger a TransformEnd notification. + SetState(WHEEL_SCROLL); + } SetState(NOTHING); diff --git a/gfx/layers/apz/test/mochitest/apz_test_native_event_utils.js b/gfx/layers/apz/test/mochitest/apz_test_native_event_utils.js index ad907c16ddb8..f9fe89fc3504 100644 --- a/gfx/layers/apz/test/mochitest/apz_test_native_event_utils.js +++ b/gfx/layers/apz/test/mochitest/apz_test_native_event_utils.js @@ -77,6 +77,18 @@ function nativeArrowDownKey() { ); } +function nativeArrowUpKey() { + switch (getPlatform()) { + case "windows": + return WIN_VK_UP; + case "mac": + return MAC_VK_UpArrow; + } + throw new Error( + "Native key events not supported on platform " + getPlatform() + ); +} + // Given an event target which may be a window or an element, get the associated window. function windowForTarget(aTarget) { if (aTarget.Window && aTarget instanceof aTarget.Window) { diff --git a/gfx/layers/apz/test/mochitest/helper_transform_end_on_keyboard_scroll.html b/gfx/layers/apz/test/mochitest/helper_transform_end_on_keyboard_scroll.html new file mode 100644 index 000000000000..7eac1bea4057 --- /dev/null +++ b/gfx/layers/apz/test/mochitest/helper_transform_end_on_keyboard_scroll.html @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/gfx/layers/apz/test/mochitest/helper_transform_end_on_wheel_scroll.html b/gfx/layers/apz/test/mochitest/helper_transform_end_on_wheel_scroll.html new file mode 100644 index 000000000000..af4f72cf447c --- /dev/null +++ b/gfx/layers/apz/test/mochitest/helper_transform_end_on_wheel_scroll.html @@ -0,0 +1,28 @@ + + + + + + + + + + + diff --git a/gfx/layers/apz/test/mochitest/test_group_keyboard.html b/gfx/layers/apz/test/mochitest/test_group_keyboard.html index 07c16756f0c9..467607d6449c 100644 --- a/gfx/layers/apz/test/mochitest/test_group_keyboard.html +++ b/gfx/layers/apz/test/mochitest/test_group_keyboard.html @@ -38,6 +38,8 @@ var subtests = [ {"file": "helper_scroll_snap_on_page_down_scroll.html"}, {"file": "helper_scroll_snap_on_page_down_scroll.html", prefs: [["test.events.async.enabled", true]]}, + {"file": "helper_transform_end_on_keyboard_scroll.html", + prefs: [["general.smoothScroll", false]] }, ]; if (isKeyApzEnabled()) { diff --git a/gfx/layers/apz/test/mochitest/test_group_wheelevents.html b/gfx/layers/apz/test/mochitest/test_group_wheelevents.html index bcf3167cc8f1..3c6594558b35 100644 --- a/gfx/layers/apz/test/mochitest/test_group_wheelevents.html +++ b/gfx/layers/apz/test/mochitest/test_group_wheelevents.html @@ -58,6 +58,8 @@ var subtests = [ {"file": "helper_relative_scroll_smoothness.html?input-type=wheel&scroll-method=scrollBy", prefs: smoothness_prefs }, {"file": "helper_relative_scroll_smoothness.html?input-type=wheel&scroll-method=scrollTo", prefs: smoothness_prefs }, {"file": "helper_relative_scroll_smoothness.html?input-type=wheel&scroll-method=scrollTop", prefs: smoothness_prefs }, + {"file": "helper_transform_end_on_wheel_scroll.html", + prefs: [["general.smoothScroll", false]] }, ]; // Only Windows has the test api implemented for this test.