Bug 263081 - [popover] element within complex shadow DOM breaks light dismiss calculation
Summary: [popover] element within complex shadow DOM breaks light dismiss calculation
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: Safari 17
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Luke Warlow
URL: https://codepen.io/Westbrook/pen/JjwVYmr
Keywords: BrowserCompat, InRadar
Depends on:
Blocks: 148695 250171
  Show dependency treegraph
 
Reported: 2023-10-12 10:36 PDT by Westbrook
Modified: 2023-10-20 15:16 PDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Westbrook 2023-10-12 10:36:59 PDT
This issue is closely related to https://bugs.webkit.org/show_bug.cgi?id=259261 in that I would have expected the flattened tree calculation added there to have prevented this, but here again, we see the light dismiss calculation for a `[popover="auto"]` element going awry.

As seen in https://codepen.io/Westbrook/pen/JjwVYmr Safari 17 and TP both overreach and close the root popover erroneously when opening the child popover.

Steps:

1) Visit https://codepen.io/Westbrook/pen/JjwVYmr
2) Click the "Show" button.
3) See the "outer" [popover] element open at the center of the page.
4) Click the "Show" button within the initial [popover] element.
5) See the "outer" [popover] element closed due to the light dismiss calculation, preventing the "inner" [popover] element from becoming visible.

If you run the same steps in Chrome, you'll see the "inner" [popover] open over the "outer" [popover] as expected.
Comment 1 Karl Dubost 2023-10-15 19:12:13 PDT
Firefox Nightly Not working
(after setting dom.element.popover.enabled to true in about:config)


In Safari the second nested showPopover() fails silently.
In chrome we can see it.
Comment 2 Westbrook 2023-10-16 05:26:09 PDT
It seems that the DSD flag was maybe removed from Firefox nightly, but that feature was only leveraged for simplicity, it wasn't part of the larger issue. This demo exemplifies the issue with imperative Shadow DOM: https://codepen.io/Westbrook/pen/jOXooPB?editors=1010
Comment 3 Radar WebKit Bug Importer 2023-10-19 10:37:19 PDT
<rdar://problem/117214343>
Comment 4 Tim Nguyen (:ntim) 2023-10-19 13:42:56 PDT
Here's another place that needs to use the flat tree: https://searchfox.org/wubkat/rev/c64f97a4afc2aa3f73f74f59630410234ca8a659/Source/WebCore/html/HTMLElement.cpp#1286
Comment 5 Luke Warlow 2023-10-19 15:28:57 PDT
I'm happy to take a look at this. I've got a WPT that covers it so shouldn't take long.
Comment 6 Luke Warlow 2023-10-19 15:41:39 PDT
Pull request: https://github.com/WebKit/WebKit/pull/19314
Comment 7 EWS 2023-10-20 15:11:52 PDT
Committed 269596@main (4ab4d8351529): <https://commits.webkit.org/269596@main>

Reviewed commits have been landed. Closing PR #19314 and removing active labels.