diff --git a/layout/xul/base/src/nsMenuFrame.cpp b/layout/xul/base/src/nsMenuFrame.cpp index 2b32b58c6c3c..4a157b68b172 100644 --- a/layout/xul/base/src/nsMenuFrame.cpp +++ b/layout/xul/base/src/nsMenuFrame.cpp @@ -1719,39 +1719,24 @@ nsMenuFrame::OnCreate() nsCOMPtr commandContent(do_QueryInterface(commandElt)); if ( commandContent ) { - nsAutoString commandAttr, menuAttr; - commandContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, commandAttr); - grandChild->GetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, menuAttr); - if (!commandAttr.Equals(menuAttr)) { - // The menu's disabled state needs to be updated to match the command. - if (commandAttr.IsEmpty()) - grandChild->UnsetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, PR_TRUE); - else grandChild->SetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, commandAttr, PR_TRUE); - } + nsAutoString commandAttr; + // The menu's disabled state needs to be updated to match the command. + if (commandContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, commandAttr)) + grandChild->SetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, commandAttr, PR_TRUE); + else + grandChild->UnsetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, PR_TRUE); - // The menu's label, accesskey, and checked states need to be updated to match the command. - // Note that (unlike the disabled state) if the command has *no* label for either, we - // assume the menu is supplying its own. - commandContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::checked, commandAttr); - grandChild->GetAttr(kNameSpaceID_None, nsHTMLAtoms::checked, menuAttr); - if (!commandAttr.Equals(menuAttr)) { - if (!commandAttr.IsEmpty()) - grandChild->SetAttr(kNameSpaceID_None, nsHTMLAtoms::checked, commandAttr, PR_TRUE); - } + // The menu's label, accesskey and checked states need to be updated + // to match the command. Note that unlike the disabled state if the + // command has *no* value, we assume the menu is supplying its own. + if (commandContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::checked, commandAttr)) + grandChild->SetAttr(kNameSpaceID_None, nsHTMLAtoms::checked, commandAttr, PR_TRUE); - commandContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::accesskey, commandAttr); - grandChild->GetAttr(kNameSpaceID_None, nsHTMLAtoms::accesskey, menuAttr); - if (!commandAttr.Equals(menuAttr)) { - if (!commandAttr.IsEmpty()) - grandChild->SetAttr(kNameSpaceID_None, nsHTMLAtoms::accesskey, commandAttr, PR_TRUE); - } + if (commandContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::accesskey, commandAttr)) + grandChild->SetAttr(kNameSpaceID_None, nsHTMLAtoms::accesskey, commandAttr, PR_TRUE); - commandContent->GetAttr(kNameSpaceID_None, nsXULAtoms::label, commandAttr); - grandChild->GetAttr(kNameSpaceID_None, nsXULAtoms::label, menuAttr); - if (!commandAttr.Equals(menuAttr)) { - if (!commandAttr.IsEmpty()) - grandChild->SetAttr(kNameSpaceID_None, nsXULAtoms::label, commandAttr, PR_TRUE); - } + if (commandContent->GetAttr(kNameSpaceID_None, nsXULAtoms::label, commandAttr)) + grandChild->SetAttr(kNameSpaceID_None, nsXULAtoms::label, commandAttr, PR_TRUE); } } } diff --git a/layout/xul/base/src/nsPopupSetFrame.cpp b/layout/xul/base/src/nsPopupSetFrame.cpp index 0080edf2964a..ea75f6a592b5 100644 --- a/layout/xul/base/src/nsPopupSetFrame.cpp +++ b/layout/xul/base/src/nsPopupSetFrame.cpp @@ -612,35 +612,24 @@ nsPopupSetFrame::OnCreate(PRInt32 aX, PRInt32 aY, nsIContent* aPopupContent) domDoc->GetElementById(command, getter_AddRefs(commandElt)); nsCOMPtr commandContent(do_QueryInterface(commandElt)); if ( commandContent ) { - nsAutoString commandDisabled, menuDisabled; - commandContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, commandDisabled); - grandChild->GetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, menuDisabled); - if (!commandDisabled.Equals(menuDisabled)) { - // The menu's disabled state needs to be updated to match the command. - if (commandDisabled.IsEmpty()) - grandChild->UnsetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, PR_TRUE); - else grandChild->SetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, commandDisabled, PR_TRUE); - } + nsAutoString commandValue; + // The menu's disabled state needs to be updated to match the command. + if (commandContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, commandValue)) + grandChild->SetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, commandValue, PR_TRUE); + else + grandChild->UnsetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, PR_TRUE); - nsAutoString commandValue, menuValue; - commandContent->GetAttr(kNameSpaceID_None, nsXULAtoms::label, commandValue); - grandChild->GetAttr(kNameSpaceID_None, nsXULAtoms::label, menuValue); - if (!commandValue.Equals(menuValue)) { - // The menu's value state needs to be updated to match the command. - // Note that (unlike the disabled state) if the command has *no* value, we - // assume the menu is supplying its own. - if (!commandValue.IsEmpty()) - grandChild->SetAttr(kNameSpaceID_None, nsXULAtoms::label, commandValue, PR_TRUE); - } + // The menu's label, accesskey and checked states need to be updated + // to match the command. Note that unlike the disabled state if the + // command has *no* value, we assume the menu is supplying its own. + if (commandContent->GetAttr(kNameSpaceID_None, nsXULAtoms::label, commandValue)) + grandChild->SetAttr(kNameSpaceID_None, nsXULAtoms::label, commandValue, PR_TRUE); - // The menu's accesskey needs to be updated to match the command. - // If the command has no accesskey, assume the menu is supplying its own. - commandContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::accesskey, commandValue); - grandChild->GetAttr(kNameSpaceID_None, nsHTMLAtoms::accesskey, menuValue); - if (!commandValue.Equals(menuValue)) { - if (!commandValue.IsEmpty()) - grandChild->SetAttr(kNameSpaceID_None, nsHTMLAtoms::accesskey, commandValue, PR_TRUE); - } + if (commandContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::accesskey, commandValue)) + grandChild->SetAttr(kNameSpaceID_None, nsHTMLAtoms::accesskey, commandValue, PR_TRUE); + + if (commandContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::checked, commandValue)) + grandChild->SetAttr(kNameSpaceID_None, nsHTMLAtoms::checked, commandValue, PR_TRUE); } } }