diff options
Diffstat (limited to 'testing/web-platform/tests/css/css-scroll-snap/snap-after-initial-layout')
9 files changed, 828 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-scroll-snap/snap-after-initial-layout/direction-rtl.html b/testing/web-platform/tests/css/css-scroll-snap/snap-after-initial-layout/direction-rtl.html new file mode 100644 index 0000000000..85724c31fe --- /dev/null +++ b/testing/web-platform/tests/css/css-scroll-snap/snap-after-initial-layout/direction-rtl.html @@ -0,0 +1,51 @@ +<!DOCTYPE html> +<title> + Scrollers should snap to the closest snap point on initial layout (using 'direction: rtl') +</title> +<link rel="help" href="https://drafts.csswg.org/css-scroll-snap/#re-snap" /> +<link rel="match" href="snap-after-initial-layout-ref.html" /> +<style> +div { + position: absolute; + margin: 0; +} + +#scroller { + height: 500px; + width: 500px; + overflow: hidden; + scroll-snap-type: both mandatory; + direction: rtl; +} + +#close-target { + width: 200px; + height: 200px; + border: solid green 50px; + top: 50px; + right: 150px; + margin: 50px; + background-color: green; + scroll-snap-align: start; +} + +#far-target { + width: 300px; + height: 300px; + top: 100px; + right: 700px; + background-color: red; + scroll-snap-align: start; +} + +.area { + width: 2000px; + height: 2000px; +} +</style> + +<div id="scroller"> + <div class="area"></div> + <div id="close-target"></div> + <div id="far-target"></div> +</div> diff --git a/testing/web-platform/tests/css/css-scroll-snap/snap-after-initial-layout/scroll-snap-initial-layout-000-ref.html b/testing/web-platform/tests/css/css-scroll-snap/snap-after-initial-layout/scroll-snap-initial-layout-000-ref.html new file mode 100644 index 0000000000..f3eaa06ac9 --- /dev/null +++ b/testing/web-platform/tests/css/css-scroll-snap/snap-after-initial-layout/scroll-snap-initial-layout-000-ref.html @@ -0,0 +1,81 @@ +<!DOCTYPE html> +<title> + CSS Scroll Snap Reference +</title> +<style> + +.scroller { + width: 100px; + height: 100px; + border: solid blue; + margin: 10px; + display: inline-block; +} + +.scroller > div { + width: 30px; + height: 30px; + background: orange; +} + +.proxfar { + border-color: orange; +} + +</style> + +<p>Test passes if there is an orange square precisely at the top left corner of each blue box (no gap), +and each orange box is empty. + + +<div class="mandatory"> + <div class="scroller"> + <div></div> + </div> + + <div class="scroller"> + <div></div> + </div> + + <div class="scroller"> + <div></div> + </div> + + <!-- on-screen --> + <div class="scroller"> + <div></div> + </div> + + <div class="scroller"> + <div></div> + </div> + + <div class="scroller"> + <div></div> + </div> +</div> + +<div class="proximity"> + <!-- off-screen --> + <div class="scroller proxfar"> + </div> + + <div class="scroller proxfar"> + </div> + + <div class="scroller proxfar"> + </div> + + <!-- on-screen --> + <div class="scroller"> + <div></div> + </div> + + <div class="scroller"> + <div></div> + </div> + + <div class="scroller"> + <div></div> + </div> +</div> diff --git a/testing/web-platform/tests/css/css-scroll-snap/snap-after-initial-layout/scroll-snap-initial-layout-000.html b/testing/web-platform/tests/css/css-scroll-snap/snap-after-initial-layout/scroll-snap-initial-layout-000.html new file mode 100644 index 0000000000..ea47c9f36c --- /dev/null +++ b/testing/web-platform/tests/css/css-scroll-snap/snap-after-initial-layout/scroll-snap-initial-layout-000.html @@ -0,0 +1,113 @@ +<!DOCTYPE html> +<title> + On-screen vs. Off-screen Snapped Initial Scroll Position (Mandatory and Proximity) +</title> +<link rel="help" href="https://drafts.csswg.org/css-scroll-snap-1/#scroll-snap-align"> +<link rel="help" href="https://drafts.csswg.org/css-scroll-snap/#re-snap"> +<link rel="author" title="Elika J. Etemad" href="http://fantasai.inkedblade.net/contact"> +<!-- Test assumes 2px proximity is enough to snap. + If your implementation has a cogent argument as to why this is too much, + please request a change to this test. ~fantasai --> +<link rel="match" href="scroll-snap-initial-layout-000-ref.html"> + +<style> + +.scroller { + scroll-snap-type: both mandatory; + overflow: hidden; + scroll-padding: 0; + width: 100px; + height: 100px; + border: solid blue; + margin: 10px; + display: inline-block; +} + +.mandatory > .scroller { + scroll-snap-type: both mandatory; +} + +.proximity > .scroller { + scroll-snap-type: both proximity; +} + +.scroller > div { + /* padding wrapper */ + width: 30px; +} + +.scroller > div > div { + /* target box */ + height: 30px; + background: orange; + scroll-snap-align: start; +} + +.proxfar { + border-color: orange; +} +.proxfar > div > div { + background: red; +} + +</style> + +<p>Test passes if there is an orange square precisely at the top left corner of each blue box (no gap), +and each orange box is empty. + + +<div class="mandatory"> + <!-- off-screen --> + <div class="scroller"> + <div style="padding: 110px;"><div class="small-target"></div></div> + </div> + + <div class="scroller"> + <div style="padding-block: 110px;"><div class="small-target"></div></div> + </div> + + <div class="scroller"> + <div style="padding-inline: 110px;"><div class="small-target"></div></div> + </div> + + <!-- on-screen --> + <div class="scroller"> + <div style="padding: 90px;"><div class="small-target"></div></div> + </div> + + <div class="scroller"> + <div style="padding-block: 90px;"><div class="small-target"></div></div> + </div> + + <div class="scroller"> + <div style="padding-inline: 90px;"><div class="small-target"></div></div> + </div> +</div> + +<div class="proximity"> + <!-- off-screen --> + <div class="scroller proxfar"> + <div style="padding: 110px;"><div class="small-target"></div></div> + </div> + + <div class="scroller proxfar"> + <div style="padding-block: 110px;"><div class="small-target"></div></div> + </div> + + <div class="scroller proxfar"> + <div style="padding-inline: 110px;"><div class="small-target"></div></div> + </div> + + <!-- on-screen --> + <div class="scroller"> + <div style="padding: 2px 110px 110px 2px;"><div class="small-target"></div></div> + </div> + + <div class="scroller"> + <div style="padding: 2px 110px 110px 2px;"><div class="small-target"></div></div> + </div> + + <div class="scroller"> + <div style="padding: 2px 110px 110px 2px;"><div class="small-target"></div></div> + </div> +</div> diff --git a/testing/web-platform/tests/css/css-scroll-snap/snap-after-initial-layout/scroll-snap-writing-mode-000-ref.html b/testing/web-platform/tests/css/css-scroll-snap/snap-after-initial-layout/scroll-snap-writing-mode-000-ref.html new file mode 100644 index 0000000000..26b622e718 --- /dev/null +++ b/testing/web-platform/tests/css/css-scroll-snap/snap-after-initial-layout/scroll-snap-writing-mode-000-ref.html @@ -0,0 +1,167 @@ +<!DOCTYPE html> +<title> + CSS Scroll Snap Reference +</title> + +<style> + +.wrapper { + /* lay out in a nice grid */ + display: grid; + gap: 0.25em; + grid-template-columns: repeat(6, max-content); +} + +.scroller { + width: 50px; + height: 50px; + border: solid silver; + border-block-start-color: blue; + border-inline-start-color: blue; + position: relative; +} + +.target { + width: 30px; + height: 30px; + background: orange; + top: 0; left: 0; right: 0; bottom: 0; + position: absolute; +} + +.TB { writing-mode: horizontal-tb; } +.LR { writing-mode: vertical-lr; } +.RL { writing-mode: vertical-rl; } +.ltr { direction: ltr; } +.rtl { direction: rtl; } + +.TB.large.invert .target { top: auto; } +.LR.large.invert .target { left: auto; } +.RL.large.invert .target { right: auto; } + +.TB.ltr.large.invert .target { left: auto; } +.TB.rtl.large.invert .target { right: auto; } +.LR.ltr.large.invert .target { top: auto; } +.LR.rtl.large.invert .target { bottom: auto; } +.RL.ltr.large.invert .target { top: auto; } +.RL.rtl.large.invert .target { bottom: auto; } + +/* not absolutizing the border colors, so that the test passes even if css-logical is not supported; */ +.large.invert { + border: solid silver; + border-block-end-color: blue; + border-inline-end-color: blue; +} + +</style> + +<p>Test passes if there is an orange square tucked into each blue corner without gaps, +and there is no red. + +<div class="wrapper"> +<!-- Simple Small Cases --> + +<div class="scroller TB ltr small"> + <div class="target"></div> +</div> + +<div class="scroller LR ltr small"> + <div class="target"></div> +</div> + +<div class="scroller RL ltr small"> + <div class="target"></div> +</div> + +<div class="scroller TB rtl small"> + <div class="target"></div> +</div> + +<div class="scroller LR rtl small"> + <div class="target"></div> +</div> + +<div class="scroller RL rtl small"> + <div class="target"></div> +</div> + +<!-- Target-inverted Small Cases + This row should be identical to the previous. --> +<div class="scroller TB ltr small invert"> + <div class="target"></div> +</div> + +<div class="scroller LR ltr small invert"> + <div class="target"></div> +</div> + +<div class="scroller RL ltr small invert"> + <div class="target"></div> +</div> + +<div class="scroller TB rtl small invert"> + <div class="target"></div> +</div> + +<div class="scroller LR rtl small invert"> + <div class="target"></div> +</div> + +<div class="scroller RL rtl small invert"> + <div class="target"></div> +</div> + +<!-- Simple Large Cases --> + +<div class="scroller TB ltr large"> + <div class="target"></div> +</div> + +<div class="scroller LR ltr large"> + <div class="target"></div> +</div> + +<div class="scroller RL ltr large"> + <div class="target"></div> +</div> + +<div class="scroller TB rtl large"> + <div class="target"></div> +</div> + +<div class="scroller LR rtl large"> + <div class="target"></div> +</div> + +<div class="scroller RL rtl large"> + <div class="target"></div> +</div> + +<!-- Target-inverted Large Cases + This is the fun one. --> + +<div class="scroller TB ltr large invert"> + <div class="target"></div> +</div> + +<div class="scroller LR ltr large invert"> + <div class="target"></div> +</div> + +<div class="scroller RL ltr large invert"> + <div class="target"></div> +</div> + +<div class="scroller TB rtl large invert"> + <div class="target"></div> +</div> + +<div class="scroller LR rtl large invert"> + <div class="target"></div> +</div> + +<div class="scroller RL rtl large invert"> + <div class="target"></div> +</div> + +</div> <!-- wrapper --> diff --git a/testing/web-platform/tests/css/css-scroll-snap/snap-after-initial-layout/scroll-snap-writing-mode-000.html b/testing/web-platform/tests/css/css-scroll-snap/snap-after-initial-layout/scroll-snap-writing-mode-000.html new file mode 100644 index 0000000000..e5d3dd9358 --- /dev/null +++ b/testing/web-platform/tests/css/css-scroll-snap/snap-after-initial-layout/scroll-snap-writing-mode-000.html @@ -0,0 +1,237 @@ +<!DOCTYPE html> +<title> + scroll-snap-align vs writing-mode +</title> +<link rel="help" href="https://drafts.csswg.org/css-scroll-snap-1/#scroll-snap-align"> +<link rel="help" href="https://drafts.csswg.org/css-scroll-snap/#re-snap"> +<link rel="match" href="scroll-snap-writing-mode-000-ref.html"> +<link rel="author" title="Elika J. Etemad" href="http://fantasai.inkedblade.net/contact"> +<style> + +.wrapper { + /* lay out in a nice grid */ + display: grid; + gap: 0.25em; + grid-template-columns: repeat(6, max-content); +} + +.scroller { + scroll-snap-type: both mandatory; + overflow: hidden; + scroll-padding: 0; + width: 50px; + height: 50px; + border: solid silver; + border-block-start-color: blue; + border-inline-start-color: blue; +} +.area { + width: 200px; + height: 200px; +} + +.target { + margin: 5px; + scroll-snap-align: start; +} + +.small .target { + width: 30px; + height: 30px; + background: orange; +} + +.large .target { + width: 51px; + height: 51px; + border-block-end: 20px solid red; + border-inline-end: 20px solid red; +} + +.large .target::before { + content: ''; + display: block; + width: 30px; + height: 30px; + background: orange; +} + +.TB { writing-mode: horizontal-tb; } +.LR { writing-mode: vertical-lr; } +.RL { writing-mode: vertical-rl; } +.ltr { direction: ltr; } +.rtl { direction: rtl; } + +.TB.ltr.invert .target { writing-mode: vertical-rl; direction: rtl; } +.TB.rtl.invert .target { writing-mode: vertical-lr; direction: rtl; } +.LR.ltr.invert .target { writing-mode: vertical-rl; direction: rtl; } +.LR.rtl.invert .target { writing-mode: vertical-rl; direction: ltr; } +.RL.ltr.invert .target { writing-mode: vertical-lr; direction: rtl; } +.RL.rtl.invert .target { writing-mode: horizontal-tb; direction: ltr; } + +.large.invert { + /* key off target‘s writing mode, which we just inverted */ + border: solid silver; + border-block-end-color: blue; + border-inline-end-color: blue; +} +</style> + +<p>Test passes if there is an orange square tucked into each blue corner without gaps, +and there is no red. + +<div class="wrapper"> +<!-- Simple Small Cases --> + +<div class="scroller TB ltr small"> + <div class="area"> + <div class="target"></div> + </div> +</div> + +<div class="scroller LR ltr small"> + <div class="area"> + <div class="target"></div> + </div> +</div> + +<div class="scroller RL ltr small"> + <div class="area"> + <div class="target"></div> + </div> +</div> + +<div class="scroller TB rtl small"> + <div class="area"> + <div class="target"></div> + </div> +</div> + +<div class="scroller LR rtl small"> + <div class="area"> + <div class="target"></div> + </div> +</div> + +<div class="scroller RL rtl small"> + <div class="area"> + <div class="target"></div> + </div> +</div> + +<!-- Target-inverted Small Cases + This row should be identical to the previous. --> +<div class="scroller TB ltr small invert"> + <div class="area"> + <div class="target"></div> + </div> +</div> + +<div class="scroller LR ltr small invert"> + <div class="area"> + <div class="target"></div> + </div> +</div> + +<div class="scroller RL ltr small invert"> + <div class="area"> + <div class="target"></div> + </div> +</div> + +<div class="scroller TB rtl small invert"> + <div class="area"> + <div class="target"></div> + </div> +</div> + +<div class="scroller LR rtl small invert"> + <div class="area"> + <div class="target"></div> + </div> +</div> + +<div class="scroller RL rtl small invert"> + <div class="area"> + <div class="target"></div> + </div> +</div> + +<!-- Simple Large Cases --> + +<div class="scroller TB ltr large"> + <div class="area"> + <div class="target"></div> + </div> +</div> + +<div class="scroller LR ltr large"> + <div class="area"> + <div class="target"></div> + </div> +</div> + +<div class="scroller RL ltr large"> + <div class="area"> + <div class="target"></div> + </div> +</div> + +<div class="scroller TB rtl large"> + <div class="area"> + <div class="target"></div> + </div> +</div> + +<div class="scroller LR rtl large"> + <div class="area"> + <div class="target"></div> + </div> +</div> + +<div class="scroller RL rtl large"> + <div class="area"> + <div class="target"></div> + </div> +</div> + +<!-- Target-inverted Large Cases + This is the fun one. --> + +<div class="scroller TB ltr large invert"> + <div class="area"> + <div class="target"></div> + </div> +</div> + +<div class="scroller LR ltr large invert"> + <div class="area"> + <div class="target"></div> + </div> +</div> + +<div class="scroller RL ltr large invert"> + <div class="area"> + <div class="target"></div> + </div> +</div> + +<div class="scroller TB rtl large invert"> + <div class="area"> + <div class="target"></div> + </div> +</div> + +<div class="scroller LR rtl large invert"> + <div class="area"> + <div class="target"></div> + </div> +</div> + +<div class="scroller RL rtl large invert"> + <div class="area"> + <div class="target"></div> + </div> +</div> + +</div> <!-- wrapper --> diff --git a/testing/web-platform/tests/css/css-scroll-snap/snap-after-initial-layout/snap-after-initial-layout-ref.html b/testing/web-platform/tests/css/css-scroll-snap/snap-after-initial-layout/snap-after-initial-layout-ref.html new file mode 100644 index 0000000000..c8009b626c --- /dev/null +++ b/testing/web-platform/tests/css/css-scroll-snap/snap-after-initial-layout/snap-after-initial-layout-ref.html @@ -0,0 +1,20 @@ +<!DOCTYPE html> +<title>Reference</title> +<style> +div { + margin: 0; + position: absolute; +} + +#target { + width: 300px; + height: 300px; + top: 0; + left: 200px; + background-color: green; +} +</style> + +<div> + <div id="target"></div> +</div> diff --git a/testing/web-platform/tests/css/css-scroll-snap/snap-after-initial-layout/writing-mode-horizontal-tb.html b/testing/web-platform/tests/css/css-scroll-snap/snap-after-initial-layout/writing-mode-horizontal-tb.html new file mode 100644 index 0000000000..9a680d10d9 --- /dev/null +++ b/testing/web-platform/tests/css/css-scroll-snap/snap-after-initial-layout/writing-mode-horizontal-tb.html @@ -0,0 +1,52 @@ +<!DOCTYPE html> +<title> + Scrollers should snap to the closest snap point on initial layout + (using 'writing-mode: horizontal-tb') +</title> +<link rel="help" href="https://drafts.csswg.org/css-scroll-snap/#re-snap" /> +<link rel="match" href="snap-after-initial-layout-ref.html" /> +<style> +div { + position: absolute; + margin: 0; +} + +#scroller { + height: 500px; + width: 500px; + overflow: hidden; + scroll-snap-type: both mandatory; + writing-mode: horizontal-tb; +} + +#close-target { + width: 200px; + height: 200px; + border: solid green 50px; + top: 50px; + left: 150px; + margin: 50px; + background-color: green; + scroll-snap-align: start end; +} + +#far-target { + width: 300px; + height: 300px; + top: 100px; + left: 500px; + background-color: red; + scroll-snap-align: start end; +} + +.area { + width: 2000px; + height: 2000px; +} +</style> + +<div id="scroller"> + <div class="area"></div> + <div id="close-target"></div> + <div id="far-target"></div> +</div> diff --git a/testing/web-platform/tests/css/css-scroll-snap/snap-after-initial-layout/writing-mode-vertical-lr.html b/testing/web-platform/tests/css/css-scroll-snap/snap-after-initial-layout/writing-mode-vertical-lr.html new file mode 100644 index 0000000000..f4de0411e0 --- /dev/null +++ b/testing/web-platform/tests/css/css-scroll-snap/snap-after-initial-layout/writing-mode-vertical-lr.html @@ -0,0 +1,52 @@ +<!DOCTYPE html> +<title> + Scrollers should snap to the closest snap point on initial layout + (using 'writing-mode: vertical-lr') +</title> +<link rel="help" href="https://drafts.csswg.org/css-scroll-snap/#re-snap" /> +<link rel="match" href="snap-after-initial-layout-ref.html" /> +<style> +div { + position: absolute; + margin: 0; +} + +#scroller { + height: 500px; + width: 500px; + overflow: hidden; + scroll-snap-type: both mandatory; + writing-mode: vertical-lr; +} + +#close-target { + width: 200px; + height: 200px; + border: solid green 50px; + top: 50px; + left: 150px; + margin: 50px; + background-color: green; + scroll-snap-align: end start; +} + +#far-target { + width: 300px; + height: 300px; + top: 100px; + left: 500px; + background-color: red; + scroll-snap-align: end start; +} + +.area { + width: 2000px; + height: 2000px; +} +</style> + +<div id="scroller"> + <div class="area"></div> + <div id="close-target"></div> + <div id="far-target"></div> +</div> diff --git a/testing/web-platform/tests/css/css-scroll-snap/snap-after-initial-layout/writing-mode-vertical-rl.html b/testing/web-platform/tests/css/css-scroll-snap/snap-after-initial-layout/writing-mode-vertical-rl.html new file mode 100644 index 0000000000..1710bc16dd --- /dev/null +++ b/testing/web-platform/tests/css/css-scroll-snap/snap-after-initial-layout/writing-mode-vertical-rl.html @@ -0,0 +1,55 @@ +<!DOCTYPE html> +<title> + Scrollers should snap to the closest snap point on initial layout + (using 'writing-mode: vertical-rl') +</title> +<link rel="help" href="https://drafts.csswg.org/css-scroll-snap/#re-snap" /> +<link rel="match" href="snap-after-initial-layout-ref.html" /> +<style> +div { + position: absolute; + margin: 0; +} + +#scroller { + /* Chrome bug using 'position:absolute' with LayoutNG disabled */ + position: relative; + + height: 500px; + width: 500px; + overflow: hidden; + scroll-snap-type: both mandatory; + writing-mode: vertical-rl; +} + +#close-target { + width: 200px; + height: 200px; + border: solid green 50px; + top: 50px; + left: 150px; + margin: 50px; + background-color: green; + scroll-snap-align: start; +} + +#far-target { + width: 300px; + height: 300px; + top: 100px; + left: 500px; + background-color: red; + scroll-snap-align: start; +} + +.area { + width: 2000px; + height: 2000px; +} +</style> + +<div id="scroller"> + <div class="area"></div> + <div id="close-target"></div> + <div id="far-target"></div> +</div> |