Bug 456374 disabled attribute doesn't update native submenu r=josh sr=roc

This commit is contained in:
Neil Rashbrook 2008-10-22 17:07:45 +01:00
parent 160e4afb66
commit 7316c49063

View File

@ -157,15 +157,13 @@ nsresult nsMenuX::Create(nsMenuObjectX* aParent, nsMenuBarX* aMenuBar, nsIConten
if (mContent->GetChildCount() == 0)
mVisible = PR_FALSE;
SetEnabled(!mContent->AttrValueIs(kNameSpaceID_None, nsWidgetAtoms::disabled,
nsWidgetAtoms::_true, eCaseMatters));
NSString *newCocoaLabelString = nsMenuUtilsX::CreateTruncatedCocoaLabel(mLabel);
mNativeMenuItem = [[NSMenuItem alloc] initWithTitle:newCocoaLabelString action:nil keyEquivalent:@""];
[newCocoaLabelString release];
[mNativeMenuItem setSubmenu:mNativeMenu];
[mNativeMenuItem setEnabled:(BOOL)mIsEnabled];
SetEnabled(!mContent->AttrValueIs(kNameSpaceID_None, nsWidgetAtoms::disabled,
nsWidgetAtoms::_true, eCaseMatters));
// We call MenuConstruct here because keyboard commands are dependent upon
// native menu items being created. If we only call MenuConstruct when a menu
@ -460,8 +458,8 @@ nsresult nsMenuX::SetEnabled(PRBool aIsEnabled)
{
if (aIsEnabled != mIsEnabled) {
// we always want to rebuild when this changes
SetRebuild(PR_TRUE);
mIsEnabled = aIsEnabled;
[mNativeMenuItem setEnabled:(BOOL)mIsEnabled];
}
return NS_OK;
}
@ -765,13 +763,10 @@ void nsMenuX::ObserveAttributeChanged(nsIDocument *aDocument, nsIContent *aConte
nsMenuObjectTypeX parentType = mParent->MenuObjectType();
if (aAttribute == nsWidgetAtoms::disabled) {
SetRebuild(PR_TRUE);
SetEnabled(!mContent->AttrValueIs(kNameSpaceID_None, nsWidgetAtoms::disabled,
nsWidgetAtoms::_true, eCaseMatters));
}
else if (aAttribute == nsWidgetAtoms::label) {
SetRebuild(PR_TRUE);
mContent->GetAttr(kNameSpaceID_None, nsWidgetAtoms::label, mLabel);
// invalidate my parent. If we're a submenu parent, we have to rebuild