Closed Bug 1358019 Opened 3 years ago Closed 8 months ago

word-break: break-all shouldn't create breaks between punctuation

Categories

(Core :: Layout: Text and Fonts, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla67
Tracking Status
firefox67 --- fixed

People

(Reporter: fantasai.bugs, Assigned: jfkthame)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

'word-break: break-all' is not supposed to affect breaking between/around punctuation, only between pairs of letters (or symbols that behave like letters for line breaking).
Testcase: http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%0A%3Cdiv%20style%3D%22word-break%3A%20break-all%20%3B%20font-size%3A%20200px%22%3EABC)%3C%2Fdiv%3E
Spec: https://www.w3.org/TR/css-text-3/#break-all

“In addition to ‘normal’ soft wrap opportunities, lines may break between any two **letters** (except where forbidden by the ‘line-break’ property). Hyphenation is not applied. This option is used mostly in a context where the text is predominantly using CJK characters with few non-CJK excerpts and it is desired that the text be better distributed on each line.”
Priority: -- → P3
Duplicate of this bug: 1472598
Copying over metadata from duplicate bug 1472598.

Xidorn points out that we might want to implement `line-break: anywhere` as part of this, to make sure that the use case has a solution.
Blocks: css-text-3
Depends on: 1011369
Attached image firefox, safari, chrome
Probably related to Bug 1272059 

Using the test case http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%0A%3Cdiv%20style%3D%22word-break%3A%20break-all%20%3B%20font-size%3A%20200px%22%3EABC)%3C%2Fdiv%3E

Firefox, Safari: They break at the punctuation.
Chrome: It breaks at the character before the punctuation.

Koji is reporting that Chrome is running into compat problems because of this bug, fwiw. Any plans for fixing yet?

(In reply to fantasai from comment #4)

Koji is reporting that Chrome is running into compat problems because of this bug, fwiw. Any plans for fixing yet?

Err, I meant to reply:

Jonathan has a better handle on all our line-breaking stuff. I'm happy to give it a shot at some point though.

It looks like our current implementation of word-break:break-all is rather too naïve: it essentially just treats every character as a potential break position -- e.g. see https://searchfox.org/mozilla-central/rev/00c0d068ece99717bea7475f7dc07e61f7f35984/intl/lwbrk/LineBreaker.cpp#901-902. (Maybe an older spec said something more like that?)

Anyhow, as currently spec'd, break-all doesn't simply mean "break anywhere"; it's defined in terms of revised line-break categories for certain classes of character. We should probably revise the impl in LineBreaker.cpp to better match the spec.

I've pushed a try job at https://treeherder.mozilla.org/#/jobs?repo=try&revision=012fd97eff0766a3add5c137777a867fe4db04e6 with an experimental patch; let's see what shakes out. Most likely there'll be a few oranges on the tree...

Turns out there's an existing web-platform reftest (word-break-break-all-020.html) for this -- it's currently marked as failing, but if we fix break-all to follow the spec then we can remove that annotation.

Nice! It would've taken me quite a bit to come up with that patch :-)

@Emilio You could map the old behavior to line-break: anywhere? :)
@jfkthame Thank you~

Pushed by jkew@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/a93501fc7922
Reimplement word-break:break-all to better match the CSS Text spec. r=masayuki
Status: NEW → RESOLVED
Closed: 8 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla67
Assignee: nobody → jfkthame
See Also: → 1531715
Regressions: 1554998
You need to log in before you can comment on or make changes to this bug.