Bug 3244 - Support the 'label' element in HTML forms
Summary: Support the 'label' element in HTML forms
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: 412
Hardware: All All
: P2 Normal
Assignee: Dave Hyatt
URL: http://www.robinlionheart.com/stds/ht...
Keywords: InRadar
: 12741 13482 (view as bug list)
Depends on:
Blocks: 4223 7671
  Show dependency treegraph
 
Reported: 2005-06-01 16:13 PDT by Dave Hyatt
Modified: 2007-04-25 10:21 PDT (History)
11 users (show)

See Also:


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-
Details | Formatted Diff | Diff
Patch that fully implements label (5.11 KB, patch)
2006-09-12 22:35 PDT, Dave Hyatt
mjs: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dave Hyatt 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.)
Comment 1 Dave Hyatt 2005-06-01 16:13:50 PDT
Apple Bug: rdar://3044177/
Comment 2 Patrick H. Lauke 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).
Comment 3 Martin Davidsson 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.
Comment 4 Eric Seidel (no email) 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...
Comment 5 Darin Adler 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!
Comment 6 Dave Hyatt 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.
Comment 7 Mark Thomas 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 ?
Comment 8 Mark Thomas 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.
Comment 9 Darin Adler 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
Comment 10 David Carson 2006-06-17 15:30:43 PDT
Additional info for label: http://www.w3schools.com/tags/tag_label.asp
Comment 11 David Kilzer (:ddkilzer) 2006-06-24 19:16:04 PDT
Reassigning to webkit-unassigned for more exposure.

Comment 12 Dave Hyatt 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).
Comment 13 Maciej Stachowiak 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)
Comment 14 Adam Roben (:aroben) 2006-09-12 23:01:48 PDT
Comment on attachment 10521 [details]
Patch that fully implements label

r=me. Great to have this working!
Comment 15 Dave Hyatt 2006-09-12 23:25:46 PDT
Fixed.
Comment 16 David Kilzer (:ddkilzer) 2006-09-13 04:09:22 PDT
(In reply to comment #15)
> Fixed.

Implementation in r16341, tests in r16340.
Comment 17 Gregory Block 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?
Comment 18 mitz 2007-02-12 06:30:16 PST
*** Bug 12741 has been marked as a duplicate of this bug. ***
Comment 19 David Kilzer (:ddkilzer) 2007-04-25 10:21:44 PDT
*** Bug 13482 has been marked as a duplicate of this bug. ***