Bug 156230 - :default CSS pseudo-class should match checkboxes+radios with a `checked` attribute
Summary: :default CSS pseudo-class should match checkboxes+radios with a `checked` att...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Benjamin Poulain
URL: https://html.spec.whatwg.org/multipag...
Keywords: HasReduction, InRadar, W3CTest
Depends on:
Blocks:
 
Reported: 2016-04-04 22:41 PDT by Chris Rebert
Modified: 2016-06-20 14:30 PDT (History)
5 users (show)

See Also:


Attachments
Testcase demonstrating the bug (645 bytes, text/html)
2016-04-04 22:41 PDT, Chris Rebert
no flags Details
Screenshot of incorrect rendering in WebKit Nightly (122.94 KB, image/png)
2016-04-04 22:44 PDT, Chris Rebert
no flags Details
Screenshot of correct rendering in Firefox (420.82 KB, image/png)
2016-04-04 22:47 PDT, Chris Rebert
no flags Details
Patch (73.10 KB, patch)
2016-06-19 15:53 PDT, Benjamin Poulain
no flags Details | Formatted Diff | Diff
Patch for landing (73.13 KB, patch)
2016-06-20 14:28 PDT, Benjamin Poulain
benjamin: commit-queue+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Rebert 2016-04-04 22:41:34 PDT
Created attachment 275642 [details]
Testcase demonstrating the bug

Per https://html.spec.whatwg.org/multipage/scripting.html#selector-default ,
the `:default:` CSS pseudo-class should match (among other things):
> * <input> elements to which the `checked` attribute applies and that have a `checked` attribute

But WebKit doesn't currently seem to make :default match in such cases.


Steps to reproduce:
1. Open the attached testcase in WebKit Nightly.

Expected result:
The text "Green", adjacent to the pre-checked checkbox and the pre-checked radio button, should have a green outline.

Actual result:
The text "Green" has a red outline.
Comment 1 Chris Rebert 2016-04-04 22:44:03 PDT
Created attachment 275643 [details]
Screenshot of incorrect rendering in WebKit Nightly
Comment 2 Chris Rebert 2016-04-04 22:47:04 PDT
Created attachment 275644 [details]
Screenshot of correct rendering in Firefox
Comment 3 Chris Rebert 2016-04-04 22:48:03 PDT
(Chrome Canary and Firefox both render the testcase correctly.)
Comment 4 Radar WebKit Bug Importer 2016-04-06 08:32:14 PDT
<rdar://problem/25576746>
Comment 6 Benjamin Poulain 2016-06-19 15:53:47 PDT
Created attachment 281624 [details]
Patch
Comment 7 Alex Christensen 2016-06-20 09:56:16 PDT
Comment on attachment 281624 [details]
Patch

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

> Source/WebCore/html/HTMLInputElement.cpp:828
> +    if (m_inputType->canBeSuccessfulSubmitButton())

Should we assert m_inputType here like we do in parseAttribute? Same in isSuccessfulSubmitButton.
Comment 8 Alex Christensen 2016-06-20 10:05:19 PDT
Comment on attachment 281624 [details]
Patch

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

> LayoutTests/fast/selectors/default-style-update-expected.txt:130
> +PASS elementsStyledWithDefaultSelector() is ["button3", "input2", "input8", "option1", "option2", "option4"]

Chrome canary fails here.  Firefox developer edition fails much earlier.  Please look into these differences.
Comment 9 Benjamin Poulain 2016-06-20 10:39:20 PDT
(In reply to comment #8)
> Comment on attachment 281624 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=281624&action=review
> 
> > LayoutTests/fast/selectors/default-style-update-expected.txt:130
> > +PASS elementsStyledWithDefaultSelector() is ["button3", "input2", "input8", "option1", "option2", "option4"]
> 
> Chrome canary fails here.  Firefox developer edition fails much earlier. 
> Please look into these differences.

Firefox fails here because it does not style radio and checkbox properly. You can see that their selector matching is fine but not styling.

Chrome fails because its CSS implementation is incredibly buggy. It rarely handles style update properly.
Comment 10 Benjamin Poulain 2016-06-20 14:28:04 PDT
Created attachment 281678 [details]
Patch for landing
Comment 11 Benjamin Poulain 2016-06-20 14:30:45 PDT
Committed r202245: <http://trac.webkit.org/changeset/202245>