Skip to content

Commit

Permalink
[anchor-position] Make 'anchor-scroll' internal
Browse files Browse the repository at this point in the history
See w3c/csswg-drafts#8675 for context.

This patch:

1. Changes the implementation to longer expose `anchor-scroll` as a
   CSS property, but use the target of `anchor-default` for scrolling
   purposes

2. Coverts tests and UA style to stop using `anchor-scroll`. The usage
   is either simply removed if there's already a default anchor, or
   changed to use `anchor-default` otherwise. The cases that assume
   different `anchor-scroll` and `anchor-default` targets are removed
   since they will no longer be a possible.

To minimize diff, this patch focuses on the implementation change.
A follow up patch will convert all in-code documentations and rename
existing classes/functions to stop referring to the functionality as
"anchor-scroll", and hence, stop the naming confusion.

Bug: 1463085
Change-Id: I3cb2000de67b2b81b4edf8b9a1303de682946232
  • Loading branch information
xiaochengh authored and chromium-wpt-export-bot committed Jul 7, 2023
1 parent 86b4ccd commit 47268e7
Show file tree
Hide file tree
Showing 47 changed files with 81 additions and 139 deletions.
2 changes: 1 addition & 1 deletion css/css-anchor-position/anchor-position-top-layer-001.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
width: 100px;
height: 100px;
background: lime;
anchor-scroll: --a;
anchor-default: --a;
outline: none;
}

Expand Down
2 changes: 1 addition & 1 deletion css/css-anchor-position/anchor-position-top-layer-002.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
width: 100px;
height: 100px;
background: lime;
anchor-scroll: --a;
anchor-default: --a;
outline: none;
}

Expand Down
2 changes: 1 addition & 1 deletion css/css-anchor-position/anchor-position-top-layer-003.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
width: 100px;
height: 100px;
background: lime;
anchor-scroll: --a;
anchor-default: --a;
outline: none;
}

Expand Down
2 changes: 1 addition & 1 deletion css/css-anchor-position/anchor-position-top-layer-004.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
width: 100px;
height: 100px;
background: lime;
anchor-scroll: --a;
anchor-default: --a;
outline: none;
}

Expand Down
2 changes: 1 addition & 1 deletion css/css-anchor-position/anchor-position-top-layer-005.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
width: 100px;
height: 100px;
background: lime;
anchor-scroll: --a;
anchor-default: --a;
}

body {
Expand Down
2 changes: 1 addition & 1 deletion css/css-anchor-position/anchor-position-top-layer-006.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
width: 100px;
height: 100px;
background: lime;
anchor-scroll: --a;
anchor-default: --a;
}

body {
Expand Down
6 changes: 3 additions & 3 deletions css/css-anchor-position/anchor-scroll-001.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<title>Basic of anchor-scroll: anchored elements should be "pinned" to the anchor when anchor is scrolled</title>
<title>Basic of anchor positioned scrolling: anchored elements should be "pinned" to the anchor when anchor is scrolled</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-ref.html">
Expand Down Expand Up @@ -40,15 +40,15 @@
position: absolute;
left: anchor(--anchor left);
bottom: anchor(--anchor top);
anchor-scroll: --anchor;
anchor-default: --anchor;
}

#outer-anchored {
color: yellow;
position: absolute;
left: anchor(--anchor left);
top: anchor(--anchor bottom);
anchor-scroll: --anchor;
anchor-default: --anchor;
}
</style>

Expand Down
4 changes: 2 additions & 2 deletions css/css-anchor-position/anchor-scroll-002.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<title>Tests anchor-scroll resolving name conflicts</title>
<title>Tests anchor positioned scrolling resolving name conflicts</title>
<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#scroll">
<link rel="author" href="mailto:[email protected]">
<script src="/resources/testharness.js"></script>
Expand Down Expand Up @@ -45,7 +45,7 @@
height: 50px;
top: anchor(--a1 top);
left: anchor(--a1 right);
anchor-scroll: --a1;
anchor-default: --a1;
}
</style>

Expand Down
6 changes: 3 additions & 3 deletions css/css-anchor-position/anchor-scroll-003.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<title>Tests anchor-scroll with fragmented containing block</title>
<title>Tests anchor positioned scrolling with fragmented containing block</title>
<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#scroll">
<link rel="author" href="mailto:[email protected]">
<script src="/resources/testharness.js"></script>
Expand Down Expand Up @@ -47,7 +47,7 @@
position: absolute;
left: anchor(--a left);
bottom: anchor(--a top);
anchor-scroll: --a;
anchor-default: --a;
width: 50px;
height: 50px;
background: lime;
Expand All @@ -72,5 +72,5 @@

let targetRect = target.getBoundingClientRect();
assert_equals(targetRect.top, 30);
}, 'anchor-scroll should work in fragmented containing block');
}, 'Scrolling should work in fragmented containing block');
</script>
4 changes: 2 additions & 2 deletions css/css-anchor-position/anchor-scroll-004.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Tests anchor-scroll with relatively positioned inline containers</title>
<title>Tests anchor positioned scrolling with relatively positioned inline containers</title>
<link rel="help" href="https://drafts4.csswg.org/css-anchor-position-1/#scroll">
<link rel="author" href="mailto:[email protected]">
<link rel="stylesheet" href="/fonts/ahem.css">
Expand Down Expand Up @@ -32,7 +32,7 @@

.target {
position: absolute;
anchor-scroll: --a;
anchor-default: --a;
top: anchor(--a bottom);
left: anchor(--a left);
color: lime;
Expand Down
4 changes: 2 additions & 2 deletions css/css-anchor-position/anchor-scroll-005.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<title>Tests 'anchor-scroll' with anchor in fixed-positioned scroller</title>
<title>Tests scrolling with anchor in fixed-positioned scroller</title>
<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#scroll">
<link rel="author" href="mailto:[email protected]">
<script src="/resources/testharness.js"></script>
Expand Down Expand Up @@ -33,7 +33,7 @@
width: 100px;
height: 100px;
bottom: anchor(--a top);
anchor-scroll: --a;
anchor-default: --a;
background: lime;
}
</style>
Expand Down
44 changes: 0 additions & 44 deletions css/css-anchor-position/anchor-scroll-basics.html

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<title>Tests that anchor-scroll doesn't crash renderer when anchor is in a scroller whose content doesn't overflow</title>
<title>Tests that scrolling doesn't crash renderer when anchor is in a scroller whose content doesn't overflow</title>
<link rel="author" href="mailto:[email protected]">
<link rel="help" href="https://drafts.csswg.org/css-anchor-1/">
<style>
Expand All @@ -23,7 +23,7 @@

#anchored {
position: absolute;
anchor-scroll: --a;
anchor-default: --a;
left: anchor(--a left);
bottom: anchor(--a top);
width: 100px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!DOCTYPE html>
<html class="test-wait">
<title>Tests that anchor-scroll doesn't crash renderer when scroller's content no longer overflows</title>
<title>Tests that scrolling doesn't crash renderer when scroller's content no longer overflows</title>
<link rel="author" href="mailto:[email protected]">
<link rel="help" href="https://drafts.csswg.org/css-anchor-1/">

Expand All @@ -23,7 +23,7 @@
position: fixed;
top: anchor(--a bottom);
left: anchor(--a left);
anchor-scroll: --a;
anchor-default: --a;
}
</style>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!DOCTYPE html>
<html class="test-wait">
<title>Tests that anchor-scroll doesn't crash renderer when scroller becomes non-scroller</title>
<title>Tests that scrolling doesn't crash renderer when scroller becomes non-scroller</title>
<link rel="author" href="mailto:[email protected]">
<link rel="help" href="https://drafts.csswg.org/css-anchor-1/">

Expand All @@ -23,7 +23,7 @@
position: fixed;
top: anchor(--a bottom);
left: anchor(--a left);
anchor-scroll: --a;
anchor-default: --a;
}
</style>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!DOCTYPE html>
<html class="test-wait">
<title>Tests that anchor-scroll doesn't crash renderer when scroller's content no longer overflows, and target precedes scroller in DOM</title>
<title>Tests that scrolling doesn't crash renderer when scroller's content no longer overflows, and target precedes scroller in DOM</title>
<link rel="author" href="mailto:[email protected]">
<link rel="help" href="https://drafts.csswg.org/css-anchor-1/">

Expand All @@ -23,7 +23,7 @@
position: fixed;
top: anchor(--a bottom);
left: anchor(--a left);
anchor-scroll: --a;
anchor-default: --a;
}
</style>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!DOCTYPE html>
<html class="test-wait">
<title>Tests that anchor-scroll doesn't crash renderer with `overflow: hidden` scroller</title>
<title>Tests that scrolling doesn't crash renderer with `overflow: hidden` scroller</title>
<link rel="author" href="mailto:[email protected]">
<link rel="help" href="https://drafts.csswg.org/css-anchor-1/">

Expand All @@ -23,7 +23,7 @@
position: fixed;
top: anchor(--a bottom);
left: anchor(--a left);
anchor-scroll: --a;
anchor-default: --a;
}
</style>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!DOCTYPE html>
<html class="reftest-wait">
<title>Tests anchor-scroll element paint order in composited scrolling</title>
<title>Tests anchor-positioned element paint order in composited scrolling</title>
<link rel="help" href="https://drafts4.csswg.org/css-anchor-position-1/#scroll">
<link rel="author" href="mailto:[email protected]">
<link rel="match" href="reference/anchor-scroll-composited-scrolling-006-ref.html">
Expand Down Expand Up @@ -29,7 +29,7 @@
background: red;
left: 0;
bottom: anchor(--a top);
anchor-scroll: --a;
anchor-default: --a;
}
#overlap {
position: absolute;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#anchored {
position: absolute;
background: green;
anchor-scroll: --a;
anchor-default: --a;
position-fallback: --fallback;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
width: 100px;
height: 100px;
background: green;
anchor-scroll: --a;
anchor-default: --a;
top: anchor(--a top);
position-fallback: --pf;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
width: 100px;
height: 100px;
background: green;
anchor-scroll: --a;
anchor-default: --a;
position-fallback: --pf;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
width: 100px;
height: 100px;
background: green;
anchor-scroll: --a;
anchor-default: --a;
position-fallback: --pf;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
width: 100px;
height: 100px;
background: green;
anchor-scroll: --a;
anchor-default: --a;
top: anchor(--a top);
position-fallback: --pf;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
width: 100px;
height: 100px;
background: green;
anchor-scroll: --a;
anchor-default: --a;
position-fallback: --pf;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
width: 100px;
height: 100px;
background: green;
anchor-scroll: --a;
anchor-default: --a;
position-fallback: --pf;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
width: 100px;
height: 100px;
background: green;
anchor-scroll: --a;
anchor-default: --a;
position-fallback: --pf;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
width: 100px;
height: 100px;
background: green;
anchor-scroll: --a;
anchor-default: --a;
position-fallback: --pf;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
width: 100px;
height: 100px;
background: green;
anchor-scroll: --a;
anchor-default: --a;
position-fallback: --pf;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
width: 100px;
height: 100px;
background: green;
anchor-scroll: --a;
anchor-default: --a;
position-fallback: --pf;
}

Expand Down
Loading

0 comments on commit 47268e7

Please sign in to comment.