Re: [csswg-drafts] [css-anchor-position-1] Using a specific box (not your CB) to determine position-fallback (#8724)

Xiaocheng brought up that we need to invoke scroll-adjustment for this rectangle, same as we do for the IMCB. If the named element is being scrolled by some ancestor, you still want to track it's current (scrolled) position, like you would have *automatically* done back when you were an abspos descendant of it and all the calculations were local.

A further concern was what to do about inset-modified stuff. In part, the reason we use IMCB is to avoid accidentally overlapping the anchor - for example, if you have `left: 0; right: anchor(left);`, you expect to fit into the space between the left edge of your CB and the anchor itself. If you end up wider than that, you want to trigger fallback and try another position, not happily overflow your anchor because you haven't overflowed your CB itself.

After some discussion, we've decided that the simplest answer that is also likely to be correct is to just intersect the two rectangles - your IMCB and the fallback-bounds rect. In the common case, your fallback-bounds rect will be a subrect of your CB, so intersecting with your IMCB will still generally produce a useful rectangle.

In some cases this might produce a significant behavior difference between "the rect you tested against as an abspos" and "the rect you're testing against as a fixpos". For example, with `left: 20px; right: anchor(left);`, as an abspos you'll be fitting into a rect inset 20px from your CB's left edge, and flush with your anchor's left edge. If you become a fixpos, that 20px is inset from the screen edge instead, which might be far away from your fallback-bounds rect; when you intersect the two, you'll instead get a rect that's flush with the fallback-bounds rect's left edge, rather than 20px away from that edge.

However, if this is important you can always correct it by rewriting your insets to refer to the fallback-bounds rect; by definition it has to be a valid anchor as well. So when you go from abspos to fixpos, you can also change from `left: 20px;` to `left: calc(anchor(--old-cb left) + 20px);` and maintain identical bounds. Since most of the time it'll work reasonably by default, and it's fixable without much effort, I think going with the simple "just intersect them" is the right answer.

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/8724#issuecomment-1571065761 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 31 May 2023 22:50:57 UTC