Bug 12726 - REGRESSION (r12073): Text wraps in the middle of a word instead of wrapping at the space before the word
Summary: REGRESSION (r12073): Text wraps in the middle of a word instead of wrapping a...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Text (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P1 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-02-10 11:04 PST by mitz
Modified: 2007-02-14 06:23 PST (History)
0 users

See Also:


Attachments
Test case (453 bytes, text/html)
2007-02-10 11:05 PST, mitz
no flags Details
Don't measure a run by adding up the widths of individual characters (38.19 KB, patch)
2007-02-10 11:29 PST, mitz
no flags Details | Formatted Diff | Diff
Use the inaccurate text measurement only as a lower bound (44.18 KB, patch)
2007-02-13 16:31 PST, mitz
hyatt: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description mitz 2007-02-10 11:04:50 PST
See the attached test case. This bug affects text areas (which use word-wrap: break-word).
Comment 1 mitz 2007-02-10 11:05:25 PST
Created attachment 13107 [details]
Test case
Comment 2 mitz 2007-02-10 11:29:50 PST
Created attachment 13108 [details]
Don't measure a run by adding up the widths of individual characters

When word-wrap is break-word, the new code is O(n^2) in the length of the first word on the line (for autowrap) or the length of the entire line (for PRE).
Comment 3 mitz 2007-02-10 15:23:32 PST
Comment on attachment 13108 [details]
Don't measure a run by adding up the widths of individual characters

I'm going to think more about this and try to come up with a better-behaved solution.
Comment 4 mitz 2007-02-13 16:31:09 PST
Created attachment 13157 [details]
Use the inaccurate text measurement only as a lower bound

This patch keeps the current mechanism that adds up single characters' widths, but once the total width overflows the line's width, it starts measuring everything as a single run. Looking at r12073, I realized that this was actually what the code was doing before that patch (modulo the bugs fixed since then). I also made things a little more efficient by not measuring or computing things that didn't change or that you no longer care about.

I think this approach is better than the alternative of not measuring anything until you hit the first word boundary, since that can be proportional to the length of the entire text object, whereas the rounding error is proportional to the length of a single line. (This might make a difference when you're editing the first line of a very long "word").
Comment 5 Dave Hyatt 2007-02-13 17:28:17 PST
Comment on attachment 13157 [details]
Use the inaccurate text measurement only as a lower bound

r=me
Comment 6 Sam Weinig 2007-02-14 06:23:30 PST
Landed in r19621.