[css-anchor-position] Support inset-area in @position-try
Support applying inset-area to the containing block size based on
computed style for each position-try option. Position-anchor,
inset-area, and insets need to be applied in order since they all rely
on the result of applying the previous.
Anchor-center offsets are also pre-computed as part of style resolution
to have the offsets ready for layout without re-invoking an
AnchorEvaluator.
Bug: 329679519
Change-Id: I4097d803eaafd45eec5647f47ac2879ecd90f269
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5401733
Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1283913}
diff --git a/css/css-anchor-position/anchor-center-offset-change.html b/css/css-anchor-position/anchor-center-offset-change.html
new file mode 100644
index 0000000..fa38315
--- /dev/null
+++ b/css/css-anchor-position/anchor-center-offset-change.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<title>CSS Anchor Positioning Test: Dynamically change the anchor-center position</title>
+<link rel="help" href="https://drafts.csswg.org/css-anchor-position-1/#anchor-center">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<style>
+ #cb {
+ position: relative;
+ width: 200px;
+ height: 200px;
+ }
+ #anchor {
+ width: 100px;
+ height: 100px;
+ anchor-name: --anchor;
+ }
+ #anchored {
+ position: absolute;
+ width: 100px;
+ height: 100px;
+ position-anchor: --anchor;
+ align-self: anchor-center;
+ left: anchor(--unknown right, 0px);
+ }
+</style>
+<div id="cb">
+ <div id="anchor"></div>
+ <div id="anchored"></div>
+</div>
+<script>
+ test(() => {
+ assert_equals(anchored.offsetLeft, 0);
+ assert_equals(anchored.offsetTop, 0);
+ }, "Anchored initially have the same width as the anchor");
+
+ test(() => {
+ anchor.style.height = "200px";
+ assert_equals(anchored.offsetLeft, 0);
+ assert_equals(anchored.offsetTop, 50);
+ }, "Increase the height of the anchor to move the anchor-center offset");
+</script>