-
Notifications
You must be signed in to change notification settings - Fork 687
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-text-4 / css-overflow-4] Interaction of text-wrap: balance
and (-webkit-)line-clamp
#9310
Comments
FWIW we (Blink) previously had this behaviour - but after web-developers tested this interaction they were confused believing that Based on this feedback we changed it to only balance the lines within the line-clamp range. We haven't received any bug reports since for this interaction. cc/ @kojiishi |
Thanks for the comment, Ian, that's interesting. I'm curious if people considered the implications of this for dynamically-varying line-clamp, or looked only at static examples? In the purely static case, balancing only the displayed lines makes good sense, but I find the dynamic behavior where changing the line-clamp value causes line-wrapping to change to be a bit disconcerting. Interested to hear what other people think...? |
From examples I've seen - most folks have a non-dynamic line-clamp (super rare to animate this). If it does change (say based on viewport/container width, etc) I suspect most web developers would still expect it to balance the visible lines. (FWIW we received this feedback from more that one set of developers trying the API - e.g. wasn't a single voice). |
…=emilio A simple form of balance for short blocks, implemented by incrementally reducing the effective inline-size used during line-breaking, up to the point where an extra line would be created. This fails the test text-wrap-balance-line-clamp-001.html, but it's unclear to me if that test is correct (see w3c/csswg-drafts#9310). If we do want the behavior expected by that test, an additional patch to handle the interaction with line-clamp will be required. Depends on D187543 Differential Revision: https://phabricator.services.mozilla.com/D187544
…nsider only the lines up to the clamp limit. r=emilio This corresponds to how Chrome behaves, and passes the test they included in WPT. It's unclear to me whether this behavior actually follows from the current spec (see w3c/csswg-drafts#9310), but it seems to be the desired result. (I've put it behind a (default-enabled) pref for now, so that it's possible to experiment with the two possible interpretations, but we can remove the pref once the spec question is clarified/confirmed.) This patch also disables balancing for fragmented/overflowing blocks, as that will not currently work well. We may want to address that as a followup issue (though it won't matter to the primary balance use-cases such as titles). Depends on D188139 Differential Revision: https://phabricator.services.mozilla.com/D188220
…=emilio A simple form of balance for short blocks, implemented by incrementally reducing the effective inline-size used during line-breaking, up to the point where an extra line would be created. This fails the test text-wrap-balance-line-clamp-001.html, but it's unclear to me if that test is correct (see w3c/csswg-drafts#9310). If we do want the behavior expected by that test, an additional patch to handle the interaction with line-clamp will be required. Depends on D187543 Differential Revision: https://phabricator.services.mozilla.com/D187544
…nsider only the lines up to the clamp limit. r=emilio This corresponds to how Chrome behaves, and passes the test they included in WPT. It's unclear to me whether this behavior actually follows from the current spec (see w3c/csswg-drafts#9310), but it seems to be the desired result. (I've put it behind a (default-enabled) pref for now, so that it's possible to experiment with the two possible interpretations, but we can remove the pref once the spec question is clarified/confirmed.) This patch also disables balancing for fragmented/overflowing blocks, as that will not currently work well. We may want to address that as a followup issue (though it won't matter to the primary balance use-cases such as titles). Depends on D188139 Differential Revision: https://phabricator.services.mozilla.com/D188220
…=emilio A simple form of balance for short blocks, implemented by incrementally reducing the effective inline-size used during line-breaking, up to the point where an extra line would be created. This fails the test text-wrap-balance-line-clamp-001.html, but it's unclear to me if that test is correct (see w3c/csswg-drafts#9310). If we do want the behavior expected by that test, an additional patch to handle the interaction with line-clamp will be required. Depends on D187543 Differential Revision: https://phabricator.services.mozilla.com/D187544 UltraBlame original commit: 0fd4431f527935234d764a167cc5a20acfc323eb
…nsider only the lines up to the clamp limit. r=emilio This corresponds to how Chrome behaves, and passes the test they included in WPT. It's unclear to me whether this behavior actually follows from the current spec (see w3c/csswg-drafts#9310), but it seems to be the desired result. (I've put it behind a (default-enabled) pref for now, so that it's possible to experiment with the two possible interpretations, but we can remove the pref once the spec question is clarified/confirmed.) This patch also disables balancing for fragmented/overflowing blocks, as that will not currently work well. We may want to address that as a followup issue (though it won't matter to the primary balance use-cases such as titles). Depends on D188139 Differential Revision: https://phabricator.services.mozilla.com/D188220 UltraBlame original commit: 7ce2b41bb730247e00da9c69a1df9a01df80633d
…=emilio A simple form of balance for short blocks, implemented by incrementally reducing the effective inline-size used during line-breaking, up to the point where an extra line would be created. This fails the test text-wrap-balance-line-clamp-001.html, but it's unclear to me if that test is correct (see w3c/csswg-drafts#9310). If we do want the behavior expected by that test, an additional patch to handle the interaction with line-clamp will be required. Depends on D187543 Differential Revision: https://phabricator.services.mozilla.com/D187544 UltraBlame original commit: eb0b125d3214a04c293cbe2f21184e85ae00302a
…nsider only the lines up to the clamp limit. r=emilio This corresponds to how Chrome behaves, and passes the test they included in WPT. It's unclear to me whether this behavior actually follows from the current spec (see w3c/csswg-drafts#9310), but it seems to be the desired result. (I've put it behind a (default-enabled) pref for now, so that it's possible to experiment with the two possible interpretations, but we can remove the pref once the spec question is clarified/confirmed.) This patch also disables balancing for fragmented/overflowing blocks, as that will not currently work well. We may want to address that as a followup issue (though it won't matter to the primary balance use-cases such as titles). Depends on D188139 Differential Revision: https://phabricator.services.mozilla.com/D188220 UltraBlame original commit: 16a3de29e4e69175f5a7c914ffa9de63b8683f2a
…=emilio A simple form of balance for short blocks, implemented by incrementally reducing the effective inline-size used during line-breaking, up to the point where an extra line would be created. This fails the test text-wrap-balance-line-clamp-001.html, but it's unclear to me if that test is correct (see w3c/csswg-drafts#9310). If we do want the behavior expected by that test, an additional patch to handle the interaction with line-clamp will be required. Depends on D187543 Differential Revision: https://phabricator.services.mozilla.com/D187544 UltraBlame original commit: 0fd4431f527935234d764a167cc5a20acfc323eb
…nsider only the lines up to the clamp limit. r=emilio This corresponds to how Chrome behaves, and passes the test they included in WPT. It's unclear to me whether this behavior actually follows from the current spec (see w3c/csswg-drafts#9310), but it seems to be the desired result. (I've put it behind a (default-enabled) pref for now, so that it's possible to experiment with the two possible interpretations, but we can remove the pref once the spec question is clarified/confirmed.) This patch also disables balancing for fragmented/overflowing blocks, as that will not currently work well. We may want to address that as a followup issue (though it won't matter to the primary balance use-cases such as titles). Depends on D188139 Differential Revision: https://phabricator.services.mozilla.com/D188220 UltraBlame original commit: 7ce2b41bb730247e00da9c69a1df9a01df80633d
…=emilio A simple form of balance for short blocks, implemented by incrementally reducing the effective inline-size used during line-breaking, up to the point where an extra line would be created. This fails the test text-wrap-balance-line-clamp-001.html, but it's unclear to me if that test is correct (see w3c/csswg-drafts#9310). If we do want the behavior expected by that test, an additional patch to handle the interaction with line-clamp will be required. Depends on D187543 Differential Revision: https://phabricator.services.mozilla.com/D187544 UltraBlame original commit: eb0b125d3214a04c293cbe2f21184e85ae00302a
…nsider only the lines up to the clamp limit. r=emilio This corresponds to how Chrome behaves, and passes the test they included in WPT. It's unclear to me whether this behavior actually follows from the current spec (see w3c/csswg-drafts#9310), but it seems to be the desired result. (I've put it behind a (default-enabled) pref for now, so that it's possible to experiment with the two possible interpretations, but we can remove the pref once the spec question is clarified/confirmed.) This patch also disables balancing for fragmented/overflowing blocks, as that will not currently work well. We may want to address that as a followup issue (though it won't matter to the primary balance use-cases such as titles). Depends on D188139 Differential Revision: https://phabricator.services.mozilla.com/D188220 UltraBlame original commit: 16a3de29e4e69175f5a7c914ffa9de63b8683f2a
…=emilio A simple form of balance for short blocks, implemented by incrementally reducing the effective inline-size used during line-breaking, up to the point where an extra line would be created. This fails the test text-wrap-balance-line-clamp-001.html, but it's unclear to me if that test is correct (see w3c/csswg-drafts#9310). If we do want the behavior expected by that test, an additional patch to handle the interaction with line-clamp will be required. Depends on D187543 Differential Revision: https://phabricator.services.mozilla.com/D187544
…nsider only the lines up to the clamp limit. r=emilio This corresponds to how Chrome behaves, and passes the test they included in WPT. It's unclear to me whether this behavior actually follows from the current spec (see w3c/csswg-drafts#9310), but it seems to be the desired result. (I've put it behind a (default-enabled) pref for now, so that it's possible to experiment with the two possible interpretations, but we can remove the pref once the spec question is clarified/confirmed.) This patch also disables balancing for fragmented/overflowing blocks, as that will not currently work well. We may want to address that as a followup issue (though it won't matter to the primary balance use-cases such as titles). Depends on D188139 Differential Revision: https://phabricator.services.mozilla.com/D188220
…=emilio A simple form of balance for short blocks, implemented by incrementally reducing the effective inline-size used during line-breaking, up to the point where an extra line would be created. This fails the test text-wrap-balance-line-clamp-001.html, but it's unclear to me if that test is correct (see w3c/csswg-drafts#9310). If we do want the behavior expected by that test, an additional patch to handle the interaction with line-clamp will be required. Depends on D187543 Differential Revision: https://phabricator.services.mozilla.com/D187544
…nsider only the lines up to the clamp limit. r=emilio This corresponds to how Chrome behaves, and passes the test they included in WPT. It's unclear to me whether this behavior actually follows from the current spec (see w3c/csswg-drafts#9310), but it seems to be the desired result. (I've put it behind a (default-enabled) pref for now, so that it's possible to experiment with the two possible interpretations, but we can remove the pref once the spec question is clarified/confirmed.) This patch also disables balancing for fragmented/overflowing blocks, as that will not currently work well. We may want to address that as a followup issue (though it won't matter to the primary balance use-cases such as titles). Depends on D188139 Differential Revision: https://phabricator.services.mozilla.com/D188220
…=emilio A simple form of balance for short blocks, implemented by incrementally reducing the effective inline-size used during line-breaking, up to the point where an extra line would be created. This fails the test text-wrap-balance-line-clamp-001.html, but it's unclear to me if that test is correct (see w3c/csswg-drafts#9310). If we do want the behavior expected by that test, an additional patch to handle the interaction with line-clamp will be required. Depends on D187543 Differential Revision: https://phabricator.services.mozilla.com/D187544 UltraBlame original commit: 0fd4431f527935234d764a167cc5a20acfc323eb
…nsider only the lines up to the clamp limit. r=emilio This corresponds to how Chrome behaves, and passes the test they included in WPT. It's unclear to me whether this behavior actually follows from the current spec (see w3c/csswg-drafts#9310), but it seems to be the desired result. (I've put it behind a (default-enabled) pref for now, so that it's possible to experiment with the two possible interpretations, but we can remove the pref once the spec question is clarified/confirmed.) This patch also disables balancing for fragmented/overflowing blocks, as that will not currently work well. We may want to address that as a followup issue (though it won't matter to the primary balance use-cases such as titles). Depends on D188139 Differential Revision: https://phabricator.services.mozilla.com/D188220 UltraBlame original commit: 7ce2b41bb730247e00da9c69a1df9a01df80633d
…=emilio A simple form of balance for short blocks, implemented by incrementally reducing the effective inline-size used during line-breaking, up to the point where an extra line would be created. This fails the test text-wrap-balance-line-clamp-001.html, but it's unclear to me if that test is correct (see w3c/csswg-drafts#9310). If we do want the behavior expected by that test, an additional patch to handle the interaction with line-clamp will be required. Depends on D187543 Differential Revision: https://phabricator.services.mozilla.com/D187544 UltraBlame original commit: eb0b125d3214a04c293cbe2f21184e85ae00302a
…nsider only the lines up to the clamp limit. r=emilio This corresponds to how Chrome behaves, and passes the test they included in WPT. It's unclear to me whether this behavior actually follows from the current spec (see w3c/csswg-drafts#9310), but it seems to be the desired result. (I've put it behind a (default-enabled) pref for now, so that it's possible to experiment with the two possible interpretations, but we can remove the pref once the spec question is clarified/confirmed.) This patch also disables balancing for fragmented/overflowing blocks, as that will not currently work well. We may want to address that as a followup issue (though it won't matter to the primary balance use-cases such as titles). Depends on D188139 Differential Revision: https://phabricator.services.mozilla.com/D188220 UltraBlame original commit: 16a3de29e4e69175f5a7c914ffa9de63b8683f2a
…=emilio A simple form of balance for short blocks, implemented by incrementally reducing the effective inline-size used during line-breaking, up to the point where an extra line would be created. This fails the test text-wrap-balance-line-clamp-001.html, but it's unclear to me if that test is correct (see w3c/csswg-drafts#9310). If we do want the behavior expected by that test, an additional patch to handle the interaction with line-clamp will be required. Depends on D187543 Differential Revision: https://phabricator.services.mozilla.com/D187544
…nsider only the lines up to the clamp limit. r=emilio This corresponds to how Chrome behaves, and passes the test they included in WPT. It's unclear to me whether this behavior actually follows from the current spec (see w3c/csswg-drafts#9310), but it seems to be the desired result. (I've put it behind a (default-enabled) pref for now, so that it's possible to experiment with the two possible interpretations, but we can remove the pref once the spec question is clarified/confirmed.) This patch also disables balancing for fragmented/overflowing blocks, as that will not currently work well. We may want to address that as a followup issue (though it won't matter to the primary balance use-cases such as titles). Depends on D188139 Differential Revision: https://phabricator.services.mozilla.com/D188220
…=emilio A simple form of balance for short blocks, implemented by incrementally reducing the effective inline-size used during line-breaking, up to the point where an extra line would be created. This fails the test text-wrap-balance-line-clamp-001.html, but it's unclear to me if that test is correct (see w3c/csswg-drafts#9310). If we do want the behavior expected by that test, an additional patch to handle the interaction with line-clamp will be required. Depends on D187543 Differential Revision: https://phabricator.services.mozilla.com/D187544 UltraBlame original commit: b8a405d2e140de87b7a8b06e95a04f984a8ddf0a
…nsider only the lines up to the clamp limit. r=emilio This corresponds to how Chrome behaves, and passes the test they included in WPT. It's unclear to me whether this behavior actually follows from the current spec (see w3c/csswg-drafts#9310), but it seems to be the desired result. (I've put it behind a (default-enabled) pref for now, so that it's possible to experiment with the two possible interpretations, but we can remove the pref once the spec question is clarified/confirmed.) This patch also disables balancing for fragmented/overflowing blocks, as that will not currently work well. We may want to address that as a followup issue (though it won't matter to the primary balance use-cases such as titles). Depends on D188139 Differential Revision: https://phabricator.services.mozilla.com/D188220 UltraBlame original commit: 8c9ba927121cd7f1cb5b31ffb86addc4c34b59a8
…=emilio A simple form of balance for short blocks, implemented by incrementally reducing the effective inline-size used during line-breaking, up to the point where an extra line would be created. This fails the test text-wrap-balance-line-clamp-001.html, but it's unclear to me if that test is correct (see w3c/csswg-drafts#9310). If we do want the behavior expected by that test, an additional patch to handle the interaction with line-clamp will be required. Depends on D187543 Differential Revision: https://phabricator.services.mozilla.com/D187544 UltraBlame original commit: b8a405d2e140de87b7a8b06e95a04f984a8ddf0a
…nsider only the lines up to the clamp limit. r=emilio This corresponds to how Chrome behaves, and passes the test they included in WPT. It's unclear to me whether this behavior actually follows from the current spec (see w3c/csswg-drafts#9310), but it seems to be the desired result. (I've put it behind a (default-enabled) pref for now, so that it's possible to experiment with the two possible interpretations, but we can remove the pref once the spec question is clarified/confirmed.) This patch also disables balancing for fragmented/overflowing blocks, as that will not currently work well. We may want to address that as a followup issue (though it won't matter to the primary balance use-cases such as titles). Depends on D188139 Differential Revision: https://phabricator.services.mozilla.com/D188220 UltraBlame original commit: 8c9ba927121cd7f1cb5b31ffb86addc4c34b59a8
…=emilio A simple form of balance for short blocks, implemented by incrementally reducing the effective inline-size used during line-breaking, up to the point where an extra line would be created. This fails the test text-wrap-balance-line-clamp-001.html, but it's unclear to me if that test is correct (see w3c/csswg-drafts#9310). If we do want the behavior expected by that test, an additional patch to handle the interaction with line-clamp will be required. Depends on D187543 Differential Revision: https://phabricator.services.mozilla.com/D187544 UltraBlame original commit: b8a405d2e140de87b7a8b06e95a04f984a8ddf0a
Animating based on an explicit number of line is likely to be very rare indeed. However, once it becomes possible to clamp on a height, rather than on an explicit number of lines, that's likely a lot less rare: animating/transitioning the element itself to reveal the hidden lines, or having the element's height change because it's container's size changed… I don't think that'll be all that rare. |
https://bugs.webkit.org/show_bug.cgi?id=268302 rdar://121858978 Reviewed by Alan Baradlay. According to spec resolution [1], if line-clamp is defined, text-wrap: balance should balance only within the clamped lines. Up to this patch, we would balance taking into consideration all the lines and we would clamp it after balance. This patches makes InlineContentBalancer::initialize() take the maximum number of visible lines into account, based into the line-clamp property. Also, this allows for a small optimization: If line-clamp clamps to 1 line, we can skip balacing. [1] w3c/csswg-drafts#9310 * LayoutTests/TestExpectations: * Source/WebCore/layout/formattingContexts/block/BlockLayoutState.h: (WebCore::Layout::BlockLayoutState::LineClamp::allowedLineCount const): * Source/WebCore/layout/formattingContexts/inline/InlineContentBalancer.cpp: (WebCore::Layout::InlineContentBalancer::initialize): (WebCore::Layout::InlineContentBalancer::computeBalanceConstraints): * Source/WebCore/layout/formattingContexts/inline/InlineContentBalancer.h: * Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp: (WebCore::Layout::InlineFormattingContext::createDisplayContentForInlineContent): Canonical link: https://commits.webkit.org/273800@main
Removed the RESOLVED line from the summary posted by the bot, as it actually belonged to the previous issue on the agenda, #9112, and putting back on the Agenda, since that's what we said we'd do |
I think an animation case is still one that is ok not to consider here. To reproduce it, an author must specify:
The issue from the current behavior (not pretty animation, which could be easily missed if it is ~200-300ms) is minor enough to grant a change this in other direction. As an author/designer, if I would encounter a case like this in my product, I'd either remove |
The CSS Working Group just discussed
The full IRC log of that discussion<fantasai> florian_irc: do we clamp first and then balance, or balance first and then clamp?<fantasai> florian_irc: dominant view in the issue is clamp first, then balance <fantasai> florian_irc: but jfkthame points out that if you animate the height, this could be a lot of rebalancing <fantasai> florian_irc: which is weird <fantasai> jfkthame: the current safari tech preview seems to do balance and then clamp behavior <fantasai> jfkthame: opposite of Blink <dbaron> fantasai: if we want both behaviors, we could change based on 'will-change' <dbaron> fantasai: could clamp-then-balance if it doesn't have 'will-change', and vice-versa <fantasai> florian_irc: the fewer additional corner cases we add for fragmentation etc the better it is for later <fantasai> astearns: I'm convinced that people want both. In case where you're not animating, if you do it one way it looks like balance doesn't do anything <fantasai> astearns: and in other case, animating is bad <fantasai> florian_irc: animatable way seems complicated in general case. With simple version of line-clamp probably alright <fantasai> florian_irc: assume part after laid out same as before <fantasai> florian_irc: but if we have `continue: fragment`, the next fragment might be a different width <fantasai> florian_irc: I'm not even sure if you move the clamping point between containers of different widhts before you clamp, what does that mean? <kizu> q+ <fantasai> [balancing independently before/after line breaks or page breaks] <astearns> ack fantasai <astearns> ack kizu <dbaron> fantasai: It's a little bit not what 'will-change' was designed for. <dbaron> [in response to astearns asking why fantasai was laughing when suggesting the switch] <fantasai> kizu: this seems like a rare enough use case... for authors if the animation is fast enough you won't notice <fantasai> ... and can otherwise work around it <fantasai> kizu: will-change suggestion is kinda weird, maybe better to use a dedicated switch <fantasai> florian_irc: agree this is a rare case. not that revealing progressivly is not rare, but on something that has balance seems rare. For headlines etc. <fantasai> florian_irc: so my inclination is to start by clamp then balance, and if we need an opt in later we worry how it works then <fantasai> astearns: given that jfkthame's test results consider this a change in WebKit, is that Ok with WebKit? <dbaron> I agree with Florian that it's a rare case and we should pick something and not add switches. <fantasai> fantasai: Seems reasonable to try, since it seems that would be desired by authors. <fantasai> RESOLVED: Clamp, then balance |
Fixed by 32dee03 |
It would be good to clarify how
text-wrap: balance
interacts withline-clamp
.Specifically, when both balancing and clamping are requested, in which order do these effects operate? Does the block first have its lines wrapped using the
balance
algorithm, and then clamping applied to the resulting lines (without affecting how they wrap), or is clamping applied first and then balancing applied only to the lines up to the clamp limit?Or in simpler terms, is it expected that
(-webkit-)line-clamp
may change the line-breaks used in a block?It seems most intuitive to me that line-clamp applies after the line-breaks for a block have been determined, as it is defined in terms of lines. But the test at https://wpt.live/css/css-text/white-space/text-wrap-balance-line-clamp-001.html appears to assume that
text-wrap: balance
will be applied only to the lines up to the-webkit-line-clamp
limit.This codepen has an example where this effect is visible. In current Chrome Canary, varying the line-clamp limit results in changes to the line-breaking throughout the paragraph. Is this the expected/desired behavior, or should it be considered a bug?
Depending on the answer to this, the text-wrap-balance-line-clamp-001.html test may need revision.
The text was updated successfully, but these errors were encountered: