Bug 156270

Summary: :indeterminate pseudo-class should match radios whose group has no checked radio
Product: WebKit Reporter: Chris Rebert <webkit>
Component: CSSAssignee: Benjamin Poulain <benjamin>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, commit-queue, koivisto, simon.fraser
Priority: P2 Keywords: HasReduction
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
URL: http://codepen.io/cvrebert/pen/RajYgY
Attachments:
Description Flags
Screenshot of incorrect rendering in WebKit Nightly
none
Screenshot of correct rendering in Chrome
none
Patch
none
Archive of layout-test-results from ews125 for ios-simulator-wk2
none
Patch none

Description Chris Rebert 2016-04-05 17:56:03 PDT
Created attachment 275732 [details]
Screenshot of incorrect rendering in WebKit Nightly

Per the HTML spec, the :indeterminate CSS pseudo-class should match (among other cases) when:
> * <input> elements whose `type` attribute is in the Radio Button state and whose
>       radio button group contains no elements whose checkedness state is true.

But WebKit doesn't currently make :indeterminate match in that case.


Steps to reproduce:
1. Open the testcase in WebKit Nightly.
2. Observe both instances of the word "Green".

Expected result:
Both words should have a green background-color.
(See attached Chrome screenshot.)

Actual result:
Both words have a white background-color.
(See attached WebKit Nightly screenshot.)
Comment 1 Chris Rebert 2016-04-05 17:56:50 PDT
Created attachment 275733 [details]
Screenshot of correct rendering in Chrome
Comment 2 Benjamin Poulain 2016-06-17 19:05:34 PDT
Created attachment 281601 [details]
Patch
Comment 3 Simon Fraser (smfr) 2016-06-17 19:26:04 PDT
Comment on attachment 281601 [details]
Patch

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

> Source/WebCore/dom/RadioButtonGroups.cpp:82
> +    bool hadCheckedButton = !!m_checkedButton;
> +    bool willHaveCheckedButton = !!button;

No need for !! in C++

> Source/WebCore/dom/RadioButtonGroups.cpp:283
> +    return !!group->checkedButton();

No need for !!
Comment 4 Benjamin Poulain 2016-06-17 19:59:38 PDT
Thanks for the review.

> > Source/WebCore/dom/RadioButtonGroups.cpp:82
> > +    bool hadCheckedButton = !!m_checkedButton;
> > +    bool willHaveCheckedButton = !!button;
> 
> No need for !! in C++

It is just to make the conversion explicit.
Especially in this case where
    m_checkedButton == button
is incorrect but 
    !!m_checkedButton == !!button
is correct.
Comment 5 Build Bot 2016-06-17 20:06:15 PDT
Comment on attachment 281601 [details]
Patch

Attachment 281601 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/1521146

New failing tests:
imported/w3c/web-platform-tests/html/semantics/selectors/pseudo-classes/indeterminate-radio.html
Comment 6 Build Bot 2016-06-17 20:06:18 PDT
Created attachment 281602 [details]
Archive of layout-test-results from ews125 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews125  Port: ios-simulator-wk2  Platform: Mac OS X 10.11.4
Comment 7 Benjamin Poulain 2016-06-17 20:41:54 PDT
Created attachment 281605 [details]
Patch
Comment 8 WebKit Commit Bot 2016-06-17 22:53:31 PDT
Comment on attachment 281605 [details]
Patch

Clearing flags on attachment: 281605

Committed r202197: <http://trac.webkit.org/changeset/202197>
Comment 9 WebKit Commit Bot 2016-06-17 22:53:35 PDT
All reviewed patches have been landed.  Closing bug.