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.)
Apple Bug: rdar://3044177/
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).
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.
Comment on attachment 3799 [details] Proposed patch for the partial implementation of LABEL element support Someone forgot to mark this for review...
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!
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.
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 ?
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.
In Radar as <rdar://problem/3044177> HTML4: clicking on the label should do the same thing clicking on the form element does
Additional info for label: http://www.w3schools.com/tags/tag_label.asp
Reassigning to webkit-unassigned for more exposure.
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).
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)
Comment on attachment 10521 [details] Patch that fully implements label r=me. Great to have this working!
Fixed.
(In reply to comment #15) > Fixed. Implementation in r16341, tests in r16340.
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?
*** Bug 12741 has been marked as a duplicate of this bug. ***
*** Bug 13482 has been marked as a duplicate of this bug. ***