haikuwebkit/LayoutTests/css3/scroll-snap/scroll-padding-overflow-pag...

90 lines
3.1 KiB
HTML
Raw Permalink Normal View History

scroll-padding should affect paging operations https://bugs.webkit.org/show_bug.cgi?id=219074 <rdar://problem/71747786> Patch by Martin Robinson <mrobinson@igalia.com> on 2021-01-25 Reviewed by Simon Fraser. Source/WebCore: Have scroll-padding affect the amount of the scrollable area that moves during paging operations. This is the behavior specified in the scroll snap specification and allows scrollable areas with partially obscured areas to properly page through their content. See https://drafts.csswg.org/css-scroll-snap-1/#propdef-scroll-padding. Tests: css3/scroll-snap/scroll-padding-mainframe-paging.html css3/scroll-snap/scroll-padding-overflow-paging.html * page/FrameView.cpp: (WebCore::FrameView::updateScrollbarSteps): Added this override method which properly sets page steps. Only FrameView has access to the document. * page/FrameView.h: * platform/ScrollView.cpp: (WebCore::ScrollView::updateScrollbars): Added this helper method, which is virtual so that FrameView can override it. (WebCore::ScrollView::updateScrollbarSteps): Use the helper method to actually set the scrollbar steps. * platform/ScrollView.h: Add new method declarations. * rendering/RenderBox.cpp: (WebCore::RenderBox::scrollPaddingForViewportRect): Add this new helper which gets the scroll-padding for a box. * rendering/RenderBox.h: Add new helper. * rendering/RenderLayer.cpp: (WebCore::expandScrollRectToVisibleTargetRectToIncludeScrollPadding): Use the new RenderBox helper. (WebCore::RenderLayer::updateScrollbarsAfterLayout): Use the new updateScrollbarSteps helper. (WebCore::RenderLayer::updateScrollbarSteps): Added this helper so that RenderLayerModelObject can update steps when necessary. * rendering/RenderLayer.h: Added new declarations. * rendering/RenderLayerModelObject.cpp: (WebCore::RenderLayerModelObject::styleDidChange): Update steps on FrameViews and RenderLayers when the style change dictates it. LayoutTests: * css3/scroll-snap/scroll-padding-mainframe-paging-expected.txt: Added. * css3/scroll-snap/scroll-padding-mainframe-paging.html: Added. * css3/scroll-snap/scroll-padding-overflow-paging-expected.txt: Added. * css3/scroll-snap/scroll-padding-overflow-paging.html: Added. * platform/ios-wk2/TestExpectations: Skip failing tests. * platform/mac-wk1/TestExpectations: Skip failing tests. Canonical link: https://commits.webkit.org/233294@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@271788 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-01-25 09:45:47 +00:00
<!DOCTYPE html>
<html>
<head>
<style>
.box {
width: 200px;
height: 200px;
}
.gallery {
overflow: scroll;
}
</style>
<script src="../../resources/js-test.js"></script>
<script src="../../resources/ui-helper.js"></script>
<script>
window.jsTestIsAsync = true;
function clickOnElement(targetElement) {
var clientRect = targetElement.getBoundingClientRect();
eventSender.mouseMoveTo(clientRect.x + 5, clientRect.y + 5);
eventSender.mouseDown();
}
async function runTests()
{
try {
var container = document.getElementById("container");
clickOnElement(container);
await UIHelper.keyDown("pageDown");
expectTrue(container.scrollTop != 0, "paging moved container");
let defaultPagePosition = container.scrollTop;
let pageProportion = container.scrollTop / container.clientHeight;
container.scrollTop = 0;
container.style.scrollPaddingTop = "10px";
await UIHelper.keyDown("pageDown");
let expected = (container.clientHeight - 10) * pageProportion;
expectTrue(container.scrollTop != 0, "paging moved padded container");
shouldBeCloseTo("container.scrollTop", expected, 1);
container.scrollTop = 0;
container.style.scrollPaddingTop = "0px";
container.style.scrollPaddingBottom = "10px";
await UIHelper.keyDown("pageDown");
expectTrue(container.scrollTop != 0, "paging moved padded container");
shouldBeCloseTo("container.scrollTop", expected, 1);
container.scrollTop = 0;
container.style.scrollPaddingTop = "10px";
container.style.scrollPaddingBottom = "10px";
await UIHelper.keyDown("pageDown");
expected = (container.clientHeight - 20) * pageProportion;
expectTrue(container.scrollTop != 0, "paging moved padded container");
shouldBeCloseTo("container.scrollTop", expected, 1);
} catch (e) {
console.log(e);
} finally {
finishJSTest();
}
}
function onLoad()
{
if (window.eventSender) {
runTests();
} else {
var console = document.getElementById('console');
console.innerText = "This test cannot be run manually."
}
}
</script>
</head>
<body onload="onLoad();">
<div id="console"></div>
<div id="container" class="box" style="overflow: scroll;">
<div class="box" style="background: green;"></div>
<div class="box" style="background: red;"></div>
<div class="box" style="background: pink;"></div>
<div class="box" style="background: yellow;"></div>
<div class="box" style="background: orange;"></div>
</div>
</body>
</html>