From 7ebe7c99a250307276346060ceb0736c7980a0a4 Mon Sep 17 00:00:00 2001 From: Neil Deakin Date: Mon, 13 Jul 2015 06:07:49 -0400 Subject: [PATCH] Bug 1177000, only consider popups of the same type when determining whether a popup shouldn't reopen, this allows dropdown buttons in popup to reopen properly, r=neil --- layout/xul/nsXULPopupManager.cpp | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/layout/xul/nsXULPopupManager.cpp b/layout/xul/nsXULPopupManager.cpp index 14e8790ff51..63d8fed4cb9 100644 --- a/layout/xul/nsXULPopupManager.cpp +++ b/layout/xul/nsXULPopupManager.cpp @@ -188,17 +188,26 @@ nsXULPopupManager::Rollup(uint32_t aCount, bool aFlush, nsMenuChainItem* item = GetTopVisibleMenu(); if (item) { if (aLastRolledUp) { - // we need to get the popup that will be closed last, so that - // widget can keep track of it so it doesn't reopen if a mouse - // down event is going to processed. - // Keep going up the menu chain to get the first level menu. This will - // be the one that closes up last. It's possible that this menu doesn't - // end up closing because the popuphiding event was cancelled, but in - // that case we don't need to deal with the menu reopening as it will - // already still be open. + // We need to get the popup that will be closed last, so that widget can + // keep track of it so it doesn't reopen if a mousedown event is going to + // processed. Keep going up the menu chain to get the first level menu of + // the same type. If a different type is encountered it means we have, + // for example, a menulist or context menu inside a panel, and we want to + // treat these as distinct. It's possible that this menu doesn't end up + // closing because the popuphiding event was cancelled, but in that case + // we don't need to deal with the menu reopening as it will already still + // be open. nsMenuChainItem* first = item; - while (first->GetParent()) - first = first->GetParent(); + while (first->GetParent()) { + nsMenuChainItem* parent = first->GetParent(); + if (first->Frame()->PopupType() != parent->Frame()->PopupType() || + first->IsContextMenu() != parent->IsContextMenu()) { + break; + } + first = parent; + } + + *aLastRolledUp = first->Content(); }