Bug 3256 - Onselect event is ignored with TEXTAREA and INPUT
Summary: Onselect event is ignored with TEXTAREA and INPUT
Status: VERIFIED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: 412
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Darin Adler
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-02 22:34 PDT by Chris Petersen
Modified: 2005-07-13 23:12 PDT (History)
1 user (show)

See Also:


Attachments
Sample test case that contains a TEXTAREA and INPUT element with onselect event (620 bytes, text/html)
2005-06-02 22:37 PDT, Chris Petersen
no flags Details
Partial fix (11.52 KB, patch)
2005-06-10 00:37 PDT, Anders Carlsson
no flags Details | Formatted Diff | Diff
Another simple test case with both an <input type=text> and a <textarea> (326 bytes, text/html)
2005-06-15 20:18 PDT, Darin Adler
no flags Details
More-complete fix (18.54 KB, patch)
2005-06-15 20:41 PDT, Darin Adler
mjs: review+
Details | Formatted Diff | Diff
Slightly better test that includes 3 types of <input> as well as <textarea> (418 bytes, text/html)
2005-06-15 20:42 PDT, Darin Adler
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Petersen 2005-06-02 22:34:17 PDT
Expected Results: Onselect event should be processed on both HTML 4.0  TEXTAREA and INPUT elements
What I got: Onselect event is not processed

Steps to reproduce:

1) Open attached test case "textarea_onselect.html" in Safari 2.0
2) In the first element (TEXTAREA) , click and place carat in field. Drag a selection over all of the text and 
mouse up. No alert is displayed (onselect)
3) In the second element (INPUT), click and place carat in field. Drag a selection over all of the text and 
mouse up. Again, no alert is displayed (onselect)
Comment 1 Chris Petersen 2005-06-02 22:37:52 PDT
Created attachment 2092 [details]
Sample test case that contains a TEXTAREA and INPUT element with onselect event
Comment 2 Chris Petersen 2005-06-07 11:05:25 PDT
Apple Bug: <rdar://problem/4141141>
Comment 3 Anders Carlsson 2005-06-10 00:37:18 PDT
Created attachment 2204 [details]
Partial fix

Here's a patch that fixes this for textareas, and puts all the necessary
machinery in place for input fields except for the actual selection
notification in KWQTextField.
The reason for it not working in KWQTextField is because the selection
notification function is called too many times, resulting in unnecessary
onSelect() calls. 
I believe the problem is that when the text field gets focus it selects
everything, causing a selection notification. Then setHasFocus changes the
selection too. I'm also getting a notification when the text field loses focus.
Comment 4 Darin Adler 2005-06-15 20:18:14 PDT
I'm working to refine the patch to get it right. Some experiments with Firefox and MacIE show that:

    1) Firefox emits select events whenever you tab into an <input type=text>, even when it's empty
    2) MacIE emits select events not only when the selection changes from a range to a range and from a 
caret to a range, but also when the selection changes from a range to a caret; we'll have to keep track the 
old selection if we want to match that behavior

Need some testing with WinIE.
Comment 5 Darin Adler 2005-06-15 20:18:57 PDT
Created attachment 2376 [details]
Another simple test case with both an <input type=text> and a <textarea>
Comment 6 Darin Adler 2005-06-15 20:41:25 PDT
Created attachment 2377 [details]
More-complete fix

I did a more-complete fix. It seems to do everything except for the fact that
it doesn't send a selection change event when changing from a range to a caret.
We'll have to check whether WinIE sends an event in this case, and if it does,
we might have to do something more fancy, since the QTextEdit API doesn't tell
you the old selection when sending the selection change signal.
Comment 7 Darin Adler 2005-06-15 20:42:23 PDT
Created attachment 2378 [details]
Slightly better test that includes 3 types of <input> as well as <textarea>
Comment 8 Darin Adler 2005-06-15 20:48:09 PDT
Testing with WinIE shows that it does not do the thing that MacIE does (send an event when the selection 
becomes a caret). So I think this patch is ready to go.
Comment 9 Anders Carlsson 2005-06-15 23:57:04 PDT
Thanks for looking at this. The new patch looks good to me.
Comment 10 Chris Petersen 2005-06-20 08:56:36 PDT
Great ! Verified fixed with TOT Webkit (6/20) under 10.4.1.
Comment 11 Joost de Valk (AlthA) 2005-07-13 23:03:47 PDT
Fixed in 10.4.2