Changeset 210267 in webkit
- Timestamp:
- Jan 3, 2017 7:39:39 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r210266 r210267 1 2017-01-03 Ryosuke Niwa <rniwa@webkit.org> 2 3 label element with tabindex >= 0 is not focusable 4 https://bugs.webkit.org/show_bug.cgi?id=102780 5 <rdar://problem/29796608> 6 7 Reviewed by Darin Adler. 8 9 Added a regression test for traversing label and legend elements by tabbing. 10 A native merge of the blink fix would have regressed this for the label element 11 while the bug in the legend element had always existed. 12 13 Also added a regression test for focusing label and legend elements with tabindex. 14 We should be able to focus either element. New behavior matches that of Chrome. 15 Firefox moves the focus to the label element like we used to before this patch. 16 17 Also merge the test fix from https://chromium.googlesource.com/chromium/src/+/085ad8697b1be50c4f93e296797a25a43a79bcfb 18 19 * fast/events/focus-label-legend-elements-expected.txt: Added. 20 * fast/events/focus-label-legend-elements-with-tab-expected.txt: Added. 21 * fast/events/focus-label-legend-elements-with-tab.html: Added. 22 * fast/events/focus-label-legend-elements.html: Added. 23 * fast/events/resources/tabindex-focus-blur-all-frame1.html: 24 * fast/events/resources/tabindex-focus-blur-all-frame2.html: 25 * fast/events/resources/tabindex-focus-blur-all.js: 26 * fast/events/tabindex-focus-blur-all-expected.txt: 27 * platform/ios-simulator-wk2/TestExpectations: 28 1 29 2017-01-03 Tim Horton <timothy_horton@apple.com> 2 30 -
trunk/LayoutTests/fast/events/resources/tabindex-focus-blur-all-frame1.html
r205858 r210267 155 155 <input type="radio" id="radioChoice1a" name="radio1" tabindex="0"><br> 156 156 <label id="label1" tabindex="-1"><input type="radio" name="radio1">label for radioChoice B</label><br> 157 <label id="label2"><input type="radio" name="radio1">label for radioChoice C</label><br> 157 158 <input type="file" id="file1" tabindex="2"><br> 158 159 input type="hidden"<input type="hidden" id="hidden1" tabindex="-1"><br> -
trunk/LayoutTests/fast/events/resources/tabindex-focus-blur-all-frame2.html
r205858 r210267 155 155 <input type="radio" id="radioChoice3a" name="radio3"><br> 156 156 <label id="label3" tabindex="2"><input type="radio" name="radio3" tabindex="0">label for radio button</label><br> 157 <label id="label4"><input type="radio" name="radio3" tabindex="0">another label for radio button</label><br> 157 158 <input type="file" id="file3" tabindex="-1"><br> 158 159 input type="hidden"<input type="hidden" id="hidden3" tabindex="3"><br> -
trunk/LayoutTests/fast/events/resources/tabindex-focus-blur-all.js
r147676 r210267 56 56 homeBase[0].focus(); 57 57 58 var resultSummary = focusCount+" focus / "+blurCount+" blur events dispatched, and should be 33 3 / 333";58 var resultSummary = focusCount+" focus / "+blurCount+" blur events dispatched, and should be 336 / 336 "; 59 59 resultSummary += (focusCount==blurCount) ? "<span style='color:green'>PASSED</span><br>" : "<span style='color:red'>FAILED</span><br>"; 60 60 resultSummary += "Total of "+failedTestCount+" focus test(s) failed."; … … 102 102 { 103 103 var elemThatShouldFocus = null; 104 var OKtoFocusOtherElement = false;104 var shouldFocusOtherElement = false; 105 105 focusedElem = null; 106 106 … … 118 118 elemThatShouldFocus = null; 119 119 120 if (tagNamesTransferFocused.find(elem.tagName)) { 121 elemThatShouldFocus = null; 122 OKtoFocusOtherElement = true; 123 } 120 if (tagNamesTransferFocused.find(elem.tagName) && elemThatShouldFocus == null) 121 shouldFocusOtherElement = true; 124 122 125 123 elem.focus(); 126 if ( elemThatShouldFocus == focusedElem || (!elemThatShouldFocus && OKtoFocusOtherElement))124 if ((!shouldFocusOtherElement && elemThatShouldFocus == focusedElem) || (shouldFocusOtherElement && elem != focusedElem)) 127 125 printToConsole("<"+elem.tagName+"> "+elem.id+" PASSED focus test"); 128 126 else { -
trunk/LayoutTests/fast/events/tabindex-focus-blur-all-expected.txt
r95381 r210267 1 33 3 focus / 333 blur events dispatched, and should be 333 / 333PASSED1 336 focus / 336 blur events dispatched, and should be 336 / 336 PASSED 2 2 Total of 0 focus test(s) failed. PASSED -
trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations
r210143 r210267 1767 1767 fast/shadow-dom/fullscreen-in-slot-fullscreenElement.html [ Skip ] 1768 1768 fast/shadow-dom/fullscreen-in-slot-webkitCurrentFullScreenElement.html [ Skip ] 1769 fast/events/focus-label-legend-elements-with-tab.html [ Skip ] 1769 1770 1770 1771 # No touch events -
trunk/Source/WebCore/ChangeLog
r210266 r210267 1 2017-01-03 Ryosuke Niwa <rniwa@webkit.org> 2 3 label element with tabindex >= 0 is not focusable 4 https://bugs.webkit.org/show_bug.cgi?id=102780 5 <rdar://problem/29796608> 6 7 Reviewed by Darin Adler. 8 9 Fixed the bug by removing the override for HTMLLabelElement::isFocusable which always returned false. 10 11 This is a behavior from r5532 but it doesn't match the latest HTML specification or that of Chrome 12 and Firefox. 13 14 Also fixed an existing bug in HTMLLabelElement::focus and HTMLLegendElement::focus which focused 15 the associated form control when there is one even if the element itself is focusable. Without this fix, 16 traversing from control with shift+tab would break since focusing the label would move the focus back 17 to the input element inside the label element. 18 19 Finally, fixed a bug in HTMLLegendElement::focus that we can call inFocus without updating layout first. 20 21 The fix was inspired by https://chromium.googlesource.com/chromium/src/+/085ad8697b1be50c4f93e296797a25a43a79bcfb 22 23 Test: fast/events/focus-label-legend-elements-with-tabindex.html 24 25 * html/HTMLLabelElement.cpp: 26 (WebCore::HTMLLabelElement::focus): 27 (WebCore::HTMLLabelElement::isFocusable): Deleted. 28 * html/HTMLLabelElement.h: 29 * html/HTMLLegendElement.cpp: 30 (WebCore::HTMLLegendElement::focus): 31 1 32 2017-01-03 Tim Horton <timothy_horton@apple.com> 2 33 -
trunk/Source/WebCore/html/HTMLLabelElement.cpp
r206332 r210267 57 57 { 58 58 return adoptRef(*new HTMLLabelElement(tagName, document)); 59 }60 61 bool HTMLLabelElement::isFocusable() const62 {63 return false;64 59 } 65 60 … … 151 146 } 152 147 153 void HTMLLabelElement::focus(bool , FocusDirection direction)148 void HTMLLabelElement::focus(bool restorePreviousSelection, FocusDirection direction) 154 149 { 155 // to match other browsers, always restore previous selection 150 if (document().haveStylesheetsLoaded()) { 151 document().updateLayout(); 152 if (isFocusable()) { 153 // The value of restorePreviousSelection is not used for label elements as it doesn't override updateFocusAppearance. 154 Element::focus(restorePreviousSelection, direction); 155 return; 156 } 157 } 158 159 // To match other browsers, always restore previous selection. 156 160 if (auto* element = control()) 157 161 element->focus(true, direction); -
trunk/Source/WebCore/html/HTMLLabelElement.h
r206332 r210267 40 40 HTMLLabelElement(const QualifiedName&, Document&); 41 41 42 bool isFocusable() const final;43 44 42 void accessKeyAction(bool sendMouseEvents) final; 45 43 -
trunk/Source/WebCore/html/HTMLLegendElement.cpp
r177996 r210267 58 58 } 59 59 60 void HTMLLegendElement::focus(bool , FocusDirection direction)60 void HTMLLegendElement::focus(bool restorePreviousSelection, FocusDirection direction) 61 61 { 62 if (isFocusable())63 Element::focus(true, direction);64 65 62 // To match other browsers' behavior, never restore previous selection. 66 if (HTMLFormControlElement* control = associatedControl()) 63 if (document().haveStylesheetsLoaded()) { 64 document().updateLayoutIgnorePendingStylesheets(); 65 if (isFocusable()) { 66 Element::focus(restorePreviousSelection, direction); 67 return; 68 } 69 } 70 if (auto* control = associatedControl()) 67 71 control->focus(false, direction); 68 72 }
Note: See TracChangeset
for help on using the changeset viewer.