Bug 1694853 - Replace getter and setter calls with property gets and sets. r=harry

This does the same but looks more modern.

Differential Revision: https://phabricator.services.mozilla.com/D106371
This commit is contained in:
Markus Stange 2021-03-04 01:24:55 +00:00
Родитель 48c3f3447c
Коммит de9c44a290
7 изменённых файлов: 77 добавлений и 90 удалений

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

@ -201,12 +201,12 @@ void nsMenuBarX::ConstructFallbackNativeMenus() {
if (!mApplicationMenuDelegate) {
mApplicationMenuDelegate = [[ApplicationMenuDelegate alloc] initWithApplicationMenu:this];
}
[sApplicationMenu setDelegate:mApplicationMenuDelegate];
sApplicationMenu.delegate = mApplicationMenuDelegate;
NSMenuItem* quitMenuItem = [[[NSMenuItem alloc] initWithTitle:labelStr
action:@selector(menuItemHit:)
keyEquivalent:keyStr] autorelease];
[quitMenuItem setTarget:nsMenuBarX::sNativeEventTarget];
[quitMenuItem setTag:eCommand_ID_Quit];
quitMenuItem.target = nsMenuBarX::sNativeEventTarget;
quitMenuItem.tag = eCommand_ID_Quit;
[sApplicationMenu addItem:quitMenuItem];
sApplicationMenuIsFallback = YES;
@ -218,8 +218,7 @@ uint32_t nsMenuBarX::GetMenuCount() { return mMenuArray.Length(); }
bool nsMenuBarX::MenuContainsAppMenu() {
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
return ([mNativeMenu numberOfItems] > 0 &&
[[mNativeMenu itemAtIndex:0] submenu] == sApplicationMenu);
return (mNativeMenu.numberOfItems > 0 && [mNativeMenu itemAtIndex:0].submenu == sApplicationMenu);
NS_OBJC_END_TRY_ABORT_BLOCK;
}
@ -237,10 +236,10 @@ void nsMenuBarX::InsertMenuAtIndex(UniquePtr<nsMenuX>&& aMenu, uint32_t aIndex)
CreateApplicationMenu(aMenu.get());
// Hook the new Application menu up to the menu bar.
NSMenu* mainMenu = [NSApp mainMenu];
NS_ASSERTION([mainMenu numberOfItems] > 0,
NSMenu* mainMenu = NSApp.mainMenu;
NS_ASSERTION(mainMenu.numberOfItems > 0,
"Main menu does not have any items, something is terribly wrong!");
[[mainMenu itemAtIndex:0] setSubmenu:sApplicationMenu];
[mainMenu itemAtIndex:0].submenu = sApplicationMenu;
}
// add menu to array that owns our menus
@ -305,7 +304,7 @@ void nsMenuBarX::ForceUpdateNativeMenuAt(const nsAString& indexString) {
[NSString stringWithCharacters:reinterpret_cast<const unichar*>(indexString.BeginReading())
length:indexString.Length()];
NSArray* indexes = [locationString componentsSeparatedByString:@"|"];
unsigned int indexCount = [indexes count];
unsigned int indexCount = indexes.count;
if (indexCount == 0) {
return;
}
@ -405,7 +404,7 @@ void nsMenuBarX::SetSystemHelpMenu() {
if (xulHelpMenu) {
NSMenu* helpMenu = (NSMenu*)xulHelpMenu->NativeData();
if (helpMenu) {
[NSApp setHelpMenu:helpMenu];
NSApp.helpMenu = helpMenu;
}
}
@ -421,8 +420,8 @@ nsresult nsMenuBarX::Paint() {
// We have to keep the same menu item for the Application menu so we keep
// passing it along.
NSMenu* outgoingMenu = [NSApp mainMenu];
NS_ASSERTION([outgoingMenu numberOfItems] > 0,
NSMenu* outgoingMenu = NSApp.mainMenu;
NS_ASSERTION(outgoingMenu.numberOfItems > 0,
"Main menu does not have any items, something is terribly wrong!");
NSMenuItem* appMenuItem = [[outgoingMenu itemAtIndex:0] retain];
@ -431,7 +430,7 @@ nsresult nsMenuBarX::Paint() {
[appMenuItem release];
// Set menu bar and event target.
[NSApp setMainMenu:mNativeMenu];
NSApp.mainMenu = mNativeMenu;
SetSystemHelpMenu();
nsMenuBarX::sLastGeckoMenuBarPainted = this;
@ -588,12 +587,12 @@ NSMenuItem* nsMenuBarX::CreateNativeAppMenuItem(nsMenuX* inMenu, const nsAString
action:action
keyEquivalent:keyEquiv];
[newMenuItem setTag:tag];
[newMenuItem setTarget:target];
[newMenuItem setKeyEquivalentModifierMask:macKeyModifiers];
newMenuItem.tag = tag;
newMenuItem.target = target;
newMenuItem.keyEquivalentModifierMask = macKeyModifiers;
MenuItemInfo* info = [[MenuItemInfo alloc] initWithMenuGroupOwner:this];
[newMenuItem setRepresentedObject:info];
newMenuItem.representedObject = info;
[info release];
return newMenuItem;
@ -608,7 +607,7 @@ void nsMenuBarX::CreateApplicationMenu(nsMenuX* inMenu) {
// At this point, the application menu is the application menu from
// the nib in cocoa widgets. We do not have a way to create an application
// menu manually, so we grab the one from the nib and use that.
sApplicationMenu = [[[[NSApp mainMenu] itemAtIndex:0] submenu] retain];
sApplicationMenu = [[NSApp.mainMenu itemAtIndex:0].submenu retain];
/*
We support the following menu items here:
@ -649,7 +648,7 @@ void nsMenuBarX::CreateApplicationMenu(nsMenuX* inMenu) {
if (!mApplicationMenuDelegate) {
mApplicationMenuDelegate = [[ApplicationMenuDelegate alloc] initWithApplicationMenu:this];
}
[sApplicationMenu setDelegate:mApplicationMenuDelegate];
sApplicationMenu.delegate = mApplicationMenuDelegate;
// This code reads attributes we are going to care about from the DOM elements
@ -692,8 +691,8 @@ void nsMenuBarX::CreateApplicationMenu(nsMenuX* inMenu) {
// set this menu item up as the Mac OS X Services menu
NSMenu* servicesMenu = [[GeckoServicesNSMenu alloc] initWithTitle:@""];
[itemBeingAdded setSubmenu:servicesMenu];
[NSApp setServicesMenu:servicesMenu];
itemBeingAdded.submenu = servicesMenu;
NSApp.servicesMenu = servicesMenu;
[itemBeingAdded release];
itemBeingAdded = nil;
@ -783,8 +782,8 @@ void nsMenuBarX::CreateApplicationMenu(nsMenuX* inMenu) {
NSMenuItem* defaultQuitItem = [[[NSMenuItem alloc] initWithTitle:@"Quit"
action:@selector(menuItemHit:)
keyEquivalent:@"q"] autorelease];
[defaultQuitItem setTarget:nsMenuBarX::sNativeEventTarget];
[defaultQuitItem setTag:eCommand_ID_Quit];
defaultQuitItem.target = nsMenuBarX::sNativeEventTarget;
defaultQuitItem.tag = eCommand_ID_Quit;
[sApplicationMenu addItem:defaultQuitItem];
}
}
@ -816,11 +815,11 @@ static BOOL gMenuItemsExecuteCommands = YES;
//
// There is no case in which we'd need to do anything or return YES
// when we have no items so we can just do this check first.
if ([self numberOfItems] <= 0) {
if (self.numberOfItems <= 0) {
return NO;
}
NSWindow* keyWindow = [NSApp keyWindow];
NSWindow* keyWindow = NSApp.keyWindow;
// If there is no key window then just behave normally. This
// probably means that this menu is associated with Gecko's
@ -829,7 +828,7 @@ static BOOL gMenuItemsExecuteCommands = YES;
return [super performKeyEquivalent:theEvent];
}
NSResponder* firstResponder = [keyWindow firstResponder];
NSResponder* firstResponder = keyWindow.firstResponder;
gMenuItemsExecuteCommands = NO;
[super performKeyEquivalent:theEvent];
@ -838,7 +837,7 @@ static BOOL gMenuItemsExecuteCommands = YES;
// Return YES if we invoked a command and there is now no key window or we changed
// the first responder. In this case we do not want to propagate the event because
// we don't want it handled again.
if (![NSApp keyWindow] || [[NSApp keyWindow] firstResponder] != firstResponder) {
if (!NSApp.keyWindow || NSApp.keyWindow.firstResponder != firstResponder) {
return YES;
}
@ -871,7 +870,7 @@ static BOOL gMenuItemsExecuteCommands = YES;
MenuItemInfo* info = [sender representedObject];
if (info) {
menuGroupOwner = [info menuGroupOwner];
menuGroupOwner = info.menuGroupOwner;
if (!menuGroupOwner) {
return;
}
@ -953,7 +952,7 @@ static BOOL gMenuItemsExecuteCommands = YES;
@implementation GeckoServicesNSMenuItem
- (id)target {
id realTarget = [super target];
id realTarget = super.target;
if (gMenuItemsExecuteCommands) {
return realTarget;
}
@ -961,7 +960,7 @@ static BOOL gMenuItemsExecuteCommands = YES;
}
- (SEL)action {
SEL realAction = [super action];
SEL realAction = super.action;
if (gMenuItemsExecuteCommands) {
return realAction;
}

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

@ -71,7 +71,7 @@ nsresult nsMenuItemIconX::SetupIcon() {
if (NS_FAILED(rv)) {
// There is no icon for this menu item. An icon might have been set
// earlier. Clear it.
[mNativeMenuItem setImage:nil];
mNativeMenuItem.image = nil;
return NS_OK;
}
@ -82,7 +82,7 @@ nsresult nsMenuItemIconX::SetupIcon() {
if (!mSetIcon) {
// Load placeholder icon.
NSSize iconSize = NSMakeSize(kIconSize, kIconSize);
[mNativeMenuItem setImage:[MOZIconHelper placeholderIconWithSize:iconSize]];
mNativeMenuItem.image = [MOZIconHelper placeholderIconWithSize:iconSize];
}
rv = mIconLoader->LoadIcon(iconURI, mContent);
@ -90,7 +90,7 @@ nsresult nsMenuItemIconX::SetupIcon() {
// There is no icon for this menu item, as an error occurred while loading it.
// An icon might have been set earlier or the place holder icon may have
// been set. Clear it.
[mNativeMenuItem setImage:nil];
mNativeMenuItem.image = nil;
}
mSetIcon = true;
@ -201,7 +201,7 @@ nsresult nsMenuItemIconX::OnComplete(imgIContainer* aImage) {
withSize:NSMakeSize(kIconSize, kIconSize)
subrect:mImageRegionRect
scaleFactor:0.0f];
[mNativeMenuItem setImage:image];
mNativeMenuItem.image = image;
if (mMenuObject) {
mMenuObject->IconUpdated();
}

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

@ -80,7 +80,7 @@ nsMenuItemX::nsMenuItemX(nsMenuX* aParent, const nsString& aLabel, EMenuItemType
action:nil
keyEquivalent:@""];
[mNativeMenuItem setEnabled:(BOOL)isEnabled];
mNativeMenuItem.enabled = isEnabled;
SetChecked(mContent->IsElement() &&
mContent->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::checked,
@ -123,11 +123,7 @@ nsresult nsMenuItemX::SetChecked(bool aIsChecked) {
mIsChecked ? u"true"_ns : u"false"_ns, true);
// update native menu item
if (mIsChecked) {
[mNativeMenuItem setState:NSOnState];
} else {
[mNativeMenuItem setState:NSOffState];
}
mNativeMenuItem.state = mIsChecked ? NSOnState : NSOffState;
return NS_OK;
@ -242,14 +238,14 @@ void nsMenuItemX::SetKeyEquiv() {
uint8_t modifiers = nsMenuUtilsX::GeckoModifiersForNodeAttribute(modifiersStr);
unsigned int macModifiers = nsMenuUtilsX::MacModifiersForGeckoModifiers(modifiers);
[mNativeMenuItem setKeyEquivalentModifierMask:macModifiers];
mNativeMenuItem.keyEquivalentModifierMask = macModifiers;
NSString* keyEquivalent = [[NSString stringWithCharacters:(unichar*)keyChar.get()
length:keyChar.Length()] lowercaseString];
if ([keyEquivalent isEqualToString:@" "]) {
[mNativeMenuItem setKeyEquivalent:@""];
mNativeMenuItem.keyEquivalent = @"";
} else {
[mNativeMenuItem setKeyEquivalent:keyEquivalent];
mNativeMenuItem.keyEquivalent = keyEquivalent;
}
return;
@ -257,7 +253,7 @@ void nsMenuItemX::SetKeyEquiv() {
}
// if the key was removed, clear the key
[mNativeMenuItem setKeyEquivalent:@""];
mNativeMenuItem.keyEquivalent = @"";
NS_OBJC_END_TRY_ABORT_BLOCK;
}
@ -292,12 +288,8 @@ void nsMenuItemX::ObserveAttributeChanged(dom::Document* aDocument, nsIContent*
} else if (aAttribute == nsGkAtoms::image) {
SetupIcon();
} else if (aAttribute == nsGkAtoms::disabled) {
if (aContent->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::disabled,
nsGkAtoms::_true, eCaseMatters)) {
[mNativeMenuItem setEnabled:NO];
} else {
[mNativeMenuItem setEnabled:YES];
}
mNativeMenuItem.enabled = !aContent->AsElement()->AttrValueIs(
kNameSpaceID_None, nsGkAtoms::disabled, nsGkAtoms::_true, eCaseMatters);
}
} else if (aContent == mCommandElement) {
// the only thing that really matters when the menu isn't showing is the
@ -318,12 +310,8 @@ void nsMenuItemX::ObserveAttributeChanged(dom::Document* aDocument, nsIContent*
}
}
// now we sync our native menu item with the command DOM node
if (aContent->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::disabled,
nsGkAtoms::_true, eCaseMatters)) {
[mNativeMenuItem setEnabled:NO];
} else {
[mNativeMenuItem setEnabled:YES];
}
mNativeMenuItem.enabled = !aContent->AsElement()->AttrValueIs(
kNameSpaceID_None, nsGkAtoms::disabled, nsGkAtoms::_true, eCaseMatters);
}
}

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

@ -119,7 +119,7 @@ NSMenuItem* nsMenuUtilsX::GetStandardEditMenuItem() {
action:nil
keyEquivalent:@""] autorelease];
NSMenu* standardEditMenu = [[NSMenu alloc] initWithTitle:@"Edit"];
[standardEditMenuItem setSubmenu:standardEditMenu];
standardEditMenuItem.submenu = standardEditMenu;
[standardEditMenu release];
// Add Undo
@ -200,7 +200,7 @@ int nsMenuUtilsX::CalculateNativeInsertionPoint(nsMenuObjectX* aParent, nsMenuOb
if (currMenu == aChild) {
return insertionPoint; // we found ourselves, break out
}
if (currMenu && [currMenu->NativeMenuItem() menu]) {
if (currMenu && currMenu->NativeMenuItem().menu) {
insertionPoint++;
}
}
@ -226,7 +226,7 @@ int nsMenuUtilsX::CalculateNativeInsertionPoint(nsMenuObjectX* aParent, nsMenuOb
} else {
nativeItem = (NSMenuItem*)(currItem->NativeData());
}
if ([nativeItem menu]) {
if (nativeItem.menu) {
insertionPoint++;
}
}
@ -236,20 +236,20 @@ int nsMenuUtilsX::CalculateNativeInsertionPoint(nsMenuObjectX* aParent, nsMenuOb
NSMenuItem* nsMenuUtilsX::NativeMenuItemWithLocation(NSMenu* aRootMenu, NSString* aLocationString,
bool aIsMenuBar) {
NSArray* indexes = [aLocationString componentsSeparatedByString:@"|"];
unsigned int pathLength = [indexes count];
NSArray<NSString*>* indexes = [aLocationString componentsSeparatedByString:@"|"];
unsigned int pathLength = indexes.count;
if (pathLength == 0) {
return nil;
}
NSMenu* currentSubmenu = aRootMenu;
for (unsigned int depth = 0; depth < pathLength; depth++) {
NSInteger targetIndex = [[indexes objectAtIndex:depth] integerValue];
NSInteger targetIndex = [indexes objectAtIndex:depth].integerValue;
if (aIsMenuBar && depth == 0) {
// We remove the application menu from consideration for the top-level menu.
targetIndex++;
}
int itemCount = [currentSubmenu numberOfItems];
int itemCount = currentSubmenu.numberOfItems;
if (targetIndex < itemCount) {
NSMenuItem* menuItem = [currentSubmenu itemAtIndex:targetIndex];
// if this is the last index just return the menu item
@ -257,8 +257,8 @@ NSMenuItem* nsMenuUtilsX::NativeMenuItemWithLocation(NSMenu* aRootMenu, NSString
return menuItem;
}
// if this is not the last index find the submenu and keep going
if ([menuItem hasSubmenu]) {
currentSubmenu = [menuItem submenu];
if (menuItem.hasSubmenu) {
currentSubmenu = menuItem.submenu;
} else {
return nil;
}

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

@ -170,7 +170,7 @@ nsMenuX::~nsMenuX() {
RemoveAll();
[mNativeMenu setDelegate:nil];
mNativeMenu.delegate = nil;
[mNativeMenu release];
[mMenuDelegate release];
// autorelease the native menu item so that anything else happening to this
@ -205,13 +205,13 @@ void nsMenuX::AddMenuItem(UniquePtr<nsMenuItemX>&& aMenuItem) {
[mNativeMenu addItem:newNativeMenuItem];
// set up target/action
[newNativeMenuItem setTarget:nsMenuBarX::sNativeEventTarget];
[newNativeMenuItem setAction:@selector(menuItemHit:)];
newNativeMenuItem.target = nsMenuBarX::sNativeEventTarget;
newNativeMenuItem.action = @selector(menuItemHit:);
// set its command. we get the unique command id from the menubar
[newNativeMenuItem setTag:mMenuGroupOwner->RegisterForCommand(menuItem)];
newNativeMenuItem.tag = mMenuGroupOwner->RegisterForCommand(menuItem);
MenuItemInfo* info = [[MenuItemInfo alloc] initWithMenuGroupOwner:mMenuGroupOwner];
[newNativeMenuItem setRepresentedObject:info];
newNativeMenuItem.representedObject = info;
[info release];
menuItem->SetupIcon();
@ -237,7 +237,7 @@ void nsMenuX::AddMenu(UniquePtr<nsMenuX>&& aMenu) {
NSMenuItem* newNativeMenuItem = menu->NativeMenuItem();
if (newNativeMenuItem) {
[mNativeMenu addItem:newNativeMenuItem];
[newNativeMenuItem setSubmenu:(NSMenu*)menu->NativeData()];
newNativeMenuItem.submenu = (NSMenu*)menu->NativeData();
}
menu->SetupIcon();
@ -298,12 +298,12 @@ nsresult nsMenuX::RemoveAll() {
if (mNativeMenu) {
// clear command id's
int itemCount = [mNativeMenu numberOfItems];
int itemCount = mNativeMenu.numberOfItems;
for (int i = 0; i < itemCount; i++) {
mMenuGroupOwner->UnregisterCommand((uint32_t)[[mNativeMenu itemAtIndex:i] tag]);
}
// get rid of Cocoa menu items
for (int i = [mNativeMenu numberOfItems] - 1; i >= 0; i--) {
for (int i = mNativeMenu.numberOfItems - 1; i >= 0; i--) {
[mNativeMenu removeItemAtIndex:i];
}
}
@ -424,7 +424,7 @@ nsresult nsMenuX::SetEnabled(bool aIsEnabled) {
if (aIsEnabled != mIsEnabled) {
// we always want to rebuild when this changes
mIsEnabled = aIsEnabled;
[mNativeMenuItem setEnabled:(BOOL)mIsEnabled];
mNativeMenuItem.enabled = mIsEnabled;
}
return NS_OK;
}
@ -441,11 +441,11 @@ GeckoNSMenu* nsMenuX::CreateMenuWithGeckoString(nsString& menuTitle) {
NSString* title = [NSString stringWithCharacters:(UniChar*)menuTitle.get()
length:menuTitle.Length()];
GeckoNSMenu* myMenu = [[GeckoNSMenu alloc] initWithTitle:title];
[myMenu setDelegate:mMenuDelegate];
myMenu.delegate = mMenuDelegate;
// We don't want this menu to auto-enable menu items because then Cocoa
// overrides our decisions and things get incorrectly enabled/disabled.
[myMenu setAutoenablesItems:NO];
myMenu.autoenablesItems = NO;
// we used to install Carbon event handlers here, but since NSMenu* doesn't
// create its underlying MenuRef until just before display, we delay until
@ -621,7 +621,7 @@ void nsMenuX::ObserveAttributeChanged(dom::Document* aDocument, nsIContent* aCon
// reuse the existing menu, to avoid rebuilding the root menu bar.
NS_ASSERTION(mNativeMenu, "nsMenuX::AttributeChanged: invalid menu handle.");
NSString* newCocoaLabelString = nsMenuUtilsX::GetTruncatedCocoaLabel(mLabel);
[mNativeMenu setTitle:newCocoaLabelString];
mNativeMenu.title = newCocoaLabelString;
} else if (parentType == eSubmenuObjectType) {
static_cast<nsMenuX*>(mParent)->SetRebuild(true);
} else if (parentType == eStandaloneNativeMenuObjectType) {
@ -662,7 +662,7 @@ void nsMenuX::ObserveAttributeChanged(dom::Document* aDocument, nsIContent* aCon
}
NSMenu* parentMenu = (NSMenu*)mParent->NativeData();
[parentMenu insertItem:mNativeMenuItem atIndex:insertionIndex];
[mNativeMenuItem setSubmenu:mNativeMenu];
mNativeMenuItem.submenu = mNativeMenu;
mVisible = true;
}
}

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

@ -100,8 +100,8 @@ nsStandaloneNativeMenu::ActivateNativeMenuItemAt(const nsAString& indexString) {
// We can't perform an action on an item with a submenu, that will raise
// an obj-c exception.
if (item && ![item hasSubmenu]) {
NSMenu* parent = [item menu];
if (item && !item.hasSubmenu) {
NSMenu* parent = item.menu;
if (parent) {
// NSLog(@"Performing action for native menu item titled: %@\n",
// [[currentSubmenu itemAtIndex:targetIndex] title]);
@ -126,8 +126,8 @@ nsStandaloneNativeMenu::ForceUpdateNativeMenuAt(const nsAString& indexString) {
NSString* locationString =
[NSString stringWithCharacters:reinterpret_cast<const unichar*>(indexString.BeginReading())
length:indexString.Length()];
NSArray* indexes = [locationString componentsSeparatedByString:@"|"];
unsigned int indexCount = [indexes count];
NSArray<NSString*>* indexes = [locationString componentsSeparatedByString:@"|"];
unsigned int indexCount = indexes.count;
if (indexCount == 0) {
return NS_OK;
}
@ -136,7 +136,7 @@ nsStandaloneNativeMenu::ForceUpdateNativeMenuAt(const nsAString& indexString) {
// now find the correct submenu
for (unsigned int i = 1; currentMenu && i < indexCount; i++) {
int targetIndex = [[indexes objectAtIndex:i] intValue];
int targetIndex = [indexes objectAtIndex:i].intValue;
int visible = 0;
uint32_t length = currentMenu->GetItemCount();
for (unsigned int j = 0; j < length; j++) {
@ -166,11 +166,11 @@ void nsStandaloneNativeMenu::IconUpdated() {
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
if (mContainerStatusBarItem) {
NSImage* menuImage = [mMenu->NativeMenuItem() image];
NSImage* menuImage = mMenu->NativeMenuItem().image;
if (menuImage) {
[menuImage setTemplate:true];
[menuImage setTemplate:YES];
}
[mContainerStatusBarItem setImage:menuImage];
mContainerStatusBarItem.image = menuImage;
}
NS_OBJC_END_TRY_ABORT_BLOCK;

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

@ -44,9 +44,9 @@ nsSystemStatusBarCocoa::StatusItem::StatusItem(nsStandaloneNativeMenu* aMenu) :
mMenu->GetNativeMenu(reinterpret_cast<void**>(&nativeMenu));
mStatusItem =
[[[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength] retain];
[mStatusItem setMenu:nativeMenu];
[mStatusItem setHighlightMode:YES];
[[NSStatusBar.systemStatusBar statusItemWithLength:NSSquareStatusItemLength] retain];
mStatusItem.menu = nativeMenu;
mStatusItem.highlightMode = YES;
// We want the status item to get its image from menu item that mMenu was
// initialized with. Icon loads are asynchronous, so we need to let the menu
@ -61,7 +61,7 @@ nsSystemStatusBarCocoa::StatusItem::~StatusItem() {
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
mMenu->SetContainerStatusBarItem(nil);
[[NSStatusBar systemStatusBar] removeStatusItem:mStatusItem];
[NSStatusBar.systemStatusBar removeStatusItem:mStatusItem];
[mStatusItem release];
mStatusItem = nil;