Clean up xpfe/appshell, removing nsIWebShellWindow in the process. Bug 282200, r=danm, sr=bzbarsky.

This commit is contained in:
bryner%brianryner.com 2005-02-19 22:42:01 +00:00
Родитель 93ab41c8c4
Коммит 890eacaa07
17 изменённых файлов: 241 добавлений и 1083 удалений

Просмотреть файл

@ -62,7 +62,6 @@
#include "nsIMsgMailSession.h"
#include "nsIPrefService.h"
#include "nsIDocShell.h"
#include "nsIWebShellWindow.h"
#include "nsIAuthPrompt.h"
#include "nsIObserverService.h"
#include "nsNetUtil.h"

Просмотреть файл

@ -57,7 +57,6 @@
#include "nsISupportsPrimitives.h"
#include "nsITimelineService.h"
#include "nsIWebBrowserChrome.h"
#include "nsIWebShellWindow.h"
#include "nsIWindowMediator.h"
#include "nsIWindowWatcher.h"
#include "nsIXULWindow.h"
@ -433,9 +432,10 @@ nsAppStartup::CreateChromeWindow2(nsIWebBrowserChrome *aParent,
if (!appShell)
return NS_ERROR_FAILURE;
appShell->CreateTopLevelWindow(0, 0, PR_FALSE, PR_FALSE,
aChromeFlags, nsIAppShellService::SIZE_TO_CONTENT,
nsIAppShellService::SIZE_TO_CONTENT, mAppShell, getter_AddRefs(newWindow));
appShell->CreateTopLevelWindow(0, 0, aChromeFlags,
nsIAppShellService::SIZE_TO_CONTENT,
nsIAppShellService::SIZE_TO_CONTENT,
mAppShell, getter_AddRefs(newWindow));
}
// if anybody gave us anything to work with, use it

Просмотреть файл

@ -53,7 +53,6 @@
#include "nsIURL.h"
#include "nsIServiceManager.h"
#include "nsNetCID.h"
#include "nsIWebShellWindow.h"
#include "nsIDOMWindow.h"
#include "nsXPCOM.h"
#include "nsISupportsPrimitives.h"

Просмотреть файл

@ -3,11 +3,11 @@
#include "nsIDOMWindowInternal.h"
#include "nsIScriptGlobalObject.h"
#include "nsIDocShell.h"
#include "nsIWebShellWindow.h"
#include "nsIBaseWindow.h"
#include "nsCOMPtr.h"
NS_DEF_PTR(nsIScriptGlobalObject);
NS_DEF_PTR(nsIWebShellWindow);
NS_DEF_PTR(nsIBaseWindow);
/*
Windows:
@ -35,7 +35,7 @@ NS_DEF_PTR(nsIWebShellWindow);
void // nsresult
Test06_raw(nsIDOMWindowInternal* aDOMWindow, nsIWebShellWindow** aWebShellWindow)
Test06_raw(nsIDOMWindowInternal* aDOMWindow, nsIBaseWindow** aBaseWindow)
// m388, w214
{
// if (!aDOMWindow)
@ -53,12 +53,12 @@ Test06_raw(nsIDOMWindowInternal* aDOMWindow, nsIWebShellWindow** aWebShellWindow
}
void // nsresult
Test06_raw_optimized(nsIDOMWindowInternal* aDOMWindow, nsIWebShellWindow** aWebShellWindow)
Test06_raw_optimized(nsIDOMWindowInternal* aDOMWindow, nsIBaseWindow** aBaseWindow)
// m332, w191
{
// if (!aDOMWindow)
// return NS_ERROR_NULL_POINTER;
(*aWebShellWindow) = 0;
(*aBaseWindow) = 0;
nsIScriptGlobalObject* scriptGlobalObject;
nsresult status = aDOMWindow->QueryInterface(NS_GET_IID(nsIScriptGlobalObject), (void**)&scriptGlobalObject);
if (NS_SUCCEEDED(status)) {
@ -73,7 +73,7 @@ Test06_raw_optimized(nsIDOMWindowInternal* aDOMWindow, nsIWebShellWindow** aWebS
}
void
Test06_nsCOMPtr_as_found(nsIDOMWindowInternal* aDOMWindow, nsCOMPtr<nsIWebShellWindow>* aWebShellWindow)
Test06_nsCOMPtr_as_found(nsIDOMWindowInternal* aDOMWindow, nsCOMPtr<nsIBaseWindow>* aBaseWindow)
// m344, w181/201
{
// if (!aDOMWindow)
@ -85,7 +85,7 @@ Test06_nsCOMPtr_as_found(nsIDOMWindowInternal* aDOMWindow, nsCOMPtr<nsIWebShellW
}
void // nsresult
Test06_nsCOMPtr00(nsIDOMWindowInternal* aDOMWindow, nsIWebShellWindow** aWebShellWindow)
Test06_nsCOMPtr00(nsIDOMWindowInternal* aDOMWindow, nsIBaseWindow** aBaseWindow)
// m328, w191/199
{
// if (!aDOMWindow)
@ -96,12 +96,12 @@ Test06_nsCOMPtr00(nsIDOMWindowInternal* aDOMWindow, nsIWebShellWindow** aWebShel
if (scriptGlobalObject)
scriptGlobalObject->GetDocShell(&temp0);
nsCOMPtr<nsIDocShell> docShell = dont_AddRef(temp0);
(*aWebShellWindow) = 0;
(*aBaseWindow) = 0;
// return status;
}
void // nsresult
Test06_nsCOMPtr_optimized(nsIDOMWindowInternal* aDOMWindow, nsCOMPtr<nsIWebShellWindow>* aWebShellWindow)
Test06_nsCOMPtr_optimized(nsIDOMWindowInternal* aDOMWindow, nsCOMPtr<nsIBaseWindow>* aBaseWindow)
// m300, w176/182
{
// if (!aDOMWindow)
@ -111,17 +111,17 @@ Test06_nsCOMPtr_optimized(nsIDOMWindowInternal* aDOMWindow, nsCOMPtr<nsIWebShell
nsIDocShell* temp0 = 0;
if (scriptGlobalObject)
scriptGlobalObject->GetDocShell(&temp0);
(*aWebShellWindow) = do_QueryInterface(nsnull, &status);
(*aBaseWindow) = do_QueryInterface(nsnull, &status);
// return status;
}
void // nsresult
Test06_nsCOMPtr02(nsIDOMWindowInternal* aDOMWindow, nsIWebShellWindow** aWebShellWindow)
Test06_nsCOMPtr02(nsIDOMWindowInternal* aDOMWindow, nsIBaseWindow** aBaseWindow)
// m320, w187/184
{
// if (!aDOMWindow)
// return NS_ERROR_NULL_POINTER;
(*aWebShellWindow) = 0;
(*aBaseWindow) = 0;
nsresult status;
nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject = do_QueryInterface(aDOMWindow, &status);
if (scriptGlobalObject) {
@ -132,12 +132,12 @@ Test06_nsCOMPtr02(nsIDOMWindowInternal* aDOMWindow, nsIWebShellWindow** aWebShel
}
void // nsresult
Test06_nsCOMPtr03(nsIDOMWindowInternal* aDOMWindow, nsCOMPtr<nsIWebShellWindow>* aWebShellWindow)
Test06_nsCOMPtr03(nsIDOMWindowInternal* aDOMWindow, nsCOMPtr<nsIBaseWindow>* aBaseWindow)
// m332, w189/188
{
// if (!aDOMWindow)
// return NS_ERROR_NULL_POINTER;
(*aWebShellWindow) = 0;
(*aBaseWindow) = 0;
nsresult status;
nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject = do_QueryInterface(aDOMWindow, &status);
if (scriptGlobalObject) {

Просмотреть файл

@ -47,7 +47,6 @@ XPIDL_MODULE = appshell
GRE_MODULE = 1
EXPORTS = \
nsIWebShellWindow.h \
nsAppShellCID.h \
$(NULL)

Просмотреть файл

@ -48,16 +48,13 @@ interface nsIAppShell;
struct JSContext;
%}
[scriptable, uuid(70c04d53-150f-450b-9106-387487a3c031)]
[scriptable, uuid(93a28ba2-7e22-11d9-9b6f-000a95d535fa)]
interface nsIAppShellService : nsISupports
{
/**
* Create a window.
* Create a window, which will be initially invisible.
* @param aParent the parent window. Can be null.
* @param aUrl the contents of the new window.
* @param aShowWindow the window remains invisible if PR_FALSE.
* @param aLoadDefaultPage controls whether the window should try to
* load a default content page on its own.
* @param aChromeMask chrome flags affecting the kind of OS border
* given to the window. see nsIBrowserWindow for
* bit/flag definitions.
@ -76,19 +73,11 @@ interface nsIAppShellService : nsISupports
const long SIZE_TO_CONTENT = -1;
nsIXULWindow createTopLevelWindow(in nsIXULWindow aParent,
in nsIURI aUrl,
in boolean aShowWindow,
in boolean aLoadDefaultPage,
in PRUint32 aChromeMask,
in long aInitialWidth,
in long aInitialHeight,
in nsIAppShell aAppShell);
/**
* Close a window.
* @param aWindow a window.
*/
void closeTopLevelWindow(in nsIXULWindow aWindow);
[noscript]
void createHiddenWindow(in nsIAppShell aAppShell);

Просмотреть файл

Просмотреть файл

@ -57,7 +57,6 @@
#include "nsIWindowWatcher.h"
#include "nsPIWindowWatcher.h"
#include "nsIDOMWindowInternal.h"
#include "nsIWebShellWindow.h"
#include "nsWebShellWindow.h"
#include "nsIEnumerator.h"
@ -170,50 +169,43 @@ nsAppShellService::CreateHiddenWindow(nsIAppShell* aAppShell)
nsCOMPtr<nsIURI> url;
rv = NS_NewURI(getter_AddRefs(url), hiddenWindowURL);
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIXULWindow> newWindow;
rv = JustCreateTopWindow(nsnull, url, PR_FALSE, PR_FALSE,
chromeMask, initialWidth, initialHeight,
PR_TRUE, aAppShell, getter_AddRefs(newWindow));
if (NS_SUCCEEDED(rv)) {
mHiddenWindow = newWindow;
NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<nsWebShellWindow> newWindow;
rv = JustCreateTopWindow(nsnull, url,
chromeMask, initialWidth, initialHeight,
PR_TRUE, aAppShell, getter_AddRefs(newWindow));
NS_ENSURE_SUCCESS(rv, rv);
mHiddenWindow.swap(newWindow);
#if defined(XP_MAC) || defined(XP_MACOSX)
// hide the hidden window by launching it into outer space. This
// way, we can keep it visible and let the OS send it activates
// to keep menus happy. This will cause it to show up in window
// lists under osx, but I think that's ok.
nsCOMPtr<nsIBaseWindow> base ( do_QueryInterface(newWindow) );
if ( base ) {
base->SetPosition ( -32000, -32000 );
base->SetVisibility ( PR_TRUE );
}
// hide the hidden window by launching it into outer space. This
// way, we can keep it visible and let the OS send it activates
// to keep menus happy. This will cause it to show up in window
// lists under osx, but I think that's ok.
mHiddenWindow->SetPosition ( -32000, -32000 );
mHiddenWindow->SetVisibility ( PR_TRUE );
#endif
// Set XPConnect's fallback JSContext (used for JS Components)
// to the DOM JSContext for this thread, so that DOM-to-XPConnect
// conversions get the JSContext private magic they need to
// succeed.
SetXPConnectSafeContext();
// RegisterTopLevelWindow(newWindow); -- Mac only
}
}
NS_ASSERTION(NS_SUCCEEDED(rv), "HiddenWindow not created");
return(rv);
// Set XPConnect's fallback JSContext (used for JS Components)
// to the DOM JSContext for this thread, so that DOM-to-XPConnect
// conversions get the JSContext private magic they need to
// succeed.
SetXPConnectSafeContext();
// RegisterTopLevelWindow(newWindow); -- Mac only
return NS_OK;
}
NS_IMETHODIMP
nsAppShellService::DestroyHiddenWindow()
{
if (mHiddenWindow) {
nsCOMPtr<nsIWebShellWindow> hiddenWin(do_QueryInterface(mHiddenWindow));
NS_ASSERTION(hiddenWin, "Hidden window is not nsIWebShellWindow!");
if (hiddenWin) {
ClearXPConnectSafeContext();
hiddenWin->Close();
}
ClearXPConnectSafeContext();
mHiddenWindow->Destroy();
mHiddenWindow = nsnull;
}
@ -225,19 +217,22 @@ nsAppShellService::DestroyHiddenWindow()
*/
NS_IMETHODIMP
nsAppShellService::CreateTopLevelWindow(nsIXULWindow *aParent,
nsIURI *aUrl,
PRBool aShowWindow, PRBool aLoadDefaultPage,
PRUint32 aChromeMask,
PRInt32 aInitialWidth, PRInt32 aInitialHeight,
nsIAppShell* aAppShell,
nsIXULWindow **aResult)
nsIURI *aUrl,
PRUint32 aChromeMask,
PRInt32 aInitialWidth,
PRInt32 aInitialHeight,
nsIAppShell* aAppShell,
nsIXULWindow **aResult)
{
nsresult rv;
rv = JustCreateTopWindow(aParent, aUrl, aShowWindow, aLoadDefaultPage,
aChromeMask, aInitialWidth, aInitialHeight,
PR_FALSE, aAppShell, aResult);
nsWebShellWindow *newWindow = nsnull;
rv = JustCreateTopWindow(aParent, aUrl,
aChromeMask, aInitialWidth, aInitialHeight,
PR_FALSE, aAppShell, &newWindow); // addrefs
*aResult = newWindow; // transfer ref
if (NS_SUCCEEDED(rv)) {
// the addref resulting from this is the owning addref for this window
@ -287,114 +282,94 @@ nsAppShellService::CalculateWindowZLevel(nsIXULWindow *aParent,
/*
* Just do the window-making part of CreateTopLevelWindow
*/
NS_IMETHODIMP
nsresult
nsAppShellService::JustCreateTopWindow(nsIXULWindow *aParent,
nsIURI *aUrl,
PRBool aShowWindow, PRBool aLoadDefaultPage,
PRUint32 aChromeMask,
PRInt32 aInitialWidth, PRInt32 aInitialHeight,
PRBool aIsHiddenWindow, nsIAppShell* aAppShell,
nsIXULWindow **aResult)
nsIURI *aUrl,
PRUint32 aChromeMask,
PRInt32 aInitialWidth,
PRInt32 aInitialHeight,
PRBool aIsHiddenWindow,
nsIAppShell* aAppShell,
nsWebShellWindow **aResult)
{
nsresult rv;
nsWebShellWindow* window;
PRBool intrinsicallySized;
*aResult = nsnull;
intrinsicallySized = PR_FALSE;
window = new nsWebShellWindow();
// Bump count to one so it doesn't die on us while doing init.
nsCOMPtr<nsIXULWindow> tempRef(window);
if (!window)
rv = NS_ERROR_OUT_OF_MEMORY;
else {
nsWidgetInitData widgetInitData;
if (aIsHiddenWindow)
widgetInitData.mWindowType = eWindowType_invisible;
else
widgetInitData.mWindowType = aChromeMask & nsIWebBrowserChrome::CHROME_OPENAS_DIALOG ?
eWindowType_dialog : eWindowType_toplevel;
nsRefPtr<nsWebShellWindow> window = new nsWebShellWindow();
NS_ENSURE_TRUE(window, NS_ERROR_OUT_OF_MEMORY);
if (aChromeMask & nsIWebBrowserChrome::CHROME_WINDOW_POPUP)
widgetInitData.mWindowType = eWindowType_popup;
nsWidgetInitData widgetInitData;
if (aIsHiddenWindow)
widgetInitData.mWindowType = eWindowType_invisible;
else
widgetInitData.mWindowType = aChromeMask & nsIWebBrowserChrome::CHROME_OPENAS_DIALOG ?
eWindowType_dialog : eWindowType_toplevel;
if (aChromeMask & nsIWebBrowserChrome::CHROME_WINDOW_POPUP)
widgetInitData.mWindowType = eWindowType_popup;
#ifdef XP_MACOSX
// Mac OS X sheet support
PRUint32 sheetMask = nsIWebBrowserChrome::CHROME_OPENAS_DIALOG |
nsIWebBrowserChrome::CHROME_MODAL;
if (aParent && ((aChromeMask & sheetMask) == sheetMask))
{
widgetInitData.mWindowType = eWindowType_sheet;
}
// Mac OS X sheet support
PRUint32 sheetMask = nsIWebBrowserChrome::CHROME_OPENAS_DIALOG |
nsIWebBrowserChrome::CHROME_MODAL;
if (aParent && ((aChromeMask & sheetMask) == sheetMask))
widgetInitData.mWindowType = eWindowType_sheet;
#endif
widgetInitData.mContentType = eContentTypeUI;
// note default chrome overrides other OS chrome settings, but
// not internal chrome
if (aChromeMask & nsIWebBrowserChrome::CHROME_DEFAULT)
widgetInitData.mBorderStyle = eBorderStyle_default;
else if ((aChromeMask & nsIWebBrowserChrome::CHROME_ALL) == nsIWebBrowserChrome::CHROME_ALL)
widgetInitData.mBorderStyle = eBorderStyle_all;
else {
widgetInitData.mBorderStyle = eBorderStyle_none; // assumes none == 0x00
if (aChromeMask & nsIWebBrowserChrome::CHROME_WINDOW_BORDERS)
widgetInitData.mBorderStyle = NS_STATIC_CAST(enum nsBorderStyle, widgetInitData.mBorderStyle | eBorderStyle_border);
if (aChromeMask & nsIWebBrowserChrome::CHROME_TITLEBAR)
widgetInitData.mBorderStyle = NS_STATIC_CAST(enum nsBorderStyle, widgetInitData.mBorderStyle | eBorderStyle_title);
if (aChromeMask & nsIWebBrowserChrome::CHROME_WINDOW_CLOSE)
widgetInitData.mBorderStyle = NS_STATIC_CAST(enum nsBorderStyle, widgetInitData.mBorderStyle | eBorderStyle_close);
if (aChromeMask & nsIWebBrowserChrome::CHROME_WINDOW_RESIZE) {
widgetInitData.mBorderStyle = NS_STATIC_CAST(enum nsBorderStyle, widgetInitData.mBorderStyle | eBorderStyle_resizeh);
// only resizable windows get the maximize button (but not dialogs)
if (!(aChromeMask & nsIWebBrowserChrome::CHROME_OPENAS_DIALOG))
widgetInitData.mBorderStyle = NS_STATIC_CAST(enum nsBorderStyle, widgetInitData.mBorderStyle | eBorderStyle_maximize);
}
// all windows (except dialogs) get minimize buttons and the system menu
widgetInitData.mContentType = eContentTypeUI;
// note default chrome overrides other OS chrome settings, but
// not internal chrome
if (aChromeMask & nsIWebBrowserChrome::CHROME_DEFAULT)
widgetInitData.mBorderStyle = eBorderStyle_default;
else if ((aChromeMask & nsIWebBrowserChrome::CHROME_ALL) == nsIWebBrowserChrome::CHROME_ALL)
widgetInitData.mBorderStyle = eBorderStyle_all;
else {
widgetInitData.mBorderStyle = eBorderStyle_none; // assumes none == 0x00
if (aChromeMask & nsIWebBrowserChrome::CHROME_WINDOW_BORDERS)
widgetInitData.mBorderStyle = NS_STATIC_CAST(enum nsBorderStyle, widgetInitData.mBorderStyle | eBorderStyle_border);
if (aChromeMask & nsIWebBrowserChrome::CHROME_TITLEBAR)
widgetInitData.mBorderStyle = NS_STATIC_CAST(enum nsBorderStyle, widgetInitData.mBorderStyle | eBorderStyle_title);
if (aChromeMask & nsIWebBrowserChrome::CHROME_WINDOW_CLOSE)
widgetInitData.mBorderStyle = NS_STATIC_CAST(enum nsBorderStyle, widgetInitData.mBorderStyle | eBorderStyle_close);
if (aChromeMask & nsIWebBrowserChrome::CHROME_WINDOW_RESIZE) {
widgetInitData.mBorderStyle = NS_STATIC_CAST(enum nsBorderStyle, widgetInitData.mBorderStyle | eBorderStyle_resizeh);
// only resizable windows get the maximize button (but not dialogs)
if (!(aChromeMask & nsIWebBrowserChrome::CHROME_OPENAS_DIALOG))
widgetInitData.mBorderStyle = NS_STATIC_CAST(enum nsBorderStyle, widgetInitData.mBorderStyle | eBorderStyle_minimize | eBorderStyle_menu);
// but anyone can explicitly ask for a minimize button
if (aChromeMask & nsIWebBrowserChrome::CHROME_WINDOW_MIN) {
widgetInitData.mBorderStyle = NS_STATIC_CAST(enum nsBorderStyle, widgetInitData.mBorderStyle | eBorderStyle_minimize );
}
widgetInitData.mBorderStyle = NS_STATIC_CAST(enum nsBorderStyle, widgetInitData.mBorderStyle | eBorderStyle_maximize);
}
if (aInitialWidth == nsIAppShellService::SIZE_TO_CONTENT ||
aInitialHeight == nsIAppShellService::SIZE_TO_CONTENT) {
aInitialWidth = 1;
aInitialHeight = 1;
intrinsicallySized = PR_TRUE;
window->SetIntrinsicallySized(PR_TRUE);
}
rv = window->Initialize(aParent, aAppShell, aUrl,
aShowWindow, aLoadDefaultPage,
aInitialWidth, aInitialHeight, aIsHiddenWindow, widgetInitData);
if (NS_SUCCEEDED(rv)) {
// this does the AddRef of the return value
rv = CallQueryInterface(NS_STATIC_CAST(nsIWebShellWindow*, window), aResult);
if (aParent)
aParent->AddChildWindow(*aResult);
}
if (aChromeMask & nsIWebBrowserChrome::CHROME_CENTER_SCREEN)
window->Center(aParent, aParent ? PR_FALSE : PR_TRUE, PR_FALSE);
// all windows (except dialogs) get minimize buttons and the system menu
if (!(aChromeMask & nsIWebBrowserChrome::CHROME_OPENAS_DIALOG))
widgetInitData.mBorderStyle = NS_STATIC_CAST(enum nsBorderStyle, widgetInitData.mBorderStyle | eBorderStyle_minimize | eBorderStyle_menu);
// but anyone can explicitly ask for a minimize button
if (aChromeMask & nsIWebBrowserChrome::CHROME_WINDOW_MIN) {
widgetInitData.mBorderStyle = NS_STATIC_CAST(enum nsBorderStyle, widgetInitData.mBorderStyle | eBorderStyle_minimize );
}
}
if (aInitialWidth == nsIAppShellService::SIZE_TO_CONTENT ||
aInitialHeight == nsIAppShellService::SIZE_TO_CONTENT) {
aInitialWidth = 1;
aInitialHeight = 1;
window->SetIntrinsicallySized(PR_TRUE);
}
nsresult rv = window->Initialize(aParent, aAppShell, aUrl,
aInitialWidth, aInitialHeight,
aIsHiddenWindow, widgetInitData);
NS_ENSURE_SUCCESS(rv, rv);
window.swap(*aResult); // transfer reference
if (aParent)
aParent->AddChildWindow(*aResult);
if (aChromeMask & nsIWebBrowserChrome::CHROME_CENTER_SCREEN)
rv = (*aResult)->Center(aParent, aParent ? PR_FALSE : PR_TRUE, PR_FALSE);
return rv;
}
NS_IMETHODIMP
nsAppShellService::CloseTopLevelWindow(nsIXULWindow* aWindow)
{
nsCOMPtr<nsIWebShellWindow> webShellWin(do_QueryInterface(aWindow));
NS_ENSURE_TRUE(webShellWin, NS_ERROR_FAILURE);
return webShellWin->Close();
}
NS_IMETHODIMP
nsAppShellService::GetHiddenWindow(nsIXULWindow **aWindow)
{
@ -522,7 +497,7 @@ nsAppShellService::UnregisterTopLevelWindow(nsIXULWindow* aWindow)
- notify the caller not to release the AppShellService after
unregistering the window
(we don't want to be deleted twice consecutively to
mHiddenWindow->Close() in our destructor)
mHiddenWindow->Destroy() in our destructor)
*/
return NS_ERROR_FAILURE;
}
@ -567,10 +542,9 @@ nsAppShellService::Observe(nsISupports* aSubject, const char *aTopic,
NS_ASSERTION(!strcmp(aTopic, "xpcom-shutdown"), "Unexpected observer topic!");
mXPCOMShuttingDown = PR_TRUE;
nsCOMPtr<nsIWebShellWindow> hiddenWin (do_QueryInterface(mHiddenWindow));
if (hiddenWin) {
if (mHiddenWindow) {
ClearXPConnectSafeContext();
hiddenWin->Close();
mHiddenWindow->Destroy();
}
return NS_OK;

Просмотреть файл

@ -42,8 +42,9 @@
#include "nsIObserver.h"
//Interfaces Needed
#include "nsIXULWindow.h"
#include "nsWebShellWindow.h"
#include "nsStringFwd.h"
#include "nsAutoPtr.h"
// {0099907D-123C-4853-A46A-43098B5FB68C}
#define NS_APPSHELLSERVICE_CID \
@ -62,18 +63,17 @@ public:
protected:
~nsAppShellService();
NS_IMETHOD JustCreateTopWindow(nsIXULWindow *aParent,
nsIURI *aUrl,
PRBool aShowWindow, PRBool aLoadDefaultPage,
PRUint32 aChromeMask,
PRInt32 aInitialWidth, PRInt32 aInitialHeight,
PRBool aIsHiddenWindow, nsIAppShell* aAppShell,
nsIXULWindow **aResult);
nsresult JustCreateTopWindow(nsIXULWindow *aParent,
nsIURI *aUrl,
PRUint32 aChromeMask,
PRInt32 aInitialWidth, PRInt32 aInitialHeight,
PRBool aIsHiddenWindow, nsIAppShell* aAppShell,
nsWebShellWindow **aResult);
PRUint32 CalculateWindowZLevel(nsIXULWindow *aParent, PRUint32 aChromeMask);
nsresult SetXPConnectSafeContext();
nsresult ClearXPConnectSafeContext();
nsCOMPtr<nsIXULWindow> mHiddenWindow;
nsRefPtr<nsWebShellWindow> mHiddenWindow;
PRPackedBool mXPCOMShuttingDown;
PRUint16 mModalWindowCount;
};

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -38,44 +38,22 @@
#ifndef nsWebShellWindow_h__
#define nsWebShellWindow_h__
#include "nsISupports.h"
#include "nsIWebShellWindow.h"
#include "nsGUIEvent.h"
#include "nsIWebProgressListener.h"
#include "nsIDocumentObserver.h"
#include "nsVoidArray.h"
#include "nsIMenu.h"
#include "nsITimer.h"
#include "nsIPrompt.h"
// can't use forward class decl's because of template bugs on Solaris
#include "nsIDOMDocument.h"
#include "nsIDOMNode.h"
#include "nsCOMPtr.h"
#include "nsXULWindow.h"
/* Forward declarations.... */
struct PLEvent;
class nsIURI;
class nsIAppShell;
class nsIContent;
class nsIDocument;
class nsIDOMCharacterData;
class nsIDOMElement;
class nsIDOMWindowInternal;
class nsIDOMHTMLImageElement;
class nsIDOMHTMLInputElement;
class nsIStreamObserver;
class nsIWidget;
class nsVoidArray;
class nsWebShellWindow : public nsXULWindow,
public nsIWebShellWindow,
public nsIWebProgressListener,
public nsIDocumentObserver
public nsIWebProgressListener
{
public:
nsWebShellWindow();
@ -83,78 +61,38 @@ public:
// nsISupports interface...
NS_DECL_ISUPPORTS_INHERITED
NS_IMETHOD LockUntilChromeLoad() { mLockedUntilChromeLoad = PR_TRUE; return NS_OK; }
NS_IMETHOD GetLockedState(PRBool& aResult) { aResult = mLockedUntilChromeLoad; return NS_OK; }
NS_IMETHOD ShouldLoadDefaultPage(PRBool *aYes)
{ *aYes = mLoadDefaultPage; return NS_OK; }
// nsIWebShellWindow methods...
NS_IMETHOD Show(PRBool aShow);
NS_IMETHOD ShowModal();
NS_IMETHOD Toolbar();
NS_IMETHOD Close();
NS_IMETHOD GetDocShell(nsIDocShell *& aWebShell);
NS_IMETHOD GetContentDocShell(nsIDocShell **aResult);
NS_IMETHOD GetWidget(nsIWidget *& aWidget);
NS_IMETHOD GetDOMWindow(nsIDOMWindowInternal** aDOMWindow);
NS_IMETHOD ConvertDocShellToDOMWindow(nsIDocShell* aShell, nsIDOMWindowInternal** aDOMWindow);
// nsWebShellWindow methods...
nsresult Initialize(nsIXULWindow * aParent, nsIAppShell* aShell, nsIURI* aUrl,
PRBool aCreatedVisible, PRBool aLoadDefaultPage,
nsresult Initialize(nsIXULWindow * aParent, nsIAppShell* aShell,
nsIURI* aUrl,
PRInt32 aInitialWidth, PRInt32 aInitialHeight,
PRBool aIsHiddenWindow, nsWidgetInitData& widgetInitData);
nsIWidget* GetWidget(void) { return mWindow; }
PRBool aIsHiddenWindow,
nsWidgetInitData& widgetInitData);
nsresult Toolbar();
// nsIWebProgressListener
NS_DECL_NSIWEBPROGRESSLISTENER
// nsIDocumentObserver
NS_DECL_NSIDOCUMENTOBSERVER
// nsINetSupport
// nsIBaseWindow
NS_IMETHOD Destroy();
protected:
nsCOMPtr<nsIDOMNode> FindNamedDOMNode(const nsAString &aName, nsIDOMNode * aParent, PRInt32 & aCount, PRInt32 aEndCount);
nsCOMPtr<nsIDOMDocument> GetNamedDOMDoc(const nsAString & aWebShellName);
void DynamicLoadMenus(nsIDOMDocument * aDOMDoc, nsIWidget * aParentWindow);
#if 0
void LoadMenus(nsIDOMDocument * aDOMDoc, nsIWidget * aParentWindow);
NS_IMETHOD CreateMenu(nsIMenuBar * aMenuBar, nsIDOMNode * aMenuNode, nsString & aMenuName);
void LoadSubMenu(nsIMenu * pParentMenu, nsIDOMElement * menuElement,nsIDOMNode * menuNode);
NS_IMETHOD LoadMenuItem(nsIMenu * pParentMenu, nsIDOMElement * menuitemElement, nsIDOMNode * menuitemNode);
#endif
virtual ~nsWebShellWindow();
nsCOMPtr<nsIDOMDocument> GetNamedDOMDoc(const nsAString & aWebShellName);
void LoadNativeMenus(nsIDOMDocument * aDOMDoc, nsIWidget * aParentWindow);
nsCOMPtr<nsIDOMNode> GetDOMNodeFromDocShell(nsIDocShell *aShell);
void ExecuteStartupCode();
void LoadContentAreas();
PRBool ExecuteCloseHandler();
virtual ~nsWebShellWindow();
static nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent);
PRBool mLockedUntilChromeLoad;
PRBool mLoadDefaultPage;
nsVoidArray mMenuDelegates;
nsIDOMNode * contextMenuTest;
nsCOMPtr<nsITimer> mSPTimer;
PRLock * mSPTimerLock;
nsCOMPtr<nsIPrompt> mPrompter;
void SetPersistenceTimer(PRUint32 aDirtyFlags);
static void FirePersistenceTimer(nsITimer *aTimer, void *aClosure);
private:
static void * HandleModalDialogEvent(PLEvent *aEvent);
static void DestroyModalDialogEvent(PLEvent *aEvent);
};

Просмотреть файл

@ -89,9 +89,6 @@
#include "nsReadableUtils.h"
#include "nsStyleConsts.h"
// XXX Get rid of this
#pragma message("WARNING: XXX bad include, remove it.")
#include "nsIWebShellWindow.h"
#include "nsWebShellWindow.h" // get rid of this one, too...
#define SIZEMODE_NORMAL NS_LITERAL_STRING("normal")
@ -124,6 +121,7 @@ nsXULWindow::nsXULWindow() : mChromeTreeOwner(nsnull),
mDebuting(PR_FALSE), mChromeLoaded(PR_FALSE),
mShowAfterLoad(PR_FALSE), mIntrinsicallySized(PR_FALSE),
mCenterAfterLoad(PR_FALSE), mIsHiddenWindow(PR_FALSE),
mLockedUntilChromeLoad(PR_FALSE),
mContextFlags(0), mBlurSuppressionLevel(0),
mPersistentAttributesDirty(0), mPersistentAttributesMask(0),
mChromeFlags(nsIWebBrowserChrome::CHROME_ALL)
@ -137,7 +135,7 @@ nsXULWindow::~nsXULWindow()
//*****************************************************************************
// nsXULWindow::nsISupports
//*****************************************************************************
//*****************************************************************************
NS_IMPL_THREADSAFE_ADDREF(nsXULWindow)
NS_IMPL_THREADSAFE_RELEASE(nsXULWindow)
@ -1703,9 +1701,10 @@ NS_IMETHODIMP nsXULWindow::CreateNewChromeWindow(PRInt32 aChromeFlags,
parent = this;
nsCOMPtr<nsIXULWindow> newWindow;
appShell->CreateTopLevelWindow(parent, nsnull, PR_FALSE, PR_FALSE,
aChromeFlags, nsIAppShellService::SIZE_TO_CONTENT,
nsIAppShellService::SIZE_TO_CONTENT, aAppShell, getter_AddRefs(newWindow));
appShell->CreateTopLevelWindow(parent, nsnull, aChromeFlags,
nsIAppShellService::SIZE_TO_CONTENT,
nsIAppShellService::SIZE_TO_CONTENT,
aAppShell, getter_AddRefs(newWindow));
NS_ENSURE_TRUE(newWindow, NS_ERROR_FAILURE);
@ -1765,14 +1764,12 @@ NS_IMETHODIMP nsXULWindow::CreateNewContentWindow(PRInt32 aChromeFlags,
NS_ENSURE_TRUE(uri, NS_ERROR_FAILURE);
nsCOMPtr<nsIXULWindow> newWindow;
appShell->CreateTopLevelWindow(parent, uri, PR_FALSE, PR_FALSE,
appShell->CreateTopLevelWindow(parent, uri,
aChromeFlags, 615, 480, aAppShell,
getter_AddRefs(newWindow));
getter_AddRefs(newWindow));
NS_ENSURE_TRUE(newWindow, NS_ERROR_FAILURE);
nsCOMPtr<nsIWebShellWindow> webShellWindow(do_QueryInterface(newWindow));
newWindow->SetChromeFlags(aChromeFlags);
nsCOMPtr<nsIAppShell> subShell(do_CreateInstance(kAppShellCID));
@ -1782,25 +1779,24 @@ NS_IMETHODIMP nsXULWindow::CreateNewContentWindow(PRInt32 aChromeFlags,
subShell->Spinup();
// Specify that we want the window to remain locked until the chrome has loaded.
webShellWindow->LockUntilChromeLoad();
nsXULWindow *xulWin = NS_STATIC_CAST(nsXULWindow*,
NS_STATIC_CAST(nsIXULWindow*,
newWindow));
PRBool locked = PR_FALSE;
webShellWindow->GetLockedState(locked);
xulWin->LockUntilChromeLoad();
// Push nsnull onto the JSContext stack before we dispatch a native event.
nsCOMPtr<nsIJSContextStack> stack(do_GetService("@mozilla.org/js/xpc/ContextStack;1"));
if(stack && NS_SUCCEEDED(stack->Push(nsnull)))
{
nsresult looprv = NS_OK;
while(NS_SUCCEEDED(looprv) && locked)
while(NS_SUCCEEDED(looprv) && xulWin->IsLocked())
{
void *data;
PRBool isRealEvent;
looprv = subShell->GetNativeEvent(isRealEvent, data);
subShell->DispatchNativeEvent(isRealEvent, data);
webShellWindow->GetLockedState(locked);
}
JSContext *cx;
@ -1912,9 +1908,7 @@ PRBool nsXULWindow::ConstrainToZLevel(
void *data;
(*aActualBelow)->GetClientData(data);
if (data) {
nsWebShellWindow *win;
win = NS_REINTERPRET_CAST(nsWebShellWindow *, data);
windowAbove = do_QueryInterface(NS_STATIC_CAST(nsIWebShellWindow *,win));
windowAbove = NS_REINTERPRET_CAST(nsWebShellWindow*, data);
}
}

Просмотреть файл

@ -69,7 +69,7 @@
class nsXULWindow : public nsIBaseWindow,
public nsIInterfaceRequestor,
public nsIXULWindow,
public nsIXULWindow,
public nsSupportsWeakReference
{
friend class nsChromeTreeOwner;
@ -82,6 +82,9 @@ public:
NS_DECL_NSIXULWINDOW
NS_DECL_NSIBASEWINDOW
void LockUntilChromeLoad() { mLockedUntilChromeLoad = PR_TRUE; }
PRBool IsLocked() const { return mLockedUntilChromeLoad; }
protected:
enum persistentAttributes {
PAD_MISC = 0x1,
@ -151,6 +154,7 @@ protected:
PRPackedBool mIntrinsicallySized;
PRPackedBool mCenterAfterLoad;
PRPackedBool mIsHiddenWindow;
PRPackedBool mLockedUntilChromeLoad;
PRUint32 mContextFlags;
PRUint32 mBlurSuppressionLevel;
PRUint32 mPersistentAttributesDirty; // persistentAttributes

Просмотреть файл

@ -54,7 +54,6 @@
#include "nsIDOMNode.h"
#include "nsIServiceManager.h"
#include "nsIWebNavigation.h"
#include "nsIWebShellWindow.h"
#include "nsIWidget.h"
#include "nsIWindowMediator.h"
#include "nsIURI.h"

Просмотреть файл

@ -67,7 +67,6 @@
#include "nsIContentViewer.h"
#include "nsIContentViewerEdit.h"
#include "nsIWebShellWindow.h"
#include "nsIWebBrowserChrome.h"
#include "nsIWindowWatcher.h"
#include "nsCOMPtr.h"

Просмотреть файл

@ -59,7 +59,6 @@
#include "nsISupportsPrimitives.h"
#include "nsITimelineService.h"
#include "nsIWebBrowserChrome.h"
#include "nsIWebShellWindow.h"
#include "nsIWindowMediator.h"
#include "nsIWindowWatcher.h"
#include "nsIXULWindow.h"
@ -892,9 +891,10 @@ nsAppStartup::CreateChromeWindow2(nsIWebBrowserChrome *aParent,
if (!appShell)
return NS_ERROR_FAILURE;
appShell->CreateTopLevelWindow(0, 0, PR_FALSE, PR_FALSE,
aChromeFlags, nsIAppShellService::SIZE_TO_CONTENT,
nsIAppShellService::SIZE_TO_CONTENT, mAppShell, getter_AddRefs(newWindow));
appShell->CreateTopLevelWindow(0, 0, aChromeFlags,
nsIAppShellService::SIZE_TO_CONTENT,
nsIAppShellService::SIZE_TO_CONTENT,
mAppShell, getter_AddRefs(newWindow));
}
// if anybody gave us anything to work with, use it

Просмотреть файл

@ -53,7 +53,6 @@
#include "nsIURL.h"
#include "nsIServiceManager.h"
#include "nsNetCID.h"
#include "nsIWebShellWindow.h"
#include "nsIDOMWindow.h"
#include "nsXPCOM.h"
#include "nsISupportsPrimitives.h"