mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-04 04:58:00 +00:00
Get MenuHelpersX compiling on 64-bit Mac OS X, some minor memory mgmt cleanup. b=459729 r=mstange sr=roc
This commit is contained in:
parent
df394d35f8
commit
104b89f8cf
@ -137,9 +137,8 @@ nsresult nsMenuItemX::Create(nsMenuX* aParent, const nsString& aLabel, EMenuItem
|
||||
mNativeMenuItem = [[NSMenuItem separatorItem] retain];
|
||||
}
|
||||
else {
|
||||
NSString *newCocoaLabelString = nsMenuUtilsX::CreateTruncatedCocoaLabel(aLabel);
|
||||
NSString *newCocoaLabelString = nsMenuUtilsX::GetTruncatedCocoaLabel(aLabel);
|
||||
mNativeMenuItem = [[NSMenuItem alloc] initWithTitle:newCocoaLabelString action:nil keyEquivalent:@""];
|
||||
[newCocoaLabelString release];
|
||||
|
||||
[mNativeMenuItem setEnabled:(BOOL)isEnabled];
|
||||
|
||||
|
@ -56,7 +56,7 @@ extern "C" MenuRef _NSGetCarbonMenu(NSMenu* aMenu);
|
||||
namespace nsMenuUtilsX
|
||||
{
|
||||
nsEventStatus DispatchCommandTo(nsIContent* aTargetContent);
|
||||
NSString* CreateTruncatedCocoaLabel(const nsString& itemLabel); // returned object is not retained
|
||||
NSString* GetTruncatedCocoaLabel(const nsString& itemLabel);
|
||||
PRUint8 GeckoModifiersForNodeAttribute(const nsString& modifiersAttribute);
|
||||
unsigned int MacModifiersForGeckoModifiers(PRUint8 geckoModifiers);
|
||||
nsMenuBarX* GetHiddenWindowMenuBar(); // returned object is not retained
|
||||
|
@ -60,18 +60,24 @@ nsEventStatus nsMenuUtilsX::DispatchCommandTo(nsIContent* aTargetContent)
|
||||
}
|
||||
|
||||
|
||||
NSString* nsMenuUtilsX::CreateTruncatedCocoaLabel(const nsString& itemLabel)
|
||||
NSString* nsMenuUtilsX::GetTruncatedCocoaLabel(const nsString& itemLabel)
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
||||
|
||||
#ifdef __LP64__
|
||||
// Don't do anything on 64-bit Mac OS X for now, there is no API that does
|
||||
// what we want. We'll probably need to roll our own solution.
|
||||
return [NSString stringWithCharacters:itemLabel.get() length:itemLabel.Length()];
|
||||
#else
|
||||
// ::TruncateThemeText() doesn't take the number of characters to truncate to, it takes a pixel with
|
||||
// to fit the string in. Ugh. I talked it over with sfraser and we couldn't come up with an
|
||||
// easy way to compute what this should be given the system font, etc, so we're just going
|
||||
// to hard code it to something reasonable and bigger fonts will just have to deal.
|
||||
const short kMaxItemPixelWidth = 300;
|
||||
NSMutableString *label = [[NSMutableString stringWithCharacters:itemLabel.get() length:itemLabel.Length()] retain];
|
||||
NSMutableString *label = [NSMutableString stringWithCharacters:itemLabel.get() length:itemLabel.Length()];
|
||||
::TruncateThemeText((CFMutableStringRef)label, kThemeMenuItemFont, kThemeStateActive, kMaxItemPixelWidth, truncMiddle, NULL);
|
||||
return label; // caller releases
|
||||
return label;
|
||||
#endif
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
||||
}
|
||||
|
@ -162,9 +162,8 @@ nsresult nsMenuX::Create(nsMenuObjectX* aParent, nsMenuBarX* aMenuBar, nsIConten
|
||||
if (mContent->GetChildCount() == 0)
|
||||
mVisible = PR_FALSE;
|
||||
|
||||
NSString *newCocoaLabelString = nsMenuUtilsX::CreateTruncatedCocoaLabel(mLabel);
|
||||
NSString *newCocoaLabelString = nsMenuUtilsX::GetTruncatedCocoaLabel(mLabel);
|
||||
mNativeMenuItem = [[NSMenuItem alloc] initWithTitle:newCocoaLabelString action:nil keyEquivalent:@""];
|
||||
[newCocoaLabelString release];
|
||||
[mNativeMenuItem setSubmenu:mNativeMenu];
|
||||
|
||||
SetEnabled(!mContent->AttrValueIs(kNameSpaceID_None, nsWidgetAtoms::disabled,
|
||||
@ -780,9 +779,8 @@ void nsMenuX::ObserveAttributeChanged(nsIDocument *aDocument, nsIContent *aConte
|
||||
if (parentType == eMenuBarObjectType) {
|
||||
// reuse the existing menu, to avoid rebuilding the root menu bar.
|
||||
NS_ASSERTION(mNativeMenu, "nsMenuX::AttributeChanged: invalid menu handle.");
|
||||
NSString *newCocoaLabelString = nsMenuUtilsX::CreateTruncatedCocoaLabel(mLabel);
|
||||
NSString *newCocoaLabelString = nsMenuUtilsX::GetTruncatedCocoaLabel(mLabel);
|
||||
[mNativeMenu setTitle:newCocoaLabelString];
|
||||
[newCocoaLabelString release];
|
||||
}
|
||||
else {
|
||||
static_cast<nsMenuX*>(mParent)->SetRebuild(PR_TRUE);
|
||||
|
Loading…
x
Reference in New Issue
Block a user