<div style="position:absolute;border:2px solid black;word-break:break-all;font-family:'Lucida Grande'">Maxwidth is wrong when word-break all is set. More and more extra pixels will creep in.</div> <div style="position:absolute;top:40px;border:2px solid black;font-family:'Lucida Grande'">Maxwidth is wrong when word-break all is set. More and more extra pixels will creep in.</div> The problem is that breaking on every character causes integer rounding to kick in for each character because of run rounding.
P1. Necessary for the feature to work at all.
For break-all only, we'll also end up breaking too early because rounding errors will accumulate during findNextLineBreak.
(In reply to comment #2) > For break-all only, we'll also end up breaking too early because rounding > errors will accumulate during findNextLineBreak. > For word-wrap:break-word, findNextLineBreak does the right thing: it uses the accumulated width ('wrapW') as an upper bound on the actual width. Once the bound is greater than 'width', it starts checking the true width. Looks like the same logic should apply to break-all. In fact, this if (breakAll || (breakWords && !midWordBreak)) { wrapW += t->width(pos, 1, f, w + wrapW); midWordBreak = w + wrapW > width; } should have taken care of it, making the 'breakAll' check in if (betweenWords || midWordBreak || breakAll) { redundant if you also changed midWordBreak &= breakWords; to say 'breakWords || breakAll'. Actually, I think the first condition could be if ((breakAll || breakWords) && !midWordBreak) {
<rdar://problem/5153030>
Created attachment 15485 [details] Avoid rounding errors with word-break:break-{all,word} No layout test regressions. Includes tests for max width and line breaking.
Comment on attachment 15485 [details] Avoid rounding errors with word-break:break-{all,word} r=me
Landed by Sam in r24278.