diff --git a/toolkit/xre/MacApplicationDelegate.mm b/toolkit/xre/MacApplicationDelegate.mm index 5b74d31a3f3f..71e6de1f4c65 100644 --- a/toolkit/xre/MacApplicationDelegate.mm +++ b/toolkit/xre/MacApplicationDelegate.mm @@ -34,6 +34,7 @@ #include "nsString.h" #include "nsCommandLineServiceMac.h" #include "nsCommandLine.h" +#include "nsStandaloneNativeMenu.h" class AutoAutoreleasePool { public: @@ -246,9 +247,12 @@ void ProcessPendingGetURLAppleEvents() { do_GetService("@mozilla.org/widget/macdocksupport;1", &rv); if (NS_FAILED(rv) || !dockSupport) return menu; - nsCOMPtr dockMenu; - rv = dockSupport->GetDockMenu(getter_AddRefs(dockMenu)); - if (NS_FAILED(rv) || !dockMenu) return menu; + nsCOMPtr dockMenuInterface; + rv = dockSupport->GetDockMenu(getter_AddRefs(dockMenuInterface)); + if (NS_FAILED(rv) || !dockMenuInterface) return menu; + + RefPtr dockMenu = + static_cast(dockMenuInterface.get()); // Determine if the dock menu items should be displayed. This also gives // the menu the opportunity to update itself before display. @@ -257,9 +261,10 @@ void ProcessPendingGetURLAppleEvents() { if (NS_FAILED(rv) || !shouldShowItems) return menu; // Obtain a copy of the native menu. - NSMenu* nativeDockMenu; - rv = dockMenu->GetNativeMenu(reinterpret_cast(&nativeDockMenu)); - if (NS_FAILED(rv) || !nativeDockMenu) return menu; + NSMenu* nativeDockMenu = dockMenu->NativeNSMenu(); + if (!nativeDockMenu) { + return menu; + } // Loop through the application-specific dock menu and insert its // contents into the dock menu that we are building for Cocoa. diff --git a/widget/cocoa/nsStandaloneNativeMenu.mm b/widget/cocoa/nsStandaloneNativeMenu.mm index 3c407a05e79d..18eb7bc82c34 100644 --- a/widget/cocoa/nsStandaloneNativeMenu.mm +++ b/widget/cocoa/nsStandaloneNativeMenu.mm @@ -75,21 +75,6 @@ nsStandaloneNativeMenu::MenuWillOpen(bool* aResult) { return NS_OK; } -NS_IMETHODIMP -nsStandaloneNativeMenu::GetNativeMenu(void** aVoidPointer) { - NS_OBJC_BEGIN_TRY_ABORT_BLOCK; - - if (mMenu) { - *aVoidPointer = mMenu->NativeNSMenu(); - [[(NSObject*)(*aVoidPointer) retain] autorelease]; - return NS_OK; - } - *aVoidPointer = nullptr; - return NS_ERROR_NOT_INITIALIZED; - - NS_OBJC_END_TRY_ABORT_BLOCK; -} - NS_IMETHODIMP nsStandaloneNativeMenu::ActivateNativeMenuItemAt(const nsAString& indexString) { NS_OBJC_BEGIN_TRY_ABORT_BLOCK; diff --git a/widget/cocoa/nsSystemStatusBarCocoa.mm b/widget/cocoa/nsSystemStatusBarCocoa.mm index 38878c0e89ff..5c5c36b2f809 100644 --- a/widget/cocoa/nsSystemStatusBarCocoa.mm +++ b/widget/cocoa/nsSystemStatusBarCocoa.mm @@ -40,12 +40,9 @@ nsSystemStatusBarCocoa::StatusItem::StatusItem(nsStandaloneNativeMenu* aMenu) : MOZ_COUNT_CTOR(nsSystemStatusBarCocoa::StatusItem); - NSMenu* nativeMenu = nil; - mMenu->GetNativeMenu(reinterpret_cast(&nativeMenu)); - mStatusItem = [[NSStatusBar.systemStatusBar statusItemWithLength:NSSquareStatusItemLength] retain]; - mStatusItem.menu = nativeMenu; + mStatusItem.menu = mMenu->NativeNSMenu(); mStatusItem.highlightMode = YES; // We want the status item to get its image from menu item that mMenu was diff --git a/widget/nsIStandaloneNativeMenu.idl b/widget/nsIStandaloneNativeMenu.idl index 7582f385cc75..b995f1f8b97b 100644 --- a/widget/nsIStandaloneNativeMenu.idl +++ b/widget/nsIStandaloneNativeMenu.idl @@ -29,13 +29,6 @@ interface nsIStandaloneNativeMenu : nsISupports */ boolean menuWillOpen(); - /** - * The native object representing the XUL menu that was passed to Init(). On - * Mac OS X, this will be a NSMenu pointer, which will be retained and - * autoreleased when the attribute is retrieved. - */ - [noscript] readonly attribute voidPtr nativeMenu; - /** * Activate the native menu item specified by |anIndexString|. This method * is intended to be used by the test suite. @@ -54,7 +47,6 @@ interface nsIStandaloneNativeMenu : nsISupports */ void forceUpdateNativeMenuAt(in AString anIndexString); - /** * Print information about the menu structure to stdout. Only used for * debugging.