haikuwebkit/LayoutTests/fast/css/pseudo-indeterminate-with-r...

29 lines
1.1 KiB
Plaintext
Raw Permalink Normal View History

:indeterminate pseudo-class should match radios whose group has no checked radio https://bugs.webkit.org/show_bug.cgi?id=156270 Reviewed by Simon Fraser. LayoutTests/imported/w3c: * web-platform-tests/html/semantics/selectors/pseudo-classes/indeterminate-expected.txt: One more pass on official tests :) Source/WebCore: The pseudo-class ":indeterminate" is supposed to match radio buttons for which the entire group has no checked button. Spec: https://html.spec.whatwg.org/#pseudo-classes:selector-indeterminate The change is straightforward with one non-obvious choice: I added matchesIndeterminatePseudoClass() in addition to shouldAppearIndeterminate(). The reason is shouldAppearIndeterminate() is used for styling and AX of elements with an indeterminate states (check boxes and progress element). There is no such UI for radio boxes. I could have extended shouldAppearIndeterminate() to radio box then filter out this case in RenderTheme. The problem is doing that would also requires changes to the repaint logic to match :indeterminate. It seemed overkill to me to change repaint() for a case that is never used in practice. Tests: fast/css/pseudo-indeterminate-radio-buttons-basics.html fast/css/pseudo-indeterminate-with-radio-buttons-style-invalidation.html fast/selectors/detached-radio-button-checked-and-indeterminate-states.html fast/selectors/pseudo-indeterminate-with-radio-buttons-style-update.html * css/SelectorCheckerTestFunctions.h: (WebCore::shouldAppearIndeterminate): * dom/Element.cpp: (WebCore::Element::matchesIndeterminatePseudoClass): * dom/Element.h: * dom/RadioButtonGroups.cpp: (WebCore::RadioButtonGroup::setCheckedButton): (WebCore::RadioButtonGroup::updateCheckedState): (WebCore::RadioButtonGroup::remove): (WebCore::RadioButtonGroup::setNeedsStyleRecalcForAllButtons): (WebCore::RadioButtonGroups::hasCheckedButton): * dom/RadioButtonGroups.h: * html/CheckboxInputType.cpp: (WebCore::CheckboxInputType::matchesIndeterminatePseudoClass): (WebCore::CheckboxInputType::shouldAppearIndeterminate): (WebCore::CheckboxInputType::supportsIndeterminateAppearance): Deleted. * html/CheckboxInputType.h: * html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::setChecked): (WebCore::HTMLInputElement::matchesIndeterminatePseudoClass): (WebCore::HTMLInputElement::shouldAppearIndeterminate): (WebCore::HTMLInputElement::radioButtonGroups): * html/HTMLInputElement.h: * html/InputType.cpp: (WebCore::InputType::matchesIndeterminatePseudoClass): (WebCore::InputType::shouldAppearIndeterminate): (WebCore::InputType::supportsIndeterminateAppearance): Deleted. * html/InputType.h: * html/RadioInputType.cpp: (WebCore::RadioInputType::matchesIndeterminatePseudoClass): (WebCore::RadioInputType::willDispatchClick): Deleted. (WebCore::RadioInputType::didDispatchClick): Deleted. (WebCore::RadioInputType::supportsIndeterminateAppearance): Deleted. The iOS specific code is just plain wrong. It was changing the indeterminate state of the input element. The spec clearly says that state is only used by checkbox: https://html.spec.whatwg.org/#dom-input-indeterminate Moreover, the style update would not change the indeterminate state of other buttons in the Button Group, which is just bizarre. RenderThemeIOS does not make use of any of this with the current style. * html/RadioInputType.h: * style/StyleSharingResolver.cpp: (WebCore::Style::SharingResolver::canShareStyleWithElement): (WebCore::Style::canShareStyleWithControl): Deleted. (WebCore::Style::SharingResolver::sharingCandidateHasIdenticalStyleAffectingAttributes): Deleted. Style sharing is unified behind the selector matching which is neat. LayoutTests: There are two important aspect to cover for this change: 1) The style is updated correctly when a Button Group composition change. 2) When the checkness changes for a Button Group, all its elements are invalidated to match :indeterminate. * fast/forms/radio/indeterminate-radio.html: This test was verifying that the property "indeterminate" of the input element is not reflected to the style through :indeterminate. I updated the test to still verify that except that we now match :indeterminate before changing the property. * fast/css/pseudo-indeterminate-radio-buttons-basics-expected.html: Added. * fast/css/pseudo-indeterminate-radio-buttons-basics.html: Added. * fast/css/pseudo-indeterminate-with-radio-buttons-style-invalidation-expected.txt: Added. * fast/css/pseudo-indeterminate-with-radio-buttons-style-invalidation.html: Added. Verify that we don't invalidate everything when the checked button changes. We only need to invalidate everything if the checked state of the whole group changes. * fast/selectors/detached-radio-button-checked-and-indeterminate-states-expected.txt: Added. * fast/selectors/detached-radio-button-checked-and-indeterminate-states.html: Added. * fast/selectors/pseudo-indeterminate-with-radio-buttons-style-update-expected.txt: Added. * fast/selectors/pseudo-indeterminate-with-radio-buttons-style-update.html: Added. Canonical link: https://commits.webkit.org/176971@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202197 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-18 05:53:28 +00:00
Verify that we do not invalidate more than needed to satisfy :indeterminate
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS elementsNeedingStyleRecalc() is []
PASS elementsWithIndeterminateStyle() is ["radio1", "radio2", "radio3", "radio4", "radio5", "radio6", "radio7", "radio8", "radio9", "radio10"]
PASS checkedElements() is []
Check radio3
PASS elementsNeedingStyleRecalc() is ["radio1", "radio2", "radio3", "radio4", "radio5"]
PASS elementsWithIndeterminateStyle() is ["radio6", "radio7", "radio8", "radio9", "radio10"]
PASS checkedElements() is ["radio3"]
Check radio8
PASS elementsNeedingStyleRecalc() is ["radio6", "radio7", "radio8", "radio9", "radio10"]
PASS elementsWithIndeterminateStyle() is []
PASS checkedElements() is ["radio3", "radio8"]
Check radio4
PASS elementsNeedingStyleRecalc() is ["radio3", "radio4"]
PASS elementsWithIndeterminateStyle() is []
PASS checkedElements() is ["radio4", "radio8"]
Check radio9
PASS elementsNeedingStyleRecalc() is ["radio8", "radio9"]
PASS elementsWithIndeterminateStyle() is []
PASS checkedElements() is ["radio4", "radio9"]
PASS successfullyParsed is true
TEST COMPLETE