-
Notifications
You must be signed in to change notification settings - Fork 708
[css-anchor-1] Issues with position fallback #8059
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
|
Wait, 1 actually doesn't work. Think about a long document with:
<style>
.spacer { height: 200vh; }
#anchor {
anchor-name: --a;
margin-left: 200vw;
}
#oof {
width: 100px; height: 100px;
position: fixed;
position-fallback: --pf;
anchor-scroll: --a;
left: anchor(--a left);
}
@position-fallback --pf {
@try { bottom: anchor(--a top); }
@try { top: anchor(--a bottom); }
}
</style>
<div class="spacer"></div>
<div id="anchor"></div>
<div class="spacer"></div>
<div id="oof"></div> After scrolling the anchor element into viewport, we expect to see the OOF above the anchor However, if we follow the behavior of 1, then for both fallback positions, the inset-modified containing block rects collapse into a line; and then both fallback positions will overflow the inset-modified containing block. Then we always end up using the last fallback position because we've run out of fallbacks. To fix it, we probably need to once again include scroll offset into If there's no good fix to 1 that still allows composited scrolling, it should be no longer considered. |
For the scroll behaviour - wouldn't we test if the element is overflowing the contianing block (similar to sticky-pos). E.g. that part of the calculation wouldn't depend on the inset-modified containing-block? |
As discussed in w3c/csswg-drafts#8059, when the inset-modified containing block (i.e., the available space) for an out-of-flow is overflowed, it's preferred to trigger position fallback. This patch implements it. Note: this patch has nothing to do with scrolling. A follow-up patch will deal with scrolling (crrev.com/c/3995704). Bug: 1309178 Change-Id: I980d91e6f155ddc030518142440ab49286df823e
Discussed with @bfgeek offline:
One idea is to somehow (conceptually) turn the fallback positions into, e.g.
In other words, if one side of the inset-modified rect has anchor queries and the other side is |
As discussed in w3c/csswg-drafts#8059, when the inset-modified containing block (i.e., the available space) for an out-of-flow is overflowed, it's preferred to trigger position fallback. This patch implements it. Note: this patch has nothing to do with scrolling. A follow-up patch will deal with scrolling (crrev.com/c/3995704). Bug: 1309178 Change-Id: I980d91e6f155ddc030518142440ab49286df823e
As discussed in w3c/csswg-drafts#8059, when the inset-modified containing block (i.e., the available space) for an out-of-flow is overflowed, it's preferred to trigger position fallback. This patch implements it. Note: this patch has nothing to do with scrolling. A follow-up patch will deal with scrolling (crrev.com/c/3995704). Bug: 1309178 Change-Id: I980d91e6f155ddc030518142440ab49286df823e
As discussed in w3c/csswg-drafts#8059, when the inset-modified containing block (i.e., the available space) for an out-of-flow is overflowed, it's preferred to trigger position fallback. This patch implements it. Note: this patch has nothing to do with scrolling. A follow-up patch will deal with scrolling (crrev.com/c/3995704). Bug: 1309178 Change-Id: I980d91e6f155ddc030518142440ab49286df823e
As discussed in w3c/csswg-drafts#8059, when the inset-modified containing block (i.e., the available space) for an out-of-flow is overflowed, it's preferred to trigger position fallback. This patch implements it. Note: this patch has nothing to do with scrolling. A follow-up patch will deal with scrolling (crrev.com/c/3995704). Bug: 1309178 Change-Id: I980d91e6f155ddc030518142440ab49286df823e
As discussed in w3c/csswg-drafts#8059, when the inset-modified containing block (i.e., the available space) for an out-of-flow is overflowed, it's preferred to trigger position fallback. This patch implements it. Note: this patch has nothing to do with scrolling. A follow-up patch will deal with scrolling (crrev.com/c/3995704). Bug: 1309178 Change-Id: I980d91e6f155ddc030518142440ab49286df823e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4020923 Reviewed-by: Koji Ishii <kojii@chromium.org> Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org> Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org> Cr-Commit-Position: refs/heads/main@{#1078344}
As discussed in w3c/csswg-drafts#8059, when the inset-modified containing block (i.e., the available space) for an out-of-flow is overflowed, it's preferred to trigger position fallback. This patch implements it. Note: this patch has nothing to do with scrolling. A follow-up patch will deal with scrolling (crrev.com/c/3995704). Bug: 1309178 Change-Id: I980d91e6f155ddc030518142440ab49286df823e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4020923 Reviewed-by: Koji Ishii <kojii@chromium.org> Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org> Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org> Cr-Commit-Position: refs/heads/main@{#1078344}
As discussed in w3c/csswg-drafts#8059, when the inset-modified containing block (i.e., the available space) for an out-of-flow is overflowed, it's preferred to trigger position fallback. This patch implements it. Note: this patch has nothing to do with scrolling. A follow-up patch will deal with scrolling (crrev.com/c/3995704). Bug: 1309178 Change-Id: I980d91e6f155ddc030518142440ab49286df823e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4020923 Reviewed-by: Koji Ishii <kojii@chromium.org> Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org> Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org> Cr-Commit-Position: refs/heads/main@{#1078344}
…ailable space is overflowed, a=testonly Automatic update from web-platform-tests [anchor-position] Trigger fallback if available space is overflowed As discussed in w3c/csswg-drafts#8059, when the inset-modified containing block (i.e., the available space) for an out-of-flow is overflowed, it's preferred to trigger position fallback. This patch implements it. Note: this patch has nothing to do with scrolling. A follow-up patch will deal with scrolling (crrev.com/c/3995704). Bug: 1309178 Change-Id: I980d91e6f155ddc030518142440ab49286df823e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4020923 Reviewed-by: Koji Ishii <kojii@chromium.org> Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org> Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org> Cr-Commit-Position: refs/heads/main@{#1078344} -- wpt-commits: 02b6f2ee96fcdb2d99d1c5a2165822a274e3060e wpt-pr: 37266
As discussed in w3c/csswg-drafts#8059, when the inset-modified containing block (i.e., the available space) for an out-of-flow is overflowed, it's preferred to trigger position fallback. This patch implements it. Note: this patch has nothing to do with scrolling. A follow-up patch will deal with scrolling (crrev.com/c/3995704). Bug: 1309178 Change-Id: I980d91e6f155ddc030518142440ab49286df823e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4020923 Reviewed-by: Koji Ishii <kojii@chromium.org> Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org> Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org> Cr-Commit-Position: refs/heads/main@{#1078344}
…ailable space is overflowed, a=testonly Automatic update from web-platform-tests [anchor-position] Trigger fallback if available space is overflowed As discussed in w3c/csswg-drafts#8059, when the inset-modified containing block (i.e., the available space) for an out-of-flow is overflowed, it's preferred to trigger position fallback. This patch implements it. Note: this patch has nothing to do with scrolling. A follow-up patch will deal with scrolling (crrev.com/c/3995704). Bug: 1309178 Change-Id: I980d91e6f155ddc030518142440ab49286df823e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4020923 Reviewed-by: Koji Ishii <kojii@chromium.org> Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org> Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org> Cr-Commit-Position: refs/heads/main@{#1078344} -- wpt-commits: 02b6f2ee96fcdb2d99d1c5a2165822a274e3060e wpt-pr: 37266
A new idea to make it work better with scrolling: For each fallback position, we can calculate a scroll-adjusted inset modified containing block, defined as follows:
We can easily run this through my previous test case and verify its correctness. Intuitively, we are still folding scroll offset into inset value evaluation; however, we are not folding it deep into each This still won't cause layout invalidation in every scrolling, and hence still supports composited scrolling. When scrolled by an amount, both the margin box and certain edges of the scroll-adjusted inset-modified containing block will be shifted; Note that they are always shifted by the same amount. Therefore:
So in the end, for each fallback position, we can still work out a range of scroll offsets, which forms a rectangle, in which the fallback position is valid. We trigger relayout only when we scroll out of this range. |
Okay, I believe I've accurately translated your suggestion into spec text. ptal? |
There's a still a minor bug, though it's probably an edge case. If the target element has 0 size, then it can still fit in the scroll-adjusted IMCB even when it's out of the original containing block -- this happens when the SAIMCB is collapsed and also out of the original CB. (e.g., with To fix it, we can require that the scroll-shifted margin box must be in both the SAIMCB and the original CB. (Equivalently, we can skip the final clamp-negative-size-to-zero step at the end of the SAIMCB calculation -- then the 0-sized element can't fit in a negative-sized SAIMCB; this requires more complicated spec text but is simpler to implement) |
Talked to @tabatkins offline. Here's the stuff we agreed to add to the spec:
|
Previously, we've been using the inset-modified containing block for position fallback, which doesn't work well with scrolling. This patch fixes the issue by using the scroll-adjusted IMCB instead, which was introduced earlier on the spec side [1]. As an implementation detail, this patch also calculates and stores the non-overflowing scroll ranges [2] for each fallback position, so that we can still use composited scrolling, and need to invalidate layout only when we have scrolled out of that range. This patch also adds WPT tests under various writing modes and directions to cover all the new code paths. [1] https://drafts4.csswg.org/css-anchor-position-1/#determine-the-position-fallback-styles [2] w3c/csswg-drafts#8059 (comment) Fixed: 1418725 Change-Id: If9e104c6ac3c51ccdfc4fa7d3cf9cbffcc5af46d
Previously, we've been using the inset-modified containing block for position fallback, which doesn't work well with scrolling. This patch fixes the issue by using the scroll-adjusted IMCB instead, which was introduced earlier on the spec side [1]. As an implementation detail, this patch also calculates and stores the non-overflowing scroll ranges [2] for each fallback position, so that we can still use composited scrolling, and need to invalidate layout only when we have scrolled out of that range. This patch also adds WPT tests under various writing modes and directions to cover all the new code paths. [1] https://drafts4.csswg.org/css-anchor-position-1/#determine-the-position-fallback-styles [2] w3c/csswg-drafts#8059 (comment) Fixed: 1418725 Change-Id: If9e104c6ac3c51ccdfc4fa7d3cf9cbffcc5af46d
Previously, we've been using the inset-modified containing block for position fallback, which doesn't work well with scrolling. This patch fixes the issue by using the scroll-adjusted IMCB instead, which was introduced earlier on the spec side [1]. As an implementation detail, this patch also calculates and stores the non-overflowing scroll ranges [2] for each fallback position, so that we can still use composited scrolling, and need to invalidate layout only when we have scrolled out of that range. This patch also adds WPT tests under various writing modes and directions to cover all the new code paths. [1] https://drafts4.csswg.org/css-anchor-position-1/#determine-the-position-fallback-styles [2] w3c/csswg-drafts#8059 (comment) Fixed: 1418725 Change-Id: If9e104c6ac3c51ccdfc4fa7d3cf9cbffcc5af46d
Previously, we've been using the inset-modified containing block for position fallback, which doesn't work well with scrolling. This patch fixes the issue by using the scroll-adjusted IMCB instead, which was introduced earlier on the spec side [1]. As an implementation detail, this patch also calculates and stores the non-overflowing scroll ranges [2] for each fallback position, so that we can still use composited scrolling, and need to invalidate layout only when we have scrolled out of that range. This patch also adds WPT tests under various writing modes and directions to cover all the new code paths. [1] https://drafts4.csswg.org/css-anchor-position-1/#determine-the-position-fallback-styles [2] w3c/csswg-drafts#8059 (comment) Bug: 1418725 Change-Id: If9e104c6ac3c51ccdfc4fa7d3cf9cbffcc5af46d
Previously, we've been using the inset-modified containing block for position fallback, which doesn't work well with scrolling. This patch fixes the issue by using the scroll-adjusted IMCB instead, which was introduced earlier on the spec side [1]. As an implementation detail, this patch also calculates and stores the non-overflowing scroll ranges [2] for each fallback position, so that we can still use composited scrolling, and need to invalidate layout only when we have scrolled out of that range. This patch also adds WPT tests under various writing modes and directions to cover all the new code paths. [1] https://drafts4.csswg.org/css-anchor-position-1/#determine-the-position-fallback-styles [2] w3c/csswg-drafts#8059 (comment) Bug: 1418725 Change-Id: If9e104c6ac3c51ccdfc4fa7d3cf9cbffcc5af46d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4292618 Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org> Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org> Cr-Commit-Position: refs/heads/main@{#1118926}
Previously, we've been using the inset-modified containing block for position fallback, which doesn't work well with scrolling. This patch fixes the issue by using the scroll-adjusted IMCB instead, which was introduced earlier on the spec side [1]. As an implementation detail, this patch also calculates and stores the non-overflowing scroll ranges [2] for each fallback position, so that we can still use composited scrolling, and need to invalidate layout only when we have scrolled out of that range. This patch also adds WPT tests under various writing modes and directions to cover all the new code paths. [1] https://drafts4.csswg.org/css-anchor-position-1/#determine-the-position-fallback-styles [2] w3c/csswg-drafts#8059 (comment) Bug: 1418725 Change-Id: If9e104c6ac3c51ccdfc4fa7d3cf9cbffcc5af46d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4292618 Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org> Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org> Cr-Commit-Position: refs/heads/main@{#1118926}
Previously, we've been using the inset-modified containing block for position fallback, which doesn't work well with scrolling. This patch fixes the issue by using the scroll-adjusted IMCB instead, which was introduced earlier on the spec side [1]. As an implementation detail, this patch also calculates and stores the non-overflowing scroll ranges [2] for each fallback position, so that we can still use composited scrolling, and need to invalidate layout only when we have scrolled out of that range. This patch also adds WPT tests under various writing modes and directions to cover all the new code paths. [1] https://drafts4.csswg.org/css-anchor-position-1/#determine-the-position-fallback-styles [2] w3c/csswg-drafts#8059 (comment) Bug: 1418725 Change-Id: If9e104c6ac3c51ccdfc4fa7d3cf9cbffcc5af46d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4292618 Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org> Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org> Cr-Commit-Position: refs/heads/main@{#1118926}
Previously, we've been using the inset-modified containing block for position fallback, which doesn't work well with scrolling. This patch fixes the issue by using the scroll-adjusted IMCB instead, which was introduced earlier on the spec side [1]. As an implementation detail, this patch also calculates and stores the non-overflowing scroll ranges [2] for each fallback position, so that we can still use composited scrolling, and need to invalidate layout only when we have scrolled out of that range. This patch also adds WPT tests under various writing modes and directions to cover all the new code paths. [1] https://drafts4.csswg.org/css-anchor-position-1/#determine-the-position-fallback-styles [2] w3c/csswg-drafts#8059 (comment) Bug: 1418725 Change-Id: If9e104c6ac3c51ccdfc4fa7d3cf9cbffcc5af46d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4292618 Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org> Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org> Cr-Commit-Position: refs/heads/main@{#1118926}
Previously, we've been using the inset-modified containing block for position fallback, which doesn't work well with scrolling. This patch fixes the issue by using the scroll-adjusted IMCB instead, which was introduced earlier on the spec side [1]. As an implementation detail, this patch also calculates and stores the non-overflowing scroll ranges [2] for each fallback position, so that we can still use composited scrolling, and need to invalidate layout only when we have scrolled out of that range. This patch also adds WPT tests under various writing modes and directions to cover all the new code paths. [1] https://drafts4.csswg.org/css-anchor-position-1/#determine-the-position-fallback-styles [2] w3c/csswg-drafts#8059 (comment) Bug: 1418725 Change-Id: If9e104c6ac3c51ccdfc4fa7d3cf9cbffcc5af46d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4292618 Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org> Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org> Cr-Commit-Position: refs/heads/main@{#1118926}
Previously, we've been using the inset-modified containing block for position fallback, which doesn't work well with scrolling. This patch fixes the issue by using the scroll-adjusted IMCB instead, which was introduced earlier on the spec side [1]. As an implementation detail, this patch also calculates and stores the non-overflowing scroll ranges [2] for each fallback position, so that we can still use composited scrolling, and need to invalidate layout only when we have scrolled out of that range. This patch also adds WPT tests under various writing modes and directions to cover all the new code paths. [1] https://drafts4.csswg.org/css-anchor-position-1/#determine-the-position-fallback-styles [2] w3c/csswg-drafts#8059 (comment) Bug: 1418725 Change-Id: If9e104c6ac3c51ccdfc4fa7d3cf9cbffcc5af46d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4292618 Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org> Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org> Cr-Commit-Position: refs/heads/main@{#1118926}
…CB for position fallback, a=testonly Automatic update from web-platform-tests [anchor-position] Use scroll-adjusted IMCB for position fallback Previously, we've been using the inset-modified containing block for position fallback, which doesn't work well with scrolling. This patch fixes the issue by using the scroll-adjusted IMCB instead, which was introduced earlier on the spec side [1]. As an implementation detail, this patch also calculates and stores the non-overflowing scroll ranges [2] for each fallback position, so that we can still use composited scrolling, and need to invalidate layout only when we have scrolled out of that range. This patch also adds WPT tests under various writing modes and directions to cover all the new code paths. [1] https://drafts4.csswg.org/css-anchor-position-1/#determine-the-position-fallback-styles [2] w3c/csswg-drafts#8059 (comment) Bug: 1418725 Change-Id: If9e104c6ac3c51ccdfc4fa7d3cf9cbffcc5af46d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4292618 Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org> Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org> Cr-Commit-Position: refs/heads/main@{#1118926} -- wpt-commits: e2169b6b0b5ca89b61b976f512e9ad52bace8597 wpt-pr: 38998
Previously, we've been using the inset-modified containing block for position fallback, which doesn't work well with scrolling. This patch fixes the issue by using the scroll-adjusted IMCB instead, which was introduced earlier on the spec side [1]. As an implementation detail, this patch also calculates and stores the non-overflowing scroll ranges [2] for each fallback position, so that we can still use composited scrolling, and need to invalidate layout only when we have scrolled out of that range. This patch also adds WPT tests under various writing modes and directions to cover all the new code paths. [1] https://drafts4.csswg.org/css-anchor-position-1/#determine-the-position-fallback-styles [2] w3c/csswg-drafts#8059 (comment) Bug: 1418725 Change-Id: If9e104c6ac3c51ccdfc4fa7d3cf9cbffcc5af46d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4292618 Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org> Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org> Cr-Commit-Position: refs/heads/main@{#1118926}
…ng fallback, and close the edge case of a 0-height abspos considered to be fitting in a negative-height CB. #8059
Okay, made two fixes here.
|
It is still the case that the size of the element can't depend on scroll offsets† - its actual IMCB for layout purposes is still determined normally, based on the anchor's initial scroll position, so if the element is †: (The scroll offset can determine which fallback styles we're using, which can have an effect on the element's size, but that's not continuous variation like actually having the IMCB depend on the scroll offset would be. It'll just flip between a small set of fallbacks, and we're already okay with that being slightly desynced from composited scrolling; it's much less obvious than having something that's, say, supposed to stretch from a scrollable anchor to the bottom of the screen and always be the correct size to fill that space.) |
In a discussion with @bfgeek today we identified some issues about how position fallback is currently specified.
The text was updated successfully, but these errors were encountered: