Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[popover] Using shadow DOM wrongly auto-hides popover by light dismiss #16234

Conversation

nt1m
Copy link
Member

@nt1m nt1m commented Jul 31, 2023

9336846

[popover] Using shadow DOM wrongly auto-hides popover by light dismiss
https://bugs.webkit.org/show_bug.cgi?id=259261
rdar://112410375

Reviewed by Ryosuke Niwa and Darin Adler.

Use the flat tree as mandated by the spec when calculating which popover to light dismiss:
- https://html.spec.whatwg.org/#topmost-clicked-popover
- https://html.spec.whatwg.org/#nearest-inclusive-open-popover
- https://html.spec.whatwg.org/#nearest-inclusive-target-popover-for-invoker

* LayoutTests/imported/w3c/web-platform-tests/html/semantics/popovers/popover-light-dismiss-flat-tree-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/popovers/popover-light-dismiss-flat-tree.html: Added.
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::handlePopoverLightDismiss):

Canonical link: https://commits.webkit.org/266457@main

4902c27

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe   πŸ›  wincairo
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug   πŸ§ͺ wpe-wk2
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac βœ… πŸ›  gtk
  πŸ§ͺ ios-wk2-wpt βœ… πŸ§ͺ mac-wk1   πŸ§ͺ gtk-wk2
βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk2 βœ… πŸ§ͺ api-gtk
βœ… πŸ›  tv βœ… πŸ§ͺ mac-AS-debug-wk2
βœ… πŸ›  tv-sim βœ… πŸ§ͺ mac-wk2-stress
βœ… πŸ›  πŸ§ͺ merge βœ… πŸ›  watch
βœ… πŸ›  watch-sim

@nt1m nt1m requested review from rniwa and cdumez as code owners July 31, 2023 18:16
@nt1m nt1m self-assigned this Jul 31, 2023
@nt1m nt1m added the DOM For bugs specific to XML/HTML DOM elements (including parsing). label Jul 31, 2023
@nt1m nt1m requested review from rwlbuis and darinadler July 31, 2023 18:29
for (auto& element : lineageOfType<HTMLElement>(*startElement)) {
if (!clickedPopover && isShowingAutoPopover(element))
clickedPopover = &element;
for (auto* element = startElement; element; element = element->parentElementInComposedTree()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunate that we don’t have a lineageOfType function that works with the composed tree.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also use RefPtr here.

if (!is<HTMLElement>(element))
continue;

auto* htmlElement = downcast<HTMLElement>(element);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two choices that are better style: use dynamicDowncast and check for nullptr rather than using both is and downcast, or use is and downcast, but pass a reference instead of a pointer to downcast.

@nt1m nt1m force-pushed the eng/popover-element-within-shadow-DOM-breaks-light-dismiss-calculation branch from 59f2c6c to 4902c27 Compare July 31, 2023 18:50
@nt1m nt1m added the merge-queue Applied to send a pull request to merge-queue label Jul 31, 2023
https://bugs.webkit.org/show_bug.cgi?id=259261
rdar://112410375

Reviewed by Ryosuke Niwa and Darin Adler.

Use the flat tree as mandated by the spec when calculating which popover to light dismiss:
- https://html.spec.whatwg.org/#topmost-clicked-popover
- https://html.spec.whatwg.org/#nearest-inclusive-open-popover
- https://html.spec.whatwg.org/#nearest-inclusive-target-popover-for-invoker

* LayoutTests/imported/w3c/web-platform-tests/html/semantics/popovers/popover-light-dismiss-flat-tree-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/popovers/popover-light-dismiss-flat-tree.html: Added.
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::handlePopoverLightDismiss):

Canonical link: https://commits.webkit.org/266457@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/popover-element-within-shadow-DOM-breaks-light-dismiss-calculation branch from 4902c27 to 9336846 Compare July 31, 2023 20:05
@webkit-commit-queue
Copy link
Collaborator

Committed 266457@main (9336846): https://commits.webkit.org/266457@main

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

@webkit-commit-queue webkit-commit-queue merged commit 9336846 into WebKit:main Jul 31, 2023
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Jul 31, 2023
@nt1m nt1m deleted the eng/popover-element-within-shadow-DOM-breaks-light-dismiss-calculation branch August 1, 2023 03:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DOM For bugs specific to XML/HTML DOM elements (including parsing).
Projects
None yet
5 participants