mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-25 19:25:43 +00:00
Bug 1467556 [wpt PR 11383] - Allows panning inside overflowing snap areas., a=testonly
Automatic update from web-platform-testsAllows panning inside overflowing snap areas. According to the spec[1], if an overflowing snap area covers the snapport in one axis and the distance between the previous snap position and the next snap position is larger than the size of the snapport, the current scroll position is a valid snap position. This patch also rewrites the data structure of SnapAreaData and SnapContainerData so that they only keep the rect and calculate the snap points, visible region, overflow condition only when scroll occurs. [1] https://drafts.csswg.org/css-scroll-snap-1/#snap-overflow Bug: 826359 Cq-Include-Trybots: luci.chromium.try :android_optional_gpu_tests_rel;master.tryserver.blink:linux_trusty_blink_rel Change-Id: Iec1ebe48abe8d2653128ac2af4e6137a14c05502 Reviewed-on: https://chromium-review.googlesource.com/1075558 Commit-Queue: Sandra Sun <sunyunjia@chromium.org> Reviewed-by: David Bokan <bokan@chromium.org> Reviewed-by: Majid Valipour <majidvp@chromium.org> Cr-Commit-Position: refs/heads/master@{#570255} -- wpt-commits: 83c33634aaf8495aa9acfe40e4612c242c45c184 wpt-pr: 11383 MozReview-Commit-ID: JmozXZZQzzx
This commit is contained in:
parent
ade000d083
commit
0d50edb7c2
@ -320285,6 +320285,12 @@
|
||||
{}
|
||||
]
|
||||
],
|
||||
"css/css-scroll-snap/overflowing-snap-areas.html": [
|
||||
[
|
||||
"/css/css-scroll-snap/overflowing-snap-areas.html",
|
||||
{}
|
||||
]
|
||||
],
|
||||
"css/css-scroll-snap/scroll-snap-type-proximity.html": [
|
||||
[
|
||||
"/css/css-scroll-snap/scroll-snap-type-proximity.html",
|
||||
@ -528142,12 +528148,16 @@
|
||||
"d6432e3ad547c16ead21070cc04278b13ec49b58",
|
||||
"support"
|
||||
],
|
||||
"css/css-scroll-snap/overflowing-snap-areas.html": [
|
||||
"d290c9e941ee860e1d7f16e40c60c9f9696788c8",
|
||||
"testharness"
|
||||
],
|
||||
"css/css-scroll-snap/scroll-snap-type-proximity.html": [
|
||||
"75bfc0b6c7686afbbf431e653ab674496ad3fe46",
|
||||
"testharness"
|
||||
],
|
||||
"css/css-scroll-snap/scrollTo-scrollBy-snaps.html": [
|
||||
"6e921f3b1c54df09d594d5e450674618eee42143",
|
||||
"1cd26585c857250870a3cafdfa077110b7403e5c",
|
||||
"testharness"
|
||||
],
|
||||
"css/css-scroll-snap/snap-at-user-scroll-end-manual.html": [
|
||||
|
@ -0,0 +1,153 @@
|
||||
<!DOCTYPE html>
|
||||
<link rel="help" href="https://drafts.csswg.org/css-scroll-snap-1" />
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<style>
|
||||
div {
|
||||
position: absolute;
|
||||
}
|
||||
.scroller-x {
|
||||
overflow: scroll;
|
||||
scroll-snap-type: x mandatory;
|
||||
width: 500px;
|
||||
height: 500px;
|
||||
}
|
||||
.scroller-y {
|
||||
overflow: scroll;
|
||||
scroll-snap-type: y mandatory;
|
||||
width: 500px;
|
||||
height: 500px;
|
||||
}
|
||||
.space {
|
||||
width: 4000px;
|
||||
height: 4000px;
|
||||
}
|
||||
.target {
|
||||
scroll-snap-align: start;
|
||||
}
|
||||
.large-x {
|
||||
width: 3000px;
|
||||
height: 400px;
|
||||
background-color: yellow;
|
||||
}
|
||||
.large-y {
|
||||
width: 400px;
|
||||
height: 2000px;
|
||||
background-color: green;
|
||||
}
|
||||
.small {
|
||||
height: 200px;
|
||||
width: 200px;
|
||||
background-color: black;
|
||||
}
|
||||
</style>
|
||||
<div class="scroller-x" id="one-target">
|
||||
<div id="space"></div>
|
||||
<div class="large-x target" id="single" style="left: 200px;"></div>
|
||||
</div>
|
||||
|
||||
<div class="scroller-x" id="x">
|
||||
<div class="space"></div>
|
||||
<div style="left: 200px;">
|
||||
<div class="target large-x"></div>
|
||||
<div class="target small" style="left: 200px"></div>
|
||||
<div class="target small" style="left: 600px"></div>
|
||||
<div class="target small" style="left: 1200px"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="scroller-y" id="y">
|
||||
<div class="space"></div>
|
||||
<div style="top: 200px;">
|
||||
<div class="target large-y"></div>
|
||||
<div class="target small" style="top: 200px"></div>
|
||||
<div class="target small" style="top: 600px"></div>
|
||||
<div class="target small" style="top: 1200px"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="scroller-x" id="two-axes" style="scroll-snap-type: both mandatory">
|
||||
<div class="space"></div>
|
||||
<div class="target large-x" style="top: 200px"></div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var one_target_scroller = document.getElementById("one-target");
|
||||
var scroller_x = document.getElementById("x");
|
||||
var scroller_y = document.getElementById("y");
|
||||
var two_axes_scroller = document.getElementById("two-axes");
|
||||
|
||||
test(() => {
|
||||
one_target_scroller.scrollTo(10, 0);
|
||||
assert_equals(one_target_scroller.scrollLeft, 200);
|
||||
assert_equals(one_target_scroller.scrollTop, 0);
|
||||
}, "Snaps to the snap position if the snap area doesn't cover the snapport on x.");
|
||||
|
||||
test(() => {
|
||||
var right_align = 3200 - one_target_scroller.clientWidth;
|
||||
one_target_scroller.scrollTo(right_align, 0);
|
||||
assert_equals(one_target_scroller.scrollLeft, right_align);
|
||||
assert_equals(one_target_scroller.scrollTop, 0);
|
||||
}, "Snaps to the snap position if the snap area covers the snapport on x on the right border.");
|
||||
|
||||
// We use end alignment for this test so that we don't fall on a snap
|
||||
// position when the snap area just covers the snapport on the left border.
|
||||
test(() => {
|
||||
document.getElementById("single").style.scrollSnapAlign = 'end';
|
||||
one_target_scroller.scrollTo(200, 0);
|
||||
assert_equals(one_target_scroller.scrollLeft, 200);
|
||||
assert_equals(one_target_scroller.scrollTop, 0);
|
||||
}, "Snaps to the snap position if the snap area covers the snapport on x on the left border.");
|
||||
|
||||
test(() => {
|
||||
scroller_x.scrollTo(500, 0);
|
||||
assert_equals(scroller_x.scrollLeft, 400);
|
||||
assert_equals(scroller_x.scrollTop, 0);
|
||||
}, "Snaps if the distance between the previous(400) and next(800) " +
|
||||
"snap positions is smaller than snapport(500) on x.");
|
||||
|
||||
test(() => {
|
||||
scroller_y.scrollTo(0, 500);
|
||||
assert_equals(scroller_y.scrollLeft, 0);
|
||||
assert_equals(scroller_y.scrollTop, 400);
|
||||
}, "Snaps if the distance between the previous(400) and next(800) " +
|
||||
"snap positions is smaller than snapport(500) on y.");
|
||||
|
||||
test(() => {
|
||||
scroller_x.scrollTo(900, 0);
|
||||
assert_equals(scroller_x.scrollLeft, 900);
|
||||
assert_equals(scroller_x.scrollTop, 0);
|
||||
}, "Snap to current scroll position which is a valid snap position, " +
|
||||
"as the snap area covers snapport on x and the distance between the " +
|
||||
"previous(800) and next(1400) is larger than snapport(500).");
|
||||
|
||||
test(() => {
|
||||
scroller_y.scrollTo(0, 900);
|
||||
assert_equals(scroller_y.scrollLeft, 0);
|
||||
assert_equals(scroller_y.scrollTop, 900);
|
||||
}, "Snap to current scroll position which is a valid snap position, " +
|
||||
"as the snap area covers snapport on y and the distance between the " +
|
||||
"previous(800) and next(1400) is larger than snapport(500).");
|
||||
|
||||
test(() => {
|
||||
scroller_x.scrollTo(1500, 0);
|
||||
assert_equals(scroller_x.scrollLeft, 1500);
|
||||
assert_equals(scroller_x.scrollTop, 0);
|
||||
}, "Snap to current scroll position which is a valid snap position, as the " +
|
||||
"snap area covers snapport on x and there is no subsequent snap positions.");
|
||||
|
||||
test(() => {
|
||||
scroller_y.scrollTo(0, 1500);
|
||||
assert_equals(scroller_y.scrollLeft, 0);
|
||||
assert_equals(scroller_y.scrollTop, 1500);
|
||||
}, "Snap to current scroll position which is a valid snap position, as the " +
|
||||
"snap area covers snapport on y and there is no subsequent snap positions.");
|
||||
|
||||
test(() => {
|
||||
two_axes_scroller.scrollTo(10, 100);
|
||||
assert_equals(two_axes_scroller.scrollLeft, 10);
|
||||
assert_equals(two_axes_scroller.scrollTop, 200);
|
||||
}, "Snap to current scroll position on x as the area is covering x axis." +
|
||||
"However, we snap to the specified snap position on y as the area is not " +
|
||||
"covering y axis.");
|
||||
</script>
|
@ -8,41 +8,55 @@ body {
|
||||
overflow: scroll;
|
||||
scroll-snap-type: both mandatory;
|
||||
}
|
||||
div {
|
||||
position: absolute;
|
||||
}
|
||||
.scroller {
|
||||
overflow: scroll;
|
||||
scroll-snap-type: both mandatory;
|
||||
}
|
||||
#div-scroller {
|
||||
#inner-scroller {
|
||||
top: 3000px;
|
||||
width: 800px;
|
||||
height: 800px;
|
||||
}
|
||||
.content {
|
||||
.space {
|
||||
left: 0px;
|
||||
top: 0px;
|
||||
width: 2100px;
|
||||
height: 2100px;
|
||||
}
|
||||
.target {
|
||||
width: 1000px;
|
||||
height: 1000px;
|
||||
width: 600px;
|
||||
height: 600px;
|
||||
scroll-snap-align: start;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.left {
|
||||
left: 0px;
|
||||
}
|
||||
.right {
|
||||
left: 1000px;
|
||||
}
|
||||
.top {
|
||||
top: 0px;
|
||||
}
|
||||
.bottom {
|
||||
top: 1000px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<body class="scroller">
|
||||
<div class="content" id="content">
|
||||
<div class="target"></div>
|
||||
<div class="target"></div>
|
||||
<div class="target"></div>
|
||||
<div class="target"></div>
|
||||
</div>
|
||||
|
||||
<div class="scroller" id="div-scroller">
|
||||
<div class="content">
|
||||
<div class="target"></div>
|
||||
<div class="target"></div>
|
||||
<div class="target"></div>
|
||||
<div class="target"></div>
|
||||
</div>
|
||||
<div class="space"></div>
|
||||
<div class="target left top"></div>
|
||||
<div class="target right top"></div>
|
||||
<div class="target left bottom"></div>
|
||||
<div class="target right bottom"></div>
|
||||
<div class="scroller" id="inner-scroller">
|
||||
<div class="space"></div>
|
||||
<div class="target left top"></div>
|
||||
<div class="target right top"></div>
|
||||
<div class="target left bottom"></div>
|
||||
<div class="target right bottom"></div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
@ -55,7 +69,7 @@ function format_dict(dict) {
|
||||
return `{${props.join(', ')}}`;
|
||||
}
|
||||
|
||||
var divScroller = document.getElementById("div-scroller");
|
||||
var divScroller = document.getElementById("inner-scroller");
|
||||
var viewport = document.scrollingElement;
|
||||
[
|
||||
[{left: 800}, 1000, 0],
|
||||
@ -140,6 +154,4 @@ var viewport = document.scrollingElement;
|
||||
assert_equals(window.scrollY, expectedY);
|
||||
}, `scrollBy(${format_dict(input)}) on window lands on (${expectedX}, ${expectedY})`);
|
||||
});
|
||||
|
||||
document.body.removeChild(document.getElementById("content"));
|
||||
</script>
|
Loading…
Reference in New Issue
Block a user