Bug 237273
Summary: | Implement focus fixup rule | ||
---|---|---|---|
Product: | WebKit | Reporter: | Tim Nguyen (:ntim) <ntim> |
Component: | DOM | Assignee: | Ryosuke Niwa <rniwa> |
Status: | RESOLVED FIXED | ||
Severity: | Normal | CC: | ahmad.saleem792, emilio, rniwa, webkit-bug-importer |
Priority: | P2 | Keywords: | InRadar |
Version: | WebKit Nightly Build | ||
Hardware: | Unspecified | ||
OS: | Unspecified |
Tim Nguyen (:ntim)
https://html.spec.whatwg.org/multipage/interaction.html#focus-fixup-rule
Focus fixup rule: When the designated focused area of the document is removed from that Document in some way (e.g. it stops being a focusable area, it is removed from the DOM, it becomes inert, etc.), designate the Document's viewport to be the new focused area of the document.
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Tim Nguyen (:ntim)
Adding this seems to work:
```
if (auto* activeElement = document.activeElement()) {
if (!activeElement->isFocusable())
document.setFocusedElement(nullptr);
}
```
I put it in the RenderingUpdateStep::FlushAutofocusCandidates block, but that's probably not the right place (not sure which one is?).
One thing that's broken is interaction with shadow DOM: shadow-dom/focus/focus-pseudo-on-shadow-host-1.html fails. This is precisely because activeElement->isFocusable() doesn't take in account contents of the shadow DOM, and wrongly clears focus in this case. Though I expect that's not too hard to fix.
Tim Nguyen (:ntim)
imported/w3c/web-platform-tests/inert/dynamic-inert-on-focused-element.tentative.html tests this functionality.
I'm actually a bit surprised there aren't more tests (e.g. moving out of a focusable area, disabled attribute, etc.)
Radar WebKit Bug Importer
<rdar://problem/89902824>
Ahmad Saleem
Safari TP 151 is still failing these tests:
https://wpt.fyi/results/inert/dynamic-inert-on-focused-element.html?label=master&label=experimental&aligned&view=subtest&q=dynamic-inert-on-focused-element
Tim Nguyen (:ntim)
Pull request: https://github.com/WebKit/WebKit/pull/6069
Ryosuke Niwa
Pull request: https://github.com/WebKit/WebKit/pull/9835
EWS
Committed 260067@main (71bc5343fd7b): <https://commits.webkit.org/260067@main>
Reviewed commits have been landed. Closing PR #9835 and removing active labels.