Last Comment Bug 656379 - CSS Hover and active should propagate from labels to the labeled content
: CSS Hover and active should propagate from labels to the labeled content
Status: VERIFIED FIXED
:
Product: Core
Classification: Components
Component: CSS Parsing and Computation (show other bugs)
: Trunk
: All All
: P1 normal (vote)
: mozilla7
Assigned To: Boris Zbarsky [:bz] (still a bit busy)
:
: Jet Villegas (:jet)
Mentors:
Depends on: 426082 710917
Blocks: 598833
  Show dependency treegraph
 
Reported: 2011-05-11 11:01 PDT by Boris Zbarsky [:bz] (still a bit busy)
Modified: 2011-12-14 21:46 PST (History)
3 users (show)
bzbarsky: in‑testsuite+
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
part 1. Move the class decl for nsHTMLLabelElement out to a header. (8.76 KB, patch)
2011-05-11 19:01 PDT, Boris Zbarsky [:bz] (still a bit busy)
bugs: review+
Details | Diff | Splinter Review
part 2. Make labels expose a nicer API for getting their labeled content. (6.15 KB, patch)
2011-05-11 19:01 PDT, Boris Zbarsky [:bz] (still a bit busy)
bugs: review+
Details | Diff | Splinter Review
part 3. Set :hover and :active state for labeled elements when their label has that state. (10.78 KB, patch)
2011-05-11 19:04 PDT, Boris Zbarsky [:bz] (still a bit busy)
dbaron: review+
Details | Diff | Splinter Review

Description Boris Zbarsky [:bz] (still a bit busy) 2011-05-11 11:01:33 PDT
We already do this for native theming; see bug 426082.

Doing this makes it easier to fix bug 598833.

The patches I attach will have a bug that's actually a bit of a pain to fix before bug 598833 lands: they won't handle dynamic removal/insertion of controls labeled by a currently hovered or active label well.  I'll fix that in bug 656377.
Comment 1 Boris Zbarsky [:bz] (still a bit busy) 2011-05-11 19:01:20 PDT
Created attachment 531829 [details] [diff] [review]
part 1.  Move the class decl for nsHTMLLabelElement out to a header.
Comment 2 Boris Zbarsky [:bz] (still a bit busy) 2011-05-11 19:01:42 PDT
Created attachment 531830 [details] [diff] [review]
part 2.  Make labels expose a nicer API for getting their labeled content.
Comment 3 Boris Zbarsky [:bz] (still a bit busy) 2011-05-11 19:04:08 PDT
Created attachment 531831 [details] [diff] [review]
part 3.  Set :hover and :active state for labeled elements when their label has that state.
Comment 4 Olli Pettay [:smaug] 2011-05-12 00:38:45 PDT
Comment on attachment 531830 [details] [diff] [review]
part 2.  Make labels expose a nicer API for getting their labeled content.


> void
> nsHTMLLabelElement::PerformAccesskey(PRBool aKeyCausesActivation,
>                                      PRBool aIsTrustedEvent)
> {
>   if (!aKeyCausesActivation) {
>-    nsCOMPtr<nsIContent> content = GetControlContent();
>-    if (content)
>-      content->PerformAccesskey(aKeyCausesActivation, aIsTrustedEvent);
>+    Element* element = GetLabeledElement();
>+    if (element)
>+      element->PerformAccesskey(aKeyCausesActivation, aIsTrustedEvent);
{
}

And could you keep element strong here. So nsRefPtr<Element> element.
Comment 5 Boris Zbarsky [:bz] (still a bit busy) 2011-05-13 00:19:12 PDT
> And could you keep element strong here.

Done.
Comment 6 David Baron :dbaron: ⌚️UTC-10 2011-05-21 14:04:46 PDT
Comment on attachment 531831 [details] [diff] [review]
part 3.  Set :hover and :active state for labeled elements when their label has that state.

r=dbaron
Comment 9 Virgil Dicu [:virgil] [QA] 2011-08-26 01:15:35 PDT
Hello.

Could anyone provide, if the case is, some simple STR or a test case to verify the issue?
Comment 10 Boris Zbarsky [:bz] (still a bit busy) 2011-08-26 08:09:35 PDT
data:text/html,<style>:hover { color: green; }</style><label for="x">Hover me</label><input id="x" value="I should turn green">
Comment 11 Virgil Dicu [:virgil] [QA] 2011-08-31 02:17:20 PDT
Thank you for the feedback.

Mozilla/5.0 (Windows NT 6.1; rv:7.0) Gecko/20100101 Firefox/7.0
Mozilla/5.0 (X11; Linux i686; rv:7.0) Gecko/20100101 Firefox/7.0
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:7.0) Gecko/20100101 Firefox/7.0
Mozilla/5.0 (Windows NT 5.1; rv:7.0) Gecko/20100101 Firefox/7.0

Verified fixed on Ubuntu 11.04, Windows XP, Windows 7 and Mac OS 10.6 with test case provided in comment 10.

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