fix for 27423, menus coming back sometimes after a item was selected. r=hyatt.
git-svn-id: svn://10.0.0.236/trunk@60412 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -75,6 +75,7 @@ XUL_ATOM(menubar, "menubar") // An XP menu bar.
|
||||
XUL_ATOM(menu, "menu") // Represents an XP menu
|
||||
XUL_ATOM(menuitem, "menuitem") // Represents an XP menu item
|
||||
XUL_ATOM(menupopup, "menupopup") // The XP menu's children.
|
||||
XUL_ATOM(menutobedisplayed, "menutobedisplayed") // The menu is about to be displayed at the next sync w/ frame
|
||||
XUL_ATOM(menuactive, "menuactive") // Whether or not a menu is active (without necessarily being open)
|
||||
XUL_ATOM(accesskey, "accesskey") // The shortcut key for a menu or menu item
|
||||
XUL_ATOM(acceltext, "acceltext") // Text to use for the accelerator
|
||||
|
||||
@@ -417,9 +417,16 @@ nsMenuFrame::ActivateMenu(PRBool aActivateFlag)
|
||||
|
||||
// We've got some children for real.
|
||||
if (child) {
|
||||
// When we sync the popup view with the frame, we'll show the popup if |menutobedisplayed|
|
||||
// is set by setting the |menuactive| attribute. This trips CSS to make the view visible.
|
||||
// We wait until the last possible moment to show to avoid flashing, but we can just go
|
||||
// ahead and hide it here if we're told to (no additional stages necessary).
|
||||
if (aActivateFlag)
|
||||
child->SetAttribute(kNameSpaceID_None, nsXULAtoms::menuactive, "true", PR_TRUE);
|
||||
else child->UnsetAttribute(kNameSpaceID_None, nsXULAtoms::menuactive, PR_TRUE);
|
||||
child->SetAttribute(kNameSpaceID_None, nsXULAtoms::menutobedisplayed, "true", PR_TRUE);
|
||||
else {
|
||||
child->UnsetAttribute(kNameSpaceID_None, nsXULAtoms::menuactive, PR_TRUE);
|
||||
child->UnsetAttribute(kNameSpaceID_None, nsXULAtoms::menutobedisplayed, PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@@ -509,6 +516,8 @@ nsMenuFrame::OpenMenuInternal(PRBool aActivateFlag)
|
||||
nsIFrame* frame = mPopupFrames.FirstChild();
|
||||
nsMenuPopupFrame* menuPopup = (nsMenuPopupFrame*)frame;
|
||||
|
||||
ActivateMenu(PR_TRUE);
|
||||
|
||||
if (menuPopup) {
|
||||
// Install a keyboard navigation listener if we're the root of the menu chain.
|
||||
PRBool onMenuBar = PR_TRUE;
|
||||
@@ -550,8 +559,6 @@ nsMenuFrame::OpenMenuInternal(PRBool aActivateFlag)
|
||||
menuPopup->SyncViewWithFrame(mPresContext, popupAnchor, popupAlign, this, -1, -1);
|
||||
}
|
||||
|
||||
ActivateMenu(PR_TRUE);
|
||||
|
||||
nsCOMPtr<nsIMenuParent> childPopup = do_QueryInterface(frame);
|
||||
UpdateDismissalListener(childPopup);
|
||||
|
||||
|
||||
@@ -323,6 +323,7 @@ nsMenuPopupFrame::SyncViewWithFrame(nsIPresContext* aPresContext,
|
||||
nsRect parentRect;
|
||||
aFrame->GetRect(parentRect);
|
||||
|
||||
#if 0
|
||||
const nsStyleDisplay* disp;
|
||||
GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&) disp);
|
||||
PRBool viewIsVisible = (NS_STYLE_VISIBILITY_VISIBLE == disp->mVisible);
|
||||
@@ -333,6 +334,7 @@ nsMenuPopupFrame::SyncViewWithFrame(nsIPresContext* aPresContext,
|
||||
if (viewWasVisible && (! viewIsVisible)) {
|
||||
view->SetVisibility(nsViewVisibility_kHide);
|
||||
}
|
||||
#endif
|
||||
|
||||
float p2t, t2p;
|
||||
aPresContext->GetScaledPixelsToTwips(&p2t);
|
||||
@@ -465,7 +467,11 @@ nsMenuPopupFrame::SyncViewWithFrame(nsIPresContext* aPresContext,
|
||||
viewManager->MoveViewTo(view, xpos, ypos);
|
||||
viewManager->ResizeView(view, mRect.width, mRect.height);
|
||||
|
||||
mContent->SetAttribute(kNameSpaceID_None, nsXULAtoms::menuactive, "true", PR_TRUE);
|
||||
nsAutoString shouldDisplay;
|
||||
mContent->GetAttribute(kNameSpaceID_None, nsXULAtoms::menutobedisplayed, shouldDisplay);
|
||||
if ( shouldDisplay.Equals("true") )
|
||||
mContent->SetAttribute(kNameSpaceID_None, nsXULAtoms::menuactive, "true", PR_TRUE);
|
||||
|
||||
#if 0
|
||||
if ((! viewWasVisible) && viewIsVisible) {
|
||||
view->SetVisibility(nsViewVisibility_kShow);
|
||||
|
||||
@@ -441,8 +441,9 @@ void
|
||||
nsPopupSetFrame::OpenPopup(PRBool aActivateFlag)
|
||||
{
|
||||
if (aActivateFlag) {
|
||||
nsIFrame* activeChild = GetActiveChild();
|
||||
ActivatePopup(PR_TRUE);
|
||||
|
||||
nsIFrame* activeChild = GetActiveChild();
|
||||
nsCOMPtr<nsIMenuParent> childPopup = do_QueryInterface(activeChild);
|
||||
UpdateDismissalListener(childPopup);
|
||||
childPopup->InstallKeyboardNavigator();
|
||||
@@ -471,9 +472,16 @@ nsPopupSetFrame::ActivatePopup(PRBool aActivateFlag)
|
||||
nsCOMPtr<nsIContent> content;
|
||||
GetActiveChildElement(getter_AddRefs(content));
|
||||
if (content) {
|
||||
// When we sync the popup view with the frame, we'll show the popup if |menutobedisplayed|
|
||||
// is set by setting the |menuactive| attribute. This trips CSS to make the view visible.
|
||||
// We wait until the last possible moment to show to avoid flashing, but we can just go
|
||||
// ahead and hide it here if we're told to (no additional stages necessary).
|
||||
if (aActivateFlag)
|
||||
content->SetAttribute(kNameSpaceID_None, nsXULAtoms::menuactive, "true", PR_TRUE);
|
||||
else content->UnsetAttribute(kNameSpaceID_None, nsXULAtoms::menuactive, PR_TRUE);
|
||||
content->SetAttribute(kNameSpaceID_None, nsXULAtoms::menutobedisplayed, "true", PR_TRUE);
|
||||
else {
|
||||
content->UnsetAttribute(kNameSpaceID_None, nsXULAtoms::menuactive, PR_TRUE);
|
||||
content->UnsetAttribute(kNameSpaceID_None, nsXULAtoms::menutobedisplayed, PR_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ XUL_ATOM(menubar, "menubar") // An XP menu bar.
|
||||
XUL_ATOM(menu, "menu") // Represents an XP menu
|
||||
XUL_ATOM(menuitem, "menuitem") // Represents an XP menu item
|
||||
XUL_ATOM(menupopup, "menupopup") // The XP menu's children.
|
||||
XUL_ATOM(menutobedisplayed, "menutobedisplayed") // The menu is about to be displayed at the next sync w/ frame
|
||||
XUL_ATOM(menuactive, "menuactive") // Whether or not a menu is active (without necessarily being open)
|
||||
XUL_ATOM(accesskey, "accesskey") // The shortcut key for a menu or menu item
|
||||
XUL_ATOM(acceltext, "acceltext") // Text to use for the accelerator
|
||||
|
||||
Reference in New Issue
Block a user