haikuwebkit/LayoutTests/css3/scroll-snap/scroll-snap-2d-offsets-comp...

82 lines
2.5 KiB
HTML
Raw Permalink Normal View History

Scroll Snap broken when using RTL layout https://bugs.webkit.org/show_bug.cgi?id=193671 <rdar://problem/47457471> Reviewed by Wenson Hsieh. Source/WebCore: There were various places in the scroll snapping code which confused scroll offsets (zero-based) with scroll positions (relative to scroll origin, can be negative). This broke snapping in `direction: rtl` content. The computation of snap locations in updateSnapOffsetsForScrollableArea() was also broken in RTL; we need to snap the right edge of boxes to the right edge of the scroller for the 'start' alignment. (Snapping for LTR boxes in an RTL scroller is poorly defined; for now, follow Gecko.) Tests: css3/scroll-snap/scroll-snap-2d-change-axis-type-rtl.html css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.rtl.html css3/scroll-snap/scroll-snap-elements-container-larger-than-children-rtl.html css3/scroll-snap/scroll-snap-iframe-rtl.html css3/scroll-snap/scroll-snap-offsets-mixed-rtl.html css3/scroll-snap/scroll-snap-offsets-rtl.html * page/scrolling/AxisScrollSnapOffsets.cpp: (WebCore::computeScrollSnapAlignOffset): (WebCore::updateSnapOffsetsForScrollableArea): * page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm: (WebCore::ScrollingTreeScrollingNodeDelegateMac::scrollOffset const): * platform/ScrollAnimator.cpp: (WebCore::ScrollAnimator::updateActiveScrollSnapIndexForOffset): (WebCore::ScrollAnimator::scrollOffset const): * platform/cocoa/ScrollController.mm: (WebCore::ScrollController::updateScrollSnapPoints): Source/WebKit: There were various places in the scroll snapping code which confused scroll offsets (zero-based) with scroll positions (relative to scroll origin, can be negative). This broke snapping in `direction: rtl` content. The computation of snap locations in updateSnapOffsetsForScrollableArea() was also broken in RTL; we need to snap the right edge of boxes to the right edge of the scroller for the 'start' alignment. (Snapping for LTR boxes in an RTL scroller is poorly defined; for now, follow Gecko.) * Shared/RemoteLayerTree/RemoteScrollingCoordinatorTransaction.cpp: (WebKit::dump): * UIProcess/API/ios/WKWebViewIOS.mm: (-[WKWebView _updateVisibleContentRects]): * UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.h: * UIProcess/RemoteLayerTree/ios/RemoteScrollingCoordinatorProxyIOS.mm: (WebKit::RemoteScrollingCoordinatorProxy::shouldSnapForMainFrameScrolling const): (WebKit::RemoteScrollingCoordinatorProxy::closestSnapOffsetForMainFrameScrolling const): (WebKit::RemoteScrollingCoordinatorProxy::hasActiveSnapPoint const): (WebKit::RemoteScrollingCoordinatorProxy::nearestActiveContentInsetAdjustedSnapOffset const): (WebKit::RemoteScrollingCoordinatorProxy::nearestActiveContentInsetAdjustedSnapPoint const): Deleted. LayoutTests: * css3/scroll-snap/resources/iframe-content-rtl.html: Added. * css3/scroll-snap/scroll-snap-2d-change-axis-type-rtl-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-change-axis-type-rtl.html: Copied from LayoutTests/css3/scroll-snap/scroll-snap-2d-change-axis-type.html. * css3/scroll-snap/scroll-snap-2d-change-axis-type.html: * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html: * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.rtl-expected.txt: Added. * css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.rtl.html: Copied from LayoutTests/css3/scroll-snap/scroll-snap-2d-offsets-computed-independently.html. * css3/scroll-snap/scroll-snap-elements-container-larger-than-children-rtl-expected.txt: Added. * css3/scroll-snap/scroll-snap-elements-container-larger-than-children-rtl.html: Copied from LayoutTests/css3/scroll-snap/scroll-snap-elements-container-larger-than-children.html. * css3/scroll-snap/scroll-snap-elements-container-larger-than-children.html: * css3/scroll-snap/scroll-snap-iframe-rtl-expected.txt: Added. * css3/scroll-snap/scroll-snap-iframe-rtl.html: Added. * css3/scroll-snap/scroll-snap-offsets-mixed-rtl-expected.txt: Added. * css3/scroll-snap/scroll-snap-offsets-mixed-rtl.html: Added. * css3/scroll-snap/scroll-snap-offsets-rtl-expected.txt: Added. * css3/scroll-snap/scroll-snap-offsets-rtl.html: Added. * fast/scrolling/home-end-keys-scroll-in-rtl-document-expected.txt: Added. Canonical link: https://commits.webkit.org/227631@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@264908 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-07-27 02:03:46 +00:00
<!DOCTYPE HTML>
<html>
<head>
<style>
#container {
position: absolute;
direction: rtl;
width: 400px;
height: 400px;
overflow: auto;
scroll-snap-type: both mandatory;
left: 0px;
top: 0px;
margin: 0;
padding: 0;
}
::-webkit-scrollbar {
display: none;
}
.cell {
width: 400px;
height: 400px;
margin: 0px;
padding: 0px;
position: absolute;
}
#top-left {
scroll-snap-align: end;
}
#middle {
scroll-snap-align: center;
}
#bottom-right {
scroll-snap-align: start;
}
.green {
background-color: green;
}
.red {
background-color: red;
}
</style>
<script src="../../resources/js-test.js"></script>
<script>
function run() {
jsTestIsAsync = true;
if (!window.testRunner || !window.internals) {
debug(`To manually test, verify that scrolling in the container snaps so that each colored box can fill
the scroll container.`);
return;
}
setTimeout(() => {
debug(`The scroll offsets are: ${internals.scrollSnapOffsets(container)}`);
finishJSTest();
}, 0);
}
</script>
</head>
<body onload=run()>
<div id="container">
<div style="top: 0px; left: 0px;" class="cell green" id="top-left"></div>
<div style="top: 0px; left: -400px;" class="cell red"></div>
<div style="top: 0px; left: -800px;" class="cell green"></div><br/>
<div style="top: 400px; left: 0px;" class="cell red"></div>
<div style="top: 400px; left: -400px;" class="cell green" id="middle"></div>
<div style="top: 400px; left: -800px;" class="cell red"></div><br/>
<div style="top: 800px; left: 0px;" class="cell green"></div>
<div style="top: 800px; left: -400px;" class="cell red"></div>
<div style="top: 800px; left: -800px;" class="cell green" id="bottom-right"></div>
</div>
<div id="output"></div>
</body>
</html>