haikuwebkit/LayoutTests/css3/scroll-snap/scroll-snap-wheel-event.html

81 lines
2.8 KiB
HTML
Raw Permalink Normal View History

Add basic (non-momentum) wheel event handling for scroll snap https://bugs.webkit.org/show_bug.cgi?id=222594 Reviewed by Darin Adler. Source/WebCore: Test: css3/scroll-snap/scroll-snap-wheel-event.html Enable scroll snapping for basic wheel events on GTK+ and WPE. The Mac port has special wheel handling due to momentum scrolling. Other scroll-snap-enabled ports can just use a basic version. * platform/ScrollAnimator.cpp: (WebCore::ScrollAnimator::scroll): Accept a bitmask of options now. This will allow using this method when handling wheel events that do not animate. (WebCore::ScrollAnimator::handleWheelEvent): Trigger ::scroll with scroll snapping enabled and pass the appropriate option to disable animations. (WebCore::ScrollAnimator::processWheelEventForScrollSnap): Deleted. * platform/ScrollAnimator.h: (WebCore::ScrollAnimator::ScrollAnimator::processWheelEventForScrollSnap): Made this a method that can be overridden by subclasses. * platform/mac/ScrollAnimatorMac.h: Added processWheelEventForScrollSnap. * platform/mac/ScrollAnimatorMac.mm: (WebCore::ScrollAnimatorMac::scroll): Pay attention to the NeverAnimate bitmask now. (WebCore::ScrollAnimatorMac::processWheelEventForScrollSnap): Added. LayoutTests: * css3/scroll-snap/scroll-snap-wheel-event-expected.txt: Added. * css3/scroll-snap/scroll-snap-wheel-event.html: Added. * platform/ios-wk2/TestExpectations: Skip new test because it uses mouse event simulation. Move existing classification to better section as well. * platform/mac-wk1/fast/scrolling/latching/scroll-snap-latching-expected.txt: Rebased this previous failing test. Canonical link: https://commits.webkit.org/236831@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276353 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-21 09:04:24 +00:00
<!DOCTYPE html>
<html>
<head>
<title>Simple wheel events should trigger scroll snapping</title>
<style type="text/css">
.container {
height: 200px;
width: 200px;
overflow: auto;
scroll-snap-type: both mandatory;
}
.horizontal-drawer {
height: 100%;
width: 500px;
}
.block {
height: 100%;
width: 200px;
scroll-snap-align: start;
}
</style>
<script src="../../resources/js-test.js"></script>
<script src="../../resources/ui-helper.js"></script>
<script>
window.jsTestIsAsync = true;
async function onLoad()
{
if (window.eventSender == undefined) {
document.getElementById('console').innerText = "Simple wheel events should trigger scroll snapping";
return;
}
try {
eventSender.mouseMoveTo(20, 190);
eventSender.mouseDown();
eventSender.mouseMoveTo(80, 190);
eventSender.mouseUp();
eventSender.mouseScrollBy(-1, 0);
let horizontalContainer = document.getElementById("horizontal-container");
await UIHelper.waitForTargetScrollAnimationToSettle(horizontalContainer);
expectTrue(horizontalContainer.scrollLeft == 200, "horizontal mouse wheel event snapped");
eventSender.mouseMoveTo(190, 220);
eventSender.mouseDown();
eventSender.mouseMoveTo(190, 270);
eventSender.mouseUp();
eventSender.mouseScrollBy(0, -1);
let verticalContainer = document.getElementById("vertical-container");
await UIHelper.waitForTargetScrollAnimationToSettle(verticalContainer);
expectTrue(verticalContainer.scrollTop == 185, "vertical mouse wheel event snapped");
} catch (e) {
console.log(e);
} finally {
finishJSTest();
}
}
</script>
</head>
<body onload="onLoad();">
<div id="horizontal-container" class="container">
<div class="horizontal-drawer">
<div class="block" style="float: left; background: #80475E"></div>
<div class="block" style="float: left; background: #CC5A71"></div>
</div>
</div>
<div id="vertical-container" class="container">
<div class="block" style="background: #80475E"></div>
<div class="block" style="background: #CC5A71"></div>
</div>
<p id="console"></p>
<script>
</script>
</body>
</html>