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
Родитель ac27227839
Коммит 5caa594efa
4 изменённых файлов: 12 добавлений и 33 удалений

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

@ -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<nsIStandaloneNativeMenu> dockMenu;
rv = dockSupport->GetDockMenu(getter_AddRefs(dockMenu));
if (NS_FAILED(rv) || !dockMenu) return menu;
nsCOMPtr<nsIStandaloneNativeMenu> dockMenuInterface;
rv = dockSupport->GetDockMenu(getter_AddRefs(dockMenuInterface));
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
// 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<void**>(&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.

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

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

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

@ -40,12 +40,9 @@ nsSystemStatusBarCocoa::StatusItem::StatusItem(nsStandaloneNativeMenu* aMenu) :
MOZ_COUNT_CTOR(nsSystemStatusBarCocoa::StatusItem);
NSMenu* nativeMenu = nil;
mMenu->GetNativeMenu(reinterpret_cast<void**>(&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

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

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