-
Notifications
You must be signed in to change notification settings - Fork 719
[css-overflow] [css-text] Interaction between whitespace collapsing and line-clamp #12008
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
Comments
With the `CSSLineClampLineBreakingEllipsis` runtime feature on, the ellipsis width computation happens as part of line breaking, so that the ellipsis gets inserted at the last possible break opportunity. However, this currently does not work with `text-wrap: nowrap` text, because regular line breaking would not wrap inside that text, but there are still break opportunities in it that must be used when clamping. This patch replaces any calls to the `ComputedStyle` methods `ShouldWrapLine` and `ShouldBreakOnlyAfterWhiteSpace` with equivalent methods in `ComputedStyle` that also check whether the line is being ellipsized for line-clamp; and replaces any such calls inside `LineBreaker` to use them. This is enough to cover the spec's requirements, which explicitly ignore break opportunities created by `overflow-wrap`. This patch also fixes the removal of trailing spaces so that when an ellipsis is inserted inside `white-space: pre` text, there are no preserved spaces between the end of the word and the ellipsis (see w3c/csswg-drafts#12008). Bug: 40336192 Change-Id: I22822d5f1d6a44e5b5c5b99a9fb698df10ffcf9c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6394977 Commit-Queue: Andreu BotellaReviewed-by: Koji Ishii Cr-Commit-Position: refs/heads/main@{#1441973}
With the `CSSLineClampLineBreakingEllipsis` runtime feature on, the ellipsis width computation happens as part of line breaking, so that the ellipsis gets inserted at the last possible break opportunity. However, this currently does not work with `text-wrap: nowrap` text, because regular line breaking would not wrap inside that text, but there are still break opportunities in it that must be used when clamping. This patch replaces any calls to the `ComputedStyle` methods `ShouldWrapLine` and `ShouldBreakOnlyAfterWhiteSpace` with equivalent methods in `ComputedStyle` that also check whether the line is being ellipsized for line-clamp; and replaces any such calls inside `LineBreaker` to use them. This is enough to cover the spec's requirements, which explicitly ignore break opportunities created by `overflow-wrap`. This patch also fixes the removal of trailing spaces so that when an ellipsis is inserted inside `white-space: pre` text, there are no preserved spaces between the end of the word and the ellipsis (see w3c/csswg-drafts#12008). Bug: 40336192 Change-Id: I22822d5f1d6a44e5b5c5b99a9fb698df10ffcf9c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6394977 Commit-Queue: Andreu BotellaReviewed-by: Koji Ishii Cr-Commit-Position: refs/heads/main@{#1441973}
With the `CSSLineClampLineBreakingEllipsis` runtime feature on, the ellipsis width computation happens as part of line breaking, so that the ellipsis gets inserted at the last possible break opportunity. However, this currently does not work with `text-wrap: nowrap` text, because regular line breaking would not wrap inside that text, but there are still break opportunities in it that must be used when clamping. This patch replaces any calls to the `ComputedStyle` methods `ShouldWrapLine` and `ShouldBreakOnlyAfterWhiteSpace` with equivalent methods in `ComputedStyle` that also check whether the line is being ellipsized for line-clamp; and replaces any such calls inside `LineBreaker` to use them. This is enough to cover the spec's requirements, which explicitly ignore break opportunities created by `overflow-wrap`. This patch also fixes the removal of trailing spaces so that when an ellipsis is inserted inside `white-space: pre` text, there are no preserved spaces between the end of the word and the ellipsis (see w3c/csswg-drafts#12008). Bug: 40336192 Change-Id: I22822d5f1d6a44e5b5c5b99a9fb698df10ffcf9c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6394977 Commit-Queue: Andreu BotellaReviewed-by: Koji Ishii Cr-Commit-Position: refs/heads/main@{#1441973}
…s inside nowrap text, a=testonly Automatic update from web-platform-tests [line-clamp] Allow inserting the ellipsis inside nowrap text With the `CSSLineClampLineBreakingEllipsis` runtime feature on, the ellipsis width computation happens as part of line breaking, so that the ellipsis gets inserted at the last possible break opportunity. However, this currently does not work with `text-wrap: nowrap` text, because regular line breaking would not wrap inside that text, but there are still break opportunities in it that must be used when clamping. This patch replaces any calls to the `ComputedStyle` methods `ShouldWrapLine` and `ShouldBreakOnlyAfterWhiteSpace` with equivalent methods in `ComputedStyle` that also check whether the line is being ellipsized for line-clamp; and replaces any such calls inside `LineBreaker` to use them. This is enough to cover the spec's requirements, which explicitly ignore break opportunities created by `overflow-wrap`. This patch also fixes the removal of trailing spaces so that when an ellipsis is inserted inside `white-space: pre` text, there are no preserved spaces between the end of the word and the ellipsis (see w3c/csswg-drafts#12008). Bug: 40336192 Change-Id: I22822d5f1d6a44e5b5c5b99a9fb698df10ffcf9c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6394977 Commit-Queue: Andreu BotellaReviewed-by: Koji Ishii Cr-Commit-Position: refs/heads/main@{#1441973} -- wpt-commits: 00037969dc735353f69f8675504126ae4041faa3 wpt-pr: 51818
…s inside nowrap text, a=testonly Automatic update from web-platform-tests [line-clamp] Allow inserting the ellipsis inside nowrap text With the `CSSLineClampLineBreakingEllipsis` runtime feature on, the ellipsis width computation happens as part of line breaking, so that the ellipsis gets inserted at the last possible break opportunity. However, this currently does not work with `text-wrap: nowrap` text, because regular line breaking would not wrap inside that text, but there are still break opportunities in it that must be used when clamping. This patch replaces any calls to the `ComputedStyle` methods `ShouldWrapLine` and `ShouldBreakOnlyAfterWhiteSpace` with equivalent methods in `ComputedStyle` that also check whether the line is being ellipsized for line-clamp; and replaces any such calls inside `LineBreaker` to use them. This is enough to cover the spec's requirements, which explicitly ignore break opportunities created by `overflow-wrap`. This patch also fixes the removal of trailing spaces so that when an ellipsis is inserted inside `white-space: pre` text, there are no preserved spaces between the end of the word and the ellipsis (see w3c/csswg-drafts#12008). Bug: 40336192 Change-Id: I22822d5f1d6a44e5b5c5b99a9fb698df10ffcf9c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6394977 Commit-Queue: Andreu BotellaReviewed-by: Koji Ishii Cr-Commit-Position: refs/heads/main@{#1441973} -- wpt-commits: 00037969dc735353f69f8675504126ae4041faa3 wpt-pr: 51818
…s inside nowrap text, a=testonly Automatic update from web-platform-tests [line-clamp] Allow inserting the ellipsis inside nowrap text With the `CSSLineClampLineBreakingEllipsis` runtime feature on, the ellipsis width computation happens as part of line breaking, so that the ellipsis gets inserted at the last possible break opportunity. However, this currently does not work with `text-wrap: nowrap` text, because regular line breaking would not wrap inside that text, but there are still break opportunities in it that must be used when clamping. This patch replaces any calls to the `ComputedStyle` methods `ShouldWrapLine` and `ShouldBreakOnlyAfterWhiteSpace` with equivalent methods in `ComputedStyle` that also check whether the line is being ellipsized for line-clamp; and replaces any such calls inside `LineBreaker` to use them. This is enough to cover the spec's requirements, which explicitly ignore break opportunities created by `overflow-wrap`. This patch also fixes the removal of trailing spaces so that when an ellipsis is inserted inside `white-space: pre` text, there are no preserved spaces between the end of the word and the ellipsis (see w3c/csswg-drafts#12008). Bug: 40336192 Change-Id: I22822d5f1d6a44e5b5c5b99a9fb698df10ffcf9c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6394977 Commit-Queue: Andreu BotellaReviewed-by: Koji Ishii Cr-Commit-Position: refs/heads/main{#1441973} -- wpt-commits: 00037969dc735353f69f8675504126ae4041faa3 wpt-pr: 51818 UltraBlame original commit: d32bb7c166f17371fbfd77e7d819ba101ec65f62
…s inside nowrap text, a=testonly Automatic update from web-platform-tests [line-clamp] Allow inserting the ellipsis inside nowrap text With the `CSSLineClampLineBreakingEllipsis` runtime feature on, the ellipsis width computation happens as part of line breaking, so that the ellipsis gets inserted at the last possible break opportunity. However, this currently does not work with `text-wrap: nowrap` text, because regular line breaking would not wrap inside that text, but there are still break opportunities in it that must be used when clamping. This patch replaces any calls to the `ComputedStyle` methods `ShouldWrapLine` and `ShouldBreakOnlyAfterWhiteSpace` with equivalent methods in `ComputedStyle` that also check whether the line is being ellipsized for line-clamp; and replaces any such calls inside `LineBreaker` to use them. This is enough to cover the spec's requirements, which explicitly ignore break opportunities created by `overflow-wrap`. This patch also fixes the removal of trailing spaces so that when an ellipsis is inserted inside `white-space: pre` text, there are no preserved spaces between the end of the word and the ellipsis (see w3c/csswg-drafts#12008). Bug: 40336192 Change-Id: I22822d5f1d6a44e5b5c5b99a9fb698df10ffcf9c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6394977 Commit-Queue: Andreu BotellaReviewed-by: Koji Ishii Cr-Commit-Position: refs/heads/main@{#1441973} -- wpt-commits: 00037969dc735353f69f8675504126ae4041faa3 wpt-pr: 51818
…s inside nowrap text, a=testonly Automatic update from web-platform-tests [line-clamp] Allow inserting the ellipsis inside nowrap text With the `CSSLineClampLineBreakingEllipsis` runtime feature on, the ellipsis width computation happens as part of line breaking, so that the ellipsis gets inserted at the last possible break opportunity. However, this currently does not work with `text-wrap: nowrap` text, because regular line breaking would not wrap inside that text, but there are still break opportunities in it that must be used when clamping. This patch replaces any calls to the `ComputedStyle` methods `ShouldWrapLine` and `ShouldBreakOnlyAfterWhiteSpace` with equivalent methods in `ComputedStyle` that also check whether the line is being ellipsized for line-clamp; and replaces any such calls inside `LineBreaker` to use them. This is enough to cover the spec's requirements, which explicitly ignore break opportunities created by `overflow-wrap`. This patch also fixes the removal of trailing spaces so that when an ellipsis is inserted inside `white-space: pre` text, there are no preserved spaces between the end of the word and the ellipsis (see w3c/csswg-drafts#12008). Bug: 40336192 Change-Id: I22822d5f1d6a44e5b5c5b99a9fb698df10ffcf9c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6394977 Commit-Queue: Andreu BotellaReviewed-by: Koji Ishii Cr-Commit-Position: refs/heads/main{#1441973} -- wpt-commits: 00037969dc735353f69f8675504126ae4041faa3 wpt-pr: 51818 UltraBlame original commit: d32bb7c166f17371fbfd77e7d819ba101ec65f62
…s inside nowrap text, a=testonly Automatic update from web-platform-tests [line-clamp] Allow inserting the ellipsis inside nowrap text With the `CSSLineClampLineBreakingEllipsis` runtime feature on, the ellipsis width computation happens as part of line breaking, so that the ellipsis gets inserted at the last possible break opportunity. However, this currently does not work with `text-wrap: nowrap` text, because regular line breaking would not wrap inside that text, but there are still break opportunities in it that must be used when clamping. This patch replaces any calls to the `ComputedStyle` methods `ShouldWrapLine` and `ShouldBreakOnlyAfterWhiteSpace` with equivalent methods in `ComputedStyle` that also check whether the line is being ellipsized for line-clamp; and replaces any such calls inside `LineBreaker` to use them. This is enough to cover the spec's requirements, which explicitly ignore break opportunities created by `overflow-wrap`. This patch also fixes the removal of trailing spaces so that when an ellipsis is inserted inside `white-space: pre` text, there are no preserved spaces between the end of the word and the ellipsis (see w3c/csswg-drafts#12008). Bug: 40336192 Change-Id: I22822d5f1d6a44e5b5c5b99a9fb698df10ffcf9c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6394977 Commit-Queue: Andreu BotellaReviewed-by: Koji Ishii Cr-Commit-Position: refs/heads/main{#1441973} -- wpt-commits: 00037969dc735353f69f8675504126ae4041faa3 wpt-pr: 51818 UltraBlame original commit: d32bb7c166f17371fbfd77e7d819ba101ec65f62
…s inside nowrap text, a=testonly Automatic update from web-platform-tests [line-clamp] Allow inserting the ellipsis inside nowrap text With the `CSSLineClampLineBreakingEllipsis` runtime feature on, the ellipsis width computation happens as part of line breaking, so that the ellipsis gets inserted at the last possible break opportunity. However, this currently does not work with `text-wrap: nowrap` text, because regular line breaking would not wrap inside that text, but there are still break opportunities in it that must be used when clamping. This patch replaces any calls to the `ComputedStyle` methods `ShouldWrapLine` and `ShouldBreakOnlyAfterWhiteSpace` with equivalent methods in `ComputedStyle` that also check whether the line is being ellipsized for line-clamp; and replaces any such calls inside `LineBreaker` to use them. This is enough to cover the spec's requirements, which explicitly ignore break opportunities created by `overflow-wrap`. This patch also fixes the removal of trailing spaces so that when an ellipsis is inserted inside `white-space: pre` text, there are no preserved spaces between the end of the word and the ellipsis (see w3c/csswg-drafts#12008). Bug: 40336192 Change-Id: I22822d5f1d6a44e5b5c5b99a9fb698df10ffcf9c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6394977 Commit-Queue: Andreu BotellaReviewed-by: Koji Ishii Cr-Commit-Position: refs/heads/main@{#1441973} -- wpt-commits: 00037969dc735353f69f8675504126ae4041faa3 wpt-pr: 51818
Interesting. I think there's several parts in there. For « nowrap does not remove wrap opportunities, it just prevents wrapping » I suspect that can be changed, and have the definition of In terms of wrap opportunities being after, not before, spaces. I agree that we don't want the ellipsis being after a space that would otherwise be removed by phase two, so we need to do ellipsis insertion after phase two. I think the case where I'm least comfortable is when the line ends with preserved white-space (which is thus not discarded) which hang (as can happen with |
We can probably say "soft wrap opportunities were breaking would be allowed (i.e. not
Although I believe the goal is for browsers to implement hanging punctuation eventually, I'm not sure how possible this currently is in Chromium. Maybe it would be doable for line-clamp ellipsis, due to the special way in which we're implementing them, but wouldn't be for other punctuation. But I would need to look into it. |
IIUC, if there's a forced line break inside |
If |
Uh oh!
There was an error while loading. Please reload this page.
The current spec text for
block-ellipsis
(which is one of the longhands forline-clamp
) says that when an ellipsis is inserted on the last line before clamp, it must be placed after the last soft wrap opportunity that would make the line with the ellipsis not overflow, considering that the content after the ellipsis gets pushed to the next line box or fragment.However, according to the Unicode line breaking algorithm, ASCII spaces don't have a break opportunity before them, but only after them. Which means any soft wrap opportunity caused by a space would show the ellipsis after the space, not at the end of the word. Or at least that would be the case if the ellipsis inline is added at the end of the line box during line breaking and before phase II of whitespace processing.
There's also the fact that the
block-ellipsis
spec text allows inserting the ellipsis in the middle oftext-wrap: nowrap
text, since it only talks about finding the last soft wrap opportunity, andnowrap
does not remove wrap opportunities, it just prevents wrapping. Given that, the question comes up of how trailing whitespace would work before the ellipsis insidewhite-space: pre
text. If we just say to collapse as usual according to phase II, and then add the ellipsis, we would still have spaces between the end of the word and the ellipsis inwhite-space: pre
text. Do we want that?The text was updated successfully, but these errors were encountered: