Bug 1980815: Ensure that the emoji picker menu item doesn't disappear from the menu bar and that its associated shortcuts continue to work on macOS. r=mac-reviewers,bradwerth a=pascalc
This is somewhat unfortunate, but I couldn't find a better way to address this. There are two aspects to this fix:
1. In order for SVG chicklets to appear in the context menu the first time it is opened, we have to set an nsMenuX to be rebuilt in its constructor (bug 1923666). However, this interferes with some menus, such as the Window and the Edit menu, since macOS adds its own menu items to these menus. This patch expands the fix for bug 1939346 for the Window menu to also include the Edit menu, where the Emoji picker is added as a menu item.
2. Bug 1808223 addressed a regression due to a macOS bug where the emoji picker and the dictation menu item are added every time that a main menu bar is set for an app, but macOS 'forgets' to remove these items when switched away from one Firefox window to another and back again. One quirk about this is that if the user switches to another APP and back to the same Firefox window, macOS will not re-add these menu items to the edit menu again. So we need to avoid removing these problematic menu items in this situation. I was hoping to implement a fix that would simply remove duplicates *after* setting the `NSApp.mainMenu`, but if we do so then macOS will remove ALL added menu items and the emoji picker will disappear entirely from the Edit menu. So this appears to be the only way to properly fix this.
Differential Revision: https://phabricator.services.mozilla.com/D268239
This commit is contained in:
committed by
pchevrel@mozilla.com
parent
16d805c5e8
commit
2a3c838e24
@@ -492,7 +492,15 @@ nsresult nsMenuBarX::Paint() {
|
|||||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||||
|
|
||||||
RemoveProblematicMenuItems(mNativeMenu);
|
// If the user switches to another app and back to the last open window, we
|
||||||
|
// should not remove the problematic menu items again or the emoji picker
|
||||||
|
// would not be able to be opened again via shortcuts. This should be the only
|
||||||
|
// time that `sLastGeckoMenuBarPainted` is checked in this method, since other
|
||||||
|
// optimizations could interfere with menu manipulations by native dialogs and
|
||||||
|
// similar (see comment above).
|
||||||
|
if (nsMenuBarX::sLastGeckoMenuBarPainted != this) {
|
||||||
|
RemoveProblematicMenuItems(mNativeMenu);
|
||||||
|
}
|
||||||
|
|
||||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||||
|
|||||||
@@ -180,6 +180,7 @@ class nsMenuX final : public nsMenuParentX,
|
|||||||
|
|
||||||
static bool IsXULHelpMenu(nsIContent* aMenuContent);
|
static bool IsXULHelpMenu(nsIContent* aMenuContent);
|
||||||
static bool IsXULWindowMenu(nsIContent* aMenuContent);
|
static bool IsXULWindowMenu(nsIContent* aMenuContent);
|
||||||
|
static bool IsXULEditMenu(nsIContent* aMenuContent);
|
||||||
|
|
||||||
// Set an observer that gets notified of menu opening and closing.
|
// Set an observer that gets notified of menu opening and closing.
|
||||||
// The menu does not keep a strong reference the observer. The observer must
|
// The menu does not keep a strong reference the observer. The observer must
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ nsMenuX::nsMenuX(nsMenuParentX* aParent, nsMenuGroupOwnerX* aMenuGroupOwner,
|
|||||||
mIcon = MakeUnique<nsMenuItemIconX>(this);
|
mIcon = MakeUnique<nsMenuItemIconX>(this);
|
||||||
|
|
||||||
if (mVisible) {
|
if (mVisible) {
|
||||||
if (!isXULWindowMenu) {
|
if (!isXULWindowMenu && !IsXULEditMenu(mContent)) {
|
||||||
SetRebuild(true);
|
SetRebuild(true);
|
||||||
}
|
}
|
||||||
SetupIcon();
|
SetupIcon();
|
||||||
@@ -1012,6 +1012,18 @@ bool nsMenuX::IsXULWindowMenu(nsIContent* aMenuContent) {
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool nsMenuX::IsXULEditMenu(nsIContent* aMenuContent) {
|
||||||
|
bool retval = false;
|
||||||
|
if (aMenuContent && aMenuContent->IsElement()) {
|
||||||
|
nsAutoString id;
|
||||||
|
aMenuContent->AsElement()->GetAttr(nsGkAtoms::id, id);
|
||||||
|
if (id.Equals(u"edit-menu"_ns)) {
|
||||||
|
retval = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// nsChangeObserver
|
// nsChangeObserver
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user