Bug 134826 - Anchor, Area and Link elements should *not* respond to :enabled selector if they have an href attribute
Summary: Anchor, Area and Link elements should *not* respond to :enabled selector if t...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Bruno Abinader
URL:
Keywords: WebExposed
Depends on:
Blocks: 137557
  Show dependency treegraph
 
Reported: 2014-07-10 21:50 PDT by Bruno Abinader
Modified: 2014-10-09 06:46 PDT (History)
3 users (show)

See Also:


Attachments
Testcase (508 bytes, text/html)
2014-07-10 21:51 PDT, Bruno Abinader
no flags Details
Patch (4.85 KB, patch)
2014-07-23 14:29 PDT, Bruno Abinader
no flags Details | Formatted Diff | Diff
Patch (5.06 KB, patch)
2014-07-24 06:39 PDT, Bruno Abinader
no flags Details | Formatted Diff | Diff
Rebased patch (5.10 KB, patch)
2014-07-24 08:25 PDT, Bruno Abinader
no flags Details | Formatted Diff | Diff
Patch (5.21 KB, patch)
2014-09-26 10:09 PDT, Bruno Abinader
no flags Details | Formatted Diff | Diff
Patch (w/ updated code for Anchor element) (6.15 KB, patch)
2014-09-26 13:42 PDT, Bruno Abinader
darin: review+
Details | Formatted Diff | Diff
Patch (6.64 KB, patch)
2014-09-29 08:33 PDT, Bruno Abinader
no flags Details | Formatted Diff | Diff
Patch (6.64 KB, patch)
2014-09-29 08:41 PDT, Bruno Abinader
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Bruno Abinader 2014-07-10 21:50:52 PDT
What steps will reproduce the problem?
1. Open attached testcase 

What is the expected output? What do you see instead?
Query for :enabled should be non-null.
Comment 1 Bruno Abinader 2014-07-10 21:51:25 PDT
Created attachment 234744 [details]
Testcase
Comment 2 Bruno Abinader 2014-07-10 21:53:25 PDT
Spec:
html.spec.whatwg.org/#selector-enabled
Comment 3 Bruno Abinader 2014-07-23 14:29:08 PDT
Created attachment 235379 [details]
Patch
Comment 4 Darin Adler 2014-07-23 15:28:25 PDT
Comment on attachment 235379 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=235379&action=review

Patch doesn’t apply.

> Source/WebCore/css/SelectorCheckerTestFunctions.h:67
> +    else if (isHTMLAnchorElement(element) || isHTMLAreaElement(element))
> +        return element->isLink();

Minor style nit: We don’t do else after return.

Performance nit: Should check the isLink bit first, before looking at the the element type, for better performance.
Comment 5 Bruno Abinader 2014-07-24 06:39:26 PDT
Created attachment 235429 [details]
Patch
Comment 6 Bruno Abinader 2014-07-24 08:25:01 PDT
Created attachment 235431 [details]
Rebased patch
Comment 7 WebKit Commit Bot 2014-07-27 19:28:21 PDT
Comment on attachment 235431 [details]
Rebased patch

Clearing flags on attachment: 235431

Committed r171671: <http://trac.webkit.org/changeset/171671>
Comment 8 WebKit Commit Bot 2014-07-27 19:28:23 PDT
All reviewed patches have been landed.  Closing bug.
Comment 9 Bruno Abinader 2014-09-26 08:23:16 PDT
Anchors, Areas & Links are no longer matched by :enabled CSS selector [1], according to this discussion from W3C Bugzilla [2]. Thus, I'm going to revert these changes.

Links:
[1] https://html5.org/r/8818
[2] https://www.w3.org/Bugs/Public/show_bug.cgi?id=26622
Comment 10 Bruno Abinader 2014-09-26 10:09:22 PDT
Created attachment 238724 [details]
Patch
Comment 11 Bruno Abinader 2014-09-26 13:42:05 PDT
Created attachment 238734 [details]
Patch (w/ updated code for Anchor element)
Comment 12 Darin Adler 2014-09-28 16:23:12 PDT
Comment on attachment 238734 [details]
Patch (w/ updated code for Anchor element)

View in context: https://bugs.webkit.org/attachment.cgi?id=238734&action=review

Hope nobody shipped a browser between when we changed this and reverted the change!

> Source/WebCore/css/SelectorCheckerTestFunctions.h:68
> -    bool isEnabled = false;
>      if (is<HTMLFormControlElement>(element) || is<HTMLOptionElement>(element) || is<HTMLOptGroupElement>(element))
> -        isEnabled = !element->isDisabledFormControl();
> -    else if (element->isLink())
> -        isEnabled = is<HTMLAnchorElement>(element) || is<HTMLAreaElement>(element);
> -    return isEnabled;
> +        return !element->isDisabledFormControl();
> +    return false;

This now seems like it would be clearer with && than with if.
Comment 13 Bruno Abinader 2014-09-29 08:27:59 PDT
(In reply to comment #12)
> (From update of attachment 238734 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=238734&action=review
> 
> Hope nobody shipped a browser between when we changed this and reverted the change!
> 
> > Source/WebCore/css/SelectorCheckerTestFunctions.h:68
> > -    bool isEnabled = false;
> >      if (is<HTMLFormControlElement>(element) || is<HTMLOptionElement>(element) || is<HTMLOptGroupElement>(element))
> > -        isEnabled = !element->isDisabledFormControl();
> > -    else if (element->isLink())
> > -        isEnabled = is<HTMLAnchorElement>(element) || is<HTMLAreaElement>(element);
> > -    return isEnabled;
> > +        return !element->isDisabledFormControl();
> > +    return false;
> 
> This now seems like it would be clearer with && than with if.

Indeed, the odds of live specifications, I guess ;)
Comment 14 Bruno Abinader 2014-09-29 08:33:51 PDT
Created attachment 238855 [details]
Patch
Comment 15 Bruno Abinader 2014-09-29 08:41:54 PDT
Created attachment 238857 [details]
Patch
Comment 16 WebKit Commit Bot 2014-09-29 09:31:37 PDT
Comment on attachment 238857 [details]
Patch

Clearing flags on attachment: 238857

Committed r174064: <http://trac.webkit.org/changeset/174064>
Comment 17 Benjamin Poulain 2014-10-07 17:23:25 PDT
Instead of removing the tests, you should have modified css-selector-enabled-links.html to ensure that :enabled *do not* match links.

Can you please create a new patch to test this properly?
Comment 18 Bruno Abinader 2014-10-08 14:19:52 PDT
(In reply to comment #17)
> Instead of removing the tests, you should have modified css-selector-enabled-links.html to ensure that :enabled *do not* match links.
> 
> Can you please create a new patch to test this properly?

Sure, I'll re-add the tests with updated results.
Comment 19 Benjamin Poulain 2014-10-08 23:56:34 PDT
(In reply to comment #18)
> (In reply to comment #17)
> > Instead of removing the tests, you should have modified css-selector-enabled-links.html to ensure that :enabled *do not* match links.
> > 
> > Can you please create a new patch to test this properly?
> 
> Sure, I'll re-add the tests with updated results.

Thanks. Please CC me on the bug.