From dab0b6a363a3ca0cef28a6bbb0c0097aedfff719 Mon Sep 17 00:00:00 2001 From: Tim Nguyen Date: Mon, 5 Jun 2023 22:15:39 -0700 Subject: [PATCH] Popover: check dialog's is modal flag instead of open attribute The following case currently does not fail dialog.showModal(); dialog.open = false; dialog.showPopover(); even though it is a top layer conflict: 1. showModal() pushes to the top layer. 2. open = false then hides the dialog, while keeping it in top layer. 3. showPopover() pushes to the top layer again. The check for the open attribute is supposed to prevent top layer conflicts, since those conflicts can leave the element in a broken state, notably after hiding. For instance, the previous sequence of actions followed by dialog.hidePopover() will leave the is modal flag set to true despite the dialog being completely removed from the top layer. Also only remove from top layer in HTMLDialogElement.prototype.close() when the is modal flag is true to prevent that method from removing popovers from the top layer. For dialog.close() to be symmetric & consistent with dialog.show(), we also stop throwing when show() is called on a dialog in the popover showing state. Tests: https://github.com/WebKit/WebKit/pull/14454. Fixes #9335. --- source | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/source b/source index 69a624c5c90..bbdb777f823 100644 --- a/source +++ b/source @@ -60325,10 +60325,6 @@ interface HTMLDialogElement : HTMLElement {
  • If this has an open attribute, then throw an "InvalidStateError" DOMException.

  • -
  • If this is in the popover showing - state, then throw an "InvalidStateError" - DOMException.

  • -
  • Add an open attribute to this, whose value is the empty string.

  • @@ -60453,14 +60449,14 @@ interface HTMLDialogElement : HTMLElement {
  • Remove subject's open attribute.

  • +
  • If the is modal flag of subject is true, then remove it from its Document's top layer.

  • +
  • Set the is modal flag of subject to false.

  • If result is not null, then set the returnValue attribute to result.

  • -
  • If subject is in its Document's top layer, then remove it.

  • -
  • If subject's previously focused element is not null, then:

    @@ -82957,8 +82953,8 @@ dictionary DragEventInit : MouseEventInit {

  • expectedDocument is not null and element's node document is not expectedDocument

  • -
  • element is a dialog element and has an open attribute

  • +
  • element is a dialog element and its is modal flag + is set to true.

  • element's fullscreen flag is set