mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 04:45:45 +00:00
Bug 100729 Sync <command> checkbox attribute with <menuitem>s in a context menu as well as in a menu bar and clean up the synchronizing code r+sr=bz
This commit is contained in:
parent
db42e94c3d
commit
8adacd68e7
@ -1719,44 +1719,29 @@ nsMenuFrame::OnCreate()
|
||||
nsCOMPtr<nsIContent> 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)) {
|
||||
nsAutoString commandAttr;
|
||||
// The menu's disabled state needs to be updated to match the command.
|
||||
if (commandAttr.IsEmpty())
|
||||
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);
|
||||
else grandChild->SetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, 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* 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())
|
||||
// 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())
|
||||
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())
|
||||
if (commandContent->GetAttr(kNameSpaceID_None, nsXULAtoms::label, commandAttr))
|
||||
grandChild->SetAttr(kNameSpaceID_None, nsXULAtoms::label, commandAttr, PR_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
@ -612,35 +612,24 @@ nsPopupSetFrame::OnCreate(PRInt32 aX, PRInt32 aY, nsIContent* aPopupContent)
|
||||
domDoc->GetElementById(command, getter_AddRefs(commandElt));
|
||||
nsCOMPtr<nsIContent> 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)) {
|
||||
nsAutoString commandValue;
|
||||
// The menu's disabled state needs to be updated to match the command.
|
||||
if (commandDisabled.IsEmpty())
|
||||
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);
|
||||
else grandChild->SetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, commandDisabled, 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())
|
||||
// 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())
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user