<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[286855] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/286855">286855</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2021-12-10 09:16:51 -0800 (Fri, 10 Dec 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Radio buttons with no form owner are not grouped
https://bugs.webkit.org/show_bug.cgi?id=220502
<rdar://problem/73300895>

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Rebaseline WPT tests now that more checks are passing.

* web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valid-expected.txt:
* web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valueMissing-expected.txt:
* web-platform-tests/html/semantics/forms/the-input-element/radio-expected.txt:

Source/WebCore:

Per the HTML specification and to match the behavior of both Gecko and Blink,
radio buttons should still be grouped, even if they are disconnected and not
owned by a form.

This patch aligns our behavior with Gecko and Blink and is based on the following
Blink commit:
- https://chromium-review.googlesource.com/c/chromium/src/+/1988087

No new tests, rebaselined existing tests.

* dom/ContainerNode.h:
(WebCore::ContainerNode::rootNode const):
* dom/ElementTraversal.h:
(WebCore::Traversal<ElementType>::inclusiveFirstWithin):
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::setChecked):
(WebCore::HTMLInputElement::didChangeForm):
(WebCore::HTMLInputElement::insertedIntoAncestor):
(WebCore::HTMLInputElement::removedFromAncestor):
(WebCore::HTMLInputElement::checkedRadioButtonForGroup const):
* html/InputType.h:
(WebCore::InputType::willUpdateCheckedness):
* html/RadioInputType.cpp:
(WebCore::RadioInputType::valueMissing const):
(WebCore::RadioInputType::willUpdateCheckedness):
* html/RadioInputType.h:

LayoutTests:

* fast/forms/radio/ValidityState-valueMissing-radio-expected.txt:
* fast/forms/radio/ValidityState-valueMissing-radio.html:
* fast/forms/radio/radio-live-validation-style-expected.txt:
* fast/forms/radio/radio-live-validation-style.html:
Update existing tests to reflect behavior change. I have verified that our behavior on those tests
is aligned with both Firefox and Chrome.

* platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valid-expected.txt:
* platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valueMissing-expected.txt:
Rebaseline WPT tests now that more checks are passing.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastformsradioValidityStatevalueMissingradioexpectedtxt">trunk/LayoutTests/fast/forms/radio/ValidityState-valueMissing-radio-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastformsradioValidityStatevalueMissingradiohtml">trunk/LayoutTests/fast/forms/radio/ValidityState-valueMissing-radio.html</a></li>
<li><a href="#trunkLayoutTestsfastformsradioradiolivevalidationstyleexpectedtxt">trunk/LayoutTests/fast/forms/radio/radio-live-validation-style-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastformsradioradiolivevalidationstylehtml">trunk/LayoutTests/fast/forms/radio/radio-live-validation-style.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmlsemanticsformsconstraintsformvalidationvalidityvalidexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valid-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmlsemanticsformsconstraintsformvalidationvalidityvalueMissingexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valueMissing-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmlsemanticsformstheinputelementradioexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/radio-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformioswk2importedw3cwebplatformtestshtmlsemanticsformsconstraintsformvalidationvalidityvalidexpectedtxt">trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valid-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformioswk2importedw3cwebplatformtestshtmlsemanticsformsconstraintsformvalidationvalidityvalueMissingexpectedtxt">trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valueMissing-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmacwk2importedw3cwebplatformtestshtmlsemanticsformsconstraintsformvalidationvalidityvalidexpectedtxt">trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valid-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmacwk2importedw3cwebplatformtestshtmlsemanticsformsconstraintsformvalidationvalidityvalueMissingexpectedtxt">trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valueMissing-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomContainerNodeh">trunk/Source/WebCore/dom/ContainerNode.h</a></li>
<li><a href="#trunkSourceWebCoredomElementTraversalh">trunk/Source/WebCore/dom/ElementTraversal.h</a></li>
<li><a href="#trunkSourceWebCoredomTypedElementDescendantIteratorh">trunk/Source/WebCore/dom/TypedElementDescendantIterator.h</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLFormControlElementcpp">trunk/Source/WebCore/html/HTMLFormControlElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLFormControlElementh">trunk/Source/WebCore/html/HTMLFormControlElement.h</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLInputElementcpp">trunk/Source/WebCore/html/HTMLInputElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlInputTypeh">trunk/Source/WebCore/html/InputType.h</a></li>
<li><a href="#trunkSourceWebCorehtmlRadioInputTypecpp">trunk/Source/WebCore/html/RadioInputType.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlRadioInputTypeh">trunk/Source/WebCore/html/RadioInputType.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (286854 => 286855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2021-12-10 17:07:12 UTC (rev 286854)
+++ trunk/LayoutTests/ChangeLog 2021-12-10 17:16:51 UTC (rev 286855)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2021-12-10  Chris Dumez  <cdumez@apple.com>
+
+        Radio buttons with no form owner are not grouped
+        https://bugs.webkit.org/show_bug.cgi?id=220502
+        <rdar://problem/73300895>
+
+        Reviewed by Darin Adler.
+
+        * fast/forms/radio/ValidityState-valueMissing-radio-expected.txt:
+        * fast/forms/radio/ValidityState-valueMissing-radio.html:
+        * fast/forms/radio/radio-live-validation-style-expected.txt:
+        * fast/forms/radio/radio-live-validation-style.html:
+        Update existing tests to reflect behavior change. I have verified that our behavior on those tests
+        is aligned with both Firefox and Chrome.
+
+        * platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valid-expected.txt:
+        * platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valueMissing-expected.txt:
+        Rebaseline WPT tests now that more checks are passing.
+
</ins><span class="cx"> 2021-12-10  Youenn Fablet  <youenn@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [ Monterey ] http/tests/workers/service/serviceworker-websocket.https.html (layout-test) is constant text failure
</span></span></pre></div>
<a id="trunkLayoutTestsfastformsradioValidityStatevalueMissingradioexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/forms/radio/ValidityState-valueMissing-radio-expected.txt (286854 => 286855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/radio/ValidityState-valueMissing-radio-expected.txt 2021-12-10 17:07:12 UTC (rev 286854)
+++ trunk/LayoutTests/fast/forms/radio/ValidityState-valueMissing-radio-expected.txt    2021-12-10 17:16:51 UTC (rev 286855)
</span><span class="lines">@@ -40,11 +40,11 @@
</span><span class="cx"> PASS inputs[2].validity.valueMissing is false
</span><span class="cx"> 
</span><span class="cx"> Not in a radio button group
</span><del>-PASS requiredButton.validity.valueMissing is false
</del><span class="cx"> PASS requiredButton.validity.valueMissing is true
</span><ins>+PASS requiredButton.validity.valueMissing is true
</ins><span class="cx"> PASS button.validity.valueMissing is true
</span><span class="cx"> PASS button.validity.valueMissing is false
</span><del>-PASS requiredButton.validity.valueMissing is false
</del><ins>+PASS requiredButton.validity.valueMissing is true
</ins><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestsfastformsradioValidityStatevalueMissingradiohtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/forms/radio/ValidityState-valueMissing-radio.html (286854 => 286855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/radio/ValidityState-valueMissing-radio.html 2021-12-10 17:07:12 UTC (rev 286854)
+++ trunk/LayoutTests/fast/forms/radio/ValidityState-valueMissing-radio.html    2021-12-10 17:16:51 UTC (rev 286855)
</span><span class="lines">@@ -71,7 +71,7 @@
</span><span class="cx"> requiredButton.type = 'radio';
</span><span class="cx"> requiredButton.name = 'victim';
</span><span class="cx"> requiredButton.required = true;
</span><del>-shouldBeFalse('requiredButton.validity.valueMissing');
</del><ins>+shouldBeTrue('requiredButton.validity.valueMissing');
</ins><span class="cx"> 
</span><span class="cx"> parent.innerHTML = '<input name=victim type=radio required><input name=victim type=radio>';
</span><span class="cx"> requiredButton = document.getElementsByName('victim')[0];
</span><span class="lines">@@ -81,7 +81,7 @@
</span><span class="cx"> parent.removeChild(button);
</span><span class="cx"> shouldBeFalse('button.validity.valueMissing');
</span><span class="cx"> parent.removeChild(requiredButton);
</span><del>-shouldBeFalse('requiredButton.validity.valueMissing');
</del><ins>+shouldBeTrue('requiredButton.validity.valueMissing');
</ins><span class="cx"> 
</span><span class="cx"> </script>
</span><span class="cx"> <script src="../../../resources/js-test-post.js"></script>
</span></span></pre></div>
<a id="trunkLayoutTestsfastformsradioradiolivevalidationstyleexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/forms/radio/radio-live-validation-style-expected.txt (286854 => 286855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/radio/radio-live-validation-style-expected.txt      2021-12-10 17:07:12 UTC (rev 286854)
+++ trunk/LayoutTests/fast/forms/radio/radio-live-validation-style-expected.txt 2021-12-10 17:16:51 UTC (rev 286855)
</span><span class="lines">@@ -7,7 +7,7 @@
</span><span class="cx"> PASS backgroundOf($("radio1")) is validColor
</span><span class="cx"> PASS parent.removeChild($("radio2")); backgroundOf($("radio1")) is invalidColor
</span><span class="cx"> PASS $("radio1").remove(); radio2.matches(":valid") is false
</span><del>-PASS radio2.remove(); radio2.matches(":valid") is true
</del><ins>+PASS radio2.remove(); radio2.matches(":valid") is false
</ins><span class="cx"> 
</span><span class="cx"> Removing a checked radio button from a required radio button group by name attribute change:
</span><span class="cx"> PASS $("radio2").name = "group2"; backgroundOf($("radio1")) is invalidColor
</span></span></pre></div>
<a id="trunkLayoutTestsfastformsradioradiolivevalidationstylehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/forms/radio/radio-live-validation-style.html (286854 => 286855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/radio/radio-live-validation-style.html      2021-12-10 17:07:12 UTC (rev 286854)
+++ trunk/LayoutTests/fast/forms/radio/radio-live-validation-style.html 2021-12-10 17:16:51 UTC (rev 286855)
</span><span class="lines">@@ -35,7 +35,7 @@
</span><span class="cx">     '<input type=radio name=group1 required id=radio3>';
</span><span class="cx"> var radio2 = $('radio2');
</span><span class="cx"> shouldBeFalse('$("radio1").remove(); radio2.matches(":valid")');
</span><del>-shouldBeTrue('radio2.remove(); radio2.matches(":valid")');
</del><ins>+shouldBeFalse('radio2.remove(); radio2.matches(":valid")');
</ins><span class="cx"> debug('');
</span><span class="cx"> 
</span><span class="cx"> debug('Removing a checked radio button from a required radio button group by name attribute change:');
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (286854 => 286855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-12-10 17:07:12 UTC (rev 286854)
+++ trunk/LayoutTests/imported/w3c/ChangeLog    2021-12-10 17:16:51 UTC (rev 286855)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2021-12-10  Chris Dumez  <cdumez@apple.com>
+
+        Radio buttons with no form owner are not grouped
+        https://bugs.webkit.org/show_bug.cgi?id=220502
+        <rdar://problem/73300895>
+
+        Reviewed by Darin Adler.
+
+        Rebaseline WPT tests now that more checks are passing.
+
+        * web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valid-expected.txt:
+        * web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valueMissing-expected.txt:
+        * web-platform-tests/html/semantics/forms/the-input-element/radio-expected.txt:
+
</ins><span class="cx"> 2021-12-10  Patrick Griffis  <pgriffis@igalia.com>
</span><span class="cx"> 
</span><span class="cx">         CSP: Allow external scripts with SRI hashes matching CSP
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmlsemanticsformsconstraintsformvalidationvalidityvalidexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valid-expected.txt (286854 => 286855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valid-expected.txt   2021-12-10 17:07:12 UTC (rev 286854)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valid-expected.txt      2021-12-10 17:16:51 UTC (rev 286855)
</span><span class="lines">@@ -23,7 +23,7 @@
</span><span class="cx"> PASS [INPUT in NUMBER status] validity.valid must be false if validity.stepMismatch is true
</span><span class="cx"> PASS [INPUT in NUMBER status] validity.valid must be false if validity.valueMissing is true
</span><span class="cx"> PASS [INPUT in CHECKBOX status] validity.valid must be false if validity.valueMissing is true
</span><del>-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 got true
</del><ins>+PASS [INPUT in RADIO status] validity.valid must be false if validity.valueMissing is true
</ins><span class="cx"> PASS [INPUT in FILE status] validity.valid must be false if validity.valueMissing is true
</span><span class="cx"> PASS [select]  validity.valid must be false if validity.valueMissing is true
</span><span class="cx"> PASS [textarea]  validity.valid must be false if validity.valueMissing is true
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmlsemanticsformsconstraintsformvalidationvalidityvalueMissingexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valueMissing-expected.txt (286854 => 286855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valueMissing-expected.txt    2021-12-10 17:07:12 UTC (rev 286854)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valueMissing-expected.txt       2021-12-10 17:16:51 UTC (rev 286855)
</span><span class="lines">@@ -38,7 +38,7 @@
</span><span class="cx"> PASS [INPUT in CHECKBOX status] The checked attribute is false
</span><span class="cx"> PASS [INPUT in RADIO status] The required attribute is not set
</span><span class="cx"> PASS [INPUT in RADIO status] The checked attribute is true
</span><del>-FAIL [INPUT in RADIO status] The checked attribute is false assert_true: The validity.valueMissing should be true. expected true got false
</del><ins>+PASS [INPUT in RADIO status] The checked attribute is false
</ins><span class="cx"> PASS [INPUT in RADIO status] The checked attribute is false and the name attribute is empty
</span><span class="cx"> PASS [INPUT in FILE status] The required attribute is not set
</span><span class="cx"> PASS [INPUT in FILE status] The Files attribute is null
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmlsemanticsformstheinputelementradioexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/radio-expected.txt (286854 => 286855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/radio-expected.txt      2021-12-10 17:07:12 UTC (rev 286854)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/radio-expected.txt 2021-12-10 17:16:51 UTC (rev 286855)
</span><span class="lines">@@ -7,8 +7,8 @@
</span><span class="cx"> PASS radio inputs with non-ASCII name attributes belong to the same radio button group
</span><span class="cx"> 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
</span><span class="cx"> PASS moving radio input element out of or into a form should still work as expected
</span><del>-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
-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
</del><ins>+PASS Radio buttons in an orphan tree should make a group
+PASS Radio buttons in different groups (because they have different form owners or no form owner) do not affect each other's checkedness
</ins><span class="cx"> PASS Radio buttons in different groups (because they are not in the same tree) do not affect each other's checkedness
</span><span class="cx"> PASS Radio buttons in different groups (because they have different name attribute values, or no name attribute) do not affect each other's checkedness
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsplatformioswk2importedw3cwebplatformtestshtmlsemanticsformsconstraintsformvalidationvalidityvalidexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valid-expected.txt (286854 => 286855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valid-expected.txt  2021-12-10 17:07:12 UTC (rev 286854)
+++ trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valid-expected.txt     2021-12-10 17:16:51 UTC (rev 286855)
</span><span class="lines">@@ -38,7 +38,7 @@
</span><span class="cx"> PASS [INPUT in NUMBER status] validity.valid must be false if validity.stepMismatch is true
</span><span class="cx"> PASS [INPUT in NUMBER status] validity.valid must be false if validity.valueMissing is true
</span><span class="cx"> PASS [INPUT in CHECKBOX status] validity.valid must be false if validity.valueMissing is true
</span><del>-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 got true
</del><ins>+PASS [INPUT in RADIO status] validity.valid must be false if validity.valueMissing is true
</ins><span class="cx"> PASS [INPUT in FILE status] validity.valid must be false if validity.valueMissing is true
</span><span class="cx"> PASS [select]  validity.valid must be false if validity.valueMissing is true
</span><span class="cx"> PASS [textarea]  validity.valid must be false if validity.valueMissing is true
</span></span></pre></div>
<a id="trunkLayoutTestsplatformioswk2importedw3cwebplatformtestshtmlsemanticsformsconstraintsformvalidationvalidityvalueMissingexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valueMissing-expected.txt (286854 => 286855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valueMissing-expected.txt   2021-12-10 17:07:12 UTC (rev 286854)
+++ trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valueMissing-expected.txt      2021-12-10 17:16:51 UTC (rev 286855)
</span><span class="lines">@@ -84,7 +84,7 @@
</span><span class="cx"> PASS [INPUT in CHECKBOX status] The checked attribute is false
</span><span class="cx"> PASS [INPUT in RADIO status] The required attribute is not set
</span><span class="cx"> PASS [INPUT in RADIO status] The checked attribute is true
</span><del>-FAIL [INPUT in RADIO status] The checked attribute is false assert_true: The validity.valueMissing should be true. expected true got false
</del><ins>+PASS [INPUT in RADIO status] The checked attribute is false
</ins><span class="cx"> PASS [INPUT in RADIO status] The checked attribute is false and the name attribute is empty
</span><span class="cx"> PASS [INPUT in FILE status] The required attribute is not set
</span><span class="cx"> PASS [INPUT in FILE status] The Files attribute is null
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk2importedw3cwebplatformtestshtmlsemanticsformsconstraintsformvalidationvalidityvalidexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valid-expected.txt (286854 => 286855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valid-expected.txt  2021-12-10 17:07:12 UTC (rev 286854)
+++ trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valid-expected.txt     2021-12-10 17:16:51 UTC (rev 286855)
</span><span class="lines">@@ -38,7 +38,7 @@
</span><span class="cx"> PASS [INPUT in NUMBER status] validity.valid must be false if validity.stepMismatch is true
</span><span class="cx"> PASS [INPUT in NUMBER status] validity.valid must be false if validity.valueMissing is true
</span><span class="cx"> PASS [INPUT in CHECKBOX status] validity.valid must be false if validity.valueMissing is true
</span><del>-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 got true
</del><ins>+PASS [INPUT in RADIO status] validity.valid must be false if validity.valueMissing is true
</ins><span class="cx"> PASS [INPUT in FILE status] validity.valid must be false if validity.valueMissing is true
</span><span class="cx"> PASS [select]  validity.valid must be false if validity.valueMissing is true
</span><span class="cx"> PASS [textarea]  validity.valid must be false if validity.valueMissing is true
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacwk2importedw3cwebplatformtestshtmlsemanticsformsconstraintsformvalidationvalidityvalueMissingexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valueMissing-expected.txt (286854 => 286855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valueMissing-expected.txt   2021-12-10 17:07:12 UTC (rev 286854)
+++ trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/constraints/form-validation-validity-valueMissing-expected.txt      2021-12-10 17:16:51 UTC (rev 286855)
</span><span class="lines">@@ -84,7 +84,7 @@
</span><span class="cx"> PASS [INPUT in CHECKBOX status] The checked attribute is false
</span><span class="cx"> PASS [INPUT in RADIO status] The required attribute is not set
</span><span class="cx"> PASS [INPUT in RADIO status] The checked attribute is true
</span><del>-FAIL [INPUT in RADIO status] The checked attribute is false assert_true: The validity.valueMissing should be true. expected true got false
</del><ins>+PASS [INPUT in RADIO status] The checked attribute is false
</ins><span class="cx"> PASS [INPUT in RADIO status] The checked attribute is false and the name attribute is empty
</span><span class="cx"> PASS [INPUT in FILE status] The required attribute is not set
</span><span class="cx"> PASS [INPUT in FILE status] The Files attribute is null
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (286854 => 286855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-12-10 17:07:12 UTC (rev 286854)
+++ trunk/Source/WebCore/ChangeLog      2021-12-10 17:16:51 UTC (rev 286855)
</span><span class="lines">@@ -1,3 +1,38 @@
</span><ins>+2021-12-10  Chris Dumez  <cdumez@apple.com>
+
+        Radio buttons with no form owner are not grouped
+        https://bugs.webkit.org/show_bug.cgi?id=220502
+        <rdar://problem/73300895>
+
+        Reviewed by Darin Adler.
+
+        Per the HTML specification and to match the behavior of both Gecko and Blink,
+        radio buttons should still be grouped, even if they are disconnected and not
+        owned by a form.
+
+        This patch aligns our behavior with Gecko and Blink and is based on the following
+        Blink commit:
+        - https://chromium-review.googlesource.com/c/chromium/src/+/1988087
+
+        No new tests, rebaselined existing tests.
+
+        * dom/ContainerNode.h:
+        (WebCore::ContainerNode::rootNode const):
+        * dom/ElementTraversal.h:
+        (WebCore::Traversal<ElementType>::inclusiveFirstWithin):
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::setChecked):
+        (WebCore::HTMLInputElement::didChangeForm):
+        (WebCore::HTMLInputElement::insertedIntoAncestor):
+        (WebCore::HTMLInputElement::removedFromAncestor):
+        (WebCore::HTMLInputElement::checkedRadioButtonForGroup const):
+        * html/InputType.h:
+        (WebCore::InputType::willUpdateCheckedness):
+        * html/RadioInputType.cpp:
+        (WebCore::RadioInputType::valueMissing const):
+        (WebCore::RadioInputType::willUpdateCheckedness):
+        * html/RadioInputType.h:
+
</ins><span class="cx"> 2021-12-10  Patrick Griffis  <pgriffis@igalia.com>
</span><span class="cx"> 
</span><span class="cx">         CSP: Allow external scripts with SRI hashes matching CSP
</span></span></pre></div>
<a id="trunkSourceWebCoredomContainerNodeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ContainerNode.h (286854 => 286855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ContainerNode.h 2021-12-10 17:07:12 UTC (rev 286854)
+++ trunk/Source/WebCore/dom/ContainerNode.h    2021-12-10 17:16:51 UTC (rev 286855)
</span><span class="lines">@@ -60,6 +60,8 @@
</span><span class="cx">     void stringReplaceAll(const String&);
</span><span class="cx">     void replaceAll(Node*);
</span><span class="cx"> 
</span><ins>+    ContainerNode& rootNode() const { return downcast<ContainerNode>(Node::rootNode()); }
+
</ins><span class="cx">     // These methods are only used during parsing.
</span><span class="cx">     // They don't send DOM mutation events or handle reparenting.
</span><span class="cx">     // However, arbitrary code may be run by beforeload handlers.
</span></span></pre></div>
<a id="trunkSourceWebCoredomElementTraversalh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ElementTraversal.h (286854 => 286855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ElementTraversal.h      2021-12-10 17:07:12 UTC (rev 286854)
+++ trunk/Source/WebCore/dom/ElementTraversal.h 2021-12-10 17:16:51 UTC (rev 286855)
</span><span class="lines">@@ -43,6 +43,10 @@
</span><span class="cx">     static ElementType* firstWithin(const ContainerNode&);
</span><span class="cx">     static ElementType* lastWithin(const Node&);
</span><span class="cx">     static ElementType* lastWithin(const ContainerNode&);
</span><ins>+    static ElementType* inclusiveFirstWithin(Node&);
+    static ElementType* inclusiveFirstWithin(ContainerNode&);
+    static ElementType* inclusiveLastWithin(Node&);
+    static ElementType* inclusiveLastWithin(ContainerNode&);
</ins><span class="cx"> 
</span><span class="cx">     // Pre-order traversal skipping non-ElementType nodes.
</span><span class="cx">     static ElementType* next(const Node&);
</span><span class="lines">@@ -235,6 +239,38 @@
</span><span class="cx"> inline ElementType* Traversal<ElementType>::lastChild(const Node& current) { return lastChildTemplate(current); }
</span><span class="cx"> 
</span><span class="cx"> template <typename ElementType>
</span><ins>+inline ElementType* Traversal<ElementType>::inclusiveFirstWithin(ContainerNode& current)
+{
+    if (is<ElementType>(current))
+        return &downcast<ElementType>(current);
+    return firstWithin(current);
+}
+
+template <typename ElementType>
+inline ElementType* Traversal<ElementType>::inclusiveFirstWithin(Node& current)
+{
+    if (is<ElementType>(current))
+        return &downcast<ElementType>(current);
+    return firstWithin(current);
+}
+
+template <typename ElementType>
+inline ElementType* Traversal<ElementType>::inclusiveLastWithin(ContainerNode& current)
+{
+    if (is<ElementType>(current))
+        return &downcast<ElementType>(current);
+    return lastWithin(current);
+}
+
+template <typename ElementType>
+inline ElementType* Traversal<ElementType>::inclusiveLastWithin(Node& current)
+{
+    if (is<ElementType>(current))
+        return &downcast<ElementType>(current);
+    return lastWithin(current);
+}
+
+template <typename ElementType>
</ins><span class="cx"> inline ElementType* Traversal<ElementType>::firstWithin(const ContainerNode& current) { return firstWithinTemplate(current); }
</span><span class="cx"> template <typename ElementType>
</span><span class="cx"> inline ElementType* Traversal<ElementType>::firstWithin(const Node& current) { return firstWithinTemplate(current); }
</span></span></pre></div>
<a id="trunkSourceWebCoredomTypedElementDescendantIteratorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/TypedElementDescendantIterator.h (286854 => 286855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/TypedElementDescendantIterator.h        2021-12-10 17:07:12 UTC (rev 286854)
+++ trunk/Source/WebCore/dom/TypedElementDescendantIterator.h   2021-12-10 17:16:51 UTC (rev 286855)
</span><span class="lines">@@ -68,6 +68,21 @@
</span><span class="cx">     const ContainerNode& m_root;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+template<typename ElementType> class InclusiveElementDescendantRange {
+public:
+    InclusiveElementDescendantRange(const ContainerNode& root);
+    ElementDescendantIterator<ElementType> begin() const;
+    static constexpr std::nullptr_t end() { return nullptr; }
+    ElementDescendantIterator<ElementType> beginAt(ElementType&) const;
+    ElementDescendantIterator<ElementType> from(Element&) const;
+
+    ElementType* first() const;
+    ElementType* last() const;
+
+private:
+    const ContainerNode& m_root;
+};
+
</ins><span class="cx"> template<typename ElementType> class DoubleElementDescendantRange {
</span><span class="cx"> public:
</span><span class="cx">     typedef ElementDescendantRange<ElementType> SingleAdapter;
</span><span class="lines">@@ -171,6 +186,43 @@
</span><span class="cx">     return Traversal<ElementType>::lastWithin(m_root);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+// InclusiveElementDescendantRange
+
+template<typename ElementType> InclusiveElementDescendantRange<ElementType>::InclusiveElementDescendantRange(const ContainerNode& root)
+    : m_root(root)
+{
+}
+
+template<typename ElementType> ElementDescendantIterator<ElementType> InclusiveElementDescendantRange<ElementType>::begin() const
+{
+    return ElementDescendantIterator<ElementType>(m_root, Traversal<ElementType>::inclusiveFirstWithin(const_cast<ContainerNode&>(m_root)));
+}
+
+template<typename ElementType> ElementDescendantIterator<ElementType> InclusiveElementDescendantRange<ElementType>::beginAt(ElementType& descendant) const
+{
+    ASSERT(&m_root == &descendant || descendant.isDescendantOf(m_root));
+    return ElementDescendantIterator<ElementType>(m_root, &descendant);
+}
+
+template<typename ElementType> ElementDescendantIterator<ElementType> InclusiveElementDescendantRange<ElementType>::from(Element& descendant) const
+{
+    ASSERT(&m_root == &descendant || descendant.isDescendantOf(m_root));
+    if (is<ElementType>(descendant))
+        return ElementDescendantIterator<ElementType>(m_root, downcast<ElementType>(&descendant));
+    ElementType* next = Traversal<ElementType>::next(descendant, &m_root);
+    return ElementDescendantIterator<ElementType>(m_root, next);
+}
+
+template<typename ElementType> ElementType* InclusiveElementDescendantRange<ElementType>::first() const
+{
+    return Traversal<ElementType>::inclusiveFirstWithin(m_root);
+}
+
+template<typename ElementType> ElementType* InclusiveElementDescendantRange<ElementType>::last() const
+{
+    return Traversal<ElementType>::inclusiveLastWithin(m_root);
+}
+
</ins><span class="cx"> // DoubleElementDescendantRange
</span><span class="cx"> 
</span><span class="cx"> template<typename ElementType> DoubleElementDescendantRange<ElementType>::DoubleElementDescendantRange(SingleAdapter&& first, SingleAdapter&& second)
</span><span class="lines">@@ -251,6 +303,11 @@
</span><span class="cx">     return ElementDescendantRange<ElementType>(root);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+template<typename ElementType> InclusiveElementDescendantRange<ElementType> inclusiveDescendantsOfType(ContainerNode& root)
+{
+    return InclusiveElementDescendantRange<ElementType>(root);
+}
+
</ins><span class="cx"> template<typename ElementType> ElementDescendantRange<const ElementType> descendantsOfType(const ContainerNode& root)
</span><span class="cx"> {
</span><span class="cx">     return ElementDescendantRange<const ElementType>(root);
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLFormControlElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLFormControlElement.cpp (286854 => 286855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLFormControlElement.cpp     2021-12-10 17:07:12 UTC (rev 286854)
+++ trunk/Source/WebCore/html/HTMLFormControlElement.cpp        2021-12-10 17:16:51 UTC (rev 286855)
</span><span class="lines">@@ -301,11 +301,6 @@
</span><span class="cx">     dispatchInputEvent();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool HTMLFormControlElement::isRequired() const
-{
-    return m_isRequired;
-}
-
</del><span class="cx"> void HTMLFormControlElement::didRecalcStyle(Style::Change)
</span><span class="cx"> {
</span><span class="cx">     // updateFromElement() can cause the selection to change, and in turn
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLFormControlElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLFormControlElement.h (286854 => 286855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLFormControlElement.h       2021-12-10 17:07:12 UTC (rev 286854)
+++ trunk/Source/WebCore/html/HTMLFormControlElement.h  2021-12-10 17:16:51 UTC (rev 286855)
</span><span class="lines">@@ -76,7 +76,7 @@
</span><span class="cx"> 
</span><span class="cx">     bool isEnumeratable() const override { return false; }
</span><span class="cx"> 
</span><del>-    bool isRequired() const;
</del><ins>+    bool isRequired() const { return m_isRequired; }
</ins><span class="cx"> 
</span><span class="cx">     const AtomString& type() const { return formControlType(); }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLInputElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (286854 => 286855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLInputElement.cpp   2021-12-10 17:07:12 UTC (rev 286854)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp      2021-12-10 17:16:51 UTC (rev 286855)
</span><span class="lines">@@ -68,6 +68,7 @@
</span><span class="cx"> #include "StepRange.h"
</span><span class="cx"> #include "StyleGeneratedImage.h"
</span><span class="cx"> #include "TextControlInnerElements.h"
</span><ins>+#include "TypedElementDescendantIterator.h"
</ins><span class="cx"> #include <wtf/IsoMallocInlines.h>
</span><span class="cx"> #include <wtf/Language.h>
</span><span class="cx"> #include <wtf/MathExtras.h>
</span><span class="lines">@@ -979,6 +980,8 @@
</span><span class="cx">     if (checked() == nowChecked)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><ins>+    m_inputType->willUpdateCheckedness(nowChecked);
+
</ins><span class="cx">     m_dirtyCheckednessFlag = true;
</span><span class="cx">     m_isChecked = nowChecked;
</span><span class="cx">     invalidateStyleForSubtree();
</span><span class="lines">@@ -1576,12 +1579,14 @@
</span><span class="cx"> 
</span><span class="cx"> void HTMLInputElement::didChangeForm()
</span><span class="cx"> {
</span><ins>+    addToRadioButtonGroup();
</ins><span class="cx">     HTMLTextFormControlElement::didChangeForm();
</span><del>-    addToRadioButtonGroup();
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Node::InsertedIntoAncestorResult HTMLInputElement::insertedIntoAncestor(InsertionType insertionType, ContainerNode& parentOfInsertedTree)
</span><span class="cx"> {
</span><ins>+    if (isRadioButton())
+        updateValidity();
</ins><span class="cx">     HTMLTextFormControlElement::insertedIntoAncestor(insertionType, parentOfInsertedTree);
</span><span class="cx"> #if ENABLE(DATALIST_ELEMENT)
</span><span class="cx">     resetListAttributeTargetObserver();
</span><span class="lines">@@ -1608,6 +1613,8 @@
</span><span class="cx">         removeFromRadioButtonGroup();
</span><span class="cx">     HTMLTextFormControlElement::removedFromAncestor(removalType, oldParentOfRemovedTree);
</span><span class="cx">     ASSERT(!isConnected());
</span><ins>+    if (removalType.disconnectedFromDocument && !form() && isRadioButton())
+        updateValidity();
</ins><span class="cx"> #if ENABLE(DATALIST_ELEMENT)
</span><span class="cx">     resetListAttributeTargetObserver();
</span><span class="cx"> #endif
</span><span class="lines">@@ -1956,8 +1963,21 @@
</span><span class="cx"> 
</span><span class="cx"> RefPtr<HTMLInputElement> HTMLInputElement::checkedRadioButtonForGroup() const
</span><span class="cx"> {
</span><ins>+    if (checked())
+        return const_cast<HTMLInputElement*>(this);
+
+    auto& name = this->name();
</ins><span class="cx">     if (RadioButtonGroups* buttons = radioButtonGroups())
</span><del>-        return buttons->checkedButtonForGroup(name());
</del><ins>+        return buttons->checkedButtonForGroup(name);
+
+    if (name.isEmpty())
+        return nullptr;
+
+    // The input is not managed by a RadioButtonGroups, we'll need to traverse the tree.
+    for (auto& descendant : descendantsOfType<HTMLInputElement>(rootNode())) {
+        if (descendant.checked() && descendant.isRadioButton() && !descendant.form() && name == descendant.name())
+            return &descendant;
+    }
</ins><span class="cx">     return nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlInputTypeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/InputType.h (286854 => 286855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/InputType.h    2021-12-10 17:07:12 UTC (rev 286854)
+++ trunk/Source/WebCore/html/InputType.h       2021-12-10 17:16:51 UTC (rev 286855)
</span><span class="lines">@@ -363,6 +363,7 @@
</span><span class="cx"> #if ENABLE(DATALIST_ELEMENT)
</span><span class="cx">     virtual bool isFocusingWithDataListDropdown() const { return false; };
</span><span class="cx"> #endif
</span><ins>+    virtual void willUpdateCheckedness(bool /*nowChecked*/) { }
</ins><span class="cx"> 
</span><span class="cx">     // Parses the specified string for the type, and return
</span><span class="cx">     // the Decimal value for the parsing result if the parsing
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlRadioInputTypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/RadioInputType.cpp (286854 => 286855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/RadioInputType.cpp     2021-12-10 17:07:12 UTC (rev 286854)
+++ trunk/Source/WebCore/html/RadioInputType.cpp        2021-12-10 17:16:51 UTC (rev 286855)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> #include "MouseEvent.h"
</span><span class="cx"> #include "NodeTraversal.h"
</span><span class="cx"> #include "SpatialNavigation.h"
</span><ins>+#include "TypedElementDescendantIterator.h"
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -45,9 +46,37 @@
</span><span class="cx"> bool RadioInputType::valueMissing(const String&) const
</span><span class="cx"> {
</span><span class="cx">     ASSERT(element());
</span><del>-    return element()->isInRequiredRadioButtonGroup() && !element()->checkedRadioButtonForGroup();
</del><ins>+    auto& name = element()->name();
+    if (auto* buttons = element()->radioButtonGroups())
+        return !buttons->checkedButtonForGroup(name) && buttons->isInRequiredGroup(*element());
+
+    if (name.isEmpty())
+        return false;
+
+    bool isRequired = false;
+    for (auto& input : inclusiveDescendantsOfType<HTMLInputElement>(element()->rootNode())) {
+        if (!input.isRadioButton() || input.form() || input.name() != name)
+            continue;
+        if (input.checked())
+            return false;
+        if (input.isRequired())
+            isRequired = true;
+    }
+    return isRequired;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void RadioInputType::willUpdateCheckedness(bool nowChecked)
+{
+    if (!nowChecked)
+        return;
+    if (element()->radioButtonGroups()) {
+        // Buttons in RadioButtonGroups are handled in HTMLInputElement::setChecked().
+        return;
+    }
+    if (auto input = element()->checkedRadioButtonForGroup())
+        input->setChecked(false);
+}
+
</ins><span class="cx"> String RadioInputType::valueMissingText() const
</span><span class="cx"> {
</span><span class="cx">     return validationMessageValueMissingForRadioText();
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlRadioInputTypeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/RadioInputType.h (286854 => 286855)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/RadioInputType.h       2021-12-10 17:07:12 UTC (rev 286854)
+++ trunk/Source/WebCore/html/RadioInputType.h  2021-12-10 17:16:51 UTC (rev 286855)
</span><span class="lines">@@ -52,6 +52,7 @@
</span><span class="cx">     void willDispatchClick(InputElementClickState&) final;
</span><span class="cx">     void didDispatchClick(Event&, const InputElementClickState&) final;
</span><span class="cx">     bool matchesIndeterminatePseudoClass() const final;
</span><ins>+    void willUpdateCheckedness(bool nowChecked) final;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre>
</div>
</div>

</body>
</html>