Skip to content

[css-overflow] Web compat issue when hiding abspos after the line-clamp point #11379

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

Open
andreubotella opened this issue Dec 16, 2024 · 11 comments

Comments

@andreubotella
Copy link
Member

Firefox has been shipping parts of the continue: collapse proposal (see #7708 and #10816) in their implementation of -webkit-line-clamp, which included hiding content after the clamp point. For absolute positioned elements, they would be hidden if they are after the clamp point in the layout tree, regardless of where they are positioned.

However, this abspos behavior seems to break the web. Firefox got three different bug reports (bugs 1934547, 1934811 and 1936267), one of which affecting LinkedIn, where an absolutely positioned element that was placed at the end of a line-clamp container (or in an ::after pseudoelement) but positioned to show before the clamp point was expected to be visible. In two of these three cases, these positioned elements were the "Show more" button that would turn off line-clamping.

All of these cases use -webkit-line-clamp together with overflow: hidden, so absolutely positioned boxes that would be positioned after the clamp point would be hidden regardless, whether they are before or after it in the layout tree. What breaks the web are abspos after the clamp point that are positioned to be visible before it. In the current proposed spec text, once the clamp point is determined, knowing whether a box should be hidden is a matter of seeing its position relative to the clamp point in the layout tree. Figuring out where an abspos is positioned with respect to the clamp point is an additional layer of layout complexity that wouldn't be present in the current proposal. The alternative is to never hide an abspos, but in that case authors would still need to specify overflow: hidden.

cc @frivoal @bfgeek @emilio @dholbert

@emilio
Copy link
Collaborator

emilio commented Dec 16, 2024

Slight preference (without having thought too hard in terms of complexity) to never hide absposes whose containing block is not within any of the lines, fwiw.

They do not belong to a "line" other than for purposes of their hypothetical position / paint order...

E.g., I think something like:

<div id=clamp>
  ... <!-- clamp point is above here -->
  <div style="position: absolute">This should paint</div>
  <div style="position: relative">
    <div style="position: absolute">This shouldn't</div>
    <div style="position: fixed">This probably should?</div>
  </div>
</div>

Implementation wise would definitely be harder tho, wonder if people have strong opinions one way or the other?

@frivoal
Copy link
Collaborator

frivoal commented Jan 10, 2025

This is unfortunate. Just hiding abspos after the clamp point was simple and convenient. That said, even though we're looking for a different behavior due to compat needs, I don't think we should introduce a difference in behavior between line-clamp under the legacy syntax and under the new one. There are already a few small differences in terms of how you activate the feature, but once it's on, it's on, and I think we should stick to that.

Now, as to what the behavior should be… I'm inclided to suggest keeping it simple, and just letting absolutely positioned elements (maybe even those that are descendents of relpos) be show, without further complication. Most likely, authors doing this will move them back to somewhere they can been seen anyway (like the LinkedIn example of the "show more" button). If authors leave the at their static position, it'll be a little weird, but it's easily rememdied: either move it to somewhere useful, or use overflow hidden.

@emilio emilio added the Agenda+ label Jan 13, 2025
@astearns astearns moved this to FTF agenda items in CSSWG January 2025 meeting Jan 22, 2025
@astearns astearns moved this from FTF agenda items to Regular agenda items in CSSWG January 2025 meeting Jan 22, 2025
@astearns astearns moved this from Regular agenda items to Thursday afternoon in CSSWG January 2025 meeting Jan 28, 2025
@css-meeting-bot
Copy link
Member

The CSS Working Group just discussed [css-overflow] Web compat issue when hiding abspos after the line-clamp point, and agreed to the following:

  • RESOLVED: do not skip painting for abs pos where the containing block for the abs pos is at or above the line clamp
The full IRC log of that discussion <nicole> emilio: I implemented line-clamp model so you don't paint lines that are clamped. Including abs pos if static position is after clamp point
<nicole> emilio: had to revert behavior change, so need a new solution
<nicole> emilio: most sensible, keep painting abs pos whose containing block is at or above the line clamp container
<nicole> emilio: not counting abs pos contained in an inline element
<florian> q+
<nicole> emilio: only abs pos that hang off of clamped container or above
<astearns> q+
<nicole> emilio: could restrict it more, main issue is you still need to dig through arbitrary content to find abs pos elements
<nicole> iank_: you need to do that anyway
<nicole> iank_: abs pos still has geometry
<nicole> emilio: still need to lay it out
<nicole> iank_: yes
<andreubotella> q+
<nicole> emilio: in gecko after layout, build display list, if you don't paint, just keep the subtree
<nicole> emilio: abspos, painting order depends on in flow position
<astearns> ack florian
<nicole> florian: could we not do it, not paint, not bother with complexity. Can't from a webcompat perspective. They use the abs. pos to add a button to expand the clamped area
<nicole> florian: Emilio's proposal is probably the best
<nicole> florian: people may move it and it will pop up out of there. If they put it somewhere reasonable the behavior will be reasonable. If they want to be sure it isn't visible, overflow hidden
<nicole> iank_: relpos can affect the painting
<kizu> q+
<nicole> emilio: the way gecko paints abs pos: traverse layout tree, end up in inflow pos of abs pos, then build display list for the abs pos
<nicole> iank_: oh, we don't do that, I'm not concerned
<nicole> astearns: is this just abs pos or other things too? ex. anchor positioning
<dholbert> (rel-pos and sticky-pos are worth considering too)
<dholbert> (but hopefully can be disregarded)
<kizu> q-
<nicole> TabAtkins: currently have the ability to do that
<astearns> ack astearns
<nicole> astearns: does position relative to anchor make a difference
<nicole> TabAtkins: it is absolutely pos
<nicole> iank_: if potential anchor is past line clamp, we don't consider that a potential anchor
<astearns> ack andreubotella
<nicole> andreubotella: not great to have text that is hidden but not abspos. One option to limit this to ____
<florian> s/____/the -webkit- prefixed version
<florian> q+
<nicole> andreubotella: but would cause a difference in layout between line-clamp and webkit-line-clamp. Not desirable.
<emilio> q+
<nicole> andreubotella: should authors be told to use overflow hidden? We were hoping to avoid this with web components
<andreubotella> s/with web components/with this redefinition of (-webkit-)line-clamp
<nicole> iank_: for the 99% case, this doesn't matter. For the cases with combat challenges, people do want the abs pos to be painted
<nicole> iank_: I think that's fine
<florian> s/combat/compat/
<nicole> iank_: we should minimize differences between webkit-line-clamp and line-clamp for autoprefixer's sake
<astearns> ack florian
<nicole> florian: also thinks this is fine, don't restrict to webkit prefix
<nicole> florian: kind of handy to create button to expand clamp
<astearns> ack emilio
<nicole> florian: in the few cases where people didn't want it to paint authors can use clip and other options
<nicole> emilio: weird if we painted arbitrary abspos. ex. an icon but not a button
<nicole> emilio: in this case you are just affecting something inside the line clamp tree, so it seems like a feature
<nicole> Emilio: proposed resolution, do not skip painting for abs pos where the position is at or above the line clamped container
<nicole> holbert: wants to add mentioning containing block
<florian> s/where the position/where the containing block
<nicole> astearns: edit, do not skip painting for abs pos where the containing block for the abs pos is at or above the line clamp
<nicole> RESOLVED: do not skip painting for abs pos where the containing block for the abs pos is at or above the line clamp

@smfr
Copy link
Contributor

smfr commented Jan 31, 2025

Did this resolution only apply to -webkit-line-clamp, or also to line-clamp?

@andreubotella
Copy link
Member Author

Did this resolution only apply to -webkit-line-clamp, or also to line-clamp?

To both.

@smfr
Copy link
Contributor

smfr commented Jan 31, 2025

Why don't we do the sensible thing for line-clamp, and only this hacky thing for the legacy property?

@emilio
Copy link
Collaborator

emilio commented Jan 31, 2025

Not opposed to that, though it'd be ideal if we didn't have a legacy switch.

@bfgeek
Copy link

bfgeek commented Jan 31, 2025

Why don't we do the sensible thing for line-clamp, and only this hacky thing for the legacy property?

It was discussed (see minutes) but in the room preference was to keep everything consistent. (And likely necessary due to auto-prefixers already using line-clamp)

@tabatkins
Copy link
Member

Importantly, this seems like a potentially useful behavior, and we dont' want to encourage people to use the old syntax just for that.

@andreubotella
Copy link
Member Author

andreubotella commented Feb 17, 2025

Would this work the same for position: fixed boxes, except depending on whether the fixed positioning containing block is at or above the line-clamp container? I haven't really thought so far about how fixed positioning would interact with line-clamp.

aarongable pushed a commit to chromium/chromium that referenced this issue May 1, 2025
In w3c/csswg-drafts#11962, the CSSWG
resolved that abspos which are descendants of a line-clamp container
must be hidden if and only if their containing block is fully after
the clamp point.

This is a significantly different behavior than the current
implementation, and this CL updates it. As part of that, it reverts a
large part of that code that deals with marking individual OOFs as
hidden for paint, and instead marks a `ContainingBlockInfo` as such.

This also implements a previous CSSWG resolution, that at
w3c/csswg-drafts#11379, which fixed a web
compat bug by saying that abspos whose containing block is the
line-clamp container or an ancestor of it should always be shown.
That previous resolution is a subset of the newer one, and so it
doesn't need any additional implementation.

This CL also rewrites most abspos tests, since they were written using
the current implementation's behavior in mind, and adds similar tests
for fixed positioning.

Bug: 40336192, 393549029, 407973206
Change-Id: I199f1c9ef01aa1e532148e8ad3227ee1932e5b4c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6396495
Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Andreu Botella <abotella@igalia.com>
Cr-Commit-Position: refs/heads/main@{#1454384}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue May 1, 2025
In w3c/csswg-drafts#11962, the CSSWG
resolved that abspos which are descendants of a line-clamp container
must be hidden if and only if their containing block is fully after
the clamp point.

This is a significantly different behavior than the current
implementation, and this CL updates it. As part of that, it reverts a
large part of that code that deals with marking individual OOFs as
hidden for paint, and instead marks a `ContainingBlockInfo` as such.

This also implements a previous CSSWG resolution, that at
w3c/csswg-drafts#11379, which fixed a web
compat bug by saying that abspos whose containing block is the
line-clamp container or an ancestor of it should always be shown.
That previous resolution is a subset of the newer one, and so it
doesn't need any additional implementation.

This CL also rewrites most abspos tests, since they were written using
the current implementation's behavior in mind, and adds similar tests
for fixed positioning.

Bug: 40336192, 393549029, 407973206
Change-Id: I199f1c9ef01aa1e532148e8ad3227ee1932e5b4c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6396495
Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Andreu Botella <abotella@igalia.com>
Cr-Commit-Position: refs/heads/main@{#1454384}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue May 1, 2025
In w3c/csswg-drafts#11962, the CSSWG
resolved that abspos which are descendants of a line-clamp container
must be hidden if and only if their containing block is fully after
the clamp point.

This is a significantly different behavior than the current
implementation, and this CL updates it. As part of that, it reverts a
large part of that code that deals with marking individual OOFs as
hidden for paint, and instead marks a `ContainingBlockInfo` as such.

This also implements a previous CSSWG resolution, that at
w3c/csswg-drafts#11379, which fixed a web
compat bug by saying that abspos whose containing block is the
line-clamp container or an ancestor of it should always be shown.
That previous resolution is a subset of the newer one, and so it
doesn't need any additional implementation.

This CL also rewrites most abspos tests, since they were written using
the current implementation's behavior in mind, and adds similar tests
for fixed positioning.

Bug: 40336192, 393549029, 407973206
Change-Id: I199f1c9ef01aa1e532148e8ad3227ee1932e5b4c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6396495
Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Andreu Botella <abotella@igalia.com>
Cr-Commit-Position: refs/heads/main@{#1454384}
@andreubotella
Copy link
Member Author

The continue: collapse spec PR (#10816) was updated with this change, and tests for this resolution have been merged in web-platform-tests/wpt#52279. That spec change and those tests cover #11962, but that resolution subsumes the one in the current issue.

lando-prod-mozilla bot pushed a commit to mozilla-firefox/firefox that referenced this issue May 12, 2025
Automatic update from web-platform-tests
[line-clamp] Update abspos hiding behavior

In w3c/csswg-drafts#11962, the CSSWG
resolved that abspos which are descendants of a line-clamp container
must be hidden if and only if their containing block is fully after
the clamp point.

This is a significantly different behavior than the current
implementation, and this CL updates it. As part of that, it reverts a
large part of that code that deals with marking individual OOFs as
hidden for paint, and instead marks a `ContainingBlockInfo` as such.

This also implements a previous CSSWG resolution, that at
w3c/csswg-drafts#11379, which fixed a web
compat bug by saying that abspos whose containing block is the
line-clamp container or an ancestor of it should always be shown.
That previous resolution is a subset of the newer one, and so it
doesn't need any additional implementation.

This CL also rewrites most abspos tests, since they were written using
the current implementation's behavior in mind, and adds similar tests
for fixed positioning.

Bug: 40336192, 393549029, 407973206
Change-Id: I199f1c9ef01aa1e532148e8ad3227ee1932e5b4c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6396495
Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Andreu Botella <abotella@igalia.com>
Cr-Commit-Position: refs/heads/main@{#1454384}

--

wpt-commits: f79e959cbbbea76f4e67fb880ec6ff21d3b0c70c
wpt-pr: 52279

Differential Revision: https://phabricator.services.mozilla.com/D248771
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue May 12, 2025
Automatic update from web-platform-tests
[line-clamp] Update abspos hiding behavior

In w3c/csswg-drafts#11962, the CSSWG
resolved that abspos which are descendants of a line-clamp container
must be hidden if and only if their containing block is fully after
the clamp point.

This is a significantly different behavior than the current
implementation, and this CL updates it. As part of that, it reverts a
large part of that code that deals with marking individual OOFs as
hidden for paint, and instead marks a `ContainingBlockInfo` as such.

This also implements a previous CSSWG resolution, that at
w3c/csswg-drafts#11379, which fixed a web
compat bug by saying that abspos whose containing block is the
line-clamp container or an ancestor of it should always be shown.
That previous resolution is a subset of the newer one, and so it
doesn't need any additional implementation.

This CL also rewrites most abspos tests, since they were written using
the current implementation's behavior in mind, and adds similar tests
for fixed positioning.

Bug: 40336192, 393549029, 407973206
Change-Id: I199f1c9ef01aa1e532148e8ad3227ee1932e5b4c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6396495
Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Andreu Botella <abotella@igalia.com>
Cr-Commit-Position: refs/heads/main@{#1454384}

--

wpt-commits: f79e959cbbbea76f4e67fb880ec6ff21d3b0c70c
wpt-pr: 52279

Differential Revision: https://phabricator.services.mozilla.com/D248771
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this issue May 14, 2025
Automatic update from web-platform-tests
[line-clamp] Update abspos hiding behavior

In w3c/csswg-drafts#11962, the CSSWG
resolved that abspos which are descendants of a line-clamp container
must be hidden if and only if their containing block is fully after
the clamp point.

This is a significantly different behavior than the current
implementation, and this CL updates it. As part of that, it reverts a
large part of that code that deals with marking individual OOFs as
hidden for paint, and instead marks a `ContainingBlockInfo` as such.

This also implements a previous CSSWG resolution, that at
w3c/csswg-drafts#11379, which fixed a web
compat bug by saying that abspos whose containing block is the
line-clamp container or an ancestor of it should always be shown.
That previous resolution is a subset of the newer one, and so it
doesn't need any additional implementation.

This CL also rewrites most abspos tests, since they were written using
the current implementation's behavior in mind, and adds similar tests
for fixed positioning.

Bug: 40336192, 393549029, 407973206
Change-Id: I199f1c9ef01aa1e532148e8ad3227ee1932e5b4c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6396495
Reviewed-by: Ian Kilpatrick <ikilpatrickchromium.org>
Commit-Queue: Andreu Botella <abotellaigalia.com>
Cr-Commit-Position: refs/heads/main{#1454384}

--

wpt-commits: f79e959cbbbea76f4e67fb880ec6ff21d3b0c70c
wpt-pr: 52279

Differential Revision: https://phabricator.services.mozilla.com/D248771

UltraBlame original commit: a954d0f2bf7ad365c6eee2273e683a4844b5686e
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this issue May 14, 2025
Automatic update from web-platform-tests
[line-clamp] Update abspos hiding behavior

In w3c/csswg-drafts#11962, the CSSWG
resolved that abspos which are descendants of a line-clamp container
must be hidden if and only if their containing block is fully after
the clamp point.

This is a significantly different behavior than the current
implementation, and this CL updates it. As part of that, it reverts a
large part of that code that deals with marking individual OOFs as
hidden for paint, and instead marks a `ContainingBlockInfo` as such.

This also implements a previous CSSWG resolution, that at
w3c/csswg-drafts#11379, which fixed a web
compat bug by saying that abspos whose containing block is the
line-clamp container or an ancestor of it should always be shown.
That previous resolution is a subset of the newer one, and so it
doesn't need any additional implementation.

This CL also rewrites most abspos tests, since they were written using
the current implementation's behavior in mind, and adds similar tests
for fixed positioning.

Bug: 40336192, 393549029, 407973206
Change-Id: I199f1c9ef01aa1e532148e8ad3227ee1932e5b4c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6396495
Reviewed-by: Ian Kilpatrick <ikilpatrickchromium.org>
Commit-Queue: Andreu Botella <abotellaigalia.com>
Cr-Commit-Position: refs/heads/main{#1454384}

--

wpt-commits: f79e959cbbbea76f4e67fb880ec6ff21d3b0c70c
wpt-pr: 52279

Differential Revision: https://phabricator.services.mozilla.com/D248771

UltraBlame original commit: a954d0f2bf7ad365c6eee2273e683a4844b5686e
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this issue May 14, 2025
Automatic update from web-platform-tests
[line-clamp] Update abspos hiding behavior

In w3c/csswg-drafts#11962, the CSSWG
resolved that abspos which are descendants of a line-clamp container
must be hidden if and only if their containing block is fully after
the clamp point.

This is a significantly different behavior than the current
implementation, and this CL updates it. As part of that, it reverts a
large part of that code that deals with marking individual OOFs as
hidden for paint, and instead marks a `ContainingBlockInfo` as such.

This also implements a previous CSSWG resolution, that at
w3c/csswg-drafts#11379, which fixed a web
compat bug by saying that abspos whose containing block is the
line-clamp container or an ancestor of it should always be shown.
That previous resolution is a subset of the newer one, and so it
doesn't need any additional implementation.

This CL also rewrites most abspos tests, since they were written using
the current implementation's behavior in mind, and adds similar tests
for fixed positioning.

Bug: 40336192, 393549029, 407973206
Change-Id: I199f1c9ef01aa1e532148e8ad3227ee1932e5b4c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6396495
Reviewed-by: Ian Kilpatrick <ikilpatrickchromium.org>
Commit-Queue: Andreu Botella <abotellaigalia.com>
Cr-Commit-Position: refs/heads/main{#1454384}

--

wpt-commits: f79e959cbbbea76f4e67fb880ec6ff21d3b0c70c
wpt-pr: 52279

Differential Revision: https://phabricator.services.mozilla.com/D248771

UltraBlame original commit: a954d0f2bf7ad365c6eee2273e683a4844b5686e
i3roly pushed a commit to i3roly/firefox-dynasty that referenced this issue May 15, 2025
Automatic update from web-platform-tests
[line-clamp] Update abspos hiding behavior

In w3c/csswg-drafts#11962, the CSSWG
resolved that abspos which are descendants of a line-clamp container
must be hidden if and only if their containing block is fully after
the clamp point.

This is a significantly different behavior than the current
implementation, and this CL updates it. As part of that, it reverts a
large part of that code that deals with marking individual OOFs as
hidden for paint, and instead marks a `ContainingBlockInfo` as such.

This also implements a previous CSSWG resolution, that at
w3c/csswg-drafts#11379, which fixed a web
compat bug by saying that abspos whose containing block is the
line-clamp container or an ancestor of it should always be shown.
That previous resolution is a subset of the newer one, and so it
doesn't need any additional implementation.

This CL also rewrites most abspos tests, since they were written using
the current implementation's behavior in mind, and adds similar tests
for fixed positioning.

Bug: 40336192, 393549029, 407973206
Change-Id: I199f1c9ef01aa1e532148e8ad3227ee1932e5b4c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6396495
Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Andreu Botella <abotella@igalia.com>
Cr-Commit-Position: refs/heads/main@{#1454384}

--

wpt-commits: f79e959cbbbea76f4e67fb880ec6ff21d3b0c70c
wpt-pr: 52279

Differential Revision: https://phabricator.services.mozilla.com/D248771
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Thursday afternoon
Development

No branches or pull requests

7 participants