зеркало из https://github.com/mozilla/pjs.git
Fix for 204672, Mac OS X menus don't respect autocheck, r/sr=bryner, a=asa
This commit is contained in:
Родитель
68de1d1595
Коммит
5a2b50472c
|
@ -68,6 +68,7 @@ WIDGET_ATOM(accesskey, "accesskey") // The shortcut key for a menu or menu item
|
|||
|
||||
WIDGET_ATOM(name, "name")
|
||||
WIDGET_ATOM(type, "type")
|
||||
WIDGET_ATOM(autocheck, "autocheck")
|
||||
WIDGET_ATOM(checked, "checked")
|
||||
WIDGET_ATOM(disabled, "disabled")
|
||||
WIDGET_ATOM(label, "label")
|
||||
|
|
|
@ -136,8 +136,11 @@ NS_METHOD nsMenuItemX::SetChecked(PRBool aIsEnabled)
|
|||
|
||||
// update the content model. This will also handle unchecking our siblings
|
||||
// if we are a radiomenu
|
||||
mContent->SetAttr(kNameSpaceID_None, nsWidgetAtoms::checked,
|
||||
mIsChecked ? NS_LITERAL_STRING("true") : NS_LITERAL_STRING("false"), PR_TRUE);
|
||||
if (mIsChecked)
|
||||
mContent->SetAttr(kNameSpaceID_None, nsWidgetAtoms::checked,
|
||||
NS_LITERAL_STRING("true"), PR_TRUE);
|
||||
else
|
||||
mContent->UnsetAttr(kNameSpaceID_None, nsWidgetAtoms::checked, PR_TRUE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -255,7 +258,16 @@ nsEventStatus nsMenuItemX::SetRebuild(PRBool aNeedsRebuild)
|
|||
*/
|
||||
NS_METHOD nsMenuItemX::DoCommand()
|
||||
{
|
||||
return MenuHelpersX::DispatchCommandTo(mWebShellWeakRef, mContent);
|
||||
// flip "checked" state if we're a checkbox menu, or an un-checked radio menu
|
||||
if (mMenuType == nsIMenuItem::eCheckbox || (mMenuType == nsIMenuItem::eRadio && !mIsChecked)) {
|
||||
nsAutoString value;
|
||||
mContent->GetAttr(kNameSpaceID_None, nsWidgetAtoms::autocheck, value);
|
||||
if (!value.Equals(NS_LITERAL_STRING("false")))
|
||||
SetChecked(!mIsChecked);
|
||||
/* the AttributeChanged code will update all the internal state */
|
||||
}
|
||||
|
||||
return MenuHelpersX::DispatchCommandTo(mWebShellWeakRef, mContent);
|
||||
}
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче