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
[css-contain-3][css-anchor-position-1] Containment makes it difficult to use anchor positioning with container queries #10040
Comments
Right, it can only see the anchor-name of the container itself given the current spec for anchor-name: "Anchor names are style-contained, scoped to a sub-tree."
Even style containment does that here: https://drafts.csswg.org/css-contain-2/#property-scoped-to-a-sub-tree
The reason why we added style containment for size containers was that generated content for counters and quotes inside the container could affect layout outside the container through intrinsic sizing, which again could affect the size of the size container, which would cause circularities in the layout when counter/quotes styles depended on size query evaluation. Counters and quotes need to be style contained for size containers. |
@lilles Right, so the questions are:
|
There is a similar desire for timeline names not being contained by style containment: #8915 (comment) The difference is that being able to discover an anchor name likely has more implications in needing more layout (is that true?). In any case, it seems that maybe having style contain names vs contain counters are two separate needs that could be addressed by two different values. FWIW, for content-visibility, we do want to contain names as well as counters, so that part is still necessary |
Sure. I don't know if it makes sense to introduce separate contain keywords or just do it implicitly through container-type.
I didn't immediately spot any items that could be lifted https://drafts.csswg.org/css-contain-2/#containment-layout but @bfgeek should have a look, but this was specifically about anchor-name containment that's not yet in the list, right? |
My instinct would be to start with the implicit change to
Yeah… or anything else related to positioning that might interfere with anchorPos being used across container boundaries. I'm not sure that I know exactly what might impact that. |
I agree that it's important to support anchors across container query boundaries, and also across every other kind of layout boundary such as So what I propose is the following:
Agenda+ with that proposed resolution. |
Small amendment via a third bullet:
|
For posterity, also reverts resolution in #9100 |
The CSS Working Group just discussed
The full IRC log of that discussion<chrishtr> miriam: right now CQ relies on on side effects from anchor positioning, because anchor names are contained by style containment<chrishtr> miriam: this will also likely cause a problem for other areas such as names for scroll-driven animations <chrishtr> miriam: developers will be frustrated if one stops the other from working <TabAtkins> chrishtr: Proposed resolution (from the issue) is undo the previous resolution, and have anchor-names no longer be contained by style or layout or size <TabAtkins> chrishtr: So that anchor positioning and CQs can work well together <TabAtkins> chrishtr: However, we still need skipped subtrees (from c-v: auto) to block those anchor names <vmpstr> auto or hidden, presumably <TabAtkins> chrishtr: Because when such content is offscreen and skipped, we want the UA to be able to skip rendering entirely, which rquires not doing the layout necessary to position the anchor <TabAtkins> chrishtr: That's fine because the content is offscreen anyway, so anchoring to is isn't useful. <miriam> q+ <Rossen_> ack miriam <chrishtr> miriam: wonder if layout containment is also an issue <kizu> q+ <emilio> q+ <TabAtkins> chrishtr: My proposed res also has it escape layout containment, which I think addresses your concern <Rossen_> ack kizu <TabAtkins> kizu: Some of the cases we'll be fixed by popover in the top layer, it'll escape containment <TabAtkins> kizu: But I think escaping via fixpos escape <TabAtkins> TabAtkins: It's just that anchor names escape, not the positioned element <TabAtkins> kizu: Okay, I thought there were other cases talked about in the thread, but if it's just anchor names that's okay <TabAtkins> chrishtr: Right <TabAtkins> miriam: But my issue is if an element inside a container is able to position relative to an element outside the container; that violates layout containment of the container for the abspos <Rossen_> q? <TabAtkins> chrishtr: Yes, it would be contained. <TabAtkins> emilio: I misunderstood Chris about whether this affects layout containment <TabAtkins> emilio: I'm confused - would the anchoring work? <TabAtkins> emilio: wouldn't this mean you can't anchor anything outside your CB chain, right? <TabAtkins> emilio: And if you hit a fixpos CB that prevents you from going further up, right? <Rossen_> ack emilio <TabAtkins> chrishtr: The case we're addressing is an element outside the CQ beinga ble to anchor to something inside the CQ <TabAtkins> iank_: Right, it's not an OOF inside the subtree beigna ble to escape, it's about being able to anchor to something inside the container <TabAtkins> emilio: Okay, yeah, I was talkinga bout the ohter way, with the positioned element inside the container <miriam> q+ <kizu> q+ <TabAtkins> TabAtkins: Remember that top layer pulls it out of the tree, and you can move it further up. <TabAtkins> q+ <khush> q+ <Rossen_> ack miriam <TabAtkins> miriam: I don't think youc an always move it futher up the tree. I want to see if we can solve that half of the problem,t oo. <TabAtkins> miriam: Containers created a fixpos CB is, as far as I can see, always a footgun, it's not something people want from containers. <TabAtkins> miriam: So if we can remove that limitation from CQs that would be excellent <TabAtkins> kizu: For the second part, an element inside a container and you want to position it outside without the top layer, the only thing I can think of is position-container, which lets you position to a different block <Rossen_> ack kizu <Rossen_> ack TabAtkins <chrishtr> TabAtkins: position container can't be used, because it uses the same scoping as anchor names <chrishtr> TabAtkins: for the same reasons that the restrictions are applied in the first place <chrishtr> TabAtkins: and changing that would amount to the same thing as pulling something up in the tree, which is a separate feature possibility <chrishtr> TabAtkins: the top layer is the best solution for all this <chrishtr> TabAtkinss: if we want some other more general thing we can solve it in the position spec <chrishtr> TabAtkins: propose we not try to solve that problem here <Rossen_> ack khush <chrishtr> khush: responding to comment about anchor being on screen causing the anchored element being relevant to the user <chrishtr> khush: not sure how to implement that <chrishtr> vmpstr: if on screen and scrolled offscreen, wont' stop being relevant <chrishtr> TabAtkins: there'd be a hysteresis <chrishtr> khushal: right, would need to bring an offscreen thing back to the screen for it to take effefct <vmpstr> q+ <Rossen_> ack vmpstr <chrishtr> vmpstr: minor clarification. Chris mentioned c-v: auto, but shouldn't we include hidden?> <chrishtr> chrishtr: agreed <chrishtr> chrishtr: hidden should be skipped <chrishtr> TabAtkins: this falls out of the definition of skipped <TabAtkins> <TabAtkins> chrishtr: Proposed resolution (from the issue) is undo the previous resolution, and have anchor-names no longer be contained by style or layout or size <TabAtkins> 08:08 <TabAtkins> chrishtr: So that anchor positioning and CQs can work well together <TabAtkins> 08:08 <TabAtkins> chrishtr: However, we still need skipped subtrees (from c-v: auto) to block those anchor names <TabAtkins> chrishtr: A little more precisely, a positioned element can anchor to something in a contained subtree, but not the opposite <TabAtkins> TabAtkins: That's handled by just saying the anchor names arent' contained <TabAtkins> RESOLVED: Undo the previous resolution - anchor names are not blocked by any form of containment. But they *are* blocked from escaping a "skipped content" element. <TabAtkins> RESOLVED: And if a positioned element is "relevant to the user", any element it's anchoring to remains "relevant to the user" as well. <Rossen_> github-bot topic: https://github.com//issues/9149 |
The second resolution isn't what I was thinking about initially. I think it's a good one, but there are a couple of cases:
I propose spending a few minutes thinking through all of the cases here, since I want to avoid to accidentally requiring rendering in an otherwise skipped subtree |
Per resolution in [1]. This reverts the parts of [2] necessary and re-introduces and optimization InsertInReverseTreeOrderInto(). [1] w3c/csswg-drafts#10040 (comment) [2] https://crrev.com/3f9c4d331fc5f555578a4a69ad04ee98380a55e6 Bug: 330520227, 329301681, 330407985, 329649094 Change-Id: I784a5366b0771973a6f2359fb012e22ff7d2db79
Per resolution in [1]. This reverts the parts of [2] necessary and re-introduces and optimization InsertInReverseTreeOrderInto(). [1] w3c/csswg-drafts#10040 (comment) [2] https://crrev.com/3f9c4d331fc5f555578a4a69ad04ee98380a55e6 Bug: 330520227, 329301681, 330407985, 329649094 Change-Id: I784a5366b0771973a6f2359fb012e22ff7d2db79
Per resolution in [1]. This reverts the parts of [2] necessary and re-introduces and optimization InsertInReverseTreeOrderInto(). [1] w3c/csswg-drafts#10040 (comment) [2] https://crrev.com/3f9c4d331fc5f555578a4a69ad04ee98380a55e6 Bug: 330520227, 329301681, 330407985, 329649094 Change-Id: I784a5366b0771973a6f2359fb012e22ff7d2db79 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5378414 Commit-Queue: Rune Lillesveen <futhark@chromium.org> Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org> Cr-Commit-Position: refs/heads/main@{#1276198}
Per resolution in [1]. This reverts the parts of [2] necessary and re-introduces and optimization InsertInReverseTreeOrderInto(). [1] w3c/csswg-drafts#10040 (comment) [2] https://crrev.com/3f9c4d331fc5f555578a4a69ad04ee98380a55e6 Bug: 330520227, 329301681, 330407985, 329649094 Change-Id: I784a5366b0771973a6f2359fb012e22ff7d2db79 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5378414 Commit-Queue: Rune Lillesveen <futhark@chromium.org> Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org> Cr-Commit-Position: refs/heads/main@{#1276198}
Per resolution in [1]. This reverts the parts of [2] necessary and re-introduces and optimization InsertInReverseTreeOrderInto(). [1] w3c/csswg-drafts#10040 (comment) [2] https://crrev.com/3f9c4d331fc5f555578a4a69ad04ee98380a55e6 Bug: 330520227, 329301681, 330407985, 329649094 Change-Id: I784a5366b0771973a6f2359fb012e22ff7d2db79 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5378414 Commit-Queue: Rune Lillesveen <futhark@chromium.org> Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org> Cr-Commit-Position: refs/heads/main@{#1276198}
After a bunch of discussions, I think it's fine if positioned elements are within c-v, because there's paint containment that would end up clipping it if if it's moved too far. It also establishes a containing block, so I don't see a use case for where this anchoring would be expected to work well when the anchor is elsewhere. |
…tent-skipping does. But anchoring prevents content-skipping from activating. #10040
…d not be style contained, a=testonly Automatic update from web-platform-tests [css-anchor-position] anchor-names should not be style contained Per resolution in [1]. This reverts the parts of [2] necessary and re-introduces and optimization InsertInReverseTreeOrderInto(). [1] w3c/csswg-drafts#10040 (comment) [2] https://crrev.com/3f9c4d331fc5f555578a4a69ad04ee98380a55e6 Bug: 330520227, 329301681, 330407985, 329649094 Change-Id: I784a5366b0771973a6f2359fb012e22ff7d2db79 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5378414 Commit-Queue: Rune Lillesveen <futhark@chromium.org> Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org> Cr-Commit-Position: refs/heads/main@{#1276198} -- wpt-commits: 8d3176749c9ee84965026a55ccd2aa9b0d646964 wpt-pr: 45244
…d not be style contained, a=testonly Automatic update from web-platform-tests [css-anchor-position] anchor-names should not be style contained Per resolution in [1]. This reverts the parts of [2] necessary and re-introduces and optimization InsertInReverseTreeOrderInto(). [1] w3c/csswg-drafts#10040 (comment) [2] https://crrev.com/3f9c4d331fc5f555578a4a69ad04ee98380a55e6 Bug: 330520227, 329301681, 330407985, 329649094 Change-Id: I784a5366b0771973a6f2359fb012e22ff7d2db79 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5378414 Commit-Queue: Rune Lillesveen <futhark@chromium.org> Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org> Cr-Commit-Position: refs/heads/main@{#1276198} -- wpt-commits: 8d3176749c9ee84965026a55ccd2aa9b0d646964 wpt-pr: 45244
Currently, container queries rely on several types of containment:
size
,layout
, andstyle
. This already causes some confusion with authors, when fixed-position elements nested in a container are now fixed to the container rather than the viewport (thanks to layout containment).That issue will become much more noticeable when container queries interact with anchor positioning. As currently defined,
layout
andstyle
containment will make it impossible for elements to anchor across different containers. I think that will mean:style
containment scopes the anchor name.layout
containment doesn't allow reference to external layout? (I'm less clear on the interaction here)While these decisions all make sense in terms of 'the promise' that each containment makes, it will cause a lot of problems for users who want to use both container queries and anchor positioning. Authors should be able to use these features without one constantly interfering with the other.
Since container queries are somewhat abstracted away from containment (we set a
container-type
, and browsers apply containment as-needed), I think the only path forward here is defining more subtle and targeted containment rules for container queries. Are there ways that we can relax how much layout and style containment is required to make container size queries work?(This came out of discussion on #9349)
/cc @tabatkins
The text was updated successfully, but these errors were encountered: