Backed out changeset 4be195c46471 (bug 1756529) for causing mochitest failures in test_group_keyboard.html CLOSED TREE

This commit is contained in:
Cristian Tuns 2022-03-19 08:40:08 -04:00
Родитель b36728f0f1
Коммит b824530498
6 изменённых файлов: 12 добавлений и 277 удалений

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

@ -17,7 +17,6 @@
#include "mozilla/DefineEnum.h"
#include "mozilla/ScrollOrigin.h"
#include "mozilla/gfx/Point.h"
#include "mozilla/ScrollTypes.h"
namespace mozilla {
@ -68,12 +67,6 @@ gfx::IntSize GetDisplayportAlignmentMultiplier(const ScreenSize& aBaseSize);
ScrollAnimationBezierPhysicsSettings ComputeBezierAnimationSettingsForOrigin(
ScrollOrigin aOrigin);
/**
* Calculate if the scrolling should be instant or smooth based based on
* preferences and the origin
*/
ScrollMode GetScrollModeForOrigin(ScrollOrigin origin);
} // namespace apz
} // namespace layers

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

@ -87,25 +87,6 @@ ScrollAnimationBezierPhysicsSettings ComputeBezierAnimationSettingsForOrigin(
return ScrollAnimationBezierPhysicsSettings{minMS, maxMS, intervalRatio};
}
ScrollMode GetScrollModeForOrigin(ScrollOrigin origin) {
if (!StaticPrefs::general_smoothScroll()) return ScrollMode::Instant;
switch (origin) {
case ScrollOrigin::Lines:
return StaticPrefs::general_smoothScroll_lines() ? ScrollMode::Smooth
: ScrollMode::Instant;
case ScrollOrigin::Pages:
return StaticPrefs::general_smoothScroll_pages() ? ScrollMode::Smooth
: ScrollMode::Instant;
case ScrollOrigin::Other:
return StaticPrefs::general_smoothScroll_other() ? ScrollMode::Smooth
: ScrollMode::Instant;
default:
MOZ_ASSERT(false, "Unknown keyboard scroll origin");
return StaticPrefs::general_smoothScroll() ? ScrollMode::Smooth
: ScrollMode::Instant;
}
}
} // namespace apz
} // namespace layers
} // namespace mozilla

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

@ -69,7 +69,6 @@
#include "mozilla/layers/APZUtils.h" // for AsyncTransform
#include "mozilla/layers/CompositorController.h" // for CompositorController
#include "mozilla/layers/DirectionUtils.h" // for GetAxis{Start,End,Length,Scale}
#include "mozilla/layers/APZPublicUtils.h" // for GetScrollMode
#include "mozilla/mozalloc.h" // for operator new, etc
#include "mozilla/Unused.h" // for unused
#include "mozilla/FloatingPoint.h" // for FuzzyEquals*
@ -1949,15 +1948,12 @@ nsEventStatus AsyncPanZoomController::OnKeyboard(const KeyboardInput& aEvent) {
// Calculate the destination for this keyboard scroll action
CSSPoint destination = GetKeyboardDestination(aEvent.mAction);
ScrollOrigin scrollOrigin =
SmoothScrollAnimation::GetScrollOriginForAction(aEvent.mAction.mType);
bool scrollSnapped =
MaybeAdjustDestinationForScrollSnapping(aEvent, destination);
ScrollMode scrollMode = apz::GetScrollModeForOrigin(scrollOrigin);
RecordScrollPayload(aEvent.mTimeStamp);
// If the scrolling is instant, then scroll immediately to the destination
if (scrollMode == ScrollMode::Instant) {
// If smooth scrolling is disabled, then scroll immediately to the destination
if (!StaticPrefs::general_smoothScroll()) {
CancelAnimation();
ParentLayerPoint startPoint, endPoint;
@ -2010,8 +2006,9 @@ nsEventStatus AsyncPanZoomController::OnKeyboard(const KeyboardInput& aEvent) {
nsPoint initialPosition =
CSSPoint::ToAppUnits(Metrics().GetVisualScrollOffset());
StartAnimation(
new SmoothScrollAnimation(*this, initialPosition, scrollOrigin));
StartAnimation(new SmoothScrollAnimation(
*this, initialPosition,
SmoothScrollAnimation::GetScrollOriginForAction(aEvent.mAction.mType)));
}
// Convert velocity from ParentLayerPoints/ms to ParentLayerPoints/s and then

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

@ -1,214 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1756529
-->
<head>
<meta charset="utf-8">
<title>Page scrolling bug test, helper page</title>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript" src="apz_test_native_event_utils.js"></script>
<script type="application/javascript" src="apz_test_utils.js"></script>
<script src="/tests/SimpleTest/paint_listener.js"></script>
<script type="application/javascript">
// --------------------------------------------------------------------
// Page scrolling not smooth test
//
// This test checks that a page scroll respects general_smoothScroll_pages preference.
//
// The page contains a <div> that is large enough to make the page
// scrollable.
//
// We trigger the page scroll and then we wait to reach destination
// Expecting an instant scroll, we check that the scroll event is called once
// --------------------------------------------------------------------
const testData = [
{scrollOrigin: "page", smooth: false,
prefs: [["general.smoothScroll", true], ["general.smoothScroll.pages", false],
["general.smoothScroll.msdPhysics.enabled", true]]},
{scrollOrigin: "page", smooth: false,
prefs: [["general.smoothScroll", false], ["general.smoothScroll.pages", true],
["general.smoothScroll.msdPhysics.enabled", true]]},
{scrollOrigin: "page", smooth: true,
prefs: [["general.smoothScroll", true], ["general.smoothScroll.pages", true],
["general.smoothScroll.msdPhysics.enabled", true]]},
{scrollOrigin: "page", smooth: false,
prefs: [["general.smoothScroll", true], ["general.smoothScroll.pages", false],
["general.smoothScroll.msdPhysics.enabled", false]]},
{scrollOrigin: "page", smooth: false,
prefs: [["general.smoothScroll", false], ["general.smoothScroll.pages", true],
["general.smoothScroll.msdPhysics.enabled", false]]},
{scrollOrigin: "page", smooth: true,
prefs: [["general.smoothScroll", true], ["general.smoothScroll.pages", true],
["general.smoothScroll.msdPhysics.enabled", false]]},
// Origin:Line Scrolling tests
{scrollOrigin: "line", smooth: false,
prefs: [["general.smoothScroll", true], ["general.smoothScroll.lines", false],
["general.smoothScroll.msdPhysics.enabled", true]]},
{scrollOrigin: "line", smooth: false,
prefs: [["general.smoothScroll", false], ["general.smoothScroll.lines", true],
["general.smoothScroll.msdPhysics.enabled", true]]},
{scrollOrigin: "line", smooth: true,
prefs: [["general.smoothScroll", true], ["general.smoothScroll.lines", true],
["general.smoothScroll.msdPhysics.enabled", true]]},
{scrollOrigin: "line", smooth: false,
prefs: [["general.smoothScroll", true], ["general.smoothScroll.lines", false],
["general.smoothScroll.msdPhysics.enabled", false]]},
{scrollOrigin: "line", smooth: false,
prefs: [["general.smoothScroll", false], ["general.smoothScroll.lines", true],
["general.smoothScroll.msdPhysics.enabled", false]]},
{scrollOrigin: "line", smooth: true,
prefs: [["general.smoothScroll", true], ["general.smoothScroll.lines", true],
["general.smoothScroll.msdPhysics.enabled", false]]},
// Origin:Other Scrolling test
{scrollOrigin: "other", smooth: false,
prefs: [["general.smoothScroll", true], ["general.smoothScroll.other", false],
["general.smoothScroll.msdPhysics.enabled", true]]},
{scrollOrigin: "other", smooth: false,
prefs: [["general.smoothScroll", false], ["general.smoothScroll.other", true],
["general.smoothScroll.msdPhysics.enabled", true]]},
{scrollOrigin: "other", smooth: true,
prefs: [["general.smoothScroll", true], ["general.smoothScroll.other", true],
["general.smoothScroll.msdPhysics.enabled", true]]},
{scrollOrigin: "other", smooth: false,
prefs: [["general.smoothScroll", true], ["general.smoothScroll.other", false],
["general.smoothScroll.msdPhysics.enabled", false]]},
{scrollOrigin: "other", smooth: false,
prefs: [["general.smoothScroll", false], ["general.smoothScroll.other", true],
["general.smoothScroll.msdPhysics.enabled", false]]},
{scrollOrigin: "other", smooth: true,
prefs: [["general.smoothScroll", true], ["general.smoothScroll.other", true],
["general.smoothScroll.msdPhysics.enabled", false]]}];
async function test(data) {
/*
Test Data:
{
scrollOrigin: "page"|"other"|"line",
smooth: bool,
prefs: prefences
}
*/
const scrollOrigin = data.scrollOrigin;
const smooth = data.smooth;
const msdPhysics = data.prefs[2][1];
var SimpleTest = window.opener.SimpleTest;
let destination = 0;
let key = "";
switch (scrollOrigin){
case "page":
destination = document.scrollingElement.clientHeight * 0.8;
key = "KEY_PageDown";
break;
case "other":
destination = 40000; // Div is 50k
key = "KEY_End";
break;
case "line":
default:
destination = 50; // pref set to scroll by 5 lines
// line scroll amounts vary by platform but are
// in the 16-19px range
key = "KEY_ArrowDown";
}
await SpecialPowers.pushPrefEnv({ set: data.prefs });
SimpleTest.info(`Testing Scrolling preferences. [origin: ${scrollOrigin}; smooth: ${smooth}; msdPhysics: ${msdPhysics}; ${destination}]`);
// Send the synthesized key event, and wait until it arrives in the
// content process.
let keyPromise = promiseOneEvent(window, "keydown", null);
window.synthesizeKey(key);
await keyPromise;
// Take control of the refresh driver. It's important to do this
// as soon as the key event has arrived, to ensure that any compositor
// animation hasn't started yet. Otherwise, the compositor animation
// could start and get in multiple samples (potentially the entire
// animation) before the content process gets a chance to observe it,
// preventing us from distinguishing smooth scrolls from instant scrolls.
let utils = SpecialPowers.DOMWindowUtils;
utils.advanceTimeAndRefresh(0);
// Flush any pending paints. This gives a chance for any handoff of
// the scroll to APZ to occur.
await promiseAllPaintsDone();
// Tick the refresh driver manually until we detect that scrolling has
// started (scrollY > 0) and then stopped (scroll offset the same in
// two subsequent ticks).
let startedScroll = false;
let stoppedScroll = false;
let scrollCount = 0;
let prevScrollPos = window.scrollY;
while (!stoppedScroll) {
// Tick the refresh driver. This triggers a composite, so any
// compositor animation will be sampled. (Main thread animations
// will also be sampled.)
utils.advanceTimeAndRefresh(16);
// Flush APZ repaints to ensure that scroll offset changes from
// a compositor sample reach the content process.
await promiseApzFlushedRepaints();
// Track the number of ticks in which the scroll offset changed.
let scrollPos = window.scrollY;
if (startedScroll && scrollPos == prevScrollPos) {
stoppedScroll = true;
break;
}
if (!startedScroll && scrollPos > 0) {
startedScroll = true;
}
if (startedScroll) {
scrollCount++;
}
prevScrollPos = scrollPos;
}
SimpleTest.info(`Scrolled to ${window.scrollY}`);
// Relinquish control of the refresh driver.
utils.restoreNormalRefresh();
SimpleTest.ok(window.scrollY >= destination, `The page did not scroll [origin: ${scrollOrigin}, smooth: ${smooth}]`);
if (smooth)
SimpleTest.ok(scrollCount > 1,
`Scrolled only once, but expecting a smooth transtion [origin: ${scrollOrigin}; msdPhysics: ${msdPhysics}]`);
else
SimpleTest.is(scrollCount, 1,
`Scrolled more than once, but expecting an instant scroll [origin: ${scrollOrigin}; msdPhysics: ${msdPhysics}]`);
// Synthesize a touch tap to cancel the animation if it's still in-progress.
// (scrollTo() does not do this as of bug 1692708, it adjusts the destination
// of the animation by a relative delta).
await synthesizeNativeTap(window, 50, 50);
await promiseApzFlushedRepaints();
// Reset scroll position for next case.
window.scrollTo(0, 0);
await promiseApzFlushedRepaints();
SimpleTest.is(0, window.scrollY, `Expected to be scrolled to origin, actually scrolled to ${window.scrollY}`)
}
async function runTests() {
for (i = 0; i < testData.length; i++){
await test(testData[i]);
}
}
waitUntilApzStable()
.then(runTests)
.then(subtestDone, subtestFailed);
</script>
</head>
<body style="height: 10000px; overflow: scroll;">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1756529">SmoothScrollPage not honored with MSD physics bug.</a>
<!-- Put enough content into the page to make it have a nonzero scroll range -->
<div style="height: 50000px;">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Tellus in metus vulputate eu. Vestibulum morbi blandit cursus risus at ultrices mi tempus imperdiet. Congue quisque egestas diam in. Pretium vulputate sapien nec sagittis aliquam malesuada bibendum arcu. Eleifend mi in nulla posuere. Proin libero nunc consequat interdum varius. Risus pretium quam vulputate dignissim suspendisse in est. Lacus vel facilisis volutpat est. Donec pretium vulputate sapien nec. Feugiat sed lectus vestibulum mattis. Platea dictumst quisque sagittis purus. Vulputate eu scelerisque felis imperdiet proin fermentum leo vel. Enim facilisis gravida neque convallis a cras semper auctor. Placerat orci nulla pellentesque dignissim enim sit.</p>
<p>Augue neque gravida in fermentum et sollicitudin ac. Mattis enim ut tellus elementum sagittis vitae et. Malesuada nunc vel risus commodo viverra maecenas accumsan. Viverra nibh cras pulvinar mattis nunc sed. Lectus nulla at volutpat diam ut venenatis tellus in. Non tellus orci ac auctor. Magna etiam tempor orci eu lobortis. Malesuada nunc vel risus commodo viverra maecenas accumsan lacus vel. Sagittis orci a scelerisque purus. Tellus pellentesque eu tincidunt tortor. Vulputate dignissim suspendisse in est ante in. Tristique et egestas quis ipsum suspendisse. Quisque egestas diam in arcu cursus. Massa massa ultricies mi quis hendrerit dolor magna eget. Mattis nunc sed blandit libero volutpat sed. Consectetur purus ut faucibus pulvinar elementum integer enim.</p>
<p>Vestibulum lorem sed risus ultricies tristique nulla. Imperdiet nulla malesuada pellentesque elit eget gravida. Feugiat nisl pretium fusce id velit ut tortor pretium. Commodo ullamcorper a lacus vestibulum sed arcu non odio. Id nibh tortor id aliquet lectus proin nibh nisl condimentum. Amet volutpat consequat mauris nunc congue nisi vitae suscipit tellus. Neque ornare aenean euismod elementum. Semper quis lectus nulla at. Massa sed elementum tempus egestas. Praesent elementum facilisis leo vel fringilla est ullamcorper eget nulla. Pellentesque elit eget gravida cum sociis natoque penatibus et. Massa enim nec dui nunc mattis enim. Laoreet suspendisse interdum consectetur libero id faucibus nisl. Fusce ut placerat orci nulla.</p>
<p>Vitae tempus quam pellentesque nec nam aliquam. Vestibulum mattis ullamcorper velit sed ullamcorper morbi tincidunt ornare. Nam libero justo laoreet sit amet. Arcu non sodales neque sodales. Nec ultrices dui sapien eget mi proin sed. Parturient montes nascetur ridiculus mus mauris vitae ultricies. Lacus sed viverra tellus in hac habitasse. Orci phasellus egestas tellus rutrum. Leo a diam sollicitudin tempor id eu nisl. Diam phasellus vestibulum lorem sed risus ultricies tristique nulla. Lectus nulla at volutpat diam ut venenatis tellus in. Cursus metus aliquam eleifend mi in nulla. Et ultrices neque ornare aenean euismod. Sit amet aliquam id diam maecenas ultricies mi. Volutpat diam ut venenatis tellus in metus vulputate eu.</p>
<p>Pellentesque elit ullamcorper dignissim cras tincidunt. Morbi tincidunt augue interdum velit euismod. Diam vel quam elementum pulvinar etiam non quam. Eget duis at tellus at urna. Posuere ac ut consequat semper viverra nam libero justo laoreet. Ac turpis egestas maecenas pharetra convallis posuere. Ultrices tincidunt arcu non sodales neque sodales ut etiam sit. In eu mi bibendum neque egestas. Pellentesque sit amet porttitor eget dolor morbi. Ac tortor dignissim convallis aenean et tortor at. Elementum tempus egestas sed sed risus pretium quam. Nisi scelerisque eu ultrices vitae auctor eu augue. Urna duis convallis convallis tellus id interdum velit laoreet id. Auctor eu augue ut lectus arcu bibendum at varius vel.</p>
</div>
</body>
</html>

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

@ -22,17 +22,6 @@ var smoothness_prefs = [
["general.smoothScroll.lines.durationMinMS", 1500]
];
var bug1756529_prefs= [
// Increase distance of line scroll (units here are "number of lines") so
// that a smooth scroll animation reliably takes multiple frames.
["toolkit.scrollbox.verticalScrollDistance", 5],
// The test performs a single-tap gesture between test cases to cancel the
// animation from the previous test case. For test cases that run fast (e.g.
// instant scrolling), two single-taps could occur close enough in succession
// that they get interpreted as a double-tap.
["apz.allow_double_tap_zooming", false]
];
var subtests = [
{"file": "helper_key_scroll.html", prefs: [["apz.test.logging_enabled", true],
["test.events.async.enabled", true]]},
@ -44,13 +33,7 @@ var subtests = [
{"file": "helper_relative_scroll_smoothness.html?input-type=native-key&scroll-method=scrollTo",
prefs: smoothness_prefs },
{"file": "helper_relative_scroll_smoothness.html?input-type=native-key&scroll-method=scrollTop",
prefs: smoothness_prefs },
// Run helper_bug1756529.html twice, first exercising the main-thread keyboard
// scrolling codepaths (e.g. PresShell::ScrollPage()), and once exercising the
// APZ keyboard scrolling codepaths.
{"file": "helper_bug1756529.html", prefs: bug1756529_prefs},
{"file": "helper_bug1756529.html", prefs: [...bug1756529_prefs,
["test.events.async.enabled", true]]},
prefs: smoothness_prefs }
];
if (isKeyApzEnabled()) {

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

@ -187,7 +187,6 @@
#include "mozilla/layers/WebRenderLayerManager.h"
#include "mozilla/layers/WebRenderUserData.h"
#include "mozilla/layout/ScrollAnchorContainer.h"
#include "mozilla/layers/APZPublicUtils.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/ProfilerMarkers.h"
#include "mozilla/ScrollTypes.h"
@ -2381,10 +2380,9 @@ NS_IMETHODIMP
PresShell::ScrollPage(bool aForward) {
nsIScrollableFrame* scrollFrame =
GetScrollableFrameToScroll(VerticalScrollDirection);
ScrollMode scrollMode = apz::GetScrollModeForOrigin(ScrollOrigin::Pages);
if (scrollFrame) {
scrollFrame->ScrollBy(
nsIntPoint(0, aForward ? 1 : -1), ScrollUnit::PAGES, scrollMode,
nsIntPoint(0, aForward ? 1 : -1), ScrollUnit::PAGES, ScrollMode::Smooth,
nullptr, mozilla::ScrollOrigin::NotSpecified,
nsIScrollableFrame::NOT_MOMENTUM, nsIScrollableFrame::ENABLE_SNAP);
}
@ -2395,14 +2393,13 @@ NS_IMETHODIMP
PresShell::ScrollLine(bool aForward) {
nsIScrollableFrame* scrollFrame =
GetScrollableFrameToScroll(VerticalScrollDirection);
ScrollMode scrollMode = apz::GetScrollModeForOrigin(ScrollOrigin::Lines);
if (scrollFrame) {
int32_t lineCount =
Preferences::GetInt("toolkit.scrollbox.verticalScrollDistance",
NS_DEFAULT_VERTICAL_SCROLL_DISTANCE);
scrollFrame->ScrollBy(
nsIntPoint(0, aForward ? lineCount : -lineCount), ScrollUnit::LINES,
scrollMode, nullptr, mozilla::ScrollOrigin::NotSpecified,
ScrollMode::Smooth, nullptr, mozilla::ScrollOrigin::NotSpecified,
nsIScrollableFrame::NOT_MOMENTUM, nsIScrollableFrame::ENABLE_SNAP);
}
return NS_OK;
@ -2412,15 +2409,14 @@ NS_IMETHODIMP
PresShell::ScrollCharacter(bool aRight) {
nsIScrollableFrame* scrollFrame =
GetScrollableFrameToScroll(HorizontalScrollDirection);
ScrollMode scrollMode = apz::GetScrollModeForOrigin(ScrollOrigin::Lines);
if (scrollFrame) {
int32_t h =
Preferences::GetInt("toolkit.scrollbox.horizontalScrollDistance",
NS_DEFAULT_HORIZONTAL_SCROLL_DISTANCE);
scrollFrame->ScrollBy(
nsIntPoint(aRight ? h : -h, 0), ScrollUnit::LINES, scrollMode, nullptr,
mozilla::ScrollOrigin::NotSpecified, nsIScrollableFrame::NOT_MOMENTUM,
nsIScrollableFrame::ENABLE_SNAP);
nsIntPoint(aRight ? h : -h, 0), ScrollUnit::LINES, ScrollMode::Smooth,
nullptr, mozilla::ScrollOrigin::NotSpecified,
nsIScrollableFrame::NOT_MOMENTUM, nsIScrollableFrame::ENABLE_SNAP);
}
return NS_OK;
}
@ -2429,10 +2425,9 @@ NS_IMETHODIMP
PresShell::CompleteScroll(bool aForward) {
nsIScrollableFrame* scrollFrame =
GetScrollableFrameToScroll(VerticalScrollDirection);
ScrollMode scrollMode = apz::GetScrollModeForOrigin(ScrollOrigin::Other);
if (scrollFrame) {
scrollFrame->ScrollBy(
nsIntPoint(0, aForward ? 1 : -1), ScrollUnit::WHOLE, scrollMode,
nsIntPoint(0, aForward ? 1 : -1), ScrollUnit::WHOLE, ScrollMode::Smooth,
nullptr, mozilla::ScrollOrigin::NotSpecified,
nsIScrollableFrame::NOT_MOMENTUM, nsIScrollableFrame::ENABLE_SNAP);
}