Bug 3244

Summary: Support the 'label' element in HTML forms
Product: WebKit Reporter: Dave Hyatt <hyatt>
Component: FormsAssignee: Dave Hyatt <hyatt>
Status: RESOLVED FIXED    
Severity: Normal CC: accessibleweb, bugs-webkit, ddkilzer, ian, jhurshman, kanda, mark.thomas, martin.davidsson, mitz, rsesek, shinyplasticbag
Priority: P2 Keywords: InRadar
Version: 412   
Hardware: All   
OS: All   
URL: http://www.robinlionheart.com/stds/html4/forms.html
Bug Depends on:    
Bug Blocks: 4223, 7671    
Attachments:
Description Flags
Proposed patch for the partial implementation of LABEL element support
darin: review-
Patch that fully implements label mjs: review+

Dave Hyatt
Reported 2005-06-01 16:13:02 PDT
If a form element has a label defined, then clicking that label should click/check/etc. the form element. Example at http://www.robinlionheart.com/stds/html4/forms.html 5/3/05 4:17 PM Dave Hyatt: Sadly I completely implemented this and then lost the patch. I will have to re-code it. 5/3/05 5:04 PM Jeff Clites: Take a look at 4105639 also: It would be nice for the implementation of this label behavior to match how radio button labels in Mac OS X work, in particular with regard to mouse-down on the label "highlighting" the corresponding form element. (That is, mouse-down highlights, click selects.)
Attachments
Proposed patch for the partial implementation of LABEL element support (1.97 KB, patch)
2005-09-07 12:42 PDT, Martin Davidsson
darin: review-
Patch that fully implements label (5.11 KB, patch)
2006-09-12 22:35 PDT, Dave Hyatt
mjs: review+
Dave Hyatt
Comment 1 2005-06-01 16:13:50 PDT
Apple Bug: rdar://3044177/
Patrick H. Lauke
Comment 2 2005-08-02 07:35:22 PDT
this came up in a discussion on the (Australian) Web Standards Group list this afternoon (see thread http://www.mail-archive.com/wsg%40webstandardsgroup.org/msg19456.html and in particular my reply later on http://www.mail-archive.com/wsg%40webstandardsgroup.org/msg19484.html ). In short: unless I'm misreading W3C WAI UAAG guideline 7, this should be implemented in accordance with the operating system convention on OS X (and should also work with both implicit and explicit labels).
Martin Davidsson
Comment 3 2005-09-07 12:42:42 PDT
Created attachment 3799 [details] Proposed patch for the partial implementation of LABEL element support I've attached a patch that enables the basic onclick functionality of a label element (not including mousedown events). I'm not conforming to the standard procedure of how to contribute code because I have no idea if my code is the correct way to do things in the WebCore. I'd love to hear some feedback though. If this patch is workable, I'll gladly look into writing a test for it.
Eric Seidel (no email)
Comment 4 2005-10-09 12:48:47 PDT
Comment on attachment 3799 [details] Proposed patch for the partial implementation of LABEL element support Someone forgot to mark this for review...
Darin Adler
Comment 5 2005-10-09 13:39:11 PDT
Comment on attachment 3799 [details] Proposed patch for the partial implementation of LABEL element support HTMLInputElementImpl* is incorrect formatting. There's spposed to be a space before the *. I don't undersand the purpose of this line of code: + inputElt->setChecked(inputElt->checked()); Also, there should not be braces around single-line if statements. Otherwise, this looks like a good start; I think the basic approach is pretty good. Please do add a test and keep working on it!
Dave Hyatt
Comment 6 2005-10-09 18:07:26 PDT
I actually implemented this feature and then sadly lost the patch. I do not actually agree with this approach. The approach I took was to actually hook in at the mouse event level and change the target of the RenderLayer hit test to be the form control that the label is attached to. You need an approach like this so that :hover and :active work properly on the controls and so that all the mouse event handlers (and not just click) fire on the control.
Mark Thomas
Comment 7 2005-11-29 03:13:40 PST
Does this patch also update any accessability information which is sent back, so the label and radio button are 1 item on the Item Chooser for example ? Also how do we move forward on this ?
Mark Thomas
Comment 8 2005-11-29 03:31:28 PST
Re-reading the coments here, but is just mouse event level is that enough ?, as I think here about the keyboard control via tab/cursor keys need to work as well correctly with/without accessability being on ? I agree that to get the highlighting correct needs the mouse event method as suggested by Dave H. Sorry but this first time on the contributing here, but once I understand how all this work will contribute more over time. Thanks Mark.
Darin Adler
Comment 9 2005-12-03 15:27:09 PST
In Radar as <rdar://problem/3044177> HTML4: clicking on the label should do the same thing clicking on the form element does
David Carson
Comment 10 2006-06-17 15:30:43 PDT
David Kilzer (:ddkilzer)
Comment 11 2006-06-24 19:16:04 PDT
Reassigning to webkit-unassigned for more exposure.
Dave Hyatt
Comment 12 2006-09-12 22:35:41 PDT
Created attachment 10521 [details] Patch that fully implements label I came up with a way to do this that still uses defaultEventHandler but that manages to hack the hover/active state for the controls properly. It's a bit like Martin's approach but a little more generic (it doesn't try to special case any particular control type). My RenderLayer suggestion was lame (it worked but is not nearly as elegant as this new way of doing hover/active, which ensures that hover/active sitll works on the label too).
Maciej Stachowiak
Comment 13 2006-09-12 22:59:30 PDT
Comment on attachment 10521 [details] Patch that fully implements label r=me Please add a test case though (you can use eventSender, see examples in fast/events)
Adam Roben (:aroben)
Comment 14 2006-09-12 23:01:48 PDT
Comment on attachment 10521 [details] Patch that fully implements label r=me. Great to have this working!
Dave Hyatt
Comment 15 2006-09-12 23:25:46 PDT
Fixed.
David Kilzer (:ddkilzer)
Comment 16 2006-09-13 04:09:22 PDT
(In reply to comment #15) > Fixed. Implementation in r16341, tests in r16340.
Gregory Block
Comment 17 2006-09-13 04:11:19 PDT
Sidenote: I can select all of the fields via their access keys, save one: control-H does not or cannot select the honorific field in that table on that page. Intentional? Bug?
mitz
Comment 18 2007-02-12 06:30:16 PST
*** Bug 12741 has been marked as a duplicate of this bug. ***
David Kilzer (:ddkilzer)
Comment 19 2007-04-25 10:21:44 PDT
*** Bug 13482 has been marked as a duplicate of this bug. ***
Note You need to log in before you can comment on or make changes to this bug.