Changeset 288734 in webkit
- Timestamp:
- Jan 27, 2022 11:58:57 PM (6 months ago)
- Location:
- trunk
- Files:
-
- 20 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/forms/radio/ValidityState-valueMissing-radio-expected.txt (modified) (1 diff)
-
LayoutTests/fast/forms/radio/ValidityState-valueMissing-radio.html (modified) (2 diffs)
-
LayoutTests/fast/forms/radio/radio-live-validation-style-expected.txt (modified) (1 diff)
-
LayoutTests/fast/forms/radio/radio-live-validation-style.html (modified) (1 diff)
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valid-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valueMissing-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/radio-expected.txt (modified) (1 diff)
-
LayoutTests/platform/gtk/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valid-expected.txt (modified) (1 diff)
-
LayoutTests/platform/gtk/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valueMissing-expected.txt (modified) (1 diff)
-
LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valid-expected.txt (modified) (1 diff)
-
LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valueMissing-expected.txt (modified) (1 diff)
-
LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valid-expected.txt (modified) (1 diff)
-
LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valueMissing-expected.txt (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/html/HTMLInputElement.cpp (modified) (5 diffs)
-
Source/WebCore/html/InputType.h (modified) (1 diff)
-
Source/WebCore/html/RadioInputType.cpp (modified) (1 diff)
-
Source/WebCore/html/RadioInputType.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r288728 r288734 1 2022-01-27 Chris Dumez <cdumez@apple.com> 2 3 Radio buttons with no form owner are not grouped 4 https://bugs.webkit.org/show_bug.cgi?id=220502 5 <rdar://problem/73300895> 6 7 Reviewed by Darin Adler. 8 9 * fast/forms/radio/ValidityState-valueMissing-radio-expected.txt: 10 * fast/forms/radio/ValidityState-valueMissing-radio.html: 11 * fast/forms/radio/radio-live-validation-style-expected.txt: 12 * fast/forms/radio/radio-live-validation-style.html: 13 Update existing tests to reflect behavior change. I have verified that our behavior on those tests 14 is aligned with both Firefox and Chrome. 15 16 * platform/gtk/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valid-expected.txt: 17 * platform/gtk/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valueMissing-expected.txt: 18 * platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valid-expected.txt: 19 * platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valueMissing-expected.txt: 20 * platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valid-expected.txt: 21 * platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valueMissing-expected.txt: 22 Rebaseline existing WPT tests now that more checks are passing. 23 1 24 2022-01-27 Antoine Quint <graouts@webkit.org> 2 25 -
trunk/LayoutTests/fast/forms/radio/ValidityState-valueMissing-radio-expected.txt
r288631 r288734 41 41 42 42 Not in a radio button group 43 PASS requiredButton.validity.valueMissing is false43 PASS requiredButton.validity.valueMissing is true 44 44 PASS requiredButton.validity.valueMissing is true 45 45 PASS button.validity.valueMissing is true 46 46 PASS button.validity.valueMissing is false 47 PASS requiredButton.validity.valueMissing is false47 PASS requiredButton.validity.valueMissing is true 48 48 PASS successfullyParsed is true 49 49 -
trunk/LayoutTests/fast/forms/radio/ValidityState-valueMissing-radio.html
r288631 r288734 72 72 requiredButton.name = 'victim'; 73 73 requiredButton.required = true; 74 shouldBe False('requiredButton.validity.valueMissing');74 shouldBeTrue('requiredButton.validity.valueMissing'); 75 75 76 76 parent.innerHTML = '<input name=victim type=radio required><input name=victim type=radio>'; … … 82 82 shouldBeFalse('button.validity.valueMissing'); 83 83 parent.removeChild(requiredButton); 84 shouldBe False('requiredButton.validity.valueMissing');84 shouldBeTrue('requiredButton.validity.valueMissing'); 85 85 86 86 </script> -
trunk/LayoutTests/fast/forms/radio/radio-live-validation-style-expected.txt
r288631 r288734 8 8 PASS parent.removeChild($("radio2")); backgroundOf($("radio1")) is invalidColor 9 9 PASS $("radio1").remove(); radio2.matches(":valid") is false 10 PASS radio2.remove(); radio2.matches(":valid") is true10 PASS radio2.remove(); radio2.matches(":valid") is false 11 11 12 12 Removing a checked radio button from a required radio button group by name attribute change: -
trunk/LayoutTests/fast/forms/radio/radio-live-validation-style.html
r288631 r288734 36 36 var radio2 = $('radio2'); 37 37 shouldBeFalse('$("radio1").remove(); radio2.matches(":valid")'); 38 shouldBe True('radio2.remove(); radio2.matches(":valid")');38 shouldBeFalse('radio2.remove(); radio2.matches(":valid")'); 39 39 debug(''); 40 40 -
trunk/LayoutTests/imported/w3c/ChangeLog
r288707 r288734 1 2022-01-27 Chris Dumez <cdumez@apple.com> 2 3 Radio buttons with no form owner are not grouped 4 https://bugs.webkit.org/show_bug.cgi?id=220502 5 <rdar://problem/73300895> 6 7 Reviewed by Darin Adler. 8 9 Rebaseline WPT tests now that more checks are passing. 10 11 * web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valid-expected.txt: 12 * web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valueMissing-expected.txt: 13 * web-platform-tests/html/semantics/forms/the-input-element/radio-expected.txt: 14 1 15 2022-01-27 Chris Dumez <cdumez@apple.com> 2 16 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valid-expected.txt
r288631 r288734 24 24 PASS [INPUT in NUMBER status] validity.valid must be false if validity.valueMissing is true 25 25 PASS [INPUT in CHECKBOX status] validity.valid must be false if validity.valueMissing is true 26 FAIL [INPUT in RADIO status] validity.valid must be false if validity.valueMissing is true assert_false: The validity.valid should be false. expected false gottrue26 PASS [INPUT in RADIO status] validity.valid must be false if validity.valueMissing is true 27 27 PASS [INPUT in FILE status] validity.valid must be false if validity.valueMissing is true 28 28 PASS [select] validity.valid must be false if validity.valueMissing is true -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valueMissing-expected.txt
r288631 r288734 39 39 PASS [INPUT in RADIO status] The required attribute is not set 40 40 PASS [INPUT in RADIO status] The checked attribute is true 41 FAIL [INPUT in RADIO status] The checked attribute is false assert_true: The validity.valueMissing should be true. expected true gotfalse41 PASS [INPUT in RADIO status] The checked attribute is false 42 42 PASS [INPUT in RADIO status] The checked attribute is false and the name attribute is empty 43 43 PASS [INPUT in FILE status] The required attribute is not set -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/radio-expected.txt
r288631 r288734 8 8 PASS changing the name of a radio input element and setting its checkedness to true makes all the other elements' checkedness in the same radio button group be set to false 9 9 PASS moving radio input element out of or into a form should still work as expected 10 FAIL Radio buttons in an orphan tree should make a group assert_false: The second radio should be unchecked after setting checked expected false got true 11 FAIL Radio buttons in different groups (because they have different form owners or no form owner) do not affect each other's checkedness assert_false: radio5 should be unchecked expected false got true 10 PASS Radio buttons in an orphan tree should make a group 11 PASS Radio buttons in different groups (because they have different form owners or no form owner) do not affect each other's checkedness 12 12 PASS Radio buttons in different groups (because they are not in the same tree) do not affect each other's checkedness 13 13 PASS Radio buttons in different groups (because they have different name attribute values, or no name attribute) do not affect each other's checkedness -
trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valid-expected.txt
r288631 r288734 39 39 PASS [INPUT in NUMBER status] validity.valid must be false if validity.valueMissing is true 40 40 PASS [INPUT in CHECKBOX status] validity.valid must be false if validity.valueMissing is true 41 FAIL [INPUT in RADIO status] validity.valid must be false if validity.valueMissing is true assert_false: The validity.valid should be false. expected false gottrue41 PASS [INPUT in RADIO status] validity.valid must be false if validity.valueMissing is true 42 42 PASS [INPUT in FILE status] validity.valid must be false if validity.valueMissing is true 43 43 PASS [select] validity.valid must be false if validity.valueMissing is true -
trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valueMissing-expected.txt
r288631 r288734 85 85 PASS [INPUT in RADIO status] The required attribute is not set 86 86 PASS [INPUT in RADIO status] The checked attribute is true 87 FAIL [INPUT in RADIO status] The checked attribute is false assert_true: The validity.valueMissing should be true. expected true gotfalse87 PASS [INPUT in RADIO status] The checked attribute is false 88 88 PASS [INPUT in RADIO status] The checked attribute is false and the name attribute is empty 89 89 PASS [INPUT in FILE status] The required attribute is not set -
trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valid-expected.txt
r288631 r288734 39 39 PASS [INPUT in NUMBER status] validity.valid must be false if validity.valueMissing is true 40 40 PASS [INPUT in CHECKBOX status] validity.valid must be false if validity.valueMissing is true 41 FAIL [INPUT in RADIO status] validity.valid must be false if validity.valueMissing is true assert_false: The validity.valid should be false. expected false gottrue41 PASS [INPUT in RADIO status] validity.valid must be false if validity.valueMissing is true 42 42 PASS [INPUT in FILE status] validity.valid must be false if validity.valueMissing is true 43 43 PASS [select] validity.valid must be false if validity.valueMissing is true -
trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valueMissing-expected.txt
r288631 r288734 85 85 PASS [INPUT in RADIO status] The required attribute is not set 86 86 PASS [INPUT in RADIO status] The checked attribute is true 87 FAIL [INPUT in RADIO status] The checked attribute is false assert_true: The validity.valueMissing should be true. expected true gotfalse87 PASS [INPUT in RADIO status] The checked attribute is false 88 88 PASS [INPUT in RADIO status] The checked attribute is false and the name attribute is empty 89 89 PASS [INPUT in FILE status] The required attribute is not set -
trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valid-expected.txt
r288631 r288734 39 39 PASS [INPUT in NUMBER status] validity.valid must be false if validity.valueMissing is true 40 40 PASS [INPUT in CHECKBOX status] validity.valid must be false if validity.valueMissing is true 41 FAIL [INPUT in RADIO status] validity.valid must be false if validity.valueMissing is true assert_false: The validity.valid should be false. expected false gottrue41 PASS [INPUT in RADIO status] validity.valid must be false if validity.valueMissing is true 42 42 PASS [INPUT in FILE status] validity.valid must be false if validity.valueMissing is true 43 43 PASS [select] validity.valid must be false if validity.valueMissing is true -
trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valueMissing-expected.txt
r288631 r288734 85 85 PASS [INPUT in RADIO status] The required attribute is not set 86 86 PASS [INPUT in RADIO status] The checked attribute is true 87 FAIL [INPUT in RADIO status] The checked attribute is false assert_true: The validity.valueMissing should be true. expected true gotfalse87 PASS [INPUT in RADIO status] The checked attribute is false 88 88 PASS [INPUT in RADIO status] The checked attribute is false and the name attribute is empty 89 89 PASS [INPUT in FILE status] The required attribute is not set -
trunk/Source/WebCore/ChangeLog
r288733 r288734 1 2022-01-27 Chris Dumez <cdumez@apple.com> 2 3 Radio buttons with no form owner are not grouped 4 https://bugs.webkit.org/show_bug.cgi?id=220502 5 <rdar://problem/73300895> 6 7 Reviewed by Darin Adler. 8 9 Per the HTML specification and to match the behavior of both Gecko and Blink, 10 radio buttons should still be grouped, even if they are disconnected and not 11 owned by a form. 12 13 This patch aligns our behavior with Gecko and Blink and is based on the following 14 Blink commit: 15 - https://chromium-review.googlesource.com/c/chromium/src/+/1988087 16 17 No new tests, rebaselined existing tests. 18 19 * html/HTMLInputElement.cpp: 20 (WebCore::HTMLInputElement::setChecked): 21 (WebCore::HTMLInputElement::didChangeForm): 22 (WebCore::HTMLInputElement::insertedIntoAncestor): 23 (WebCore::HTMLInputElement::removedFromAncestor): 24 (WebCore::HTMLInputElement::checkedRadioButtonForGroup const): 25 * html/InputType.h: 26 (WebCore::InputType::willUpdateCheckedness): 27 * html/RadioInputType.cpp: 28 (WebCore::RadioInputType::valueMissing const): 29 (WebCore::RadioInputType::willUpdateCheckedness): 30 * html/RadioInputType.h: 31 1 32 2022-01-27 Diego Pino Garcia <dpino@igalia.com> 2 33 -
trunk/Source/WebCore/html/HTMLInputElement.cpp
r288631 r288734 62 62 #include "PlatformMouseEvent.h" 63 63 #include "PseudoClassChangeInvalidation.h" 64 #include "RadioInputType.h" 64 65 #include "RenderTextControlSingleLine.h" 65 66 #include "RenderTheme.h" … … 981 982 return; 982 983 984 m_inputType->willUpdateCheckedness(isChecked); 985 983 986 Style::PseudoClassChangeInvalidation checkedInvalidation(*this, CSSSelector::PseudoClassChecked, isChecked); 984 987 … … 1587 1590 resetListAttributeTargetObserver(); 1588 1591 #endif 1592 if (isRadioButton()) 1593 updateValidity(); 1589 1594 return InsertedIntoAncestorResult::NeedsPostInsertionCallback; 1590 1595 } … … 1609 1614 HTMLTextFormControlElement::removedFromAncestor(removalType, oldParentOfRemovedTree); 1610 1615 ASSERT(!isConnected()); 1616 if (removalType.disconnectedFromDocument && !form() && isRadioButton()) 1617 updateValidity(); 1611 1618 #if ENABLE(DATALIST_ELEMENT) 1612 1619 resetListAttributeTargetObserver(); … … 1957 1964 RefPtr<HTMLInputElement> HTMLInputElement::checkedRadioButtonForGroup() const 1958 1965 { 1966 ASSERT(isRadioButton()); 1967 1968 if (checked()) 1969 return const_cast<HTMLInputElement*>(this); 1970 1971 auto& name = this->name(); 1959 1972 if (RadioButtonGroups* buttons = radioButtonGroups()) 1960 return buttons->checkedButtonForGroup(name()); 1961 return nullptr; 1973 return buttons->checkedButtonForGroup(name); 1974 1975 if (name.isEmpty()) 1976 return nullptr; 1977 1978 ASSERT(!isConnected()); 1979 ASSERT(!form()); 1980 1981 // The input is not managed by a RadioButtonGroups, we'll need to traverse the tree. 1982 RefPtr<HTMLInputElement> checkedRadio; 1983 RadioInputType::forEachButtonInDetachedGroup(rootNode(), name, [&](auto& input) { 1984 if (input.checked()) { 1985 checkedRadio = &input; 1986 return false; 1987 } 1988 return true; 1989 }); 1990 return checkedRadio; 1962 1991 } 1963 1992 -
trunk/Source/WebCore/html/InputType.h
r288631 r288734 364 364 virtual bool isFocusingWithDataListDropdown() const { return false; }; 365 365 #endif 366 virtual void willUpdateCheckedness(bool /*nowChecked*/) { } 366 367 367 368 // Parses the specified string for the type, and return -
trunk/Source/WebCore/html/RadioInputType.cpp
r288631 r288734 47 47 { 48 48 ASSERT(element()); 49 return element()->isInRequiredRadioButtonGroup() && !element()->checkedRadioButtonForGroup(); 49 auto& name = element()->name(); 50 if (auto* buttons = element()->radioButtonGroups()) 51 return !buttons->checkedButtonForGroup(name) && buttons->isInRequiredGroup(*element()); 52 53 if (name.isEmpty()) 54 return false; 55 56 ASSERT(!element()->isConnected()); 57 ASSERT(!element()->form()); 58 59 bool isRequired = false; 60 bool foundCheckedRadio = false; 61 forEachButtonInDetachedGroup(element()->rootNode(), name, [&](auto& input) { 62 if (input.checked()) { 63 foundCheckedRadio = true; 64 return false; 65 } 66 if (input.isRequired()) 67 isRequired = true; 68 return true; 69 }); 70 return isRequired && !foundCheckedRadio; 71 } 72 73 void RadioInputType::forEachButtonInDetachedGroup(ContainerNode& rootNode, const String& groupName, const Function<bool(HTMLInputElement&)>& apply) 74 { 75 ASSERT(!groupName.isEmpty()); 76 77 for (auto* descendant = Traversal<HTMLElement>::inclusiveFirstWithin(rootNode); descendant;) { 78 if (is<HTMLFormElement>(*descendant)) { 79 // No need to consider the descendants of a <form> since they will have a form owner and we're only 80 // interested in <input> elements without a form owner. 81 descendant = Traversal<HTMLElement>::nextSkippingChildren(*descendant, &rootNode); 82 continue; 83 } 84 auto* input = dynamicDowncast<HTMLInputElement>(*descendant); 85 if (input && input->isRadioButton() && !input->form() && input->name() == groupName) { 86 bool shouldContinue = apply(*input); 87 if (!shouldContinue) 88 return; 89 } 90 descendant = Traversal<HTMLElement>::next(*descendant, &rootNode); 91 } 92 } 93 94 void RadioInputType::willUpdateCheckedness(bool nowChecked) 95 { 96 if (!nowChecked) 97 return; 98 if (element()->radioButtonGroups()) { 99 // Buttons in RadioButtonGroups are handled in HTMLInputElement::setChecked(). 100 return; 101 } 102 if (auto input = element()->checkedRadioButtonForGroup()) 103 input->setChecked(false); 50 104 } 51 105 -
trunk/Source/WebCore/html/RadioInputType.h
r288631 r288734 41 41 explicit RadioInputType(HTMLInputElement& element) : BaseCheckableInputType(Type::Radio, element) { } 42 42 43 static void forEachButtonInDetachedGroup(ContainerNode& rootName, const String& groupName, const Function<bool(HTMLInputElement&)>&); 44 43 45 private: 44 46 const AtomString& formControlType() const final; … … 53 55 void didDispatchClick(Event&, const InputElementClickState&) final; 54 56 bool matchesIndeterminatePseudoClass() const final; 57 void willUpdateCheckedness(bool nowChecked) final; 55 58 }; 56 59
Note: See TracChangeset
for help on using the changeset viewer.