mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 875157 (part 1) - add isParentWindowMainWidgetVisible to nsIDOMWindowUtils. r=bz
--HG-- extra : rebase_source : ba752abd8c16276e438d3af0742a9d74897acad0
This commit is contained in:
parent
22609655c2
commit
0bf40bcd37
@ -3286,6 +3286,36 @@ nsDOMWindowUtils::AllowScriptsToClose()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWindowUtils::GetIsParentWindowMainWidgetVisible(bool* aIsVisible)
|
||||
{
|
||||
if (!nsContentUtils::IsCallerChrome()) {
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
|
||||
// this should reflect the "is parent window visible" logic in
|
||||
// nsWindowWatcher::OpenWindowInternal()
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
|
||||
NS_ENSURE_STATE(window);
|
||||
|
||||
nsCOMPtr<nsIWidget> parentWidget;
|
||||
nsIDocShell *docShell = window->GetDocShell();
|
||||
if (docShell) {
|
||||
nsCOMPtr<nsIDocShellTreeOwner> parentTreeOwner;
|
||||
docShell->GetTreeOwner(getter_AddRefs(parentTreeOwner));
|
||||
nsCOMPtr<nsIBaseWindow> parentWindow(do_GetInterface(parentTreeOwner));
|
||||
if (parentWindow) {
|
||||
parentWindow->GetMainWidget(getter_AddRefs(parentWidget));
|
||||
}
|
||||
}
|
||||
if (!parentWidget) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
*aIsVisible = parentWidget->IsVisible();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWindowUtils::IsNodeDisabledForEvents(nsIDOMNode* aNode, bool* aRetVal)
|
||||
{
|
||||
|
@ -42,7 +42,7 @@ interface nsIURI;
|
||||
interface nsIDOMEventTarget;
|
||||
interface nsIRunnable;
|
||||
|
||||
[scriptable, uuid(a806d366-cc52-11e2-bc9a-ba3212c84021)]
|
||||
[scriptable, uuid(cbe333d7-5b2c-4a9b-b99b-e6e388afa62b)]
|
||||
interface nsIDOMWindowUtils : nsISupports {
|
||||
|
||||
/**
|
||||
@ -1366,6 +1366,17 @@ interface nsIDOMWindowUtils : nsISupports {
|
||||
*/
|
||||
void allowScriptsToClose();
|
||||
|
||||
/**
|
||||
* Is the parent window's main widget visible? If it isn't, we probably
|
||||
* don't want to display any dialogs etc it may request. This corresponds
|
||||
* to the visibility check in nsWindowWatcher::OpenWindowInternal().
|
||||
*
|
||||
* Will throw a DOM security error if called without chrome privileges or
|
||||
* NS_ERROR_NOT_AVAILABLE in the unlikely event that the parent window's
|
||||
* main widget can't be reached.
|
||||
*/
|
||||
readonly attribute boolean isParentWindowMainWidgetVisible;
|
||||
|
||||
/**
|
||||
* In certain cases the event handling of nodes, form controls in practice,
|
||||
* may be disabled. Such cases are for example the existence of disabled
|
||||
|
@ -636,6 +636,10 @@ nsWindowWatcher::OpenWindowInternal(nsIDOMWindow *aParent,
|
||||
nsCOMPtr<nsIWidget> parentWidget;
|
||||
if (parentWindow)
|
||||
parentWindow->GetMainWidget(getter_AddRefs(parentWidget));
|
||||
// NOTE: the logic for this visibility check is duplicated in
|
||||
// nsIDOMWindowUtils::isParentWindowMainWidgetVisible - if we change
|
||||
// how a window is determined "visible" in this context then we should
|
||||
// also adjust that attribute and/or any consumers of it...
|
||||
if (parentWidget && !parentWidget->IsVisible())
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user