Bug 1700706 - Clear active and capturing content before opening native menus. r=tnikkel

This is copied from the nsMenuPopupFrame::ShowPopup just a few lines below.
The native menu consumes mouseup events so we need to clear :active and capturing content just before opening the menu.

Differential Revision: https://phabricator.services.mozilla.com/D109672
This commit is contained in:
Markus Stange 2021-03-24 23:51:05 +00:00
Родитель 502d8c18c3
Коммит b7f729bf73
1 изменённых файлов: 11 добавлений и 0 удалений

Просмотреть файл

@ -958,6 +958,17 @@ void nsMenuPopupFrame::InitializePopupAtRect(nsIContent* aTriggerContent,
void nsMenuPopupFrame::ShowNativeMenu() {
MOZ_RELEASE_ASSERT(mNativeMenu);
// While the native menu is open, it consumes mouseup events.
// Clear any :active state and mouse capture now so that we don't get stuck in
// that state.
EventStateManager* activeESM = static_cast<EventStateManager*>(
EventStateManager::GetActiveEventStateManager());
if (activeESM) {
EventStateManager::ClearGlobalActiveContent(activeESM);
}
PresShell::ReleaseCapturingContent();
bool succeeded = mNativeMenu->ShowAsContextMenu(
DesktopPoint::FromUnknownPoint(mScreenRect.TopLeft()));
if (!succeeded) {