Commit 7316c490 authored by Neil Rashbrook's avatar Neil Rashbrook
Browse files

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

parent 160e4afb
Loading
Loading
Loading
Loading
+3 −8
Original line number Diff line number Diff line
@@ -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