Bug 9528

Summary: REGRESSION: arrow key skips '>' in Bugzilla replies due to '\n' in text nodes
Product: WebKit Reporter: David Kilzer (:ddkilzer) <ddkilzer>
Component: FormsAssignee: Anders Carlsson <andersca>
Status: RESOLVED FIXED    
Severity: Normal CC: adele, ap, c.petersen87, darin, ggaren, ian, joost
Priority: P1 Keywords: InRadar, Regression
Version: 420+   
Hardware: Mac   
OS: OS X 10.4   
Attachments:
Description Flags
patch to handle \n and \r in setInnerText -- no test cases or change log
none
Patch with test case adele: review+

Description David Kilzer (:ddkilzer) 2006-06-21 05:08:08 PDT
Steps to reproduce:

1. Open a Bugzilla bug (like this one).
2. Click "reply" to a comment (like this description field).
3. Position the cursor at the end of a line where the next line starts with a '>' character.
4. Hit the right arrow key.

Expected results:

The cursor should go to the beginning of the next line (to the left of the '>' character).

Actual results:

The cursor jumps over the '>' character and lands to its right.
Comment 1 Joost de Valk (AlthA) 2006-06-21 05:10:05 PDT
Heh David, i keep wondering how you find bugs like this one :)
Comment 2 David Kilzer (:ddkilzer) 2006-06-21 05:10:43 PDT
(In reply to comment #0)
> Steps to reproduce:
> 
> 1. Open a Bugzilla bug (like this one).
> 2. Click "reply" to a comment (like this description field).
> 3. Position the cursor at the end of a line where the next line starts with a
> '>' character.
> 4. Hit the right arrow key. 

Actually, you must hit the right arrow key TWICE for the cursor to move.

Deleting the '>' characters proves quite challenging as well.  I'm guessing this is related.

Comment 3 David Kilzer (:ddkilzer) 2006-06-21 05:11:45 PDT
(In reply to comment #1)
> Heh David, i keep wondering how you find bugs like this one :) 

Just by filing bugs! :)  I tend to be very sensitive to the behavior of mouse and keyboard actions, and notice differences very quickly.

Comment 4 David Kilzer (:ddkilzer) 2006-06-21 05:13:05 PDT
Interestingly, if you type your own text with '>' characters, this does not happen.  There is something special about what the "reply" function does when pasting text into the textarea.  Maybe there's some CR/LF wackiness going on?

Comment 5 jonathanjohnsson 2006-06-21 07:57:03 PDT
Maybe you already know this, but this happened somewhere between the nightlies labeled r14926 and r14941.
Comment 6 Darin Adler 2006-06-24 20:04:40 PDT
(In reply to comment #4)
> Interestingly, if you type your own text with '>' characters, this does not
> happen.  There is something special about what the "reply" function does when
> pasting text into the textarea.  Maybe there's some CR/LF wackiness going on?

Yes, I'm sure this is a CR/LF issue.
Comment 7 Darin Adler 2006-06-25 16:35:33 PDT
(In reply to comment #6)
> Yes, I'm sure this is a CR/LF issue.

No, I'm wrong. Not a CR/LF issue at all. Instead the issue is that there are actual newline characters in the reply. But when editing we get <br> elements instead. Presumably we always want one or the other. I'm not sure which. Since <br> works right now, my focus should probably be on translating the newlines to <br> elements on the way in, but it also would be good to have editing work properly with actual newline characters in it. I don't see anything in the CSS style sheet or the code that would set the white space mode properly to make the newline characters work, so I really don't know what's going on there.
Comment 8 Darin Adler 2006-06-25 16:39:16 PDT
This boils down to the fact that we use setInnerText, and setInnerText does not turn the newlines into <br> elements. And it should! At least in some whitespace modes.
Comment 9 Darin Adler 2006-06-25 17:03:19 PDT
Created attachment 9028 [details]
patch to handle \n and \r in setInnerText -- no test cases or change log
Comment 10 Darin Adler 2006-06-26 08:22:11 PDT
*** Bug 9592 has been marked as a duplicate of this bug. ***
Comment 11 David Kilzer (:ddkilzer) 2006-07-01 21:11:18 PDT
*** Bug 9681 has been marked as a duplicate of this bug. ***
Comment 12 Anders Carlsson 2006-07-06 17:40:53 PDT
Created attachment 9242 [details]
Patch with test case
Comment 13 Adele Peterson 2006-07-06 17:48:49 PDT
Comment on attachment 9242 [details]
Patch with test case

Anders also tested WinIE and found that this matches their behavior.
Comment 14 Anders Carlsson 2006-07-06 17:55:19 PDT
Committed in r15194