From bac899f5b27b9f0e54963d01f3a6bb049d11b843 Mon Sep 17 00:00:00 2001 From: Stephen A Pohl Date: Thu, 24 Nov 2016 09:20:39 -0500 Subject: [PATCH] Bug 1319911: Revert changeset 3d7142a4f06d from bug 1292527 due to reported regression. r=me --- widget/cocoa/nsMenuBarX.h | 13 --------- widget/cocoa/nsMenuBarX.mm | 57 +------------------------------------- widget/cocoa/nsMenuX.mm | 7 +---- 3 files changed, 2 insertions(+), 75 deletions(-) diff --git a/widget/cocoa/nsMenuBarX.h b/widget/cocoa/nsMenuBarX.h index f976ce4a665c..7cbb8ce62ab4 100644 --- a/widget/cocoa/nsMenuBarX.h +++ b/widget/cocoa/nsMenuBarX.h @@ -15,19 +15,10 @@ #include "nsINativeMenuService.h" #include "nsString.h" -class nsMenuBarX; class nsMenuX; class nsIWidget; class nsIContent; -// ApplicationMenuDelegate is used to receive Cocoa notifications. -@interface ApplicationMenuDelegate : NSObject -{ - nsMenuBarX* mApplicationMenu; // weak ref -} -- (id)initWithApplicationMenu:(nsMenuBarX*)aApplicationMenu; -@end - // The native menu service for creating native menu bars. class nsNativeMenuServiceX : public nsINativeMenuService { @@ -117,8 +108,6 @@ public: void ForceNativeMenuReload(); // used for testing static char GetLocalizedAccelKey(const char *shortcutID); static void ResetNativeApplicationMenu(); - void SetNeedsRebuild(); - void ApplicationMenuOpened(); protected: void ConstructNativeMenus(); @@ -134,8 +123,6 @@ protected: nsTArray> mMenuArray; nsIWidget* mParentWindow; // [weak] GeckoNSMenu* mNativeMenu; // root menu, representing entire menu bar - bool mNeedsRebuild; - ApplicationMenuDelegate* mApplicationMenuDelegate; }; #endif // nsMenuBarX_h_ diff --git a/widget/cocoa/nsMenuBarX.mm b/widget/cocoa/nsMenuBarX.mm index e16e4ee3ad8b..ff25eb81fc8a 100644 --- a/widget/cocoa/nsMenuBarX.mm +++ b/widget/cocoa/nsMenuBarX.mm @@ -55,43 +55,12 @@ NS_IMETHODIMP nsNativeMenuServiceX::CreateNativeMenuBar(nsIWidget* aParent, nsIC return mb->Create(aParent, aMenuBarNode); } -// -// ApplicationMenuDelegate Objective-C class -// - -@implementation ApplicationMenuDelegate - -- (id)initWithApplicationMenu:(nsMenuBarX*)aApplicationMenu -{ - NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL; - - if ((self = [super init])) { - mApplicationMenu = aApplicationMenu; - } - return self; - - NS_OBJC_END_TRY_ABORT_BLOCK_NIL; -} - -- (void)menuWillOpen:(NSMenu*)menu -{ - mApplicationMenu->ApplicationMenuOpened(); -} - -- (void)menuDidClose:(NSMenu*)menu -{ -} - -@end - nsMenuBarX::nsMenuBarX() -: nsMenuGroupOwnerX(), mParentWindow(nullptr), mNeedsRebuild(false) +: nsMenuGroupOwnerX(), mParentWindow(nullptr) { NS_OBJC_BEGIN_TRY_ABORT_BLOCK; mNativeMenu = [[GeckoNSMenu alloc] initWithTitle:@"MainMenuBar"]; - mApplicationMenuDelegate = - [[ApplicationMenuDelegate alloc] initWithApplicationMenu:this]; NS_OBJC_END_TRY_ABORT_BLOCK; } @@ -123,11 +92,6 @@ nsMenuBarX::~nsMenuBarX() // before the registration hash table is destroyed. mMenuArray.Clear(); - if (sApplicationMenu) { - ResetNativeApplicationMenu(); - } - [mApplicationMenuDelegate release]; - [mNativeMenu release]; NS_OBJC_END_TRY_ABORT_BLOCK; @@ -214,7 +178,6 @@ void nsMenuBarX::ConstructFallbackNativeMenus() } sApplicationMenu = [[[[NSApp mainMenu] itemAtIndex:0] submenu] retain]; - [sApplicationMenu setDelegate:mApplicationMenuDelegate]; NSMenuItem* quitMenuItem = [[[NSMenuItem alloc] initWithTitle:labelStr action:@selector(menuItemHit:) keyEquivalent:keyStr] autorelease]; @@ -509,22 +472,6 @@ void nsMenuBarX::ResetNativeApplicationMenu() sApplicationMenuIsFallback = NO; } -void nsMenuBarX::SetNeedsRebuild() -{ - mNeedsRebuild = true; -} - -void nsMenuBarX::ApplicationMenuOpened() -{ - if (mNeedsRebuild) { - if (!mMenuArray.IsEmpty()) { - ResetNativeApplicationMenu(); - CreateApplicationMenu(mMenuArray[0].get()); - } - mNeedsRebuild = false; - } -} - // Hide the item in the menu by setting the 'hidden' attribute. Returns it in |outHiddenNode| so // the caller can hang onto it if they so choose. It is acceptable to pass nsull // for |outHiddenNode| if the caller doesn't care about the hidden node. @@ -697,8 +644,6 @@ nsresult nsMenuBarX::CreateApplicationMenu(nsMenuX* inMenu) */ if (sApplicationMenu) { - [sApplicationMenu setDelegate:mApplicationMenuDelegate]; - // This code reads attributes we are going to care about from the DOM elements NSMenuItem *itemBeingAdded = nil; diff --git a/widget/cocoa/nsMenuX.mm b/widget/cocoa/nsMenuX.mm index 62aad2a4d8ee..757221eac638 100644 --- a/widget/cocoa/nsMenuX.mm +++ b/widget/cocoa/nsMenuX.mm @@ -450,13 +450,8 @@ void nsMenuX::MenuConstruct() void nsMenuX::SetRebuild(bool aNeedsRebuild) { - if (!gConstructingMenu) { + if (!gConstructingMenu) mNeedsRebuild = aNeedsRebuild; - if (mParent->MenuObjectType() == eMenuBarObjectType) { - nsMenuBarX* mb = static_cast(mParent); - mb->SetNeedsRebuild(); - } - } } nsresult nsMenuX::SetEnabled(bool aIsEnabled)