|
| 1 | +<!DOCTYPE html> |
| 2 | +<html id=root> |
| 3 | +<title>CSS Anchor Positioning: position-area vs initial containing block</title> |
| 4 | +<link rel="help" href="https://drafts.csswg.org/css-anchor-position/#position-area"> |
| 5 | +<script src="/resources/testharness.js"></script> |
| 6 | +<script src="/resources/testharnessreport.js"></script> |
| 7 | +<style> |
| 8 | + :root { |
| 9 | + margin: 10px 20px; |
| 10 | + border: 2px solid; |
| 11 | + overflow: hidden; |
| 12 | + } |
| 13 | + #anchored { |
| 14 | + position: fixed; |
| 15 | + inset: 0; |
| 16 | + border: solid orange; |
| 17 | + } |
| 18 | + #sizer { |
| 19 | + position: absolute; |
| 20 | + inset: 0; |
| 21 | + height: 100vh; |
| 22 | + width: 100vw; |
| 23 | + } |
| 24 | + |
| 25 | +</style> |
| 26 | +<div id="sizer"></div> |
| 27 | +<div id="container"> |
| 28 | + <div id="anchored"></div> |
| 29 | +</div> |
| 30 | +<script> |
| 31 | + function check(title, expected_offsets) { |
| 32 | + test(() => { |
| 33 | + assert_equals(anchored.offsetLeft, expected_offsets.left, "Check expected offsetLeft"); |
| 34 | + assert_equals(anchored.offsetTop, expected_offsets.top, "Check expected offsetTop"); |
| 35 | + assert_equals(anchored.offsetWidth, expected_offsets.width, "Check expected offsetWidth"); |
| 36 | + assert_equals(anchored.offsetHeight, expected_offsets.height, "Check expected offsetHeight"); |
| 37 | + }, "Offsets for: " + title); |
| 38 | + } |
| 39 | + |
| 40 | + vh = sizer.offsetHeight; |
| 41 | + vw = sizer.offsetWidth; |
| 42 | + |
| 43 | + check("position-area: none for basic ICB", {left:0, top:0, width:vw, height:vh}); |
| 44 | + |
| 45 | + anchored.positionArea = "span-all"; |
| 46 | + check("position-area: span-all for basic ICB", {left:0, top:0, width:vw, height:vh}); |
| 47 | + |
| 48 | + sizer.style.width = "200vw"; |
| 49 | + sizer.style.height = "200vh"; |
| 50 | + check("position-area: span-all for abspos overflowing ICB", {left:0, top:0, width:vw, height:vh}); |
| 51 | + |
| 52 | + sizer.style.position = "static"; |
| 53 | + check("position-area: span-all for in-flow overflowing ICB", {left:0, top:0, width:vw, height: vh}); |
| 54 | + |
| 55 | + root.style.width = "200vw"; |
| 56 | + check("position-area: span-all for root overflowing ICB", {left:0, top:0, width: vw, height: vh}); |
| 57 | + |
| 58 | + root.style.width = "50%"; |
| 59 | + root.style.height = "50%"; |
| 60 | + check("position-area: span-all for abspos overflowing ICB and reduced root", {left:0, top:0, width:vw, height:vh}); |
| 61 | + |
| 62 | + anchored.style.positionArea = "none"; |
| 63 | + check("position-area: none for in-flow overflowing ICB and reduced root", {left:0, top:0, width:vw, height:vh}); |
| 64 | +</script> |
0 commit comments