Bug 1880868 [wpt PR 44654] - Adjust anchor position offset with chained anchor position, a=testonly

Automatic update from web-platform-tests
Adjust anchor position offset with chained anchor position

Like 5297007, this CL adjusts anchor position by the offset of chained
anchored containers.

Bug: 40947467
Change-Id: I233145abe11d5eb1288ca3940388930d2149214d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5274137
Reviewed-by: Robert Flack <[email protected]>
Commit-Queue: Xianzhu Wang <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1264708}

--

wpt-commits: 4a5bbfc904a789669c73c9581a2c8625d3b62c4c
wpt-pr: 44654
This commit is contained in:
Xianzhu Wang authored and moz-wptsync-bot committed 2024-03-01 20:10:03 +00:00
1 parent 161f861060
commit 1152308945
11 files changed
+609

No files matched your search

@@ -0,0 +1,37 @@
<!DOCTYPE html>
<title>Tests circular anchor relasionship</title>
<link rel="author" href="mailto:[email protected]">
<link rel="help" href="https://drafts.csswg.org/css-anchor-1/">
<link rel="match" href="reference/anchor-position-circular-ref.html">
<style>
body {
margin: 0;
}
div {
width: 100px;
height: 100px;
}
#anchored1 {
position: absolute;
anchor-default: --a1;
left: anchor(--a1 left);
top: anchor(--a1 bottom);
background: orange;
anchor-name: --a2;
}
#anchored2 {
position: absolute;
anchor-default: --a2;
left: anchor(--a2 left);
top: anchor(--a2 bottom);
background: green;
anchor-name: --a1;
}
</style>
<div id="anchored1"></div>
<div id="anchored2"></div>
@@ -0,0 +1,55 @@
<!DOCTYPE html>
<title>Tests scroll adjustments of element anchored to another anchored element</title>
<link rel="author" href="mailto:[email protected]">
<link rel="help" href="https://drafts.csswg.org/css-anchor-1/">
<link rel="match" href="reference/anchor-scroll-chained-001.tentative-ref.html">
<style>
body {
margin: 0;
}
div {
width: 100px;
height: 100px;
}
#scroller {
overflow: scroll;
}
#anchor {
anchor-name: --a1;
height: 20px;
background: orange;
}
#anchored1 {
position: absolute;
anchor-default: --a1;
left: anchor(--a1 left);
top: anchor(--a1 bottom);
background: green;
anchor-name: --a2;
}
#anchored2 {
position: absolute;
anchor-default: --a2;
left: anchor(--a2 left);
top: anchor(--a2 bottom);
background: lime;
}
</style>
<div id="scroller">
<div style="height: 230px"></div>
<div id="anchor"></div>
<div style="height: 230px"></div>
</div>
<div id="anchored1"></div>
<div id="anchored2"></div>
<script>
scroller.scrollTop = 200;
</script>
@@ -0,0 +1,66 @@
<!DOCTYPE html>
<title>Tests scroll adjustments of element anchored to another anchored element</title>
<link rel="author" href="mailto:[email protected]">
<link rel="help" href="https://drafts.csswg.org/css-anchor-1/">
<link rel="match" href="reference/anchor-scroll-chained-002.tentative-ref.html">
<style>
body {
margin: 0;
}
div {
width: 100px;
height: 100px;
}
#scroller1 {
width: 200px;
height: 200px;
position: relative;
}
#scroller1,#scroller2 {
overflow: scroll;
}
#anchor {
anchor-name: --a1;
height: 20px;
background: orange;
}
#anchored1 {
position: absolute;
anchor-default: --a1;
left: anchor(--a1 left);
top: anchor(--a1 bottom);
background: green;
anchor-name: --a2;
}
#anchored2 {
position: absolute;
anchor-default: --a2;
left: anchor(--a2 left);
top: anchor(--a2 bottom);
background: lime;
}
</style>
<div id="scroller1">
<div style="height: 100px"></div>
<div id="scroller2">
<div style="height: 230px"></div>
<div id="anchor"></div>
<div style="height: 230px"></div>
</div>
<div style="height: 100px"></div>
<div id="anchored1"></div>
</div>
<div id="anchored2"></div>
<script>
scroller1.scrollTop = 80;
scroller2.scrollTop = 200;
</script>
@@ -0,0 +1,68 @@
<!DOCTYPE html>
<title>Tests scroll adjustments of element anchored to another anchored element</title>
<link rel="author" href="mailto:[email protected]">
<link rel="help" href="https://drafts.csswg.org/css-anchor-1/">
<link rel="match" href="reference/anchor-scroll-chained-002.tentative-ref.html">
<style>
body {
margin: 0;
}
div {
width: 100px;
height: 100px;
}
#scroller1 {
width: 200px;
height: 200px;
position: relative;
}
#scroller1,#scroller2 {
overflow: scroll;
}
#anchor {
anchor-name: --a1;
height: 20px;
background: orange;
}
#anchored1 {
position: absolute;
anchor-default: --a1;
left: anchor(--a1 left);
top: anchor(--a1 bottom);
background: green;
anchor-name: --a2;
z-index: 1;
}
#anchored2 {
position: absolute;
anchor-default: --a2;
left: anchor(--a2 left);
top: anchor(--a2 bottom);
background: lime;
z-index: 1;
}
</style>
<div id="anchored2"></div>
<div id="scroller1">
<div id="anchored1"></div>
<div style="height: 100px"></div>
<div id="scroller2">
<div style="height: 230px"></div>
<div id="anchor"></div>
<div style="height: 230px"></div>
</div>
<div style="height: 100px"></div>
</div>
<script>
scroller1.scrollTop = 80;
scroller2.scrollTop = 200;
</script>
@@ -0,0 +1,78 @@
<!DOCTYPE html>
<title>Tests scroll adjustments of element anchored to another anchored element</title>
<link rel="author" href="mailto:[email protected]">
<link rel="help" href="https://drafts.csswg.org/css-anchor-1/">
<link rel="match" href="reference/anchor-scroll-chained-004.tentative-ref.html">
<style>
body {
margin: 0;
}
div {
width: 100px;
height: 100px;
}
#scroller1 {
width: 200px;
height: 200px;
position: relative;
}
#scroller1,#scroller2,#scroller3 {
overflow: scroll;
}
#anchor1 {
anchor-name: --a1;
height: 20px;
background: orange;
}
#anchor2 {
anchor-name: --a2;
height: 20px;
background: cyan;
}
#anchored1 {
position: absolute;
anchor-default: --a1;
left: anchor(--a1 left);
top: anchor(--a1 bottom);
background: green;
}
#anchored2 {
position: absolute;
anchor-default: --a2;
left: anchor(--a2 left);
top: anchor(--a2 bottom);
background: lime;
}
</style>
<div id="scroller1">
<div style="height: 100px"></div>
<div id="scroller2">
<div style="height: 230px"></div>
<div id="anchor1"></div>
<div style="height: 230px"></div>
</div>
<div style="height: 100px"></div>
<div id="anchored1">
<div id="scroller3">
<div style="height: 230px"></div>
<div id="anchor2"></div>
<div style="height: 230px"></div>
</div>
</div>
</div>
<div id="anchored2"></div>
<script>
scroller1.scrollTop = 80;
scroller2.scrollTop = 200;
scroller3.scrollTop = 200;
</script>
@@ -0,0 +1,65 @@
<!DOCTYPE html>
<title>Tests scroll adjustments of element anchored to another anchored element with fallback</title>
<link rel="author" href="mailto:[email protected]">
<link rel="help" href="https://drafts.csswg.org/css-anchor-1/">
<link rel="match" href="reference/anchor-scroll-chained-fallback.tentative-ref.html">
<style>
body {
margin: 0;
}
div {
width: 100px;
height: 100px;
}
#scroller {
overflow: scroll;
width: 300px;
height: 300px;
}
#anchor {
anchor-name: --a1;
background: orange;
margin: 250px 0;
}
#anchored1 {
position: absolute;
anchor-default: --a1;
background: green;
position-fallback: --fallback;
anchor-name: --a2;
}
#anchored2 {
position: absolute;
anchor-default: --a2;
left: anchor(--a2 left);
top: anchor(--a2 bottom);
background: lime;
}
@position-fallback --fallback {
@try {
left: anchor(--a1 left);
bottom: anchor(--a1 top);
}
@try {
left: anchor(--a1 right);
top: anchor(--a1 top);
}
}
</style>
<div id="scroller">
<div id="anchor"></div>
</div>
<div id="anchored1"></div>
<div id="anchored2"></div>
<script>
scroller.scrollTop = 200;
</script>
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<style>
div {
width: 100px;
height: 100px;
}
#anchored1 {
position: absolute;
left: 0;
top: 0;
background: orange;
}
#anchored2 {
position: absolute;
left: 0;
top: 100px;
background: green;
}
</style>
<div id="anchored1"></div>
<div id="anchored2"></div>
@@ -0,0 +1,47 @@
<!DOCTYPE html>
<style>
body {
margin: 0;
}
div {
width: 100px;
height: 100px;
}
#scroller {
overflow: scroll;
}
#anchor {
height: 20px;
background: orange;
}
#anchored1 {
position: absolute;
top: 50px;
left: 0;
background: green;
}
#anchored2 {
position: absolute;
top: 150px;
left: 0;
background: lime;
}
</style>
<div id="scroller">
<div style="height: 230px"></div>
<div id="anchor"></div>
<div style="height: 230px"></div>
</div>
<div id="anchored1"></div>
<div id="anchored2"></div>
<script>
scroller.scrollTop = 200;
</script>
@@ -0,0 +1,55 @@
<!DOCTYPE html>
<style>
body {
margin: 0;
}
div {
width: 100px;
height: 100px;
}
#scroller1 {
width: 200px;
height: 200px;
}
#scroller1,#scroller2 {
overflow: scroll;
}
#anchor {
height: 20px;
background: orange;
}
#anchored1 {
position: absolute;
top: 70px;
background: green;
}
#anchored2 {
position: absolute;
top: 170px;
background: lime;
}
</style>
<div id="scroller1">
<div style="height: 100px"></div>
<div id="scroller2">
<div style="height: 230px"></div>
<div id="anchor"></div>
<div style="height: 230px"></div>
</div>
<div style="height: 250px"></div>
</div>
<div id="anchored1"></div>
<div id="anchored2"></div>
<script>
scroller1.scrollTop = 80;
scroller2.scrollTop = 200;
</script>
@@ -0,0 +1,68 @@
<!DOCTYPE html>
<style>
body {
margin: 0;
height: 700px;
}
div {
width: 100px;
height: 100px;
}
#scroller1 {
width: 200px;
height: 200px;
position: relative;
}
#scroller1,#scroller2,#scroller3 {
overflow: scroll;
}
#anchor1 {
height: 20px;
background: orange;
}
#anchor2 {
height: 20px;
background: cyan;
}
#anchored1 {
position: absolute;
top: 70px;
background: green;
}
#anchored2 {
position: absolute;
top: 120px;
background: lime;
}
</style>
<div id="scroller1">
<div style="height: 100px"></div>
<div id="scroller2">
<div style="height: 230px"></div>
<div id="anchor1"></div>
<div style="height: 230px"></div>
</div>
<div style="height: 250px"></div>
</div>
<div id="anchored1">
<div id="scroller3">
<div style="height: 230px"></div>
<div id="anchor2"></div>
<div style="height: 230px"></div>
</div>
</div>
<div id="anchored2"></div>
<script>
scroller1.scrollTop = 80;
scroller2.scrollTop = 200;
scroller3.scrollTop = 200;
</script>
@@ -0,0 +1,46 @@
<!DOCTYPE html>
<style>
body {
margin: 0;
}
div {
width: 100px;
height: 100px;
}
#scroller {
overflow: scroll;
width: 300px;
height: 300px;
}
#anchor {
background: orange;
margin: 250px 0;
}
#anchored1 {
position: absolute;
background: green;
top: 50px;
left: 100px;
}
#anchored2 {
position: absolute;
background: lime;
top: 150px;
left: 100px;
}
</style>
<div id="scroller">
<div id="anchor"></div>
</div>
<div id="anchored1"></div>
<div id="anchored2"></div>
<script>
scroller.scrollTop = 200;
</script>