Bug 1699792 - Remove nativeData IDL property and use the NativeNSMenu() C++ method instead. r=harry

Depends on D109022

Differential Revision: https://phabricator.services.mozilla.com/D109113
This commit is contained in:
Markus Stange
2021-03-23 13:40:24 +00:00
parent b52a14b84b
commit 9221e3eff6
4 changed files with 12 additions and 33 deletions

View File

@@ -34,6 +34,7 @@
#include "nsString.h" #include "nsString.h"
#include "nsCommandLineServiceMac.h" #include "nsCommandLineServiceMac.h"
#include "nsCommandLine.h" #include "nsCommandLine.h"
#include "nsStandaloneNativeMenu.h"
class AutoAutoreleasePool { class AutoAutoreleasePool {
public: public:
@@ -246,9 +247,12 @@ void ProcessPendingGetURLAppleEvents() {
do_GetService("@mozilla.org/widget/macdocksupport;1", &rv); do_GetService("@mozilla.org/widget/macdocksupport;1", &rv);
if (NS_FAILED(rv) || !dockSupport) return menu; if (NS_FAILED(rv) || !dockSupport) return menu;
nsCOMPtr<nsIStandaloneNativeMenu> dockMenu; nsCOMPtr<nsIStandaloneNativeMenu> dockMenuInterface;
rv = dockSupport->GetDockMenu(getter_AddRefs(dockMenu)); rv = dockSupport->GetDockMenu(getter_AddRefs(dockMenuInterface));
if (NS_FAILED(rv) || !dockMenu) return menu; if (NS_FAILED(rv) || !dockMenuInterface) return menu;
RefPtr<nsStandaloneNativeMenu> dockMenu =
static_cast<nsStandaloneNativeMenu*>(dockMenuInterface.get());
// Determine if the dock menu items should be displayed. This also gives // Determine if the dock menu items should be displayed. This also gives
// the menu the opportunity to update itself before display. // the menu the opportunity to update itself before display.
@@ -257,9 +261,10 @@ void ProcessPendingGetURLAppleEvents() {
if (NS_FAILED(rv) || !shouldShowItems) return menu; if (NS_FAILED(rv) || !shouldShowItems) return menu;
// Obtain a copy of the native menu. // Obtain a copy of the native menu.
NSMenu* nativeDockMenu; NSMenu* nativeDockMenu = dockMenu->NativeNSMenu();
rv = dockMenu->GetNativeMenu(reinterpret_cast<void**>(&nativeDockMenu)); if (!nativeDockMenu) {
if (NS_FAILED(rv) || !nativeDockMenu) return menu; return menu;
}
// Loop through the application-specific dock menu and insert its // Loop through the application-specific dock menu and insert its
// contents into the dock menu that we are building for Cocoa. // contents into the dock menu that we are building for Cocoa.

View File

@@ -75,21 +75,6 @@ nsStandaloneNativeMenu::MenuWillOpen(bool* aResult) {
return NS_OK; 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 NS_IMETHODIMP
nsStandaloneNativeMenu::ActivateNativeMenuItemAt(const nsAString& indexString) { nsStandaloneNativeMenu::ActivateNativeMenuItemAt(const nsAString& indexString) {
NS_OBJC_BEGIN_TRY_ABORT_BLOCK; NS_OBJC_BEGIN_TRY_ABORT_BLOCK;

View File

@@ -40,12 +40,9 @@ nsSystemStatusBarCocoa::StatusItem::StatusItem(nsStandaloneNativeMenu* aMenu) :
MOZ_COUNT_CTOR(nsSystemStatusBarCocoa::StatusItem); MOZ_COUNT_CTOR(nsSystemStatusBarCocoa::StatusItem);
NSMenu* nativeMenu = nil;
mMenu->GetNativeMenu(reinterpret_cast<void**>(&nativeMenu));
mStatusItem = mStatusItem =
[[NSStatusBar.systemStatusBar statusItemWithLength:NSSquareStatusItemLength] retain]; [[NSStatusBar.systemStatusBar statusItemWithLength:NSSquareStatusItemLength] retain];
mStatusItem.menu = nativeMenu; mStatusItem.menu = mMenu->NativeNSMenu();
mStatusItem.highlightMode = YES; mStatusItem.highlightMode = YES;
// We want the status item to get its image from menu item that mMenu was // We want the status item to get its image from menu item that mMenu was

View File

@@ -29,13 +29,6 @@ interface nsIStandaloneNativeMenu : nsISupports
*/ */
boolean menuWillOpen(); 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 * Activate the native menu item specified by |anIndexString|. This method
* is intended to be used by the test suite. * is intended to be used by the test suite.
@@ -54,7 +47,6 @@ interface nsIStandaloneNativeMenu : nsISupports
*/ */
void forceUpdateNativeMenuAt(in AString anIndexString); void forceUpdateNativeMenuAt(in AString anIndexString);
/** /**
* Print information about the menu structure to stdout. Only used for * Print information about the menu structure to stdout. Only used for
* debugging. * debugging.