VERIFIED FIXED 4672
Incorrect highlight when selection begins with space and word-spacing>0
https://bugs.webkit.org/show_bug.cgi?id=4672
Summary Incorrect highlight when selection begins with space and word-spacing>0
mitz
Reported 2005-08-26 10:20:39 PDT
Summary: when word-spacing is positive and the selection begins with a space, the highlight is not the right width (does not take into account the width of the initial space). To reproduce: open the testcase in Safari, click in the space next to the M and drag from there to the right. Expected: highlight to cover the entire space once the cursor crosses the middle of the space, and to extend over the letters one at a time as they are reached. Actual: once the cursor crosses the middle of the space, a thin highlight appears near the M. As the cursor is dragged over the letters, the highlight becomes wider.
Attachments
testcase (322 bytes, text/html)
2005-08-26 10:21 PDT, mitz
no flags
suggested fix (818 bytes, patch)
2005-08-26 11:09 PDT, mitz
no flags
add leading word space to the selection rect (817 bytes, patch)
2005-08-26 14:19 PDT, mitz
darin: review+
revised patch (1.80 KB, patch)
2005-08-27 03:11 PDT, mitz
darin: review-
revised patch (2.92 KB, patch)
2005-08-28 07:23 PDT, mitz
darin: review+
mitz
Comment 1 2005-08-26 10:21:18 PDT
Created attachment 3586 [details] testcase
mitz
Comment 2 2005-08-26 11:09:07 PDT
Created attachment 3587 [details] suggested fix
mitz
Comment 3 2005-08-26 11:11:29 PDT
Comment on attachment 3587 [details] suggested fix Give floatWidth the preceding character so that it can account for word spacing. (It is never given the entire string for performance reasons, see font.cpp r1.20).
mitz
Comment 4 2005-08-26 11:21:21 PDT
Comment on attachment 3587 [details] suggested fix Oops. Breaks some layout tests.
Darin Adler
Comment 5 2005-08-26 11:24:44 PDT
Comment on attachment 3587 [details] suggested fix Is one preceding character always good enough?
mitz
Comment 6 2005-08-26 11:33:18 PDT
I think so. It's only used by widthForNextCharacter() in WebTextRenderer.m:2241 .
mitz
Comment 7 2005-08-26 13:24:12 PDT
Sorry, that's line 2171 in WebTextRenderer.m. Looks like a lot of the code relies on the current behavior of not passing the preceding char (in a way that I don't know how to fix for negative word-spacing), so I'll try a different approach for the fix.
mitz
Comment 8 2005-08-26 14:19:02 PDT
Created attachment 3589 [details] add leading word space to the selection rect
mitz
Comment 9 2005-08-26 14:22:42 PDT
Comment on attachment 3589 [details] add leading word space to the selection rect This uses the same logic as WebTextRenderer's widthForNextCharacter to decide if word spacing should be added.
Darin Adler
Comment 10 2005-08-26 19:35:24 PDT
Comment on attachment 3589 [details] add leading word space to the selection rect Looks OK, although I'd like to see a local variable to avoid the 4 calls to textObject(). In fact, maybe that function should be made inline.
mitz
Comment 11 2005-08-27 03:11:38 PDT
Created attachment 3606 [details] revised patch Made textObject() inline AND added a local variable to avoid calling it repeatedly from selectionRect().
Oliver Hunt
Comment 12 2005-08-27 04:30:19 PDT
I hate word-spacing :-/ Exists in ToT, as at 27/8/05
Darin Adler
Comment 13 2005-08-27 11:44:20 PDT
Comment on attachment 3606 [details] revised patch Once textObject() is inlined, it needs to be in the header.
mitz
Comment 14 2005-08-28 07:23:23 PDT
Created attachment 3623 [details] revised patch Moved textObject() to the header (couldn't define it inside the InlineTextBox definition since it needs RenderText to be defined).
Darin Adler
Comment 15 2005-08-28 11:08:41 PDT
Comment on attachment 3623 [details] revised patch r=me
Note You need to log in before you can comment on or make changes to this bug.