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>();

View file

@ -10,8 +10,8 @@ interface HTMLDialogElement : HTMLElement {
[CEReactions]
attribute boolean open;
attribute DOMString returnValue;
// [CEReactions]
// void show();
[CEReactions]
undefined show();
// [CEReactions]
// void showModal();
[CEReactions]

View file

@ -1,3 +0,0 @@
[dialog-close-event.html]
[Test that dialog receives a close event upon closing.]
expected: FAIL

View file

@ -1,7 +1,4 @@
[dialog-focus-previous-outside.html]
[Focus should not be restored if the currently focused element is not inside the dialog.]
expected: FAIL
[Focus restore should not occur when the focused element is in a shadowroot outside of the dialog.]
expected: FAIL

View file

@ -1,6 +1,3 @@
[dialog-focusing-steps-disconnected.html]
[dialog.show(): focusing steps should not change focus on disconnected <dialog>]
expected: FAIL
[dialog.showModal() should throw on disconnected <dialog>]
expected: FAIL

View file

@ -1,6 +1,3 @@
[dialog-focusing-steps-inert.html]
[dialog.show(): focusing steps should not change focus when dialog is inert]
expected: FAIL
[dialog.showModal(): focusing steps should apply focus fixup rule when dialog is inert]
expected: FAIL

View file

@ -1,4 +0,0 @@
[dialog-focusing-steps-prevent-autofocus.html]
[After showing a dialog, non-dialog autofocus processing won't work.]
expected: FAIL

View file

@ -1,3 +0,0 @@
[dialog-open-2.html]
[Tests that dialog is visible after show() is called and not visible after close() is called.]
expected: FAIL

View file

@ -1,4 +0,0 @@
[dialog-return-value.html]
[Tests dialog.returnValue is settable and returns the last value set.]
expected: FAIL

View file

@ -1,7 +1,4 @@
[modal-dialog-in-visibility-hidden.html]
[Non-modal dialog should let parent visibility inherit]
expected: FAIL
[Modal dialog should have visibility: visible by default in UA sheet]
expected: FAIL

View file

@ -1,3 +0,0 @@
[non-modal-dialog-layout.html]
[Tests layout of non-modal dialogs.]
expected: FAIL

View file

@ -1,3 +1,3 @@
[submit-dialog-close-event.html]
[Tests submitting a dialog on a close event triggered by a previous submission.]
expected: FAIL
expected: TIMEOUT

View file

@ -3165,9 +3165,6 @@
[HTMLTableElement interface: attribute summary]
expected: FAIL
[HTMLDialogElement interface: operation show()]
expected: FAIL
[HTMLUListElement interface: attribute type]
expected: FAIL

View file

@ -3,4 +3,4 @@
expected: FAIL
[<dialog>-contained autofocus element gets focused when the dialog is shown]
expected: FAIL
expected: TIMEOUT

View file

@ -1,3 +0,0 @@
[dialog-close-event.html]
[Test that dialog receives a close event upon closing.]
expected: FAIL

View file

@ -1,7 +1,4 @@
[dialog-focus-previous-outside.html]
[Focus should not be restored if the currently focused element is not inside the dialog.]
expected: FAIL
[Focus restore should not occur when the focused element is in a shadowroot outside of the dialog.]
expected: FAIL

View file

@ -1,6 +1,3 @@
[dialog-focusing-steps-disconnected.html]
[dialog.show(): focusing steps should not change focus on disconnected <dialog>]
expected: FAIL
[dialog.showModal() should throw on disconnected <dialog>]
expected: FAIL

View file

@ -1,6 +1,3 @@
[dialog-focusing-steps-inert.html]
[dialog.show(): focusing steps should not change focus when dialog is inert]
expected: FAIL
[dialog.showModal(): focusing steps should apply focus fixup rule when dialog is inert]
expected: FAIL

View file

@ -1,3 +0,0 @@
[dialog-focusing-steps-prevent-autofocus.html]
[After showing a dialog, non-dialog autofocus processing won't work.]
expected: FAIL

View file

@ -1,3 +0,0 @@
[dialog-open-2.html]
[Tests that dialog is visible after show() is called and not visible after close() is called.]
expected: FAIL

View file

@ -1,3 +0,0 @@
[dialog-return-value.html]
[Tests dialog.returnValue is settable and returns the last value set.]
expected: FAIL

View file

@ -1,7 +1,4 @@
[modal-dialog-in-visibility-hidden.html]
[Non-modal dialog should let parent visibility inherit]
expected: FAIL
[Modal dialog should have visibility: visible by default in UA sheet]
expected: FAIL

View file

@ -1,3 +0,0 @@
[non-modal-dialog-layout.html]
[Tests layout of non-modal dialogs.]
expected: FAIL

View file

@ -1,3 +1,4 @@
[submit-dialog-close-event.html]
expected: TIMEOUT
[Tests submitting a dialog on a close event triggered by a previous submission.]
expected: FAIL
expected: TIMEOUT