disable browser appcore's load of default page for new windows created by NewWebShell. fixes bug 11404. a:cyeh@netscape.com

This commit is contained in:
danm%netscape.com 1999-08-16 22:23:19 +00:00
parent cea0ae8198
commit 0ce57055ba
14 changed files with 73 additions and 37 deletions

View File

@ -302,6 +302,7 @@ nsMessenger::Open3PaneWindow()
rv = appShell->CreateTopLevelWindow(nsnull, // parent
url,
PR_TRUE,
PR_TRUE,
NS_CHROME_ALL_CHROME,
nsnull, // callbacks
NS_SIZETOCONTENT, // width

View File

@ -183,6 +183,7 @@ nsPrefMigrationProgressDialog::CreateProfileProgressDialog()
rv = appShell->CreateTopLevelWindow( nsnull,
url,
PR_TRUE,
PR_TRUE,
NS_CHROME_ALL_CHROME,
this, // callbacks??
0,

View File

@ -610,8 +610,8 @@ newWind(char* urlName)
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIWebShellWindow> newWindow;
appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, NS_CHROME_ALL_CHROME,
nsnull, NS_SIZETOCONTENT, NS_SIZETOCONTENT,
appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, PR_TRUE,
NS_CHROME_ALL_CHROME, nsnull, NS_SIZETOCONTENT, NS_SIZETOCONTENT,
getter_AddRefs(newWindow));
NS_RELEASE(url);
@ -679,7 +679,7 @@ nsBrowserAppCore::WalletEditor(nsIDOMWindow* aWin)
nsCOMPtr<nsIWebShellWindow> parent;
DOMWindowToWebShellWindow(aWin, &parent);
window = nsnull;
appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE,
appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, PR_TRUE,
NS_CHROME_ALL_CHROME | NS_CHROME_OPEN_AS_DIALOG,
cb, 504, 436, &window);
if (window != nsnull) {
@ -732,7 +732,7 @@ nsBrowserAppCore::SignonViewer(nsIDOMWindow* aWin)
nsCOMPtr<nsIWebShellWindow> parent;
DOMWindowToWebShellWindow(aWin, &parent);
window = nsnull;
appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE,
appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, PR_TRUE,
NS_CHROME_ALL_CHROME | NS_CHROME_OPEN_AS_DIALOG,
cb, 504, 436, &window);
if (window != nsnull) {
@ -784,7 +784,7 @@ nsBrowserAppCore::CookieViewer(nsIDOMWindow* aWin)
nsCOMPtr<nsIWebShellWindow> parent;
DOMWindowToWebShellWindow(aWin, &parent);
window = nsnull;
appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE,
appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, PR_TRUE,
NS_CHROME_ALL_CHROME | NS_CHROME_OPEN_AS_DIALOG,
cb, 504, 436, &window);
@ -881,7 +881,7 @@ nsBrowserAppCore::WalletPreview(nsIDOMWindow* aWin, nsIDOMWindow* aForm)
nsCOMPtr<nsIWebShellWindow> parent;
DOMWindowToWebShellWindow(aWin, &parent);
window = nsnull;
appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE,
appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, PR_TRUE,
NS_CHROME_ALL_CHROME | NS_CHROME_OPEN_AS_DIALOG,
cb, 504, 436, &window);
if (window != nsnull) {
@ -1048,6 +1048,14 @@ nsBrowserAppCore::LoadInitialPage(void)
// No URL was provided in the command line. Load the default provided
// in the navigator.xul;
// but first, abort if the window doesn't want a default page loaded
if (mWebShellWin) {
PRBool loadDefault;
mWebShellWin->ShouldLoadDefaultPage(&loadDefault);
if (!loadDefault)
return NS_OK;
}
nsCOMPtr<nsIDOMElement> argsElement;
rv = FindNamedXULElement(mWebShell, "args", &argsElement);
@ -1750,8 +1758,8 @@ nsBrowserAppCore::NewWindow()
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIWebShellWindow> newWindow;
appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, NS_CHROME_ALL_CHROME,
nsnull, NS_SIZETOCONTENT, NS_SIZETOCONTENT,
appShell->CreateTopLevelWindow(nsnull, url, PR_TRUE, PR_TRUE,
NS_CHROME_ALL_CHROME, nsnull, NS_SIZETOCONTENT, NS_SIZETOCONTENT,
getter_AddRefs(newWindow));
NS_RELEASE(url);

View File

@ -168,7 +168,7 @@ nsToolkitCore::ShowDialog(const nsString& aUrl, nsIDOMWindow* aParent) {
nsCOMPtr<nsIWebShellWindow> parent;
DOMWindowToWebShellWindow(aParent, &parent);
window = nsnull;
appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE,
appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, PR_TRUE,
NS_CHROME_ALL_CHROME | NS_CHROME_OPEN_AS_DIALOG,
nsnull, 615, 480, &window);
@ -203,8 +203,9 @@ nsToolkitCore::ShowWindow(const nsString& aUrl, nsIDOMWindow* aParent) {
nsCOMPtr<nsIWebShellWindow> parent;
DOMWindowToWebShellWindow(aParent, &parent);
nsCOMPtr<nsIWebShellWindow> window;
appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, NS_CHROME_ALL_CHROME,
nsnull, NS_SIZETOCONTENT, NS_SIZETOCONTENT,
appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, PR_TRUE,
NS_CHROME_ALL_CHROME, nsnull,
NS_SIZETOCONTENT, NS_SIZETOCONTENT,
getter_AddRefs(window));
return rv;
@ -320,8 +321,9 @@ nsToolkitCore::ShowWindowWithArgs(const nsString& aUrl,
cb = nsDontQueryInterface<nsArgCallbacks>( new nsArgCallbacks( aArgs ) );
nsCOMPtr<nsIWebShellWindow> window;
appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, NS_CHROME_ALL_CHROME,
cb, NS_SIZETOCONTENT, NS_SIZETOCONTENT,
appShell->CreateTopLevelWindow(parent, urlObj, PR_TRUE, PR_TRUE,
NS_CHROME_ALL_CHROME, cb,
NS_SIZETOCONTENT, NS_SIZETOCONTENT,
getter_AddRefs(window));
return rv;

View File

@ -81,6 +81,8 @@ interface nsIAppShellService : nsISupports
* @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.
@ -96,7 +98,8 @@ interface nsIAppShellService : nsISupports
*/
void CreateTopLevelWindow(in nsIWebShellWindow aParent,
in nsIURI aUrl,
in boolean showWindow,
in boolean aShowWindow,
in boolean aLoadDefaultPage,
in PRUint32 aChromeMask,
in nsIXULWindowCallbacks aCallbacks,
in long aInitialWidth, in long aInitialHeight,

View File

@ -50,6 +50,15 @@ public:
NS_IMETHOD LockUntilChromeLoad() = 0;
NS_IMETHOD GetLockedState(PRBool& aResult) = 0;
/**
* Useful only during window initialization, this method knows whether
* the window should try to load a default page, or just wait for
* further instructions.
* @param aYes returns PR_TRUE iff a default page should be loaded.
* @return always NS_OK
*/
NS_IMETHOD ShouldLoadDefaultPage(PRBool *aYes) = 0;
};

View File

@ -107,6 +107,7 @@ public:
NS_IMETHOD CreateTopLevelWindow(nsIWebShellWindow *aParent,
nsIURI *aUrl,
PRBool aShowWindow,
PRBool aLoadDefaultPage,
PRUint32 aChromeMask,
nsIXULWindowCallbacks *aCallbacks,
PRInt32 aInitialWidth, PRInt32 aInitialHeight,
@ -129,7 +130,7 @@ protected:
NS_IMETHOD JustCreateTopWindow(nsIWebShellWindow *aParent,
nsIURI *aUrl,
PRBool aShowWindow,
PRBool aShowWindow, PRBool aLoadDefaultPage,
PRUint32 aChromeMask,
nsIXULWindowCallbacks *aCallbacks,
PRInt32 aInitialWidth, PRInt32 aInitialHeight,
@ -292,8 +293,9 @@ void nsAppShellService::CreateHiddenWindow()
#endif
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIWebShellWindow> newWindow;
rv = JustCreateTopWindow(nsnull, url, PR_FALSE, NS_CHROME_ALL_CHROME,
nsnull, 100, 100, getter_AddRefs(newWindow));
rv = JustCreateTopWindow(nsnull, url, PR_FALSE, PR_FALSE,
NS_CHROME_ALL_CHROME, nsnull, 100, 100,
getter_AddRefs(newWindow));
if (NS_SUCCEEDED(rv)) {
mHiddenWindow = newWindow;
// RegisterTopLevelWindow(newWindow); -- Mac only
@ -523,7 +525,7 @@ nsAppShellService::PopThreadEventQueue() {
NS_IMETHODIMP
nsAppShellService::CreateTopLevelWindow(nsIWebShellWindow *aParent,
nsIURI *aUrl,
PRBool aShowWindow,
PRBool aShowWindow, PRBool aLoadDefaultPage,
PRUint32 aChromeMask,
nsIXULWindowCallbacks *aCallbacks,
PRInt32 aInitialWidth, PRInt32 aInitialHeight,
@ -532,8 +534,9 @@ nsAppShellService::CreateTopLevelWindow(nsIWebShellWindow *aParent,
{
nsresult rv;
rv = JustCreateTopWindow(aParent, aUrl, aShowWindow, aChromeMask,
aCallbacks, aInitialWidth, aInitialHeight,
rv = JustCreateTopWindow(aParent, aUrl, aShowWindow, aLoadDefaultPage,
aChromeMask, aCallbacks,
aInitialWidth, aInitialHeight,
aResult);
if (NS_SUCCEEDED(rv))
@ -550,7 +553,7 @@ nsAppShellService::CreateTopLevelWindow(nsIWebShellWindow *aParent,
NS_IMETHODIMP
nsAppShellService::JustCreateTopWindow(nsIWebShellWindow *aParent,
nsIURI *aUrl,
PRBool aShowWindow,
PRBool aShowWindow, PRBool aLoadDefaultPage,
PRUint32 aChromeMask,
nsIXULWindowCallbacks *aCallbacks,
PRInt32 aInitialWidth, PRInt32 aInitialHeight,
@ -598,7 +601,7 @@ nsAppShellService::JustCreateTopWindow(nsIWebShellWindow *aParent,
}
rv = window->Initialize(aParent, mAppShell, aUrl,
aShowWindow, nsnull, aCallbacks,
aShowWindow, aLoadDefaultPage, nsnull, aCallbacks,
aInitialWidth, aInitialHeight, widgetInitData);
if (NS_SUCCEEDED(rv)) {
@ -670,7 +673,7 @@ nsAppShellService::RunModalDialog(
} else {
pushedQueue = PR_TRUE;
PushThreadEventQueue();
rv = CreateTopLevelWindow(aParent, aUrl, PR_TRUE, aChromeMask,
rv = CreateTopLevelWindow(aParent, aUrl, PR_TRUE, PR_TRUE, aChromeMask,
aCallbacks, aInitialWidth, aInitialHeight, &theWindow);
}

View File

@ -1042,7 +1042,7 @@ nsIWebShellWindow* FindWebShellWindow(nsIXULWindowCallbacks* inCallbacks)
rv = appShellService->CreateTopLevelWindow(
nsnull,
urlObj, // nsIURI* of chrome
PR_TRUE,
PR_TRUE, PR_TRUE,
NS_CHROME_ALL_CHROME,
inCallbacks, // callbacks
NS_SIZETOCONTENT, NS_SIZETOCONTENT,

View File

@ -560,7 +560,8 @@ nsresult nsNetSupportDialog::DoDialog( nsString& inXULURL )
return result;
}
result = appShellService->CreateTopLevelWindow(nsnull, dialogURL, PR_TRUE,
result = appShellService->CreateTopLevelWindow(nsnull, dialogURL,
PR_TRUE, PR_TRUE,
NS_CHROME_ALL_CHROME | NS_CHROME_OPEN_AS_DIALOG,
this, 300, 200, &dialogWindow);
mWebShellWindow = dialogWindow;

View File

@ -224,6 +224,7 @@ nsWebShellWindow::nsWebShellWindow()
mChromeMask = NS_CHROME_ALL_CHROME;
mIntrinsicallySized = PR_FALSE;
mCreatedVisible = PR_TRUE;
mLoadDefaultPage = PR_TRUE;
}
@ -329,6 +330,7 @@ nsWebShellWindow::QueryInterface(REFNSIID aIID, void** aInstancePtr)
nsresult nsWebShellWindow::Initialize(nsIWebShellWindow* aParent,
nsIAppShell* aShell, nsIURI* aUrl,
PRBool aCreatedVisible,
PRBool aLoadDefaultPage,
nsIStreamObserver* anObserver,
nsIXULWindowCallbacks *aCallbacks,
PRInt32 aInitialWidth, PRInt32 aInitialHeight,
@ -338,6 +340,7 @@ nsresult nsWebShellWindow::Initialize(nsIWebShellWindow* aParent,
nsIWidget *parentWidget;
mCreatedVisible = aCreatedVisible;
mLoadDefaultPage = aLoadDefaultPage;
// XXX: need to get the default window size from prefs...
// Doesn't come from prefs... will come from CSS/XUL/RDF
@ -1309,15 +1312,13 @@ nsWebShellWindow::CreatePopup(nsIDOMElement* aElement, nsIDOMElement* aPopupCont
if (nsnull == window) {
return NS_ERROR_OUT_OF_MEMORY;
}
// temporarily disabling parentage because non-Windows platforms
// seem to be interpreting it in unexpected ways.
nsWidgetInitData widgetInitData;
widgetInitData.mWindowType = eWindowType_popup;
widgetInitData.mBorderStyle = eBorderStyle_default;
window->SetIntrinsicallySized(PR_TRUE);
rv = window->Initialize((nsIWebShellWindow *) nsnull, nsnull, nsnull,
PR_TRUE, nsnull, nsnull,
PR_TRUE, PR_TRUE, nsnull, nsnull,
1, 1, widgetInitData);
if (NS_FAILED(rv))
@ -1475,8 +1476,9 @@ nsWebShellWindow::NewWebShell(PRUint32 aChromeMask, PRBool aVisible,
// return it immediately.
nsIWebShellWindow *parent = aChromeMask & NS_CHROME_DEPENDENT ? this : nsnull;
rv = appShell->CreateTopLevelWindow(parent, nsnull, PR_FALSE, aChromeMask,
nsnull, NS_SIZETOCONTENT, NS_SIZETOCONTENT,
rv = appShell->CreateTopLevelWindow(parent, nsnull, PR_FALSE, PR_FALSE,
aChromeMask, nsnull,
NS_SIZETOCONTENT, NS_SIZETOCONTENT,
getter_AddRefs(newWindow));
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIBrowserWindow> browser(do_QueryInterface(newWindow));
@ -1513,8 +1515,8 @@ nsWebShellWindow::NewWebShell(PRUint32 aChromeMask, PRBool aVisible,
#endif // NECKO
if (NS_SUCCEEDED(rv)) {
rv = appShell->CreateTopLevelWindow(nsnull, urlObj, PR_FALSE, aChromeMask,
nsnull, 615, 480,
rv = appShell->CreateTopLevelWindow(nsnull, urlObj, PR_FALSE, PR_FALSE,
aChromeMask, nsnull, 615, 480,
getter_AddRefs(newWindow));
}
@ -2546,7 +2548,7 @@ NS_IMETHODIMP nsWebShellWindow::Init(nsIAppShell* aAppShell,
widgetInitData.mWindowType = eWindowType_child;
widgetInitData.mBorderStyle = eBorderStyle_default;
rv = Initialize(nsnull, aAppShell, urlObj, PR_TRUE,
rv = Initialize(nsnull, aAppShell, urlObj, PR_TRUE, PR_TRUE,
nsnull, nsnull, aBounds.width, aBounds.height, widgetInitData);
mChromeMask = aChromeMask;
if (NS_SUCCEEDED(rv))

View File

@ -114,6 +114,9 @@ public:
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; }
NS_IMETHOD FindWebShellWithName(const PRUnichar* aName,
nsIWebShell*& aResult);
@ -130,7 +133,8 @@ public:
NS_IMETHOD ConvertWebShellToDOMWindow(nsIWebShell* aShell, nsIDOMWindow** aDOMWindow);
// nsWebShellWindow methods...
nsresult Initialize(nsIWebShellWindow * aParent, nsIAppShell* aShell, nsIURI* aUrl,
PRBool aCreatedVisible, nsIStreamObserver* anObserver,
PRBool aCreatedVisible, PRBool aLoadDefaultPage,
nsIStreamObserver* anObserver,
nsIXULWindowCallbacks *aCallbacks,
PRInt32 aInitialWidth, PRInt32 aInitialHeight,
nsWidgetInitData& widgetInitData);
@ -310,6 +314,7 @@ protected:
PRBool mChromeInitialized;
PRUint32 mChromeMask;
PRBool mCreatedVisible;
PRBool mLoadDefaultPage;
nsVoidArray mMenuDelegates;

View File

@ -670,7 +670,7 @@ int main1(int argc, char* argv[])
nsCOMPtr<nsIWebShellWindow> profWindow;
rv = profAppShell->CreateTopLevelWindow(nsnull, profURL,
PR_TRUE, NS_CHROME_ALL_CHROME,
PR_TRUE, PR_TRUE, NS_CHROME_ALL_CHROME,
nsnull, profWinWidth, profWinHeight,
getter_AddRefs(profWindow));
@ -722,7 +722,7 @@ int main1(int argc, char* argv[])
if ( !useArgs ) {
nsCOMPtr<nsIWebShellWindow> newWindow;
rv = appShell->CreateTopLevelWindow(nsnull, url,
PR_TRUE, NS_CHROME_ALL_CHROME,
PR_TRUE, PR_TRUE, NS_CHROME_ALL_CHROME,
nsnull, NS_SIZETOCONTENT, NS_SIZETOCONTENT,
getter_AddRefs(newWindow));
} else {

View File

@ -1042,7 +1042,7 @@ nsIWebShellWindow* FindWebShellWindow(nsIXULWindowCallbacks* inCallbacks)
rv = appShellService->CreateTopLevelWindow(
nsnull,
urlObj, // nsIURI* of chrome
PR_TRUE,
PR_TRUE, PR_TRUE,
NS_CHROME_ALL_CHROME,
inCallbacks, // callbacks
NS_SIZETOCONTENT, NS_SIZETOCONTENT,

View File

@ -233,6 +233,7 @@ nsInstallProgressDialog::Open()
rv = appShell->CreateTopLevelWindow( nsnull,
url,
PR_TRUE,
PR_TRUE,
NS_CHROME_ALL_CHROME,
this, // callbacks??
0,