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
This commit is contained in:
Hiroyuki Ikezoe 2022-07-14 02:19:11 +00:00
Родитель d152ee99bf
Коммит 52a1e4ddb2
6 изменённых файлов: 105 добавлений и 0 удалений

Просмотреть файл

@ -2006,6 +2006,12 @@ nsEventStatus AsyncPanZoomController::OnKeyboard(const KeyboardInput& aEvent) {
distance, ScrollSource::Keyboard); distance, ScrollSource::Keyboard);
CallDispatchScroll(startPoint, endPoint, handoffState); 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); SetState(NOTHING);
@ -2426,7 +2432,14 @@ nsEventStatus AsyncPanZoomController::OnScrollWheel(
ParentLayerPoint startPoint = aEvent.mLocalOrigin; ParentLayerPoint startPoint = aEvent.mLocalOrigin;
ParentLayerPoint endPoint = aEvent.mLocalOrigin - delta; ParentLayerPoint endPoint = aEvent.mLocalOrigin - delta;
RecordScrollPayload(aEvent.mTimeStamp); RecordScrollPayload(aEvent.mTimeStamp);
CallDispatchScroll(startPoint, endPoint, handoffState); 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); SetState(NOTHING);

Просмотреть файл

@ -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. // Given an event target which may be a window or an element, get the associated window.
function windowForTarget(aTarget) { function windowForTarget(aTarget) {
if (aTarget.Window && aTarget instanceof aTarget.Window) { if (aTarget.Window && aTarget instanceof aTarget.Window) {

Просмотреть файл

@ -0,0 +1,48 @@
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<script src="apz_test_utils.js"></script>
<script src="apz_test_native_event_utils.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/NativeKeyCodes.js"></script>
<script src="/tests/SimpleTest/paint_listener.js"></script>
<style>
html, body { margin: 0; }
body {
height: 10000px;
}
</style>
<script>
async function test() {
// Send a native key event which doesn't cause any scroll, so that now
// subsequent native key events will be able to be handled by APZ. See bug
// 1774519 about what happens without this event.
const UpArrowKeyCode = nativeArrowUpKey();
await new Promise(resolve => {
synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US,
UpArrowKeyCode, {} /* no modifier */,
"", "", resolve); });
const transformEndPromise = promiseTransformEnd();
const DownArrowKeyCode = nativeArrowDownKey();
await new Promise(resolve => {
synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US,
DownArrowKeyCode, {} /* no modifier */,
"", "", resolve); });
await transformEndPromise;
ok(true, "Got an APZ:TransformEnd ");
}
if (getPlatform() == "mac" || getPlatform() == "windows") {
waitUntilApzStable()
.then(test)
.then(subtestDone, subtestFailed);
} else {
ok(true, "Skipping test because native key events are not supported on " +
getPlatform());
subtestDone();
}
</script>

Просмотреть файл

@ -0,0 +1,28 @@
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<script src="apz_test_utils.js"></script>
<script src="apz_test_native_event_utils.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/paint_listener.js"></script>
<style>
html, body { margin: 0; }
body {
height: 10000px;
}
</style>
<script>
async function test() {
let transformEndPromise = promiseTransformEnd();
await promiseMoveMouseAndScrollWheelOver(document.documentElement, 100, 100);
await transformEndPromise;
ok(true, "Got an APZ:TransformEnd ");
}
waitUntilApzStable()
.then(test)
.then(subtestDone, subtestFailed);
</script>

Просмотреть файл

@ -38,6 +38,8 @@ var subtests = [
{"file": "helper_scroll_snap_on_page_down_scroll.html"}, {"file": "helper_scroll_snap_on_page_down_scroll.html"},
{"file": "helper_scroll_snap_on_page_down_scroll.html", {"file": "helper_scroll_snap_on_page_down_scroll.html",
prefs: [["test.events.async.enabled", true]]}, prefs: [["test.events.async.enabled", true]]},
{"file": "helper_transform_end_on_keyboard_scroll.html",
prefs: [["general.smoothScroll", false]] },
]; ];
if (isKeyApzEnabled()) { if (isKeyApzEnabled()) {

Просмотреть файл

@ -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=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=scrollTo", prefs: smoothness_prefs },
{"file": "helper_relative_scroll_smoothness.html?input-type=wheel&scroll-method=scrollTop", 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. // Only Windows has the test api implemented for this test.