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

Not clamping baseline position when scrollable overflow gives weird results #7660

Closed
tabatkins opened this issue Aug 29, 2022 · 5 comments
Closed

Comments

@tabatkins
Copy link
Member

Currently, the spec defines that the baselines of scrollable flex/grid items are calculated assuming the item is at its initial scroll position. This allows (and impls currently accept) the baseline to be substantially outside of the box itself, if the first line of text is taller than the box.

See testcase:

<!DOCTYPE html>
<div style="display: inline-flex; border: solid; overflow: scroll; height: 100px; font-size: 200px">
  This<br>is<br>a<br>text
</div>
text

Per our (not currently applied to the spec...) resolution in #2781, scrollable inline-blocks should take their baseline from their content, clamped by the bottom edge of the box, precisely to avoid this unintuitive behavior. (That said, for inline blocks specifically, we may be constrained by compat to ignoring the baselines of scrollable boxes and just using the margin edge; but at least it's still within the edges of the box.)

Regardless of inline blocks, we should apply this clamping behavior in flex and grid layout, and to whichever atomic inlines we can.

This would be a change away from cross-browser consistent behavior, but the current behavior is very bad and very unlikely to be relied upon (it requires the first line to be taller than the item). As last-baseline alignment begins to be implemented, however, it will become much easier to trigger.

@bfgeek
Copy link

bfgeek commented Aug 29, 2022

One thing I'd like to discuss is the edge to clamp to - I suspect border-box edge will be a little more consistent (e.g. this is typically what we synthesize off).

@fantasai
Copy link
Collaborator

+1 to border-box edge

@css-meeting-bot
Copy link
Member

The CSS Working Group just discussed Not clamping baseline position when scrollable overflow gives weird results, and agreed to the following:

  • RESOLVED: baselines of a scrollable container should be clamped to the scrollable area
The full IRC log of that discussion <Rossen_> Topic: Not clamping baseline position when scrollable overflow gives weird results
<Rossen_> github: https://github.com//issues/7660
<fremy> fantasai: sorry, inline-flex not inline-block
<fremy> fantasai: the issue is that the text is bigger than the box itself
<fremy> fantasai: so, the reste of the text is aligned to a line that is beyond the box itself
<fremy> fantasai: which doesn't make much sense
<fremy> fantasai: the proposal is to clamp the baseline to the border box
<fremy> Rossen_: do we also do this in the other direction?
<fremy> fantasai: good point, we probably should do it in this direction as well
<fremy> asterns: what is the effect that this would do?
<florian> q+
<fremy> Rossen_: align "text" to the bottom of the scrollable box
<Rossen_> ack florian
<fremy> dbaron: this would be based based on the initial scroll position?
<fremy> fantasai: yes
<fremy> florian: what about overflow: clip?
<fremy> TabAtkins: probably the same?
<fremy> iank_: well
<emilio> q+
<fremy> iank_: probably we don't want that because we resolved that overflow:clip should not have any effect on the layout
<emilio> q-
<fremy> iank_: there is already some margin clipping anyway
<fremy> dbaron: I agree, clip should not apply
<emilio> +1 to dbaron :)
<emeyer> q+
<fremy> emilio: I concur as well
<fremy> TabAtkins: currently, the reverse issue exists
<dbaron> s/clip should not apply/overflow:clip should not do anything different because overflow:clip shouldn't influence layout/
<Rossen_> ack emeyer
<heycam> q+
<fremy> rob: am I correct that the baseline can not be above or beyond the scrollable area?
<fremy> fantasai: yes, correct
<fremy> rob: then, sure, no objection
<fantasai> s/rob/emeyer/
<fantasai> s/rob/emeyer/
<Rossen_> q
<heycam> q-
<fremy> dholbert: the correct rendering would be that the border would align with the text
<fremy> dholbert: but we don't want to do that, right?
<iank_> q+
<fremy> Rossen_: yes, otherwise we would need to take a dependency on the font size etc...
<fremy> Rossen_: so, the proposed resolution is to clamp the baseline
<fremy> Rossen_: any other comment?
<dholbert> clarifying my question: I was asking if the border-top of the scrollable thing would align with the baseline of the text. And the answer was yes, it would
<dholbert> (in the "reverse scenario")
<fremy> iank_: can we keep last-baseline separated from this?
<fantasai> s/keep/keep inline-block/
<fremy> iank_: I don't want to change the margin behavior yet
<Rossen_> ack iank_
<fremy> TabAtkins: I'm fine with this for now
<fremy> Rossen_: any objection?
<fremy> RESOLVED: baselines of a scrollable container should be clamped to the scrollable area

@dholbert
Copy link
Member

dholbert commented Sep 15, 2022

Here's a version where the baseline is above the start edge:

<!DOCTYPE html>
<div style="display: inline-flex; border: solid; overflow: scroll; height: 300px; font-size: 200px">
<div style="margin-top: -250px">This<br>is<br>a<br>text</div></div> text

image

As discussed, the expectation here would be that the border-top should be aligned with the baseline of "text".

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Oct 3, 2022
... if in a scroll container.

See: w3c/csswg-drafts#7660

Effectively if we are in a scroll container (overflow:hidden or
overflow:scroll) clamp the baselines to the border-box edges.

Bug: 885175
Change-Id: I9c53e736fa156c5239384a5d11154a27643a6ac8
aarongable pushed a commit to chromium/chromium that referenced this issue Oct 3, 2022
... if in a scroll container.

See: w3c/csswg-drafts#7660

Effectively if we are in a scroll container (overflow:hidden or
overflow:scroll) clamp the baselines to the border-box edges.

Bug: 885175
Change-Id: I9c53e736fa156c5239384a5d11154a27643a6ac8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3925659
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: David Grogan <dgrogan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1054237}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Oct 3, 2022
... if in a scroll container.

See: w3c/csswg-drafts#7660

Effectively if we are in a scroll container (overflow:hidden or
overflow:scroll) clamp the baselines to the border-box edges.

Bug: 885175
Change-Id: I9c53e736fa156c5239384a5d11154a27643a6ac8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3925659
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: David Grogan <dgrogan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1054237}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Oct 3, 2022
... if in a scroll container.

See: w3c/csswg-drafts#7660

Effectively if we are in a scroll container (overflow:hidden or
overflow:scroll) clamp the baselines to the border-box edges.

Bug: 885175
Change-Id: I9c53e736fa156c5239384a5d11154a27643a6ac8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3925659
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: David Grogan <dgrogan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1054237}
@fantasai
Copy link
Collaborator

fantasai commented Oct 3, 2022

Spec text is already at the end of https://www.w3.org/TR/css-align-3/#baseline-export

If, in the case of a scroll container box, the resulting position of a first/last baseline is past a box’s end/start border edge, its position is clamped to that border edge.

It's a little hard to read, so we rewrote it to

If the position of a scroll container’s first/last baseline is outside its border edge, that baseline’s position is clamped to the border edge.

@fantasai fantasai closed this as completed Oct 3, 2022
mjfroman pushed a commit to mjfroman/moz-libwebrtc-third-party that referenced this issue Oct 14, 2022
... if in a scroll container.

See: w3c/csswg-drafts#7660

Effectively if we are in a scroll container (overflow:hidden or
overflow:scroll) clamp the baselines to the border-box edges.

Bug: 885175
Change-Id: I9c53e736fa156c5239384a5d11154a27643a6ac8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3925659
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: David Grogan <dgrogan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1054237}
NOKEYCHECK=True
GitOrigin-RevId: 75f43ae40f2f7cceb000b81271819b8ffd875180
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Oct 21, 2022
…es to border-box..., a=testonly

Automatic update from web-platform-tests
[last-baseline] Clamp first/last baselines to border-box...

... if in a scroll container.

See: w3c/csswg-drafts#7660

Effectively if we are in a scroll container (overflow:hidden or
overflow:scroll) clamp the baselines to the border-box edges.

Bug: 885175
Change-Id: I9c53e736fa156c5239384a5d11154a27643a6ac8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3925659
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: David Grogan <dgrogan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1054237}

--

wpt-commits: a7ca49d8492524b6ff426ec6e7d424657bb3502d
wpt-pr: 36228
jamienicol pushed a commit to jamienicol/gecko that referenced this issue Oct 26, 2022
…es to border-box..., a=testonly

Automatic update from web-platform-tests
[last-baseline] Clamp first/last baselines to border-box...

... if in a scroll container.

See: w3c/csswg-drafts#7660

Effectively if we are in a scroll container (overflow:hidden or
overflow:scroll) clamp the baselines to the border-box edges.

Bug: 885175
Change-Id: I9c53e736fa156c5239384a5d11154a27643a6ac8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3925659
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: David Grogan <dgrogan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1054237}

--

wpt-commits: a7ca49d8492524b6ff426ec6e7d424657bb3502d
wpt-pr: 36228
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

6 participants