Skip to content
Snippets Groups Projects
Commit 7e709162 authored by masayuki%d-toybox.com's avatar masayuki%d-toybox.com
Browse files

Bug 295223 Bookmark menu collapses when hovering folder in level 1, quickly...

Bug 295223 Bookmark menu collapses when hovering folder in level 1, quickly marking another folder in level 1, and then hovering folder in level 2 (subfolder of first folder). r+sr=bryner
parent f82d1468
No related branches found
No related tags found
No related merge requests found
......@@ -40,9 +40,9 @@
#define nsIMenuParent_h___
// {81C0BF71-9F50-4f4d-8B6A-D6B233C100C2}
// {0D1F2281-A530-419c-AE2C-21672590A9EC}
#define NS_IMENUPARENT_IID \
{ 0x81c0bf71, 0x9f50, 0x4f4d, { 0x8b, 0x6a, 0xd6, 0xb2, 0x33, 0xc1, 0x0, 0xc2 } };
{ 0x0d1f2281, 0xa530, 0x419c, { 0xae, 0x2c, 0x21, 0x67, 0x25, 0x90, 0xa9, 0xec } }
class nsIMenuFrame;
class nsIDOMKeyEvent;
......@@ -156,6 +156,7 @@ public:
NS_IMETHOD DismissChain() = 0;
NS_IMETHOD HideChain() = 0;
NS_IMETHOD KillPendingTimers() = 0;
NS_IMETHOD CancelPendingTimers() = 0;
NS_IMETHOD CreateDismissalListener() = 0;
......@@ -172,7 +173,8 @@ public:
NS_IMETHOD SetIsContextMenu(PRBool aIsContextMenu) = 0;
NS_IMETHOD GetIsContextMenu(PRBool& aIsContextMenu) = 0;
NS_IMETHOD GetParentPopup(nsIMenuParent** aResult) = 0;
};
#endif
......
......@@ -82,11 +82,15 @@ public:
NS_IMETHOD SetIsContextMenu(PRBool aIsContextMenu) { return NS_OK; };
NS_IMETHOD GetIsContextMenu(PRBool& aIsContextMenu) { aIsContextMenu = PR_FALSE; return NS_OK; };
NS_IMETHOD GetParentPopup(nsIMenuParent** aResult) { *aResult = nsnull;
return NS_OK;};
NS_IMETHOD IsActive() { return mIsActive; };
NS_IMETHOD IsOpen();
NS_IMETHOD KillPendingTimers();
NS_IMETHOD CancelPendingTimers() { return NS_OK; };
// Closes up the chain of open cascaded menus.
NS_IMETHOD DismissChain();
......
......@@ -568,6 +568,14 @@ nsMenuFrame::SelectMenu(PRBool aActivateFlag)
nsAutoString domEventToFire;
if (aActivateFlag) {
if (mMenuParent) {
nsIMenuParent* ancestor = nsnull;
nsresult rv = mMenuParent->GetParentPopup(&ancestor);
while (NS_SUCCEEDED(rv) && ancestor) {
ancestor->CancelPendingTimers();
rv = ancestor->GetParentPopup(&ancestor);
}
}
// Highlight the menu.
mContent->SetAttr(kNameSpaceID_None, nsXULAtoms::menuactive, NS_LITERAL_STRING("true"), PR_TRUE);
// The menuactivated event is used by accessibility to track the user's movements through menus
......
......@@ -1754,12 +1754,15 @@ NS_IMETHODIMP
nsMenuPopupFrame::GetParentPopup(nsIMenuParent** aMenuParent)
{
*aMenuParent = nsnull;
nsIFrame* frame = GetParent();
if (frame) {
nsIFrame* grandparent = frame->GetParent();
if (grandparent ) {
CallQueryInterface(grandparent, aMenuParent);
nsIFrame* parent = GetParent();
while (parent) {
nsCOMPtr<nsIMenuParent> menuParent = do_QueryInterface(parent);
if (menuParent) {
*aMenuParent = menuParent.get();
NS_ADDREF(*aMenuParent);
return NS_OK;
}
parent = parent->GetParent();
}
return NS_OK;
}
......@@ -2031,39 +2034,11 @@ nsMenuPopupFrame::Notify(nsITimer* aTimer)
if (aTimer == mCloseTimer.get()) {
PRBool menuOpen = PR_FALSE;
mTimerMenu->MenuIsOpen(menuOpen);
if (menuOpen) {
if (mCurrentMenu != mTimerMenu) {
// Walk through all of the sub-menus of this menu item until we get to the
// last sub-menu, then check if that sub-menu has an active menu item. If it
// does, then keep that menu open. If it doesn't, close menu and its sub-menus.
nsIFrame* child = mTimerMenu->GetMenuChild();
nsIMenuFrame *currentMenuItem = nsnull;
nsIMenuParent *menuParent;
while (child && NS_SUCCEEDED(CallQueryInterface(child, &menuParent)))
{
// get the selected menu item for this sub-menu
currentMenuItem = menuParent->GetCurrentMenuItem();
// if this sub-menu has a selected menu item, does that item open a sub-menu?
child = currentMenuItem ? currentMenuItem->GetMenuChild() : nsnull;
} // while we're not at the last submenu
if (currentMenuItem)
{
// the sub-menu has a selected menu item, we're dealing with case (1)
SetCurrentMenuItem(mTimerMenu);
}
else {
// Nothing selected. Either the mouse never made it to the submenu
// in case (1) or we're in a sibling of a grandparent in case (2).
// Regardless, close up the open chain.
mTimerMenu->OpenMenu(PR_FALSE);
}
} // if not the menu with an open submenu
} // if menu open
if (mCloseTimer) {
if (menuOpen)
mTimerMenu->OpenMenu(PR_FALSE);
if (mCloseTimer)
mCloseTimer->Cancel();
}
}
mCloseTimer = nsnull;
......@@ -2096,6 +2071,20 @@ nsMenuPopupFrame::KillPendingTimers ( )
} // KillPendingTimers
NS_IMETHODIMP
nsMenuPopupFrame::CancelPendingTimers()
{
if (mCloseTimer && mTimerMenu) {
if (mTimerMenu != mCurrentMenu) {
SetCurrentMenuItem(mTimerMenu);
}
mCloseTimer->Cancel();
mCloseTimer = nsnull;
mTimerMenu = nsnull;
}
return NS_OK;
}
void
nsMenuPopupFrame::MoveTo(PRInt32 aLeft, PRInt32 aTop)
{
......
......@@ -106,6 +106,7 @@ public:
NS_IMETHOD HideChain();
NS_IMETHOD KillPendingTimers();
NS_IMETHOD CancelPendingTimers();
NS_IMETHOD InstallKeyboardNavigator();
NS_IMETHOD RemoveKeyboardNavigator();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment