Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Choose closest covering position for large snap areas
This patch modifies the logic to find snap positions so that when a scroller is scrolled to a position which only partially covers a snap area larger than itself, if it snaps to this large snap area, it snaps to the nearest boundary of that snap area where the snap area covers the snap port, rather than doing a jump to honor the specified scroll-snap-align. Below are a few notes about changes made to tests: snap-area-overflow-boundary.html is corrected so that both test cases correctly verify the scroll offset when snapped to the lower element. The scroll amount in the second test case is also adjusted to ensure it is enough to snap to the lower div. The expectations at the end of scroll-on-large-element-not-covering-snapport.tentative.html are updated to account for choosing a snap position different from the scroll-snap-align-specified position for snap areas larger than their snapports. scroll-snap-type-on-root-element.html is updated to account for scrollbar width since snapping to the right edge of the target is valid. This patch picks new programmatic scroll offsets for snap-to-visible-areas-margin-both.html so that the top-left of intersection of the right-top and left-bottom targets' scroll-margins is closer than the bottom-right of the intersection. scrollend-with-snap-on-fractional-offset.html and scroll-start-with-scroll-snap-tentative.html are adjusted to use snap area sizes that don't cover the snap port. (cherry picked from commit 0295a2c) Bug: 1420762 Change-Id: I72d18b8ca44ea5aef015e59b67e4de34a66d8a1e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4806971 Reviewed-by: Robert Flack <flackr@chromium.org> Commit-Queue: David Awogbemila <awogbemila@chromium.org> Cr-Original-Commit-Position: refs/heads/main@{#1193634} Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4853949 Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Auto-Submit: David Awogbemila <awogbemila@chromium.org> Reviewed-by: Steve Kobes <skobes@chromium.org> Commit-Queue: Steve Kobes <skobes@chromium.org> Cr-Commit-Position: refs/branch-heads/5993@{#188} Cr-Branched-From: 5113507-refs/heads/main@{#1192594}
- Loading branch information
David Awogbemila
authored and
Chromium LUCI CQ
committed
Sep 12, 2023
1 parent
023392d
commit 799e733
Showing
15 changed files
with
181 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 0 additions & 5 deletions
5
...web_tests/external/wpt/css/css-scroll-snap/input/snap-area-overflow-boundary-expected.txt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
...arty/blink/web_tests/external/wpt/css/css-scroll-snap/overflowing-snap-areas-expected.txt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
third_party/blink/web_tests/external/wpt/css/css-scroll-snap/snap-into-covering-area.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<link rel="help" href="https://drafts.csswg.org/css-scroll-snap-1/#scroll-snap-type" /> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/resources/testdriver.js"></script> | ||
<script src="/resources/testdriver-actions.js"></script> | ||
<script src="/resources/testdriver-vendor.js"></script> | ||
<script src="/dom/events/scrolling/scroll_support.js"></script> | ||
</head> | ||
|
||
<body> | ||
<style> | ||
#scroller { | ||
overflow: scroll; | ||
height: 500px; | ||
width: 500px; | ||
background-color: blue; | ||
scroll-snap-type: y mandatory; | ||
position: absolute; | ||
} | ||
|
||
.snap_point { | ||
scroll-snap-align: start; | ||
width: 40%; | ||
position: relative; | ||
left: 30%; | ||
} | ||
|
||
.big { | ||
height: 1000%; | ||
background-color: pink; | ||
border: solid 1px red; | ||
} | ||
|
||
.small { | ||
height: 50%; | ||
background-color: purple; | ||
border: solid 1px black; | ||
} | ||
</style> | ||
<div id="scroller"> | ||
<div class="big snap_point" id="big_snap_point"></div> | ||
<div class="small snap_point"> | ||
<button id="scrollerButton">scrollerButton</button> | ||
</div> | ||
</div> | ||
<script> | ||
promise_test(async(t) => { | ||
const x = scroller.clientWidth / 2; | ||
const y = scroller.clientHeight / 2; | ||
|
||
// Scroll all the way down to the smaller snap area which doesn't cover | ||
// the snapport. | ||
let scrollend_promise = new Promise((resolve) => { | ||
scroller.addEventListener("scrollend", resolve); | ||
}); | ||
scroller.scrollTop = scroller.scrollHeight; | ||
await scrollend_promise; | ||
|
||
// Scroll up with one press of the arrow-up button. | ||
scrollend_promise = new Promise((resolve) => { | ||
scroller.addEventListener("scrollend", resolve); | ||
}); | ||
const arrowUp = '\uE013'; | ||
await test_driver.send_keys(scrollerButton, arrowUp); | ||
|
||
await scrollend_promise; | ||
assert_equals(scroller.scrollTop, big_snap_point.offsetHeight - scroller.clientHeight, | ||
"scroller is snapped to the bottom of the larger snap area, not the top"); | ||
}); | ||
</script> | ||
</body> | ||
|
||
</html> |
Oops, something went wrong.