<!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>[210384] branches/safari-603-branch</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/210384">210384</a></dd>
<dt>Author</dt> <dd>matthew_hanson@apple.com</dd>
<dt>Date</dt> <dd>2017-01-05 15:49:17 -0800 (Thu, 05 Jan 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/210267">r210267</a>. rdar://problem/29796608</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari603branchLayoutTestsChangeLog">branches/safari-603-branch/LayoutTests/ChangeLog</a></li>
<li><a href="#branchessafari603branchLayoutTestsfasteventsresourcestabindexfocusblurallframe1html">branches/safari-603-branch/LayoutTests/fast/events/resources/tabindex-focus-blur-all-frame1.html</a></li>
<li><a href="#branchessafari603branchLayoutTestsfasteventsresourcestabindexfocusblurallframe2html">branches/safari-603-branch/LayoutTests/fast/events/resources/tabindex-focus-blur-all-frame2.html</a></li>
<li><a href="#branchessafari603branchLayoutTestsfasteventsresourcestabindexfocusbluralljs">branches/safari-603-branch/LayoutTests/fast/events/resources/tabindex-focus-blur-all.js</a></li>
<li><a href="#branchessafari603branchLayoutTestsfasteventstabindexfocusblurallexpectedtxt">branches/safari-603-branch/LayoutTests/fast/events/tabindex-focus-blur-all-expected.txt</a></li>
<li><a href="#branchessafari603branchLayoutTestsplatformiossimulatorwk2TestExpectations">branches/safari-603-branch/LayoutTests/platform/ios-simulator-wk2/TestExpectations</a></li>
<li><a href="#branchessafari603branchSourceWebCoreChangeLog">branches/safari-603-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari603branchSourceWebCorehtmlHTMLLabelElementcpp">branches/safari-603-branch/Source/WebCore/html/HTMLLabelElement.cpp</a></li>
<li><a href="#branchessafari603branchSourceWebCorehtmlHTMLLabelElementh">branches/safari-603-branch/Source/WebCore/html/HTMLLabelElement.h</a></li>
<li><a href="#branchessafari603branchSourceWebCorehtmlHTMLLegendElementcpp">branches/safari-603-branch/Source/WebCore/html/HTMLLegendElement.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari603branchLayoutTestsfasteventsfocuslabellegendelementsexpectedtxt">branches/safari-603-branch/LayoutTests/fast/events/focus-label-legend-elements-expected.txt</a></li>
<li><a href="#branchessafari603branchLayoutTestsfasteventsfocuslabellegendelementswithtabexpectedtxt">branches/safari-603-branch/LayoutTests/fast/events/focus-label-legend-elements-with-tab-expected.txt</a></li>
<li><a href="#branchessafari603branchLayoutTestsfasteventsfocuslabellegendelementswithtabhtml">branches/safari-603-branch/LayoutTests/fast/events/focus-label-legend-elements-with-tab.html</a></li>
<li><a href="#branchessafari603branchLayoutTestsfasteventsfocuslabellegendelementshtml">branches/safari-603-branch/LayoutTests/fast/events/focus-label-legend-elements.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari603branchLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/LayoutTests/ChangeLog (210383 => 210384)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/LayoutTests/ChangeLog        2017-01-05 23:49:12 UTC (rev 210383)
+++ branches/safari-603-branch/LayoutTests/ChangeLog        2017-01-05 23:49:17 UTC (rev 210384)
</span><span class="lines">@@ -1,5 +1,37 @@
</span><span class="cx"> 2017-01-05 Matthew Hanson <matthew_hanson@apple.com>
</span><span class="cx">
</span><ins>+ Merge r210267. rdar://problem/29796608
+
+ 2017-01-03 Ryosuke Niwa <rniwa@webkit.org>
+
+ label element with tabindex >= 0 is not focusable
+ https://bugs.webkit.org/show_bug.cgi?id=102780
+ <rdar://problem/29796608>
+
+ Reviewed by Darin Adler.
+
+ Added a regression test for traversing label and legend elements by tabbing.
+ A native merge of the blink fix would have regressed this for the label element
+ while the bug in the legend element had always existed.
+
+ Also added a regression test for focusing label and legend elements with tabindex.
+ We should be able to focus either element. New behavior matches that of Chrome.
+ Firefox moves the focus to the label element like we used to before this patch.
+
+ Also merge the test fix from https://chromium.googlesource.com/chromium/src/+/085ad8697b1be50c4f93e296797a25a43a79bcfb
+
+ * fast/events/focus-label-legend-elements-expected.txt: Added.
+ * fast/events/focus-label-legend-elements-with-tab-expected.txt: Added.
+ * fast/events/focus-label-legend-elements-with-tab.html: Added.
+ * fast/events/focus-label-legend-elements.html: Added.
+ * fast/events/resources/tabindex-focus-blur-all-frame1.html:
+ * fast/events/resources/tabindex-focus-blur-all-frame2.html:
+ * fast/events/resources/tabindex-focus-blur-all.js:
+ * fast/events/tabindex-focus-blur-all-expected.txt:
+ * platform/ios-simulator-wk2/TestExpectations:
+
+2017-01-05 Matthew Hanson <matthew_hanson@apple.com>
+
</ins><span class="cx"> Merge r210022. rdar://problem/29316054
</span><span class="cx">
</span><span class="cx"> 2016-12-20 Megan Gardner <megan_gardner@apple.com>
</span></span></pre></div>
<a id="branchessafari603branchLayoutTestsfasteventsfocuslabellegendelementsexpectedtxt"></a>
<div class="addfile"><h4>Added: branches/safari-603-branch/LayoutTests/fast/events/focus-label-legend-elements-expected.txt (0 => 210384)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/LayoutTests/fast/events/focus-label-legend-elements-expected.txt         (rev 0)
+++ branches/safari-603-branch/LayoutTests/fast/events/focus-label-legend-elements-expected.txt        2017-01-05 23:49:17 UTC (rev 210384)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+Tests for calling focus() on a label element and a legend element. They should not move the focus to the associated element.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS testContent.querySelector("label").focus(); document.activeElement is testContent.querySelector("label")
+PASS testContent.querySelector("legend").focus(); document.activeElement is testContent.querySelector("legend")
+PASS successfullyParsed is true
+
+TEST COMPLETE
+ foo
+
</ins></span></pre></div>
<a id="branchessafari603branchLayoutTestsfasteventsfocuslabellegendelementswithtabexpectedtxt"></a>
<div class="addfile"><h4>Added: branches/safari-603-branch/LayoutTests/fast/events/focus-label-legend-elements-with-tab-expected.txt (0 => 210384)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/LayoutTests/fast/events/focus-label-legend-elements-with-tab-expected.txt         (rev 0)
+++ branches/safari-603-branch/LayoutTests/fast/events/focus-label-legend-elements-with-tab-expected.txt        2017-01-05 23:49:17 UTC (rev 210384)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+Tests for moving focus by pressing tab key across label and legend elements.
+To manually test, press tab key seven times then shift+tab six times.
+It should traverse focusable elements in the ascending order from 1 to 7 and then in the descending order back to 1.
+
+
+1. An input element inside a non-focusable label element
+2. A label element with an input element
+3. An input elment inside a focusable label element
+4. A label element with just text
+6. A focusable legend element inside a fieldset element
+7. An input element inside a fieldset element
+7. An input element inside a fieldset element
+6. A focusable legend element inside a fieldset element
+4. A label element with just text
+3. An input elment inside a focusable label element
+2. A label element with an input element
+1. An input element inside a non-focusable label element
+
</ins></span></pre></div>
<a id="branchessafari603branchLayoutTestsfasteventsfocuslabellegendelementswithtabhtml"></a>
<div class="addfile"><h4>Added: branches/safari-603-branch/LayoutTests/fast/events/focus-label-legend-elements-with-tab.html (0 => 210384)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/LayoutTests/fast/events/focus-label-legend-elements-with-tab.html         (rev 0)
+++ branches/safari-603-branch/LayoutTests/fast/events/focus-label-legend-elements-with-tab.html        2017-01-05 23:49:17 UTC (rev 210384)
</span><span class="lines">@@ -0,0 +1,72 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<body>
+<p>Tests for moving focus by pressing tab key across label and legend elements.<br>
+To manually test, press tab key seven times then shift+tab six times.<br>
+It should traverse focusable elements in the ascending order from 1 to 7 and then in the descending order back to 1.</p>
+</p>
+<input id="startingNode">
+<div id="test-content">
+ <label title="FAIL - a non-focusable label with an input should not be focused">
+ <input title="1. An input element inside a non-focusable label element">hello
+ </label>
+ <label tabindex="0" title="2. A label element with an input element">
+ <input title="3. An input elment inside a focusable label element">world</label>
+ <label tabindex="0" title="4. A label element with just text">webkit</label>
+ <label title="FAIL - an label element without tabindex should not be focused">rocks</label>
+ <fieldset tabindex="0" title="5. A fieldset element with tabindex">
+ <legend tabindex="0" title="6. A focusable legend element inside a fieldset element">foo</legend>
+ <input title="7. An input element inside a fieldset element">
+ </fieldset>
+</div>
+<style> :focus { background: red; } </style>
+<pre id="result"></pre>
+<script>
+
+function moveFocusForward(focusCount)
+{
+ setTimeout(function () {
+ if (!focusCount)
+ return moveFocusBackward(7);
+ eventSender.keyDown('\t');
+ setTimeout(function () {
+ moveFocusForward(focusCount - 1);
+ }, 1);
+ }, 1);
+}
+
+function moveFocusBackward(focusCount)
+{
+ setTimeout(function () {
+ if (!focusCount) {
+ testContent.style.display = 'none';
+ testRunner.notifyDone();
+ return;
+ }
+ eventSender.keyDown('\t', ['shiftKey']);
+ setTimeout(function () {
+ moveFocusBackward(focusCount - 1);
+ }, 1);
+ }, 1);
+}
+
+let testContent = document.getElementById('test-content');
+
+window.onload = () => {
+ document.getElementById('startingNode').focus();
+ if (window.eventSender) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ }
+ moveFocusForward(7);
+}
+
+testContent.querySelectorAll('*').forEach((element) => {
+ element.onfocus = function () {
+ document.getElementById('result').textContent += (element.title || 'FAIL - focused an unexpected element') + '\n';
+ }
+});
+
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="branchessafari603branchLayoutTestsfasteventsfocuslabellegendelementshtml"></a>
<div class="addfile"><h4>Added: branches/safari-603-branch/LayoutTests/fast/events/focus-label-legend-elements.html (0 => 210384)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/LayoutTests/fast/events/focus-label-legend-elements.html         (rev 0)
+++ branches/safari-603-branch/LayoutTests/fast/events/focus-label-legend-elements.html        2017-01-05 23:49:17 UTC (rev 210384)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../resources/js-test.js"></script>
+<div id="test-content">
+ <label tabindex="0"><input tabindex="0"></label>
+ <fieldset tabindex="0">
+ <legend tabindex="0">foo</legend>
+ <input tabindex="0">
+ </fieldset>
+</div>
+<script>
+
+description('Tests for calling focus() on a label element and a legend element. They should not move the focus to the associated element.');
+
+let testContent = document.getElementById('test-content');
+shouldBe('testContent.querySelector("label").focus(); document.activeElement', 'testContent.querySelector("label")');
+shouldBe('testContent.querySelector("legend").focus(); document.activeElement', 'testContent.querySelector("legend")');
+
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="branchessafari603branchLayoutTestsfasteventsresourcestabindexfocusblurallframe1html"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/LayoutTests/fast/events/resources/tabindex-focus-blur-all-frame1.html (210383 => 210384)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/LayoutTests/fast/events/resources/tabindex-focus-blur-all-frame1.html        2017-01-05 23:49:12 UTC (rev 210383)
+++ branches/safari-603-branch/LayoutTests/fast/events/resources/tabindex-focus-blur-all-frame1.html        2017-01-05 23:49:17 UTC (rev 210384)
</span><span class="lines">@@ -154,6 +154,7 @@
</span><span class="cx"> <input type="checkbox" id="checkbox1"><br>
</span><span class="cx"> <input type="radio" id="radioChoice1a" name="radio1" tabindex="0"><br>
</span><span class="cx"> <label id="label1" tabindex="-1"><input type="radio" name="radio1">label for radioChoice B</label><br>
</span><ins>+<label id="label2"><input type="radio" name="radio1">label for radioChoice C</label><br>
</ins><span class="cx"> <input type="file" id="file1" tabindex="2"><br>
</span><span class="cx"> input type="hidden"<input type="hidden" id="hidden1" tabindex="-1"><br>
</span><span class="cx"> input type="image"<input type="image" id="inputImage1" src="abe.png" tabindex="3"><br>
</span></span></pre></div>
<a id="branchessafari603branchLayoutTestsfasteventsresourcestabindexfocusblurallframe2html"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/LayoutTests/fast/events/resources/tabindex-focus-blur-all-frame2.html (210383 => 210384)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/LayoutTests/fast/events/resources/tabindex-focus-blur-all-frame2.html        2017-01-05 23:49:12 UTC (rev 210383)
+++ branches/safari-603-branch/LayoutTests/fast/events/resources/tabindex-focus-blur-all-frame2.html        2017-01-05 23:49:17 UTC (rev 210384)
</span><span class="lines">@@ -154,6 +154,7 @@
</span><span class="cx"> <input type="checkbox" id="checkbox3" tabindex="0"><br>
</span><span class="cx"> <input type="radio" id="radioChoice3a" name="radio3"><br>
</span><span class="cx"> <label id="label3" tabindex="2"><input type="radio" name="radio3" tabindex="0">label for radio button</label><br>
</span><ins>+<label id="label4"><input type="radio" name="radio3" tabindex="0">another label for radio button</label><br>
</ins><span class="cx"> <input type="file" id="file3" tabindex="-1"><br>
</span><span class="cx"> input type="hidden"<input type="hidden" id="hidden3" tabindex="3"><br>
</span><span class="cx"> input type="image"<input type="image" id="inputImage3" src="abe.png" tabindex="-1"><br>
</span></span></pre></div>
<a id="branchessafari603branchLayoutTestsfasteventsresourcestabindexfocusbluralljs"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/LayoutTests/fast/events/resources/tabindex-focus-blur-all.js (210383 => 210384)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/LayoutTests/fast/events/resources/tabindex-focus-blur-all.js        2017-01-05 23:49:12 UTC (rev 210383)
+++ branches/safari-603-branch/LayoutTests/fast/events/resources/tabindex-focus-blur-all.js        2017-01-05 23:49:17 UTC (rev 210384)
</span><span class="lines">@@ -55,7 +55,7 @@
</span><span class="cx"> var homeBase = window.frames[1].document.getElementsByClassName('homebase');
</span><span class="cx"> homeBase[0].focus();
</span><span class="cx">
</span><del>- var resultSummary = focusCount+" focus / "+blurCount+" blur events dispatched, and should be 333 / 333 ";
</del><ins>+ var resultSummary = focusCount+" focus / "+blurCount+" blur events dispatched, and should be 336 / 336 ";
</ins><span class="cx"> resultSummary += (focusCount==blurCount) ? "<span style='color:green'>PASSED</span><br>" : "<span style='color:red'>FAILED</span><br>";
</span><span class="cx"> resultSummary += "Total of "+failedTestCount+" focus test(s) failed.";
</span><span class="cx"> if (failedTestCount)
</span><span class="lines">@@ -101,7 +101,7 @@
</span><span class="cx"> function testProgrammaticFocus(elem)
</span><span class="cx"> {
</span><span class="cx"> var elemThatShouldFocus = null;
</span><del>- var OKtoFocusOtherElement = false;
</del><ins>+ var shouldFocusOtherElement = false;
</ins><span class="cx"> focusedElem = null;
</span><span class="cx">
</span><span class="cx"> if (elem.tabIndex == elem.getAttribute("tabindex")) // this means tabindex was explicitly set
</span><span class="lines">@@ -117,13 +117,11 @@
</span><span class="cx"> if (elem.tabIndex == -1 && elem.tagName == "AREA")
</span><span class="cx"> elemThatShouldFocus = null;
</span><span class="cx">
</span><del>- if (tagNamesTransferFocused.find(elem.tagName)) {
- elemThatShouldFocus = null;
- OKtoFocusOtherElement = true;
- }
</del><ins>+ if (tagNamesTransferFocused.find(elem.tagName) && elemThatShouldFocus == null)
+ shouldFocusOtherElement = true;
</ins><span class="cx">
</span><span class="cx"> elem.focus();
</span><del>- if (elemThatShouldFocus == focusedElem || (!elemThatShouldFocus && OKtoFocusOtherElement))
</del><ins>+ if ((!shouldFocusOtherElement && elemThatShouldFocus == focusedElem) || (shouldFocusOtherElement && elem != focusedElem))
</ins><span class="cx"> printToConsole("<"+elem.tagName+"> "+elem.id+" PASSED focus test");
</span><span class="cx"> else {
</span><span class="cx"> failedTestCount++;
</span></span></pre></div>
<a id="branchessafari603branchLayoutTestsfasteventstabindexfocusblurallexpectedtxt"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/LayoutTests/fast/events/tabindex-focus-blur-all-expected.txt (210383 => 210384)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/LayoutTests/fast/events/tabindex-focus-blur-all-expected.txt        2017-01-05 23:49:12 UTC (rev 210383)
+++ branches/safari-603-branch/LayoutTests/fast/events/tabindex-focus-blur-all-expected.txt        2017-01-05 23:49:17 UTC (rev 210384)
</span><span class="lines">@@ -1,2 +1,2 @@
</span><del>-333 focus / 333 blur events dispatched, and should be 333 / 333 PASSED
</del><ins>+336 focus / 336 blur events dispatched, and should be 336 / 336 PASSED
</ins><span class="cx"> Total of 0 focus test(s) failed. PASSED
</span></span></pre></div>
<a id="branchessafari603branchLayoutTestsplatformiossimulatorwk2TestExpectations"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/LayoutTests/platform/ios-simulator-wk2/TestExpectations (210383 => 210384)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/LayoutTests/platform/ios-simulator-wk2/TestExpectations        2017-01-05 23:49:12 UTC (rev 210383)
+++ branches/safari-603-branch/LayoutTests/platform/ios-simulator-wk2/TestExpectations        2017-01-05 23:49:17 UTC (rev 210384)
</span><span class="lines">@@ -1786,6 +1786,7 @@
</span><span class="cx"> fast/shadow-dom/fullscreen-in-shadow-webkitCurrentFullScreenElement.html [ Skip ]
</span><span class="cx"> fast/shadow-dom/fullscreen-in-slot-fullscreenElement.html [ Skip ]
</span><span class="cx"> fast/shadow-dom/fullscreen-in-slot-webkitCurrentFullScreenElement.html [ Skip ]
</span><ins>+fast/events/focus-label-legend-elements-with-tab.html [ Skip ]
</ins><span class="cx">
</span><span class="cx"> # No touch events
</span><span class="cx"> fast/visual-viewport/ios/zoomed-focus-in-fixed.html [ Skip ]
</span></span></pre></div>
<a id="branchessafari603branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebCore/ChangeLog (210383 => 210384)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/Source/WebCore/ChangeLog        2017-01-05 23:49:12 UTC (rev 210383)
+++ branches/safari-603-branch/Source/WebCore/ChangeLog        2017-01-05 23:49:17 UTC (rev 210384)
</span><span class="lines">@@ -1,5 +1,40 @@
</span><span class="cx"> 2017-01-05 Matthew Hanson <matthew_hanson@apple.com>
</span><span class="cx">
</span><ins>+ Merge r210267. rdar://problem/29796608
+
+ 2017-01-03 Ryosuke Niwa <rniwa@webkit.org>
+
+ label element with tabindex >= 0 is not focusable
+ https://bugs.webkit.org/show_bug.cgi?id=102780
+ <rdar://problem/29796608>
+
+ Reviewed by Darin Adler.
+
+ Fixed the bug by removing the override for HTMLLabelElement::isFocusable which always returned false.
+
+ This is a behavior from r5532 but it doesn't match the latest HTML specification or that of Chrome
+ and Firefox.
+
+ Also fixed an existing bug in HTMLLabelElement::focus and HTMLLegendElement::focus which focused
+ the associated form control when there is one even if the element itself is focusable. Without this fix,
+ traversing from control with shift+tab would break since focusing the label would move the focus back
+ to the input element inside the label element.
+
+ Finally, fixed a bug in HTMLLegendElement::focus that we can call inFocus without updating layout first.
+
+ The fix was inspired by https://chromium.googlesource.com/chromium/src/+/085ad8697b1be50c4f93e296797a25a43a79bcfb
+
+ Test: fast/events/focus-label-legend-elements-with-tabindex.html
+
+ * html/HTMLLabelElement.cpp:
+ (WebCore::HTMLLabelElement::focus):
+ (WebCore::HTMLLabelElement::isFocusable): Deleted.
+ * html/HTMLLabelElement.h:
+ * html/HTMLLegendElement.cpp:
+ (WebCore::HTMLLegendElement::focus):
+
+2017-01-05 Matthew Hanson <matthew_hanson@apple.com>
+
</ins><span class="cx"> Merge r210273. rdar://problem/29834093
</span><span class="cx">
</span><span class="cx"> 2017-01-04 Tim Horton <timothy_horton@apple.com>
</span></span></pre></div>
<a id="branchessafari603branchSourceWebCorehtmlHTMLLabelElementcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebCore/html/HTMLLabelElement.cpp (210383 => 210384)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/Source/WebCore/html/HTMLLabelElement.cpp        2017-01-05 23:49:12 UTC (rev 210383)
+++ branches/safari-603-branch/Source/WebCore/html/HTMLLabelElement.cpp        2017-01-05 23:49:17 UTC (rev 210384)
</span><span class="lines">@@ -58,11 +58,6 @@
</span><span class="cx"> return adoptRef(*new HTMLLabelElement(tagName, document));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool HTMLLabelElement::isFocusable() const
-{
- return false;
-}
-
</del><span class="cx"> LabelableElement* HTMLLabelElement::control()
</span><span class="cx"> {
</span><span class="cx"> const AtomicString& controlId = attributeWithoutSynchronization(forAttr);
</span><span class="lines">@@ -150,9 +145,18 @@
</span><span class="cx"> return (element && element->willRespondToMouseClickEvents()) || HTMLElement::willRespondToMouseClickEvents();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void HTMLLabelElement::focus(bool, FocusDirection direction)
</del><ins>+void HTMLLabelElement::focus(bool restorePreviousSelection, FocusDirection direction)
</ins><span class="cx"> {
</span><del>- // to match other browsers, always restore previous selection
</del><ins>+ if (document().haveStylesheetsLoaded()) {
+ document().updateLayout();
+ if (isFocusable()) {
+ // The value of restorePreviousSelection is not used for label elements as it doesn't override updateFocusAppearance.
+ Element::focus(restorePreviousSelection, direction);
+ return;
+ }
+ }
+
+ // To match other browsers, always restore previous selection.
</ins><span class="cx"> if (auto* element = control())
</span><span class="cx"> element->focus(true, direction);
</span><span class="cx"> }
</span></span></pre></div>
<a id="branchessafari603branchSourceWebCorehtmlHTMLLabelElementh"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebCore/html/HTMLLabelElement.h (210383 => 210384)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/Source/WebCore/html/HTMLLabelElement.h        2017-01-05 23:49:12 UTC (rev 210383)
+++ branches/safari-603-branch/Source/WebCore/html/HTMLLabelElement.h        2017-01-05 23:49:17 UTC (rev 210384)
</span><span class="lines">@@ -39,8 +39,6 @@
</span><span class="cx"> private:
</span><span class="cx"> HTMLLabelElement(const QualifiedName&, Document&);
</span><span class="cx">
</span><del>- bool isFocusable() const final;
-
</del><span class="cx"> void accessKeyAction(bool sendMouseEvents) final;
</span><span class="cx">
</span><span class="cx"> // Overridden to update the hover/active state of the corresponding control.
</span></span></pre></div>
<a id="branchessafari603branchSourceWebCorehtmlHTMLLegendElementcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-603-branch/Source/WebCore/html/HTMLLegendElement.cpp (210383 => 210384)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-603-branch/Source/WebCore/html/HTMLLegendElement.cpp        2017-01-05 23:49:12 UTC (rev 210383)
+++ branches/safari-603-branch/Source/WebCore/html/HTMLLegendElement.cpp        2017-01-05 23:49:17 UTC (rev 210384)
</span><span class="lines">@@ -57,13 +57,17 @@
</span><span class="cx"> return descendantsOfType<HTMLFormControlElement>(*enclosingFieldset).first();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void HTMLLegendElement::focus(bool, FocusDirection direction)
</del><ins>+void HTMLLegendElement::focus(bool restorePreviousSelection, FocusDirection direction)
</ins><span class="cx"> {
</span><del>- if (isFocusable())
- Element::focus(true, direction);
-
</del><span class="cx"> // To match other browsers' behavior, never restore previous selection.
</span><del>- if (HTMLFormControlElement* control = associatedControl())
</del><ins>+ if (document().haveStylesheetsLoaded()) {
+ document().updateLayoutIgnorePendingStylesheets();
+ if (isFocusable()) {
+ Element::focus(restorePreviousSelection, direction);
+ return;
+ }
+ }
+ if (auto* control = associatedControl())
</ins><span class="cx"> control->focus(false, direction);
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>