Skip to content

[css-text] line-break: anywhere but normal breaking at spaces #3561

Closed

Description

@kojiishi

We added line-break: anywhere, but resolved to break at preserved spaces too.

Looking at requests from authors (crbug.com/720205 and an author page linked from it), what author wants is Gecko/WebKit behavior, which is break before/after any punctuation, but not at preserved spaces.

I understand some members do want to break at preserved spaces, and but including it breaks the original requests.

Can we add a value to help the original request?

Activity

  1. kojiishi commented on Jan 28, 2019

    @kojiishi
    ContributorAuthor

    There's a possibility to change break-all to match to Gecko/WebKit. Since the two impls do differently from the spec for a long time that I'm seeing some Japanese sites stopped using break-all these days. However, some major sites such as Yahoo! Japan are still using it, so I'm in a mixed feeling about this.

    If we were going to take this route, then the new value in this request is not needed, but a new value for the original CJK purpose is nice to have.

    cc @upsuper @litherum

  2. kojiishi commented on Jan 28, 2019

    @kojiishi
    ContributorAuthor

    A test showing cases @jsbin

    IIUC what authors want at crbug.com/720205 is Gecko/WebKit behavior on these two cases, but neither value of the spec provide it.

  3. fantasai commented on Jan 29, 2019

    @fantasai
    Collaborator

    Hi Koji, I'm a little confused exactly what you're requesting here. As long as break-spaces is not specified, a space at the end of the line will not take up any space. So there will not be any break that wraps a space to the beginning of a line. Are you talking about a different kind of space?

  4. kojiishi commented on Jan 29, 2019

    @kojiishi
    ContributorAuthor

    Thanks, that's great. Currently the line-break: anywhere states that:

    There is a soft wrap opportunity around every typographic character unit, including around any punctuation character or preserved spaces

    Should "around preserved spaces" be applied only when break-spaces is also specified?

  5. fantasai commented on Jan 29, 2019

    @fantasai
    Collaborator

    @kojiishi Hm, I'm not sure.

    Technically, when spaces hang (default behavior) it doesn't matter whether there is a break opportunity or not around them, they'll still "fit" on the line so we won't break before them even if there is an opportunity... So I think either way you get the behavior you want for line-break: anywhere (except when break-spaces is specified of course).

    cc @frivoal

  6. kojiishi commented on Jan 30, 2019

    @kojiishi
    ContributorAuthor

    Oh, I see, I was under impression that only non-breakable sequences can hang, since hanging is a type of emergency operations for CJK to avoid expansions or lagged lines, but probably not for other writing systems.

    I'm good with the interpretation, @frivoal great if you can confirm the text has nothing to do unless break-spaces is specified.

  7. frivoal commented on Jan 30, 2019

    @frivoal
    Collaborator

    I confirm. If white-space is:

    • no-wrap or pre, then we don't break anyway
    • normal or pre-line, there's no preserved space at the end of the line, so line-break: anywhere can't add soft wrap opportunities around them
    • pre-wrap, there are preserved spaces at the end of the line, but they hang, so soft wrap opportunities don't do anything
    • break-spaces, then line-break: anywhere does add soft wrap opportunities around them.

    So I think the spec is fine as is, except if we want a note to clarify the pre-wrap case.

  8. kojiishi commented on Jan 30, 2019

    @kojiishi
    ContributorAuthor

    so soft wrap opportunities don't do anything

    Thank you for the confirmation. If a definition in the spec doesn't do anything, isn't it better to not to have it?

    If you want that effect only when break-spaces is specified, it is helpful if we can write so.

  9. javifernandez commented on Feb 5, 2019

    @javifernandez
    Contributor

    As far I understand it, the new 'break-spaces' value already provides soft wrap opportunities around preserved spaces. What does this combination with line-break: anywhere provide ?

    https://drafts.csswg.org/css-text-3/#valdef-white-space-break-spaces

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

  10. frivoal commented on Feb 6, 2019

    @frivoal
    Collaborator

    As far I understand it, the new 'break-spaces' value already provides soft wrap opportunities around preserved spaces. What does this combination with line-break: anywhere provide ?

    line-break: anywhere isn't just about spaces, but on the topic of spaces, it changes one thing of the behavior of white-space:break-spaces when used together: white-space:break-spaces introduces break opportunities after every space. That means that between the last letter of a word and the first space, there isn't one. If you addline-break: anywhere, then there is also a break opportunity there.

  11. kojiishi commented on Feb 6, 2019

    @kojiishi
    ContributorAuthor

    So, IIUC:

    • line-break: anywhere changes nothing about breaking before/after spaces.
    • white-space: break-space disallows hanging spaces, and adds break opportunities after every spaces, including between spaces.
    • white-space: break-space when used with line-break: anywhere adds break opportunities before spaces too.

    Is this correct?

    If so, it'd be very helpful if the spec has these conditions more straight.

  12. frivoal commented on Feb 6, 2019

    @frivoal
    Collaborator

    Basically yes, and I'm all for making the spec clearer if it isn't now, but to me the way you describe it more confusing than what's in the spec (even though I now understand what you mean):

    * `line-break: anywhere` changes nothing about breaking before/after spaces.
    

    well, it changes nothings about breaking before or after preserved spaces when there are no preserved spaces. Other kinds of spaces (nbsp, narrow non breaking spaces, etc) do get break opportunities. Also, line-break is about breaking opportunities, not forced breaks, so it has no effect when you don't need to wrap at all, as is the case when preserved spaces hang (pre-wrap), or when wrapping is disabled entirely (pre, nowrap).

    Maybe we can keep the normative prose as it is, and add a note like:

    Note: anywhere only allows preserved spaces at the end of the line to be wrapped to the next line when white-space is break-spaces, because in other cases:

    • preserved spaces at the end/start of the line are discarded (normal, pre-line)
    • wrapping is forbidden altoghether (nowrap, pre)
    • wrapping spaces is unecessary as they hang (pre-wrap).

    When it does have an effect on preserved spaces, with break-spaces, it allows breaking before the first of a sequence of preserved spaces, which break-spaces does not do on its own.

  13. javifernandez commented on Feb 11, 2019

    @javifernandez
    Contributor

    line-break: anywhere isn't just about spaces, but on the topic of spaces, it changes one thing of the behavior of white-space:break-spaces when used together: white-space:break-spaces introduces break opportunities after every space. That means that between the last letter of a word and the first space, there isn't one. If you addline-break: anywhere, then there is also a break opportunity there.

    I see; although the same happens when combining white-space: break-spaces and overflow-wrap: break-word, right ? In that case there is also a break opportunity between the last letter of a word and the first space. Are these two combinations totally equivalent ?

  14. frivoal commented on Apr 23, 2019

    @frivoal
    Collaborator

    I see; although the same happens when combining white-space: break-spaces and overflow-wrap: break-word, right ? In that case there is also a break opportunity between the last letter of a word and the first space. Are these two combinations totally equivalent ?

    Yes, it is similar, but no, it is not totally equivalent: overflow-wrap: break-word or overflow-wrap: anywhere (together with white-space:break-spaces) will add a wrapping opportunity between the last letter of the word and the first space after it if there's no other wrapping opportunity in the line.

  15. self-assigned this
    on Apr 23, 2019
  16. frivoal commented on Sep 27, 2019

    @frivoal
    Collaborator

    tested by line-break-anywhere-005.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions