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] line breaking rules around replaced-inline content incorrectly refer to ID class #3085

Closed
faceless2 opened this issue Sep 6, 2018 · 3 comments

Comments

@faceless2
Copy link

Section 5.1 of css-text-3 says:

The line breaking behavior of a replaced element or other atomic inline is equivalent to an ideographic character (Unicode linebreaking class ID [UAX14]), and additionally, for Web-compatibility, introduces a soft wrap opportunity between itself and any adjacent U+00A0 NO-BREAK SPACE character.

I'm not sure this is correct, for several reasons.

First, the next paragraph defines the behaviour of word-break: keep-all as:

Specifically it controls whether a soft wrap opportunity exists between adjacent typographic letter units (or other typographic character units belonging to the NU, AL, AI, or ID Unicode line breaking classes [UAX14]).

Which seems to imply that the soft-break opportunties are identical between "a国b" and "a[IMG]b", and that they can be prevented by setting "word-break: keep all".

Second, the line-breaking rules for ID class characters in UAX#14 do not match current browser behaviour even with word-break: normal. UAX#14 rule LB23a disallows a word-break between a numeric prefix (eg U+002C, plus sign) and an ideograph, but clearly the intention in CSS is not to disallow a soft wrap between a plus sign and a replaced inline.

The UAX#14 algorithm refers the object-replacement character, and explicitly states that this character is used to represent inline-objects in its algorithm. The behaviour of this approach seems to match current browser behaviour. So I think this bullet-point in 5.1 should be altered to:

The line breaking behavior of a replaced element or other atomic inline is equivalent to an object-replacement character (U+FFFC, Unicode linebreaking class CB [UAX14]), and additionally, for Web-compatibility, introduces a soft wrap opportunity between itself and any adjacent U+00A0 NO-BREAK SPACE character. While UAX#14 allows the break behaviour of class CB characters to be further defined by the object itself, this is not done in CSS and inline object is treated as an "unresolved CB".

Or something along those lines. The phrase "unresolved CB" is from UAX#14.

Related: #2559, #567

@frivoal frivoal added the css-text-3 Current Work label Sep 7, 2018
@fantasai
Copy link
Collaborator

Treating replaced elements as ID was intentional. See discussion in https://lists.w3.org/Archives/Public/www-style/2015Mar/0187.html

If there's a Web-compat issue around here, please let us know exactly what it is so we can make targetted exceptions as necessary.

@faceless2
Copy link
Author

Thanks, I hadn't found that discussion. To sum it up here for posterity, the issue was that linebreaks around images used for emoji (shakes head at emoji) were incorrect; I can't see the original discussion on this, but in the previous version a sequence like (😀) would have break opportunities before and after the emoji, I presume the intention was to prevent that.

It's explicitly stated in the link you referenced that this is a breaking change as it will prevent breaks between brackets and images:

fantasai: Or "(<img>)", you can't break in the parentheses anymore, they'll stay with the image.

This is deliberate, it is a breaking change, but that's been discussed and considered acceptable. So I'll close this issue.

But: I've put a pull request in at web-platform-tests/wpt#13027 for a new testcase which I think covers the behaviour discussed here; as none of the browsers seem to support this properly yet, if you fancy reviewing it would be nice!

@frivoal frivoal added Testing Unnecessary Memory aid - issue doesn't require tests and removed Needs Review of Test Case(s) labels Dec 30, 2022
@frivoal
Copy link
Collaborator

frivoal commented Dec 30, 2022

This is no longer current.

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

No branches or pull requests

3 participants