Skip to content
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-2][css-conditional-5] Weaker form of layout containment for container queries. #10544

Open
bfgeek opened this issue Jul 8, 2024 · 3 comments

Comments

@bfgeek
Copy link

bfgeek commented Jul 8, 2024

Layout containment was originally added as a performance optimization for engines. To ensure that a layout inside an element wont affect the layout outside (more or less).

With container queries we split it out into layout+size containment so that we can target one dimension, e.g. layout+inline-size containment. This was good! But IMO it didn't go far enough.

Ideally we should have done weak-layout+inline-size (and there may be still time left to do this).

With container-queries (due to this) we have limited ourselves in a number of ways - e.g.

And we are breaking the layout containment optimization via allowing anchors to escape layout contained subtree, e.g. #10040 with this resolution we've allowed the layout inside of a contain:layout element to affect things outside.

For container queries the only "layout" containment we really need is that it establishes a new formatting context.
(I've quickly checked https://chromium-review.googlesource.com/c/chromium/src/+/5685175 ).

There are a few of potential paths.

  1. Attempt to change container-queries when used via: container-type to ensure a new type of "weak-layout" containment (just establishing the new formatting context rule).
  2. Attempt to change container-queries (via container-type not to enforce layout containment, (just size containment) and specify that container-type establishes a new formatting context. (In an ideal world my preferred option).
  3. If not web compatible, (e.g. people might be relying on establishing a containing block for example). We could introduce a new values for container-type to allow this less strict version. e.g. container-type: new-inline-size

With all 3 of these we should undo - the anchor-pos resolution in #10040 and make layout containment contain anchors again.

@mirisuzanne
Copy link
Contributor

I also would love to make this distinction, and prefer option 2. It seems like something we would have to do with some urgency to avoid compat issues?

@bfgeek
Copy link
Author

bfgeek commented Jul 10, 2024

Yeah it's somewhat urgent to make this change - I'll Adgenda+ think to gauge the temperature on this.

@bfgeek bfgeek added the Agenda+ label Jul 10, 2024
@css-meeting-bot
Copy link
Member

The CSS Working Group just discussed Containment, and agreed to the following:

  • RESOLVED: container-type does not force layout containment, but does force an independent formatting context
The full IRC log of that discussion <fantasai> Topic: Containment
<fantasai> github: https://wiki.csswg.org/planning/tpac-2024#proposed-covid-protocols
<fantasai> iank_: When we did CQ, we split containment into layout and size containment
<fantasai> iank_: inline-size and block-size also
<dbaron> github: https://github.com//issues/10544
<fantasai> iank_: We've been running into issues because of enforcing layout containment
<florian> q+
<fantasai> iank_: when you CQ, you can't baseline-align, you can't allow abspos/fixedbpos to escape, scrollable overflow is broken, etc.
<fantasai> iank_: side-effects are annoying for developers
<fantasai> iank_: After investigation, the only restriction we really need is that it establishes a new formatting context
<fantasai> iank_: Lots of issues where devs ask us to remove these restrictions
<fantasai> iank_: a few paths forward
<emilio> q+
<fantasai> iank_: most ideal one, which contains the most compat risk -- but we're fine trying that, roll out behind a flag and work with devs to fix sites -- is to change container type to not enforce layout conainment, just size containment
<fantasai> iank_: and also establish a new formatting context
<fantasai> iank_: that's my ideal proposal
<fantasai> iank_: There are a couple other variants possible
<fantasai> iank_: miriam would also like to take this variant
<Rossen2> ack florian
<fantasai> florian: I'm unsure. I understand the desire to relax these constraints
<fantasai> florian: but not convinced about necessity
<fantasai> florian: e.g. abspos, if you allow to escape, then at a higher level in the tree they could cause scrollbars
<fantasai> florian: which then change the layout space you have to lay out in
<fantasai> florian: which changes the width you're querying against
<fantasai> florian: so it's annoying, but the constraint was there to break the circularity
<fantasai> florian: so yes, annoying, but are they necessary? and otherwise how do you cope?
<fantasai> iank_: falls under "always move forward" constraint
<fantasai> iank_: if you set up container, then can cause relayout
<fantasai> iank_: principle is moving forward -- so you add scrollbars, and don't remove them
<Rossen2> ack emilio
<fantasai> emilio: was going to bring up similar concerns
<fantasai> emilio: last time I checked, browsers still somewhat inconsistent wrt circularities
<fantasai> emilio: has that changed?
<fantasai> emilio: not opposed to removing, but...
<fantasai> emilio: for all browsers it's straighforward to do *something*
<fantasai> emilio: we break cycles similarly to webkit
<fantasai> iank_: I don't think you or webkit are following the spec
<fantasai> emilio: for us it would be a bigger change, because circular case would become a lot more common
<fantasai> iank_: block-size circularity is pretty common, actually
<fantasai> iank_: and I would like to fix this for web developers. It's the #1 complaint we receive for container queries
<florian> q?
<fantasai> emilio: they should complain to the WG
<florian> q+
<fantasai> iank_: they have been
<Rossen2> ack florian
<fantasai> florian: "always move forward" approach, you're saying FF and WK don't follow it well? How well is specified?
<fantasai> florian: Are we sure that we can gain interop on this approach?
<fantasai> florian: if so, then that's a path forward
<fantasai> florian: but if unproven, then maybe it's premature to resolve this issue
<fantasai> florian: maybe need to make sure "always move forward" is web-compatible
<fantasai> iank_: We do it today, so definitely web-compatible
<fantasai> iank_: FF and WK fail some tests because not doing it correctly
<fantasai> iank_: it comes down to interleaving style and layout, and I think we're the only ones doing it correctly today
<fantasai> florian: is it well-defined enough?
<fantasai> iank_: I also don't want to stall on this issue, because compat closes
<emilio> +1
<Rossen2> ack fantasai
<fantasai> fantasai: Can't speak for webkit officially because haven't discussed internally
<emilio> fantasai: can't speak for webkit, but in principle we want to support authors making their use cases work
<emilio> ah
<fantasai> fantasai: Some concerns about style/layout interleaving being underspecified -- I know Tab was handwaving at it in anchorpos spec
<fantasai> fantasai: would be good to get that specced thorougly
<fantasai> fantasai: but I think we should support Chrome experimenting to see how far we can push this in the direction that authors expect
<fantasai> iank_: [proposal]
<fantasai> iank_: Option 1 is introducing a new containment type, and then we have to define what that does
<fantasai> iank_: This option bypasses it
<iank_> proposed resolution: container-type does not force layout containment, but does force an independent formatting context.
<florian> i/[proposal]/florian: Not exactly sure what the difference in practice is between option 1 and 2, but seems fine.
<fantasai> RESOLVED: container-type does not force layout containment, but does force an independent formatting context
<Rossen2> fantasai: asking TabAtkins and iank_ to work on this independently and bring it back to the WG for review
<TabAtkins> Yeah happy to get an edit into the spec and ask for review
<fantasai> s/this independently/defining style+layout interleaving more thoroughly/
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Jul 25, 2024
As per:
w3c/csswg-drafts#10544 (comment)

Drop layout containment from container-type.
Placed behind the flag:
ContainerTypeNoLayoutContainment
In case we need to switch it off.

Developers can opt into the old behaviour by adding "contain: layout"
to their container.

This solves a bunch of issues web developers have been having with
container queries including:
 - Not allowing abspos/fixedpos to escape subtrees (useful for
   tooltips etc).
 - Baseline aligning.
 - Ensuring scrollable overflow to calculated in a more intuitive
   manner.

Fixed: 355215704
Change-Id: I4c02984dac8c49f105bd442f058089ed5cc2cd3d
aarongable pushed a commit to chromium/chromium that referenced this issue Jul 25, 2024
As per:
w3c/csswg-drafts#10544 (comment)

Drop layout containment from container-type.
Placed behind the flag:
ContainerTypeNoLayoutContainment
In case we need to switch it off.

Developers can opt into the old behaviour by adding "contain: layout"
to their container.

This solves a bunch of issues web developers have been having with
container queries including:
 - Not allowing abspos/fixedpos to escape subtrees (useful for
   tooltips etc).
 - Baseline aligning.
 - Ensuring scrollable overflow to calculated in a more intuitive
   manner.

Fixed: 355215704
Change-Id: I4c02984dac8c49f105bd442f058089ed5cc2cd3d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5738176
Reviewed-by: David Grogan <dgrogan@chromium.org>
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1333234}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Jul 25, 2024
As per:
w3c/csswg-drafts#10544 (comment)

Drop layout containment from container-type.
Placed behind the flag:
ContainerTypeNoLayoutContainment
In case we need to switch it off.

Developers can opt into the old behaviour by adding "contain: layout"
to their container.

This solves a bunch of issues web developers have been having with
container queries including:
 - Not allowing abspos/fixedpos to escape subtrees (useful for
   tooltips etc).
 - Baseline aligning.
 - Ensuring scrollable overflow to calculated in a more intuitive
   manner.

Fixed: 355215704
Change-Id: I4c02984dac8c49f105bd442f058089ed5cc2cd3d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5738176
Reviewed-by: David Grogan <dgrogan@chromium.org>
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1333234}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Jul 25, 2024
As per:
w3c/csswg-drafts#10544 (comment)

Drop layout containment from container-type.
Placed behind the flag:
ContainerTypeNoLayoutContainment
In case we need to switch it off.

Developers can opt into the old behaviour by adding "contain: layout"
to their container.

This solves a bunch of issues web developers have been having with
container queries including:
 - Not allowing abspos/fixedpos to escape subtrees (useful for
   tooltips etc).
 - Baseline aligning.
 - Ensuring scrollable overflow to calculated in a more intuitive
   manner.

Fixed: 355215704
Change-Id: I4c02984dac8c49f105bd442f058089ed5cc2cd3d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5738176
Reviewed-by: David Grogan <dgrogan@chromium.org>
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1333234}
karlcow added a commit to karlcow/WebKit that referenced this issue Jul 26, 2024
…ndependent formatting context

https://bugs.webkit.org/show_bug.cgi?id=277122
rdar://132549134

Reviewed by NOBODY (OOPS!).

container-type does not force layout containment, but does force
an independent formatting context by CSS WG resolution on
w3c/csswg-drafts#10544

FIXME: This is a draft. To add/import the relevant WPT tests.
web-platform-tests/wpt@27c89c6

* Source/WebCore/rendering/RenderElement.cpp:
(WebCore::RenderElement::establishesIndependentFormattingContext const):
* Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp:
(WebCore::StyleRareNonInheritedData::usedContain const):
karlcow added a commit to karlcow/WebKit that referenced this issue Jul 26, 2024
…ndependent formatting context

https://bugs.webkit.org/show_bug.cgi?id=277122
rdar://132549134

Reviewed by NOBODY (OOPS!).

container-type does not force layout containment, but does force
an independent formatting context by CSS WG resolution on
w3c/csswg-drafts#10544

FIXME: This is a draft. To add/import the relevant WPT tests.
web-platform-tests/wpt@27c89c6

* Source/WebCore/rendering/RenderElement.cpp:
(WebCore::RenderElement::establishesIndependentFormattingContext const):
* Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp:
(WebCore::StyleRareNonInheritedData::usedContain const):
karlcow added a commit to karlcow/WebKit that referenced this issue Jul 26, 2024
…ndependent formatting context

https://bugs.webkit.org/show_bug.cgi?id=277122
rdar://132549134

Reviewed by NOBODY (OOPS!).

container-type does not force layout containment, but does force
an independent formatting context by CSS WG resolution on
w3c/csswg-drafts#10544

FIXME: This is a draft. To add/import the relevant WPT tests.
web-platform-tests/wpt@27c89c6

* Source/WebCore/rendering/RenderElement.cpp:
(WebCore::RenderElement::establishesIndependentFormattingContext const):
* Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp:
(WebCore::StyleRareNonInheritedData::usedContain const):
karlcow added a commit to karlcow/WebKit that referenced this issue Jul 29, 2024
…ndependent formatting context

https://bugs.webkit.org/show_bug.cgi?id=277122
rdar://132549134

Reviewed by NOBODY (OOPS!).

container-type does not force layout containment, but does force
an independent formatting context by CSS WG resolution on
w3c/csswg-drafts#10544

This takes into account the latest import for container queries
WPT tests formatting
WebKit#31273
web-platform-tests/wpt@27c89c6

* Source/WebCore/rendering/RenderElement.cpp:
(WebCore::RenderElement::establishesIndependentFormattingContext const):
* Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp:
(WebCore::StyleRareNonInheritedData::usedContain const):
* LayoutTests/imported/w3c/web-platform-tests/css/css-conditional/container-queries/*
karlcow added a commit to karlcow/WebKit that referenced this issue Jul 29, 2024
…ndependent formatting context

https://bugs.webkit.org/show_bug.cgi?id=277122
rdar://132549134

Reviewed by NOBODY (OOPS!).

container-type does not force layout containment, but does force
an independent formatting context by CSS WG resolution on
w3c/csswg-drafts#10544

This takes into account the latest import for container queries
WPT tests formatting
web-platform-tests/wpt@27c89c6

* Source/WebCore/rendering/RenderElement.cpp:
(WebCore::RenderElement::establishesIndependentFormattingContext const):
* Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp:
(WebCore::StyleRareNonInheritedData::usedContain const):
nt1m pushed a commit to karlcow/WebKit that referenced this issue Jul 29, 2024
…pendent formatting context

https://bugs.webkit.org/show_bug.cgi?id=277122
rdar://132549134

Reviewed by NOBODY (OOPS!).

container-type does not force layout containment, but does force
an independent formatting context by CSS WG resolution on
w3c/csswg-drafts#10544

This takes into account the latest import for container queries
WPT tests formatting
web-platform-tests/wpt@27c89c6

* LayoutTests/TestExpectations:
* Source/WebCore/rendering/RenderElement.cpp:
(WebCore::RenderElement::establishesIndependentFormattingContext const):
(WebCore::RenderElement::hasEligibleContainmentForSizeQuery const):
* Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp:
(WebCore::StyleRareNonInheritedData::usedContain const):
nt1m pushed a commit to karlcow/WebKit that referenced this issue Jul 29, 2024
…pendent formatting context

https://bugs.webkit.org/show_bug.cgi?id=277122
rdar://132549134

Reviewed by NOBODY (OOPS!).

container-type does not force layout containment, but does force
an independent formatting context by CSS WG resolution on
w3c/csswg-drafts#10544

This takes into account the latest import for container queries
WPT tests formatting
web-platform-tests/wpt@27c89c6

* LayoutTests/TestExpectations:
* Source/WebCore/rendering/RenderElement.cpp:
(WebCore::RenderElement::establishesIndependentFormattingContext const):
(WebCore::RenderElement::hasEligibleContainmentForSizeQuery const):
* Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp:
(WebCore::StyleRareNonInheritedData::usedContain const):
karlcow added a commit to karlcow/WebKit that referenced this issue Jul 30, 2024
…pendent formatting context

https://bugs.webkit.org/show_bug.cgi?id=277122
rdar://132549134

Reviewed by NOBODY (OOPS!).

container-type does not force layout containment, but does force
an independent formatting context by CSS WG resolution on
w3c/csswg-drafts#10544

This takes into account the latest import for container queries
WPT tests formatting
web-platform-tests/wpt@27c89c6

* LayoutTests/TestExpectations:
* Source/WebCore/rendering/RenderElement.cpp:
(WebCore::RenderElement::establishesIndependentFormattingContext const):
(WebCore::RenderElement::hasEligibleContainmentForSizeQuery const):
* Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp:
(WebCore::StyleRareNonInheritedData::usedContain const):

Co-authored-by: Tim Nguyen <ntim@apple.com>
karlcow added a commit to karlcow/WebKit that referenced this issue Jul 30, 2024
…pendent formatting context

https://bugs.webkit.org/show_bug.cgi?id=277122
rdar://132549134

Reviewed by NOBODY (OOPS!).

container-type does not force layout containment, but does force
an independent formatting context by CSS WG resolution on
w3c/csswg-drafts#10544

This takes into account the latest import for container queries
WPT tests formatting
web-platform-tests/wpt@27c89c6

* LayoutTests/TestExpectations:
* Source/WebCore/rendering/RenderElement.cpp:
(WebCore::RenderElement::establishesIndependentFormattingContext const):
(WebCore::RenderElement::hasEligibleContainmentForSizeQuery const):
* Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp:
(WebCore::StyleRareNonInheritedData::usedContain const):

Co-authored-by: Tim Nguyen <ntim@apple.com>
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Jul 30, 2024
…ent from container-type., a=testonly

Automatic update from web-platform-tests
[container-queries] Drop layout containment from container-type.

As per:
w3c/csswg-drafts#10544 (comment)

Drop layout containment from container-type.
Placed behind the flag:
ContainerTypeNoLayoutContainment
In case we need to switch it off.

Developers can opt into the old behaviour by adding "contain: layout"
to their container.

This solves a bunch of issues web developers have been having with
container queries including:
 - Not allowing abspos/fixedpos to escape subtrees (useful for
   tooltips etc).
 - Baseline aligning.
 - Ensuring scrollable overflow to calculated in a more intuitive
   manner.

Fixed: 355215704
Change-Id: I4c02984dac8c49f105bd442f058089ed5cc2cd3d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5738176
Reviewed-by: David Grogan <dgrogan@chromium.org>
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1333234}

--

wpt-commits: 27c89c6f06af177cbd8f2ba5517be3c110fa50a0
wpt-pr: 47298
karlcow added a commit to karlcow/WebKit that referenced this issue Jul 31, 2024
…pendent formatting context

https://bugs.webkit.org/show_bug.cgi?id=277122
rdar://132549134

Reviewed by NOBODY (OOPS!).

container-type does not force layout containment, but does force
an independent formatting context by CSS WG resolution on
w3c/csswg-drafts#10544

This takes into account the latest import for container queries
WPT tests formatting
web-platform-tests/wpt@27c89c6

* LayoutTests/TestExpectations:
* Source/WebCore/rendering/RenderBlock.cpp:
(WebCore::RenderBlock::firstLineBaseline const):
* Source/WebCore/rendering/RenderElement.cpp:
(WebCore::RenderElement::establishesIndependentFormattingContext const):
(WebCore::RenderElement::hasEligibleContainmentForSizeQuery const):
* Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp:
(WebCore::StyleRareNonInheritedData::usedContain const):

Co-authored-by: Tim Nguyen <ntim@apple.com>
jamienicol pushed a commit to jamienicol/gecko that referenced this issue Aug 5, 2024
…ent from container-type., a=testonly

Automatic update from web-platform-tests
[container-queries] Drop layout containment from container-type.

As per:
w3c/csswg-drafts#10544 (comment)

Drop layout containment from container-type.
Placed behind the flag:
ContainerTypeNoLayoutContainment
In case we need to switch it off.

Developers can opt into the old behaviour by adding "contain: layout"
to their container.

This solves a bunch of issues web developers have been having with
container queries including:
 - Not allowing abspos/fixedpos to escape subtrees (useful for
   tooltips etc).
 - Baseline aligning.
 - Ensuring scrollable overflow to calculated in a more intuitive
   manner.

Fixed: 355215704
Change-Id: I4c02984dac8c49f105bd442f058089ed5cc2cd3d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5738176
Reviewed-by: David Grogan <dgrogan@chromium.org>
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1333234}

--

wpt-commits: 27c89c6f06af177cbd8f2ba5517be3c110fa50a0
wpt-pr: 47298
i3roly pushed a commit to i3roly/firefox-dynasty that referenced this issue Aug 7, 2024
…ent from container-type., a=testonly

Automatic update from web-platform-tests
[container-queries] Drop layout containment from container-type.

As per:
w3c/csswg-drafts#10544 (comment)

Drop layout containment from container-type.
Placed behind the flag:
ContainerTypeNoLayoutContainment
In case we need to switch it off.

Developers can opt into the old behaviour by adding "contain: layout"
to their container.

This solves a bunch of issues web developers have been having with
container queries including:
 - Not allowing abspos/fixedpos to escape subtrees (useful for
   tooltips etc).
 - Baseline aligning.
 - Ensuring scrollable overflow to calculated in a more intuitive
   manner.

Fixed: 355215704
Change-Id: I4c02984dac8c49f105bd442f058089ed5cc2cd3d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5738176
Reviewed-by: David Grogan <dgrogan@chromium.org>
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1333234}

--

wpt-commits: 27c89c6f06af177cbd8f2ba5517be3c110fa50a0
wpt-pr: 47298
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants