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-text-3] When is allowed to break before the first preserved white-space after a word ? #3701

Closed
javifernandez opened this issue Mar 1, 2019 · 7 comments

Comments

Projects
None yet
3 participants
@javifernandez
Copy link
Contributor

commented Mar 1, 2019

It may be other cases, but I'd like some clarification regarding how to deal with preserved white-spaces character generated by the white-space: break-spaces feature.

According to the spec,it must break AFTER any white-space:

A line breaking opportunity exists after every preserved white space character, including between white space characters.

However, depending on the case and in combination with other CSS properties, there may be soft-breaking opportunities BEFORE the first space after a word. The following table describes what I think is the expected behavior when using white-space: break-spaces in combination with other properties:

propertyvaluebreak beforeConditional
overflow-wrapnormalNoNever
break-wordYesIf no previous opportunity
anywhereYesIf no previous opportunity
word-break normalNoNever
break-allNoNever
keep-allNoNever
line-breakanywhereyesAlways

Is the content of this table correct, according to the last draft of the spec ?

Assuming it's correct, lets consider the following example:

<style>
div {
  width: 4ch;
  line-height: 1;
  border: 1px solid;
}
</style>

<div>X XX X</div>

The table bellow shows Chrome's current behavior when loading the example above with the different combination of the line-breaking properties:

caseword-breakoverflow-wrapline-breakresult
0normalnormalauto
1normalbreak-wordauto
2normalanywhereauto
3break-allnormalauto
4break-allbreak-wordauto
5normalnormalanywhere
6break-allnormalanywhere
7normalbreak-wordanywhere
8break-allbreak-wordanywhere

Are all these cases correctly rendered ?

@emilio

This comment has been minimized.

Copy link
Collaborator

commented Mar 4, 2019

Blink doesn't implement overflow-wrap: anywhere, is that right?

@javifernandez

This comment has been minimized.

Copy link
Contributor Author

commented Mar 7, 2019

Blink doesn't implement overflow-wrap: anywhere, is that right?

Right, but it's in my todo list; right after implementing line-break: anywhere

@frivoal

This comment has been minimized.

Copy link
Collaborator

commented Apr 17, 2019

Is the content of this table correct, according to the last draft of the spec ?

Yes, that matches my own understanding.

Are all these cases correctly rendered ?

All cases assume white-space: break-spaces ? In that case, then I think it has bugs. I would expect this instead (i.e. case 0 to 4 are different, case 5 to 8 are the same):

caseword-breakoverflow-wrapline-breakresult
0normalnormalauto X
XX X
1normalbreak-wordauto X
XX X
2normalanywhereauto X
XX X
3break-allnormalauto X X
X X
4break-allbreak-wordauto X X
X X
5normalnormalanywhere
6break-allnormalanywhere
7normalbreak-wordanywhere
8break-allbreak-wordanywhere

@fantasai, do you agree?

@frivoal

This comment has been minimized.

Copy link
Collaborator

commented Apr 23, 2019

@javifernandez Is there a spec issue to be discussed further, or can we consider this question answered and close this?

@javifernandez

This comment has been minimized.

Copy link
Contributor Author

commented Apr 24, 2019

Why breaking after the last letter is not allowed in cases 1 (overflow-wrap: break-word) and 2 (oveflow-wrap: anywhere) ?

@javifernandez

This comment has been minimized.

Copy link
Contributor Author

commented Apr 24, 2019

Why breaking after the last letter is not allowed in cases 1 (overflow-wrap: break-word) and 2 (oveflow-wrap: anywhere) ?

I see, it's because there is a previous breaking opportunity.

@javifernandez

This comment has been minimized.

Copy link
Contributor Author

commented Apr 24, 2019

@frivoal I think everything is clear now and we can close this issue now.

@frivoal frivoal closed this Apr 25, 2019

miroljub1995 pushed a commit to miroljub1995/webkit that referenced this issue May 1, 2019

jfernandez@igalia.com
line should not be broken before the first space after a word
https://bugs.webkit.org/show_bug.cgi?id=197278

Reviewed by Myles C. Maxfield.

LayoutTests/imported/w3c:

Added new Web Platform Tests to cover the cases discussed [1] with the CSS WG.

[1] w3c/csswg-drafts#3701

* web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-001-expected.html: Added.
* web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-001.html: Added.
* web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-002-expected.html: Added.
* web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-002.html: Added.
* web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-003-expected.html: Added.
* web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-003.html: Added.
* web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-004-expected.html: Added.
* web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-004.html: Added.
* web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-005-expected.html: Added.
* web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-005.html: Added.
* web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-006-expected.html: Added.
* web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-006.html: Added.
* web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-007-expected.html: Added.
* web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-007.html: Added.
* web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-008-expected.html: Added.
* web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-008.html: Added.
* web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-009-expected.html: Added.
* web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-009.html: Added.
* web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-010-expected.html: Added.
* web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-010.html: Added.
* web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-011-expected.html: Added.
* web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-011.html: Added.
* web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-012-expected.html: Added.
* web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-012.html: Added.
* web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-013-expected.html: Added.
* web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-013.html: Added.

Source/WebCore:

The 'white-space: break-spaces' only adds breaking opportunities after
a white space character. However, it's possible to break before the
first space after a word when the feature is used in combination with
other properties, like overflow-wrap.

However, breaking before the first space should not be allowed if
there are previous opportunities. We wrongly assumed that we had to
consider these previous breaking opportunities if the proper combination
of line breaking properties is being used, so that breaking before the
first space after a word is allowed.

This wrong assumption caused several issues, like the one described in
the bug, that lead to incorrectly break before the first space even
though there are previous opportunities, either white spaces or between
letters.

Theses issues have been analyzed [1] by the CSS WG and finally agreed on a
expected behavior, represented in the Web Platform tests added in this
patch.

For the later case, of considering previous opportunities between
letters, we have a seperated issue #952254, so the tests covering such
cases will be added to the TestExpecations as Failure entries.

[1] w3c/csswg-drafts#3701

Tests: imported/w3c/web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-001.html
       imported/w3c/web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-002.html
       imported/w3c/web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-003.html
       imported/w3c/web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-004.html
       imported/w3c/web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-005.html
       imported/w3c/web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-006.html
       imported/w3c/web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-007.html
       imported/w3c/web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-008.html
       imported/w3c/web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-009.html
       imported/w3c/web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-010.html
       imported/w3c/web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-011.html
       imported/w3c/web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-012.html
       imported/w3c/web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-013.html

* rendering/line/BreakingContext.h:
(WebCore::BreakingContext::handleText):
(WebCore::BreakingContext::trailingSpacesHang):

LayoutTests:

Added a few Skip (due to unimplemented features) and Failure (break-all related
issues) entries for some of the tests added by this patch.

* TestExpectations:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@244748 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.