Skip to content

Commit

Permalink
Bug 1837529 [wpt PR 40463] - [anchor-position] Parse and evaluator `a…
Browse files Browse the repository at this point in the history
…uto` and `auto-size` keywords, a=testonly

Automatic update from web-platform-tests
[anchor-position] Parse and evaluator `auto` and `auto-size` keywords

This patch adds two more anchor side keywords `auto` and `auto-size`
to the `anchor()` function, and evaluates them by converting them into
the corresponding physical sides.

This patch doesn't implement the automatic fallbacks, which will be
implemented by a follow-up patch.

Spec: https://drafts.csswg.org/css-anchor-position-1/#anchor-auto

Bug: 1412864
Change-Id: I0494ab943a07ab9916b430600d4f49235c5df084
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4602508
Commit-Queue: Koji Ishii <[email protected]>
Reviewed-by: Koji Ishii <[email protected]>
Auto-Submit: Xiaocheng Hu <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1155689}

--

wpt-commits: 11ff902e0691e9ed7d659bd7bba02eabdb9949d2
wpt-pr: 40463
  • Loading branch information
xiaochengh authored and moz-wptsync-bot committed Jun 21, 2023
1 parent c32285a commit 4528a9a
Showing 1 changed file with 71 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<!DOCTYPE html>
<title>Tests automatic anchor positioning without fallbacks</title>
<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#anchor-auto">
<link rel="auto" href="mailto:[email protected]">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<script src="support/test-common.js"></script>

<style>
body {
margin: 0;
}

#cb {
position: absolute;
width: 500px;
height: 500px;
}

#anchor {
margin-left: 150px;
margin-top: 250px;
width: 100px;
height: 100px;
background: orange;
anchor-name: --a;
}

.target {
position: absolute;
width: 100px;
height: 100px;
background: lime;
}

#target1 {
top: anchor(--a auto); /* should evaluate to `bottom` */
left: anchor(--a auto-same); /* should evaluate to `left` */
}

#target2 {
bottom: anchor(--a auto); /* should evaluate to `top` */
right: anchor(--a auto-same); /* should evaluate to `right` */
}

#target3 {
top: anchor(--a auto-same); /* should evaluate to `top` */
left: anchor(--a auto); /* should evaluate to `right` */
}

#target4 {
bottom: anchor(--a auto-same); /* should evaluate to `bottom` */
right: anchor(--a auto); /* should evaluate to `left` */
}
</style>

<body onload="checkLayoutForAnchorPos('.target')">
<div id="cb">
<div id="anchor"></div>

<div id="target1" class="target"
data-offset-x="150" data-offset-y="350"></div>
<div id="target2" class="target"
data-offset-x="150" data-offset-y="150"></div>
<div id="target3" class="target"
data-offset-x="250" data-offset-y="250"></div>
<div id="target4" class="target"
data-offset-x="50" data-offset-y="250"></div>
</div>
</body>

0 comments on commit 4528a9a

Please sign in to comment.