Partially implement dialog.show() (#32681)

Signed-off-by: Luke Warlow <lwarlow@igalia.com>
This commit is contained in:
Luke Warlow 2024-07-26 17:03:25 +01:00 committed by GitHub
parent 902bf57331
commit 8f377a0cb1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 32 additions and 65 deletions

View file

@ -11,7 +11,7 @@ use crate::dom::bindings::codegen::Bindings::HTMLDialogElementBinding::HTMLDialo
use crate::dom::bindings::inheritance::Castable;
use crate::dom::bindings::root::DomRoot;
use crate::dom::bindings::str::DOMString;
use crate::dom::document::Document;
use crate::dom::document::{Document, FocusType};
use crate::dom::element::Element;
use crate::dom::eventtarget::EventTarget;
use crate::dom::htmlelement::HTMLElement;
@ -70,6 +70,31 @@ impl HTMLDialogElementMethods for HTMLDialogElement {
*self.return_value.borrow_mut() = return_value;
}
/// <https://html.spec.whatwg.org/multipage/#dom-dialog-show>
fn Show(&self) {
let element = self.upcast::<Element>();
// Step 1 TODO: Check is modal flag is false
if element.has_attribute(&local_name!("open")) {
return;
}
// TODO: Step 2 If this has an open attribute, then throw an "InvalidStateError" DOMException.
// Step 3
element.set_bool_attribute(&local_name!("open"), true);
// TODO: Step 4 Set this's previously focused element to the focused element.
// TODO: Step 5 Let hideUntil be the result of running topmost popover ancestor given this, null, and false.
// TODO: Step 6 If hideUntil is null, then set hideUntil to this's node document.
// TODO: Step 7 Run hide all popovers until given hideUntil, false, and true.
// TODO(Issue #32702): Step 8 Run the dialog focusing steps given this.
}
// https://html.spec.whatwg.org/multipage/#dom-dialog-close
fn Close(&self, return_value: Option<DOMString>) {
let element = self.upcast::<Element>();