Bug 1845587 - Don't close Firefox popups when MacOS toolbar menu opens. r=mstange

Now that we have native context menus we don't have to worry about those competing with the toolbar menus.

Differential Revision: https://phabricator.services.mozilla.com/D184631
This commit is contained in:
Eitan Isaacson 2023-08-07 17:18:19 +00:00
Родитель a9e2694194
Коммит b8cc36b196
2 изменённых файлов: 0 добавлений и 16 удалений

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

@ -34,7 +34,6 @@ class nsIWidget;
- (id)initWithGeckoMenu:(nsMenuX*)geckoMenu; - (id)initWithGeckoMenu:(nsMenuX*)geckoMenu;
- (void)runBlockWhenOpen:(void (^)())block; - (void)runBlockWhenOpen:(void (^)())block;
- (void)menu:(NSMenu*)menu willActivateItem:(NSMenuItem*)item; - (void)menu:(NSMenu*)menu willActivateItem:(NSMenuItem*)item;
@property BOOL menuIsInMenubar;
@end @end
class nsMenuXObserver { class nsMenuXObserver {

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

@ -88,7 +88,6 @@ nsMenuX::nsMenuX(nsMenuParentX* aParent, nsMenuGroupOwnerX* aMenuGroupOwner, nsI
SwizzleDynamicIndexingMethods(); SwizzleDynamicIndexingMethods();
mMenuDelegate = [[MenuDelegate alloc] initWithGeckoMenu:this]; mMenuDelegate = [[MenuDelegate alloc] initWithGeckoMenu:this];
mMenuDelegate.menuIsInMenubar = mMenuGroupOwner->GetMenuBar() != nullptr;
if (!nsMenuBarX::sNativeEventTarget) { if (!nsMenuBarX::sNativeEventTarget) {
nsMenuBarX::sNativeEventTarget = [[NativeMenuItemTarget alloc] init]; nsMenuBarX::sNativeEventTarget = [[NativeMenuItemTarget alloc] init];
@ -1153,20 +1152,6 @@ void nsMenuX::Dump(uint32_t aIndent) const {
return; return;
} }
if (self.menuIsInMenubar) {
// If a menu in the menubar is trying open while a non-native menu is open, roll up the
// non-native menu and reject the menubar opening attempt, effectively consuming the event.
nsIRollupListener* rollupListener = nsBaseWidget::GetActiveRollupListener();
if (rollupListener) {
nsCOMPtr<nsIWidget> rollupWidget = rollupListener->GetRollupWidget();
if (rollupWidget) {
rollupListener->Rollup({0, nsIRollupListener::FlushViews::Yes});
[menu cancelTracking];
return;
}
}
}
// Hold a strong reference to mGeckoMenu while calling its methods. // Hold a strong reference to mGeckoMenu while calling its methods.
RefPtr<nsMenuX> geckoMenu = mGeckoMenu; RefPtr<nsMenuX> geckoMenu = mGeckoMenu;
geckoMenu->MenuOpened(); geckoMenu->MenuOpened();