Bug 3244 - Support the 'label' element in HTML forms
: Support the 'label' element in HTML forms
Status: RESOLVED FIXED
: WebKit
Forms
: 412
: All All
: P2 Normal
Assigned To:
: http://www.robinlionheart.com/stds/ht...
: InRadar
:
: 4223 7671
  Show dependency treegraph
 
Reported: 2005-06-01 16:13 PST by
Modified: 2007-04-25 10:21 PST (History)


Attachments
Proposed patch for the partial implementation of LABEL element support (1.97 KB, patch)
2005-09-07 12:42 PST, Martin Davidsson
darin: review-
Review Patch | Details | Formatted Diff | Diff
Patch that fully implements label (5.11 KB, patch)
2006-09-12 22:35 PST, Dave Hyatt
mjs: review+
Review Patch | Details | Formatted Diff | Diff


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2005-06-01 16:13:02 PST
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 From 2005-06-01 16:13:50 PST -------
Apple Bug: rdar://3044177/
------- Comment #2 From 2005-08-02 07:35:22 PST -------
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 From 2005-09-07 12:42:42 PST -------
Created an attachment (id=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 From 2005-10-09 12:48:47 PST -------
(From update of attachment 3799 [details])
Someone forgot to mark this for review...
------- Comment #5 From 2005-10-09 13:39:11 PST -------
(From update of attachment 3799 [details])
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 From 2005-10-09 18:07:26 PST -------
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 From 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 From 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 From 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 From 2006-06-17 15:30:43 PST -------
Additional info for label: http://www.w3schools.com/tags/tag_label.asp
------- Comment #11 From 2006-06-24 19:16:04 PST -------
Reassigning to webkit-unassigned for more exposure.
------- Comment #12 From 2006-09-12 22:35:41 PST -------
Created an attachment (id=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 From 2006-09-12 22:59:30 PST -------
(From update of attachment 10521 [details])
r=me

Please add a test case though (you can use eventSender, see examples in fast/events)
------- Comment #14 From 2006-09-12 23:01:48 PST -------
(From update of attachment 10521 [details])
r=me. Great to have this working!
------- Comment #15 From 2006-09-12 23:25:46 PST -------
Fixed.
------- Comment #16 From 2006-09-13 04:09:22 PST -------
(In reply to comment #15)
> Fixed.

Implementation in r16341, tests in r16340.
------- Comment #17 From 2006-09-13 04:11:19 PST -------
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 From 2007-02-12 06:30:16 PST -------
*** Bug 12741 has been marked as a duplicate of this bug. ***
------- Comment #19 From 2007-04-25 10:21:44 PST -------
*** Bug 13482 has been marked as a duplicate of this bug. ***