mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Improve inter-document focus handling (#36649)
*Describe the changes that this pull request makes here. This will be the commit message.* rewritten the PR #28571 Implement [Window#focus](https://html.spec.whatwg.org/multipage/#dom-window-focus), [Window#blur](https://html.spec.whatwg.org/multipage/#dom-window-blur) Testing: WPT Fixes: #8981 #9421 --------- Signed-off-by: kongbai1996 <1782765876@qq.com> Co-authored-by: yvt <i@yvt.jp>
This commit is contained in:
parent
27570987fd
commit
0c0ee04b8e
33 changed files with 1123 additions and 242 deletions
|
@ -32,7 +32,7 @@ use crate::dom::bindings::str::DOMString;
|
|||
use crate::dom::characterdata::CharacterData;
|
||||
use crate::dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration, CSSStyleOwner};
|
||||
use crate::dom::customelementregistry::CallbackReaction;
|
||||
use crate::dom::document::{Document, FocusType};
|
||||
use crate::dom::document::{Document, FocusInitiator};
|
||||
use crate::dom::documentfragment::DocumentFragment;
|
||||
use crate::dom::domstringmap::DOMStringMap;
|
||||
use crate::dom::element::{AttributeMutation, Element};
|
||||
|
@ -415,18 +415,19 @@ impl HTMLElementMethods<crate::DomTypeHolder> for HTMLElement {
|
|||
// TODO: Mark the element as locked for focus and run the focusing steps.
|
||||
// https://html.spec.whatwg.org/multipage/#focusing-steps
|
||||
let document = self.owner_document();
|
||||
document.request_focus(Some(self.upcast()), FocusType::Element, can_gc);
|
||||
document.request_focus(Some(self.upcast()), FocusInitiator::Local, can_gc);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-blur
|
||||
fn Blur(&self, can_gc: CanGc) {
|
||||
// TODO: Run the unfocusing steps.
|
||||
// TODO: Run the unfocusing steps. Focus the top-level document, not
|
||||
// the current document.
|
||||
if !self.as_element().focus_state() {
|
||||
return;
|
||||
}
|
||||
// https://html.spec.whatwg.org/multipage/#unfocusing-steps
|
||||
let document = self.owner_document();
|
||||
document.request_focus(None, FocusType::Element, can_gc);
|
||||
document.request_focus(None, FocusInitiator::Local, can_gc);
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom-view/#dom-htmlelement-offsetparent
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue