// XXXdholbert -- this function is duplicated in nsPrintDialogGTK.cpp // and needs to be unified in some generic utility class. nsIWidget *nsBaseFilePicker::DOMWindowToWidget(nsIDOMWindow *dw) { nsCOMPtr<nsIWidget> widget; nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(dw); if (window) { nsCOMPtr<nsIBaseWindow> baseWin(do_QueryInterface(window->GetDocShell())); while (!widget && baseWin) { baseWin->GetParentWidget(getter_AddRefs(widget)); if (!widget) { nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(baseWin)); if (!docShellAsItem) return nsnull; nsCOMPtr<nsIDocShellTreeItem> parent; docShellAsItem->GetSameTypeParent(getter_AddRefs(parent)); window = do_GetInterface(parent); if (!window) return nsnull; baseWin = do_QueryInterface(window->GetDocShell()); } } } // This will return a pointer that we're about to release, but // that's ok since the docshell (nsIBaseWindow) holds the widget // alive. return widget.get(); }
/* * Checks to see if any existing window is currently in fullscreen mode. */ static PRBool CheckForFullscreenWindow() { nsCOMPtr<nsIWindowMediator> wm(do_GetService(NS_WINDOWMEDIATOR_CONTRACTID)); if (!wm) return PR_FALSE; nsCOMPtr<nsISimpleEnumerator> windowList; wm->GetXULWindowEnumerator(nsnull, getter_AddRefs(windowList)); if (!windowList) return PR_FALSE; for (;;) { PRBool more = PR_FALSE; windowList->HasMoreElements(&more); if (!more) return PR_FALSE; nsCOMPtr<nsISupports> supportsWindow; windowList->GetNext(getter_AddRefs(supportsWindow)); nsCOMPtr<nsIBaseWindow> baseWin(do_QueryInterface(supportsWindow)); if (baseWin) { PRInt32 sizeMode; nsCOMPtr<nsIWidget> widget; baseWin->GetMainWidget(getter_AddRefs(widget)); if (widget && NS_SUCCEEDED(widget->GetSizeMode(&sizeMode)) && sizeMode == nsSizeMode_Fullscreen) { return PR_TRUE; } } } return PR_FALSE; }
//----------------------------------------------------------- HWND nsPrintingPromptService::GetHWNDForDOMWindow(nsIDOMWindow *aWindow) { nsCOMPtr<nsIWebBrowserChrome> chrome; HWND hWnd = NULL; // We might be embedded so check this path first if (mWatcher) { nsCOMPtr<nsIDOMWindow> fosterParent; if (!aWindow) { // it will be a dependent window. try to find a foster parent. mWatcher->GetActiveWindow(getter_AddRefs(fosterParent)); aWindow = fosterParent; } mWatcher->GetChromeForWindow(aWindow, getter_AddRefs(chrome)); } if (chrome) { nsCOMPtr<nsIEmbeddingSiteWindow> site(do_QueryInterface(chrome)); if (site) { HWND w; site->GetSiteWindow(reinterpret_cast<void **>(&w)); return w; } } // Now we might be the Browser so check this path nsCOMPtr<nsPIDOMWindow> window(do_QueryInterface(aWindow)); nsCOMPtr<nsIDocShellTreeItem> treeItem = do_QueryInterface(window->GetDocShell()); if (!treeItem) return nullptr; nsCOMPtr<nsIDocShellTreeOwner> treeOwner; treeItem->GetTreeOwner(getter_AddRefs(treeOwner)); if (!treeOwner) return nullptr; nsCOMPtr<nsIWebBrowserChrome> webBrowserChrome(do_GetInterface(treeOwner)); if (!webBrowserChrome) return nullptr; nsCOMPtr<nsIBaseWindow> baseWin(do_QueryInterface(webBrowserChrome)); if (!baseWin) return nullptr; nsCOMPtr<nsIWidget> widget; baseWin->GetMainWidget(getter_AddRefs(widget)); if (!widget) return nullptr; return (HWND)widget->GetNativeData(NS_NATIVE_TMP_WINDOW); }
nsPrintObject::~nsPrintObject() { MOZ_COUNT_DTOR(nsPrintObject); DestroyPresentation(); if (mDidCreateDocShell && mDocShell) { nsCOMPtr<nsIBaseWindow> baseWin(do_QueryInterface(mDocShell)); if (baseWin) { baseWin->Destroy(); } } mDocShell = nullptr; mTreeOwner = nullptr; // mTreeOwner must be released after mDocShell; }
nsPrintObject::~nsPrintObject() { MOZ_COUNT_DTOR(nsPrintObject); for (uint32_t i=0;i<mKids.Length();i++) { nsPrintObject* po = mKids[i]; delete po; } DestroyPresentation(); if (mDidCreateDocShell && mDocShell) { nsCOMPtr<nsIBaseWindow> baseWin(do_QueryInterface(mDocShell)); if (baseWin) { baseWin->Destroy(); } } mDocShell = nullptr; mTreeOwner = nullptr; // mTreeOwner must be released after mDocShell; }