зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1478347: Ensure that macOS-provided menu items are available in the Edit menu, especially in multi-language environments where Firefox may have a different language than the OS. r=mstange
Differential Revision: https://phabricator.services.mozilla.com/D193931
This commit is contained in:
Родитель
4160ed800a
Коммит
877adfeec8
|
@ -40,6 +40,7 @@
|
|||
#include "nsCommandLine.h"
|
||||
#include "nsStandaloneNativeMenu.h"
|
||||
#include "nsCocoaUtils.h"
|
||||
#include "nsMenuBarX.h"
|
||||
|
||||
class AutoAutoreleasePool {
|
||||
public:
|
||||
|
@ -53,6 +54,11 @@ class AutoAutoreleasePool {
|
|||
@interface MacApplicationDelegate : NSObject <NSApplicationDelegate> {
|
||||
}
|
||||
|
||||
// This is used as a workaround for bug 1478347 in order to make OS-provided
|
||||
// menu items such as the emoji picker available in the Edit menu, especially
|
||||
// in multi-language environments.
|
||||
- (IBAction)copy:(id)aSender;
|
||||
|
||||
@end
|
||||
|
||||
enum class LaunchStatus {
|
||||
|
@ -140,6 +146,10 @@ void ProcessPendingGetURLAppleEvents() {
|
|||
|
||||
@implementation MacApplicationDelegate
|
||||
|
||||
- (IBAction)copy:(id)aSender {
|
||||
[nsMenuBarX::sNativeEventTarget menuItemHit:aSender];
|
||||
}
|
||||
|
||||
- (id)init {
|
||||
NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
|
||||
|
||||
|
|
|
@ -536,7 +536,7 @@ void nsMenuBarX::MenuChildChangedVisibility(const MenuChild& aChild,
|
|||
NSMenuItem* item = child->NativeNSMenuItem();
|
||||
if (aIsVisible) {
|
||||
NSInteger insertionPoint = CalculateNativeInsertionPoint(child);
|
||||
[mNativeMenu insertItem:child->NativeNSMenuItem() atIndex:insertionPoint];
|
||||
[mNativeMenu insertItem:item atIndex:insertionPoint];
|
||||
} else if ([mNativeMenu indexOfItem:item] != -1) {
|
||||
[mNativeMenu removeItem:item];
|
||||
}
|
||||
|
|
|
@ -97,10 +97,22 @@ nsMenuItemX::nsMenuItemX(nsMenuX* aParent, const nsString& aLabel,
|
|||
|
||||
mIsVisible = !nsMenuUtilsX::NodeIsHiddenOrCollapsed(mContent);
|
||||
|
||||
// All menu items share the same target and action, and are differentiated
|
||||
// be a unique (representedObject, tag) pair.
|
||||
mNativeMenuItem.target = nsMenuBarX::sNativeEventTarget;
|
||||
mNativeMenuItem.action = @selector(menuItemHit:);
|
||||
// All menu items other than the "Copy" menu item share the same target and
|
||||
// action, and are differentiated be a unique (representedObject, tag) pair.
|
||||
// The "Copy" menu item is a special case that requires a macOS-default
|
||||
// action of `copy:` and a default target in order for the "Edit" menu to be
|
||||
// populated with OS-provided menu items such as the Emoji picker,
|
||||
// especially in multi-language environments (see bug 1478347). Our
|
||||
// application delegate implements `copy:` by simply forwarding it to
|
||||
// [nsMenuBarX::sNativeEventTarget menuItemHit:].
|
||||
if (mContent->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::id,
|
||||
u"menu_copy"_ns, eCaseMatters)) {
|
||||
mNativeMenuItem.action = @selector(copy:);
|
||||
} else {
|
||||
mNativeMenuItem.action = @selector(menuItemHit:);
|
||||
mNativeMenuItem.target = nsMenuBarX::sNativeEventTarget;
|
||||
}
|
||||
|
||||
mNativeMenuItem.representedObject = mMenuGroupOwner->GetRepresentedObject();
|
||||
mNativeMenuItem.tag = mMenuGroupOwner->RegisterForCommand(this);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче