VERIFIED FIXED 3654
cursor position accessors on KWQTextArea require \n
https://bugs.webkit.org/show_bug.cgi?id=3654
Summary cursor position accessors on KWQTextArea require \n
Kevin Ballard
Reported 2005-06-22 15:16:10 PDT
The accessors for the cursor position on KWQTextArea are not line ending-agnostic - they require \n (and work with \r\n simply because you can't put the cursor between the \r and the \n). This is actually only used to save the cursor position when changing the text value of the field, so the only way to test it is to give the field a text value using carriage returns, set the selection, then change the text value to something else with newlines, and check the selection. The cursor will be stuck in the first line of the field instead of where it should be.
Attachments
A testcase for the bug (1.34 KB, text/html)
2005-06-22 15:18 PDT, Kevin Ballard
no flags
A patch for this problem (6.04 KB, patch)
2005-06-24 00:08 PDT, Kevin Ballard
darin: review+
A better testcase (1.73 KB, text/html)
2005-06-24 12:26 PDT, Kevin Ballard
no flags
Kevin Ballard
Comment 1 2005-06-22 15:17:16 PDT
The reason this depends on 3401 is simply for the testcase - it requires the ability to get/set the selection.
Kevin Ballard
Comment 2 2005-06-22 15:18:21 PDT
Created attachment 2554 [details] A testcase for the bug
Kevin Ballard
Comment 3 2005-06-22 15:19:50 PDT
I have a fix for this already, but I can't create a proper patch until bug 3401 is committed, because I have a lot of changes in the same file for bug 3401 which cause problems with generating a patch just for this file.
Kevin Ballard
Comment 4 2005-06-24 00:08:17 PDT
Created attachment 2614 [details] A patch for this problem
Darin Adler
Comment 5 2005-06-24 08:35:14 PDT
I don't understand how the test case works. I thought that you changed the setter so that it would convert non-standard line endings to standard ones. If so, then this doesn't test the code in KWQTextArea, does it?
Kevin Ballard
Comment 6 2005-06-24 12:10:07 PDT
No, I stopped doing that when I added the updateFromElement() call - instead I just invalidated the cached value, so the next retrieve would get the translated value, but the textarea still has the newline style of the input text. What this does is it sets the textarea text to be all carriage returns, so the textarea's cursor functions thinks it's a single paragraph (pre-patch). It then sets the textarea text to be all newlines (plus the exclamation mark - otherwise it will think it's the same text and not bother calling updateFromElement), which calls updateFromElement. That fetches the cursor position, gets a large index in paragraph 0 (assuming the selection is past a carriage return), sets the text to use newlines, and then tries setting the cursor position again. The cursor ends up being in the last position in paragraph 0, which in the testcase means it will be in index 7 instead of index 10 where it belongs. The fix makes the getCursorPosition... actually return the right paragraph/index, so when setting it again it works. And I just realized that this doesn't actually test the line ending-agnostic behaviour of setCursorPosition..., just getCursorPosition.... Let me see if I can get a testcase working for setCursorPosition... as well.
Kevin Ballard
Comment 7 2005-06-24 12:26:05 PDT
Created attachment 2631 [details] A better testcase Ok, this testcase tests both getCursorPosition... and setCursorPosition... (and hence, RangeOfParagraph() as well).
Darin Adler
Comment 8 2005-06-24 21:23:35 PDT
Comment on attachment 2614 [details] A patch for this problem Looks good, r=me.
Note You need to log in before you can comment on or make changes to this bug.