From 573442ffe3b924b15f5e081cb53e3f72cb9d01af Mon Sep 17 00:00:00 2001 From: Joey Arhar Date: Wed, 31 Jan 2024 07:32:32 -0800 Subject: [PATCH 1/5] Allow top layer elements to be nested within popovers Fixes https://github.com/whatwg/html/issues/9998 Implemented in chromium here: https://chromium-review.googlesource.com/c/chromium/src/+/5229300 --- source | 61 ++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 14 deletions(-) diff --git a/source b/source index dffcc9efcd2..f87e8c8574e 100644 --- a/source +++ b/source @@ -61121,8 +61121,11 @@ interface HTMLDialogElement : HTMLElement {
  • Set this's previously focused element to the focused element.

  • -
  • Run hide all popovers given this's node - document.

  • +
  • Let hideUntil be the result of running topmost popover ancestor + given this, null, and false.

  • + +
  • Run hide all popovers until given + hideUntil, false, and true.

  • Run the dialog focusing steps given this.

  • @@ -61184,8 +61187,11 @@ interface HTMLDialogElement : HTMLElement {
  • Set this's previously focused element to the focused element.

  • -
  • Run hide all popovers given this's node - document.

  • +
  • Let hideUntil be the result of running topmost popover ancestor + given this, null, and false.

  • + +
  • Run hide all popovers until given + hideUntil, false, and true.

  • Run the dialog focusing steps given this.

  • @@ -84446,7 +84452,7 @@ dictionary DragEventInit : MouseEventInit { data-x="popover-showing-state">showing; otherwise false.

    -

    To hide all popovers until, given an To hide all popovers until, given an HTML element or Document endpoint, a boolean focusPreviousElement, and a boolean fireEvents:

    @@ -84538,10 +84544,10 @@ dictionary DragEventInit : MouseEventInit { hide all popovers until given document, false, and false.

    -

    To find the topmost popover ancestor, given a Node - newPopover, and an HTML element or null - invoker, perform the following steps. They return an HTML element or null.

    +

    To find the topmost popover ancestor, given a Node + newPopoverOrTopLayerElement, an HTML element or + null invoker, and a boolean isPopover, perform the following steps. They + return an HTML element or null.

    The topmost popover ancestor algorithm will return the topmost (latest in the @@ -84569,11 +84575,38 @@ dictionary DragEventInit : MouseEventInit {

      +
    1. +

      If isPopover is true:

      + +
        +
      1. Assert: newPopoverOrTopLayerElement is an HTML element.

      2. + +
      3. Assert: newPopoverOrTopLayerElement's popover attribute is not in the no popover state or the manual state.

      4. + +
      5. Assert: newPopoverOrTopLayerElement's popover visibility + state is not in the popover showing + state.

      6. +
      +
    2. + +
    3. +

      Otherwise:

      + +
        +
      1. Assert: invoker is null.

      2. +
      +
    4. +
    5. Let popoverPositions be an empty ordered map.

    6. Let index be 0.

    7. -
    8. Let document be newPopover's node document.

    9. +
    10. Let document be newPopoverOrTopLayerElement's node + document.

    11. For each popover of document's showing auto popover @@ -84587,8 +84620,8 @@ dictionary DragEventInit : MouseEventInit {

    -
  • Set popoverPositions[newPopover] to - index.

  • +
  • If isPopover is true, then Set + popoverPositions[newPopoverOrTopLayerElement] to index.

  • Increment index by 1.

  • @@ -84616,8 +84649,8 @@ dictionary DragEventInit : MouseEventInit { -
  • Run checkAncestor given newPopover's parent node within the - flat tree.

  • +
  • Run checkAncestor given newPopoverOrTopLayerElement's parent node + within the flat tree.

  • Run checkAncestor given invoker.

  • From 726f18704eb3b938bb01a1241948f9c618e985bf Mon Sep 17 00:00:00 2001 From: Joey Arhar Date: Tue, 6 Feb 2024 11:56:08 -0800 Subject: [PATCH 2/5] fix null hideUntil --- source | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source b/source index f87e8c8574e..12b7db1b6ef 100644 --- a/source +++ b/source @@ -61124,6 +61124,9 @@ interface HTMLDialogElement : HTMLElement {
  • Let hideUntil be the result of running topmost popover ancestor given this, null, and false.

  • +
  • If hideUntil is null, then set hideUntil to this's + node document.

  • +
  • Run hide all popovers until given hideUntil, false, and true.

  • @@ -61190,6 +61193,9 @@ interface HTMLDialogElement : HTMLElement {
  • Let hideUntil be the result of running topmost popover ancestor given this, null, and false.

  • +
  • If hideUntil is null, then set hideUntil to this's + node document.

  • +
  • Run hide all popovers until given hideUntil, false, and true.

  • From fefa64ee810120a0fc7e12b7cc3f4391326584d2 Mon Sep 17 00:00:00 2001 From: Joey Arhar Date: Tue, 6 Feb 2024 12:06:55 -0800 Subject: [PATCH 3/5] update note for ancestor popover --- source | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source b/source index 12b7db1b6ef..07be4e3909a 100644 --- a/source +++ b/source @@ -84557,10 +84557,10 @@ dictionary DragEventInit : MouseEventInit {

    The topmost popover ancestor algorithm will return the topmost (latest in the - showing auto popover list) ancestor popover for the provided popover. Popovers can - be related to each other in several ways, creating a tree of popovers. There are two paths - through which one popover (call it the "child" popover) can have a topmost ancestor popover (call - it the "parent" popover):

    + showing auto popover list) ancestor popover for the provided popover or top layer + element. Popovers can be related to each other in several ways, creating a tree of popovers. + There are two paths through which one popover (call it the "child" popover) can have a topmost + ancestor popover (call it the "parent" popover):

    1. The popovers are nested within each other in the node tree. In this case, the descendant @@ -84578,6 +84578,10 @@ dictionary DragEventInit : MouseEventInit { containing an invoking element that points back to the containing popover), and it allows for the construction of a well-formed tree from the (possibly cyclic) graph of connections. Only auto popovers are considered.

      + +

      If the provided element is a top layer element such as a dialog which is not + showing as a popover, then topmost popover ancestor will only look in the node tree + to find the first popover.

      From 001b4bc0fb49efb371e5b0b34e3aa1ed504172b3 Mon Sep 17 00:00:00 2001 From: Joey Arhar Date: Tue, 6 Feb 2024 13:00:54 -0800 Subject: [PATCH 4/5] capitalization --- source | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source b/source index 07be4e3909a..b80ea169b23 100644 --- a/source +++ b/source @@ -84630,7 +84630,7 @@ dictionary DragEventInit : MouseEventInit {
    -
  • If isPopover is true, then Set +

  • If isPopover is true, then set popoverPositions[newPopoverOrTopLayerElement] to index.

  • Increment index by 1.

  • @@ -84664,7 +84664,7 @@ dictionary DragEventInit : MouseEventInit {
  • Run checkAncestor given invoker.

  • -
  • return topmostPopoverAncestor.

  • +
  • Return topmostPopoverAncestor.

  • To find the nearest inclusive open popover given a Node From 86e134a902992c010613034b80b774efec1458db Mon Sep 17 00:00:00 2001 From: Joey Arhar Date: Fri, 9 Feb 2024 09:57:29 -0800 Subject: [PATCH 5/5] remove hide all popovers --- source | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/source b/source index b80ea169b23..8b153f829a2 100644 --- a/source +++ b/source @@ -84194,7 +84194,7 @@ dictionary DragEventInit : MouseEventInit { data-x="attr-popover">popover attribute.

  • Let ancestor be the result of running the topmost popover - ancestor algorithm given element and invoker.

  • + ancestor algorithm given element, invoker, and true.

  • If ancestor is null, then set ancestor to document.

  • @@ -84546,10 +84546,6 @@ dictionary DragEventInit : MouseEventInit { happens. For example, during light-dismiss of a popover, this algorithm ensures that we close only the popovers that aren't related to the node clicked by the user.

    -

    To hide all popovers, given a Document document, run - hide all popovers until given document, - false, and false.

    -

    To find the topmost popover ancestor, given a Node newPopoverOrTopLayerElement, an HTML element or null invoker, and a boolean isPopover, perform the following steps. They