mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 12:25:53 +00:00
Bug 539317 - [10.6] Help menu does not include Apple search if no visible windows. r=josh
This commit is contained in:
parent
30fbafac45
commit
66f3a78ea8
@ -131,6 +131,8 @@ public:
|
||||
PRUint32 GetMenuCount();
|
||||
bool MenuContainsAppMenu();
|
||||
nsMenuX* GetMenuAt(PRUint32 aIndex);
|
||||
nsMenuX* GetXULHelpMenu();
|
||||
void SetSystemHelpMenu();
|
||||
nsresult Paint();
|
||||
void ForceUpdateNativeMenuAt(const nsAString& indexString);
|
||||
void ForceNativeMenuReload(); // used for testing
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "nsMenuUtilsX.h"
|
||||
#include "nsCocoaUtils.h"
|
||||
#include "nsCocoaWindow.h"
|
||||
#include "nsToolkit.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
@ -314,6 +315,34 @@ nsMenuX* nsMenuBarX::GetMenuAt(PRUint32 aIndex)
|
||||
return mMenuArray[aIndex];
|
||||
}
|
||||
|
||||
nsMenuX* nsMenuBarX::GetXULHelpMenu()
|
||||
{
|
||||
// The Help menu is usually (always?) the last one, so we start there and
|
||||
// count back.
|
||||
for (PRInt32 i = GetMenuCount() - 1; i >= 0; --i) {
|
||||
nsMenuX* aMenu = GetMenuAt(i);
|
||||
if (aMenu && nsMenuX::IsXULHelpMenu(aMenu->Content()))
|
||||
return aMenu;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
// On SnowLeopard and later we must tell the OS which is our Help menu.
|
||||
// Otherwise it will only add Spotlight for Help (the Search item) to our
|
||||
// Help menu if its label/title is "Help" -- i.e. if the menu is in English.
|
||||
// This resolves bugs 489196 and 539317.
|
||||
void nsMenuBarX::SetSystemHelpMenu()
|
||||
{
|
||||
if (!nsToolkit::OnSnowLeopardOrLater())
|
||||
return;
|
||||
nsMenuX* xulHelpMenu = GetXULHelpMenu();
|
||||
if (xulHelpMenu) {
|
||||
NSMenu* helpMenu = (NSMenu*)xulHelpMenu->NativeData();
|
||||
if (helpMenu)
|
||||
[NSApp setHelpMenu:helpMenu];
|
||||
}
|
||||
}
|
||||
|
||||
nsresult nsMenuBarX::Paint()
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
@ -334,6 +363,7 @@ nsresult nsMenuBarX::Paint()
|
||||
|
||||
// Set menu bar and event target.
|
||||
[NSApp setMainMenu:mNativeMenu];
|
||||
SetSystemHelpMenu();
|
||||
nsMenuBarX::sLastGeckoMenuBarPainted = this;
|
||||
|
||||
gSomeMenuBarPainted = YES;
|
||||
|
@ -515,13 +515,6 @@ GeckoNSMenu* nsMenuX::CreateMenuWithGeckoString(nsString& menuTitle)
|
||||
// overrides our decisions and things get incorrectly enabled/disabled.
|
||||
[myMenu setAutoenablesItems:NO];
|
||||
|
||||
// On SnowLeopard and later we must tell the OS which is our Help menu.
|
||||
// Otherwise it will only add Spotlight for Help (the Search item) to our
|
||||
// Help menu if its label/title is "Help" -- i.e. if the menu is in English.
|
||||
// This resolves bug 489196.
|
||||
if (nsToolkit::OnSnowLeopardOrLater() && nsMenuX::IsXULHelpMenu(mContent))
|
||||
[NSApp setHelpMenu:myMenu];
|
||||
|
||||
// we used to install Carbon event handlers here, but since NSMenu* doesn't
|
||||
// create its underlying MenuRef until just before display, we delay until
|
||||
// that happens. Now we install the event handlers when Cocoa notifies
|
||||
|
Loading…
Reference in New Issue
Block a user