Changeset 274365 in webkit
- Timestamp:
- Mar 12, 2021 11:03:26 AM (16 months ago)
- Location:
- trunk
- Files:
-
- 2 added
- 6 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-visible-001.html (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-visible-019-expected.txt (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-visible-019.html (added)
-
LayoutTests/platform/ios/TestExpectations (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/page/EventHandler.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r274359 r274365 1 2021-03-12 Manuel Rego Casasnovas <rego@igalia.com> 2 3 [selectors] :focus-visible matches body after keyboard event 4 https://bugs.webkit.org/show_bug.cgi?id=223113 5 6 Reviewed by Antti Koivisto. 7 8 * platform/ios/TestExpectations: Skip new test for iOS. 9 1 10 2021-03-12 Robert Jenner <jenner@apple.com> 2 11 -
trunk/LayoutTests/imported/w3c/ChangeLog
r274355 r274365 1 2021-03-12 Manuel Rego Casasnovas <rego@igalia.com> 2 3 [selectors] :focus-visible matches body after keyboard event 4 https://bugs.webkit.org/show_bug.cgi?id=223113 5 6 Reviewed by Antti Koivisto. 7 8 * web-platform-tests/css/selectors/focus-visible-001.html: Modify the test to verify 9 that only the element matches :focus-visible (and not the body). 10 * web-platform-tests/css/selectors/focus-visible-019-expected.txt: Added. 11 * web-platform-tests/css/selectors/focus-visible-019.html: Added new test to check script focus in keyboard event, 12 and that again only the element matches :focus-visible (and not the body). 13 1 14 2021-03-12 Antoine Quint <graouts@webkit.org> 2 15 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-visible-001.html
r271395 r274365 40 40 <script> 41 41 async_test(function(t) { 42 el.addEventListener("focus", t.step_func (function() {42 el.addEventListener("focus", t.step_func_done(function() { 43 43 assert_equals(getComputedStyle(el).outlineColor, "rgb(0, 128, 0)", `outlineColor for ${el.tagName}#${el.id} should be green`); 44 44 assert_not_equals(getComputedStyle(el).backgroundColor, "rgb(255, 0, 0)", `backgroundColor for ${el.tagName}#${el.id} should NOT be red`); 45 t.done(); 45 46 let focusVisiblePseudoAll = document.querySelectorAll(':focus-visible'); 47 assert_equals(focusVisiblePseudoAll.length, 1, "Only 1 element matches ':focus-visible'"); 48 let focusVisiblePseudo = document.querySelector(':focus-visible'); 49 assert_equals(el, focusVisiblePseudo, "${el.tagName}#${el.id} matches ':focus-visible'"); 46 50 })); 47 51 const tab_key = '\ue004'; -
trunk/LayoutTests/platform/ios/TestExpectations
r274244 r274365 3396 3396 webkit.org/b/209734 imported/w3c/web-platform-tests/css/selectors/focus-visible-012.html [ Skip ] 3397 3397 webkit.org/b/209734 imported/w3c/web-platform-tests/css/selectors/focus-visible-013.html [ Skip ] 3398 webkit.org/b/209734 imported/w3c/web-platform-tests/css/selectors/focus-visible-019.html [ Skip ] 3398 3399 webkit.org/b/209734 imported/w3c/web-platform-tests/css/selectors/hover-002.html [ Skip ] 3399 3400 -
trunk/Source/WebCore/ChangeLog
r274362 r274365 1 2021-03-12 Manuel Rego Casasnovas <rego@igalia.com> 2 3 [selectors] :focus-visible matches body after keyboard event 4 https://bugs.webkit.org/show_bug.cgi?id=223113 5 6 Reviewed by Antti Koivisto. 7 8 Fix the bug with some changes in EventHandler::internalKeyEvent(). 9 When you use TAB (or other key) the |element| variable in this method is the document body, 10 however that element is not focused (element->focused() is false). 11 Before this patch we were marking the element as matchin :focus-visible, 12 however we shouldn't do that if the element is not focused (added a condition to avoid doing that). 13 14 Apart from that this patch also fixes a related issue, if a keyboard event handler is changing focus via script 15 there's a part of this method that takes care of updating the |element| variable. 16 In that case we have to remove :focus-visible flag from the previous element, and add it to the new one. 17 18 Test: imported/w3c/web-platform-tests/css/selectors/focus-visible-001.html 19 Test: imported/w3c/web-platform-tests/css/selectors/focus-visible-019.html 20 21 * page/EventHandler.cpp: 22 (WebCore::EventHandler::internalKeyEvent): 23 1 24 2021-03-12 Alex Christensen <achristensen@webkit.org> 2 25 -
trunk/Source/WebCore/page/EventHandler.cpp
r274352 r274365 3534 3534 keydown->setTarget(element); 3535 3535 3536 // If the user interacts with the page via the keyboard, the currently focused element should match :focus-visible. 3537 // Just typing a modifier key is not considered user interaction with the page, but Shift + a (or Caps Lock + a) is considered an interaction. 3538 if (keydown->modifierKeys().isEmpty() || ((keydown->shiftKey() || keydown->capsLockKey()) && !initialKeyEvent.text().isEmpty())) 3539 element->setHasFocusVisible(true); 3536 auto shouldMatchFocusVisible = [initialKeyEvent, keydown](const Element& element) { 3537 if (!element.focused()) 3538 return false; 3539 3540 // If the user interacts with the page via the keyboard, the currently focused element should match :focus-visible. 3541 // Just typing a modifier key is not considered user interaction with the page, but Shift + a (or Caps Lock + a) is considered an interaction. 3542 return keydown->modifierKeys().isEmpty() || ((keydown->shiftKey() || keydown->capsLockKey()) && !initialKeyEvent.text().isEmpty()); 3543 }; 3544 element->setHasFocusVisible(shouldMatchFocusVisible(*element)); 3540 3545 3541 3546 if (initialKeyEvent.type() == PlatformEvent::RawKeyDown) { … … 3584 3589 // But if we are dispatching a fake backward compatibility keypress, then we pretend that the keypress happened on the original element. 3585 3590 if (!keydownResult) { 3591 element->setHasFocusVisible(false); 3586 3592 element = eventTargetElementForDocument(m_frame.document()); 3587 3593 if (!element) 3588 3594 return false; 3595 element->setHasFocusVisible(shouldMatchFocusVisible(*element)); 3589 3596 } 3590 3597
Note: See TracChangeset
for help on using the changeset viewer.