Bug 989947 - disable popups during modal alerts on OS X, r=bz

This commit is contained in:
Gijs Kruitbosch 2014-11-12 17:05:29 +00:00
parent b34a02ceac
commit e62dfd0026
2 changed files with 28 additions and 8 deletions

View File

@ -8818,6 +8818,16 @@ nsGlobalWindow::LeaveModalState()
nsGlobalWindow *inner = topWin->GetCurrentInnerWindowInternal();
if (inner)
inner->mLastDialogQuitTime = TimeStamp::Now();
if (topWin->mModalStateDepth == 0) {
nsCOMPtr<nsIDOMEvent> event;
NS_NewDOMEvent(getter_AddRefs(event), topWin, nullptr, nullptr);
event->InitEvent(NS_LITERAL_STRING("endmodalstate"), true, false);
event->SetTrusted(true);
event->GetInternalNSEvent()->mFlags.mOnlyChromeDispatch = true;
bool dummy;
topWin->DispatchEvent(event, &dummy);
}
}
bool

View File

@ -16,6 +16,7 @@
#include "nsIXULDocument.h"
#include "nsIXULTemplateBuilder.h"
#include "nsCSSFrameConstructor.h"
#include "nsGlobalWindow.h"
#include "nsLayoutUtils.h"
#include "nsViewManager.h"
#include "nsIComponentManager.h"
@ -1594,18 +1595,18 @@ nsXULPopupManager::MayShowPopup(nsMenuPopupFrame* aPopup)
if (!baseWin)
return false;
nsCOMPtr<nsIDocShellTreeItem> root;
dsti->GetRootTreeItem(getter_AddRefs(root));
if (!root) {
return false;
}
nsCOMPtr<nsIDOMWindow> rootWin = root->GetWindow();
// chrome shells can always open popups, but other types of shells can only
// open popups when they are focused and visible
if (dsti->ItemType() != nsIDocShellTreeItem::typeChrome) {
// only allow popups in active windows
nsCOMPtr<nsIDocShellTreeItem> root;
dsti->GetRootTreeItem(getter_AddRefs(root));
if (!root) {
return false;
}
nsCOMPtr<nsIDOMWindow> rootWin = root->GetWindow();
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
if (!fm || !rootWin)
return false;
@ -1630,6 +1631,15 @@ nsXULPopupManager::MayShowPopup(nsMenuPopupFrame* aPopup)
return false;
}
#ifdef XP_MACOSX
if (rootWin) {
nsGlobalWindow *globalWin = static_cast<nsGlobalWindow *>(rootWin.get());
if (globalWin->IsInModalState()) {
return false;
}
}
#endif
// cannot open a popup that is a submenu of a menupopup that isn't open.
nsMenuFrame* menuFrame = do_QueryFrame(aPopup->GetParent());
if (menuFrame) {