From d55424e88f732c663d1ec988a3fbe98d6c9a89e5 Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Fri, 12 Jun 2020 18:19:49 -0400 Subject: [PATCH] Update document focus when element focusability changes. --- components/script/dom/document.rs | 11 +++ components/script/dom/element.rs | 72 ++++++++++++++++++- components/script/dom/htmlbuttonelement.rs | 1 + components/script/dom/htmlelement.rs | 56 +-------------- components/script/dom/htmlfieldsetelement.rs | 3 + components/script/dom/htmlinputelement.rs | 2 + components/script/dom/htmltextareaelement.rs | 1 + .../focus-fixup-rule-one-no-dialogs.html.ini | 15 ---- 8 files changed, 89 insertions(+), 72 deletions(-) diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 97ca60af115..385f7c2139e 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -1025,6 +1025,17 @@ impl Document { *self.focus_transaction.borrow_mut() = FocusTransaction::InTransaction(Default::default()); } + /// + pub(crate) fn perform_focus_fixup_rule(&self, not_focusable: &Element) { + if Some(not_focusable) != self.focused.get().as_ref().map(|e| &**e) { + return; + } + self.request_focus( + self.GetBody().as_ref().map(|e| &*e.upcast()), + FocusType::Element, + ) + } + /// Request that the given element receive focus once the current transaction is complete. /// If None is passed, then whatever element is currently focused will no longer be focused /// once the transaction is complete. diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 458f301e238..5518ddd3837 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -1300,12 +1300,12 @@ impl Element { if self.is_actually_disabled() { return false; } - // TODO: Check whether the element is being rendered (i.e. not hidden). let node = self.upcast::(); if node.get_flag(NodeFlags::SEQUENTIALLY_FOCUSABLE) { return true; } - // https://html.spec.whatwg.org/multipage/#specially-focusable + + // , , ,