зеркало из https://github.com/mozilla/gecko-dev.git
Fix embedding bustage from bug 406730. Patch by Markus Stange <mstange@themasta.com>, r/sr=roc, a1.9=beltzner
This commit is contained in:
Родитель
250b4a6398
Коммит
4b2e5ea845
|
@ -2241,45 +2241,45 @@ nsGlobalWindow::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
|
|||
// Set / unset the "active" attribute on the documentElement
|
||||
// of the top level window
|
||||
nsCOMPtr<nsIWidget> mainWidget = GetMainWidget();
|
||||
NS_ENSURE_TRUE(mainWidget, nsnull);
|
||||
if (mainWidget) {
|
||||
// Get the top level widget (if the main widget is a sheet, this will
|
||||
// be the sheet's top (non-sheet) parent).
|
||||
nsCOMPtr<nsIWidget> topLevelWidget = mainWidget->GetSheetWindowParent();
|
||||
if (!topLevelWidget)
|
||||
topLevelWidget = mainWidget;
|
||||
|
||||
// Get the top level widget (if the main widget is a sheet, this will
|
||||
// be the sheet's top (non-sheet) parent).
|
||||
nsCOMPtr<nsIWidget> topLevelWidget = mainWidget->GetSheetWindowParent();
|
||||
if (!topLevelWidget)
|
||||
topLevelWidget = mainWidget;
|
||||
// Get the top level widget's nsGlobalWindow
|
||||
nsCOMPtr<nsIDOMWindowInternal> topLevelWindow;
|
||||
if (topLevelWidget == mainWidget) {
|
||||
topLevelWindow = static_cast<nsIDOMWindowInternal *>(this);
|
||||
} else {
|
||||
// This is a workaround for the following problem:
|
||||
// When a window with an open sheet loses focus, only the sheet window
|
||||
// receives the NS_DEACTIVATE event. However, it's not the sheet that
|
||||
// should lose the "active" attribute, but the containing top level window.
|
||||
void* clientData;
|
||||
topLevelWidget->GetClientData(clientData); // clientData is nsXULWindow
|
||||
nsISupports* data = static_cast<nsISupports*>(clientData);
|
||||
nsCOMPtr<nsIInterfaceRequestor> req(do_QueryInterface(data));
|
||||
topLevelWindow = do_GetInterface(req);
|
||||
}
|
||||
|
||||
// Get the top level widget's nsGlobalWindow
|
||||
nsCOMPtr<nsIDOMWindowInternal> topLevelWindow;
|
||||
if (topLevelWidget == mainWidget) {
|
||||
topLevelWindow = static_cast<nsIDOMWindowInternal *>(this);
|
||||
} else {
|
||||
// This is a workaround for the following problem:
|
||||
// When a window with an open sheet loses focus, only the sheet window
|
||||
// receives the NS_DEACTIVATE event. However, it's not the sheet that
|
||||
// should lose the "active" attribute, but the containing top level window.
|
||||
void* clientData;
|
||||
topLevelWidget->GetClientData(clientData); // clientData is nsXULWindow
|
||||
nsISupports* data = static_cast<nsISupports*>(clientData);
|
||||
nsCOMPtr<nsIInterfaceRequestor> req(do_QueryInterface(data));
|
||||
topLevelWindow = do_GetInterface(req);
|
||||
}
|
||||
|
||||
if (topLevelWindow) {
|
||||
// Only set the attribute if the document is a XUL document and the
|
||||
// window is a chrome window
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
topLevelWindow->GetDocument(getter_AddRefs(domDoc));
|
||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
|
||||
nsCOMPtr<nsIDOMXULDocument> xulDoc(do_QueryInterface(doc));
|
||||
nsCOMPtr<nsIDOMChromeWindow> chromeWin = do_QueryInterface(topLevelWindow);
|
||||
if (xulDoc && chromeWin) {
|
||||
nsCOMPtr<nsIContent> rootElem = doc->GetRootContent();
|
||||
if (aVisitor.mEvent->message == NS_ACTIVATE)
|
||||
rootElem->SetAttr(kNameSpaceID_None, nsGkAtoms::active,
|
||||
NS_LITERAL_STRING("true"), PR_TRUE);
|
||||
else
|
||||
rootElem->UnsetAttr(kNameSpaceID_None, nsGkAtoms::active, PR_TRUE);
|
||||
if (topLevelWindow) {
|
||||
// Only set the attribute if the document is a XUL document and the
|
||||
// window is a chrome window
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
topLevelWindow->GetDocument(getter_AddRefs(domDoc));
|
||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
|
||||
nsCOMPtr<nsIDOMXULDocument> xulDoc(do_QueryInterface(doc));
|
||||
nsCOMPtr<nsIDOMChromeWindow> chromeWin = do_QueryInterface(topLevelWindow);
|
||||
if (xulDoc && chromeWin) {
|
||||
nsCOMPtr<nsIContent> rootElem = doc->GetRootContent();
|
||||
if (aVisitor.mEvent->message == NS_ACTIVATE)
|
||||
rootElem->SetAttr(kNameSpaceID_None, nsGkAtoms::active,
|
||||
NS_LITERAL_STRING("true"), PR_TRUE);
|
||||
else
|
||||
rootElem->UnsetAttr(kNameSpaceID_None, nsGkAtoms::active, PR_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче