Bug 1837360 - Popover: Align to the update of specification regarding nested popover, r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D181121
This commit is contained in:
Cathie Chen
2023-06-16 13:59:43 +00:00
parent e8f64f693e
commit 7dab75f453
4 changed files with 53 additions and 11 deletions

View File

@@ -3381,6 +3381,14 @@ void nsGenericHTMLElement::ShowPopoverInternal(
RefPtr<Document> document = OwnerDoc();
MOZ_ASSERT(!OwnerDoc()->TopLayerContains(*this));
bool wasShowingOrHiding = GetPopoverData()->IsShowingOrHiding();
GetPopoverData()->SetIsShowingOrHiding(true);
auto cleanupShowingFlag = MakeScopeExit([&]() {
if (auto* popoverData = GetPopoverData()) {
popoverData->SetIsShowingOrHiding(wasShowingOrHiding);
}
});
// Fire beforetoggle event and re-check popover validity.
if (FireToggleEvent(PopoverVisibilityState::Hidden,
PopoverVisibilityState::Showing, u"beforetoggle"_ns)) {
@@ -3397,7 +3405,8 @@ void nsGenericHTMLElement::ShowPopoverInternal(
if (!ancestor) {
ancestor = document;
}
document->HideAllPopoversUntil(*ancestor, false, true);
document->HideAllPopoversUntil(*ancestor, false,
/* aFireEvents = */ !wasShowingOrHiding);
// TODO: Handle if document changes, see
// https://github.com/whatwg/html/issues/9177