Bug 1319911: Revert changeset 3d7142a4f06d from bug 1292527 due to reported regression. r=me

This commit is contained in:
Stephen A Pohl 2016-11-24 09:20:39 -05:00
Родитель 36605f9e7b
Коммит bac899f5b2
3 изменённых файлов: 2 добавлений и 75 удалений

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

@ -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<NSMenuDelegate>
{
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<mozilla::UniquePtr<nsMenuX>> mMenuArray;
nsIWidget* mParentWindow; // [weak]
GeckoNSMenu* mNativeMenu; // root menu, representing entire menu bar
bool mNeedsRebuild;
ApplicationMenuDelegate* mApplicationMenuDelegate;
};
#endif // nsMenuBarX_h_

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

@ -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;

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

@ -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<nsMenuBarX*>(mParent);
mb->SetNeedsRebuild();
}
}
}
nsresult nsMenuX::SetEnabled(bool aIsEnabled)