added support for opening new windows with _blank url targets.

This commit is contained in:
michaelp%netscape.com 1998-08-19 21:00:51 +00:00
Родитель 264a7aab20
Коммит 58241d2492
5 изменённых файлов: 98 добавлений и 12 удалений

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

@ -177,6 +177,7 @@ public:
NS_IMETHOD ProgressLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aProgress, PRInt32 aProgressMax); NS_IMETHOD ProgressLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aProgress, PRInt32 aProgressMax);
NS_IMETHOD EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aStatus); NS_IMETHOD EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aStatus);
NS_IMETHOD OverLink(nsIWebShell* aShell, const PRUnichar* aURLSpec, const PRUnichar* aTargetSpec); NS_IMETHOD OverLink(nsIWebShell* aShell, const PRUnichar* aURLSpec, const PRUnichar* aTargetSpec);
NS_IMETHOD NewWebShell(nsIWebShell *&aNewWebShell);
// nsILinkHandler // nsILinkHandler
NS_IMETHOD OnLinkClick(nsIFrame* aFrame, NS_IMETHOD OnLinkClick(nsIFrame* aFrame,
@ -405,8 +406,10 @@ nsWebShell::QueryInterface(REFNSIID aIID, void** aInstancePtr)
AddRef(); AddRef();
return NS_OK; return NS_OK;
} }
if (aIID.Equals(kISupportsIID)) { if (aIID.Equals(kILinkHandlerIID)) {
*aInstancePtr = (void*)(nsISupports*)(nsIWebShell*)this; //I added this for plugin support of jumping
//through links. maybe there is a better way... MMP
*aInstancePtr = (void*)(nsILinkHandler*)this;
AddRef(); AddRef();
return NS_OK; return NS_OK;
} }
@ -415,6 +418,11 @@ nsWebShell::QueryInterface(REFNSIID aIID, void** aInstancePtr)
AddRef(); AddRef();
return NS_OK; return NS_OK;
} }
if (aIID.Equals(kISupportsIID)) {
*aInstancePtr = (void*)(nsISupports*)(nsIWebShell*)this;
AddRef();
return NS_OK;
}
if (nsnull != mInnerWindow) { if (nsnull != mInnerWindow) {
return mInnerWindow->QueryInterface(aIID, aInstancePtr); return mInnerWindow->QueryInterface(aIID, aInstancePtr);
} }
@ -1240,6 +1248,15 @@ nsWebShell::OverLink(nsIWebShell* aShell, const PRUnichar* aURLSpec, const PRUni
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
nsWebShell::NewWebShell(nsIWebShell *&aNewWebShell)
{
if (nsnull != mContainer) {
return mContainer->NewWebShell(aNewWebShell);
}
return NS_OK;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1339,10 +1356,14 @@ nsWebShell::GetTarget(const PRUnichar* aName)
nsIWebShell* target = nsnull; nsIWebShell* target = nsnull;
if (name.EqualsIgnoreCase("_blank")) { if (name.EqualsIgnoreCase("_blank")) {
// XXX Need api in nsIWebShellContainer nsIWebShell *shell;
NS_ASSERTION(0, "not implemented yet"); if (NS_OK == NewWebShell(shell))
target = this; target = shell;
NS_ADDREF(target); else
{
//don't know what to do here? MMP
NS_ASSERTION(PR_FALSE, "unable to get new webshell");
}
} }
else if (name.EqualsIgnoreCase("_self")) { else if (name.EqualsIgnoreCase("_self")) {
target = this; target = this;

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

@ -70,6 +70,9 @@ public:
NS_IMETHOD OverLink(nsIWebShell* aShell, const PRUnichar* aURLSpec, const PRUnichar* aTargetSpec) = 0; NS_IMETHOD OverLink(nsIWebShell* aShell, const PRUnichar* aURLSpec, const PRUnichar* aTargetSpec) = 0;
//instances
NS_IMETHOD NewWebShell(nsIWebShell *&aNewWebShell) = 0;
// Chrome control // Chrome control
// NS_IMETHOD SetHistoryIndex(PRInt32 aIndex, PRInt32 aMaxIndex) = 0; // NS_IMETHOD SetHistoryIndex(PRInt32 aIndex, PRInt32 aMaxIndex) = 0;

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

@ -177,6 +177,7 @@ public:
NS_IMETHOD ProgressLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aProgress, PRInt32 aProgressMax); NS_IMETHOD ProgressLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aProgress, PRInt32 aProgressMax);
NS_IMETHOD EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aStatus); NS_IMETHOD EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aStatus);
NS_IMETHOD OverLink(nsIWebShell* aShell, const PRUnichar* aURLSpec, const PRUnichar* aTargetSpec); NS_IMETHOD OverLink(nsIWebShell* aShell, const PRUnichar* aURLSpec, const PRUnichar* aTargetSpec);
NS_IMETHOD NewWebShell(nsIWebShell *&aNewWebShell);
// nsILinkHandler // nsILinkHandler
NS_IMETHOD OnLinkClick(nsIFrame* aFrame, NS_IMETHOD OnLinkClick(nsIFrame* aFrame,
@ -405,8 +406,10 @@ nsWebShell::QueryInterface(REFNSIID aIID, void** aInstancePtr)
AddRef(); AddRef();
return NS_OK; return NS_OK;
} }
if (aIID.Equals(kISupportsIID)) { if (aIID.Equals(kILinkHandlerIID)) {
*aInstancePtr = (void*)(nsISupports*)(nsIWebShell*)this; //I added this for plugin support of jumping
//through links. maybe there is a better way... MMP
*aInstancePtr = (void*)(nsILinkHandler*)this;
AddRef(); AddRef();
return NS_OK; return NS_OK;
} }
@ -415,6 +418,11 @@ nsWebShell::QueryInterface(REFNSIID aIID, void** aInstancePtr)
AddRef(); AddRef();
return NS_OK; return NS_OK;
} }
if (aIID.Equals(kISupportsIID)) {
*aInstancePtr = (void*)(nsISupports*)(nsIWebShell*)this;
AddRef();
return NS_OK;
}
if (nsnull != mInnerWindow) { if (nsnull != mInnerWindow) {
return mInnerWindow->QueryInterface(aIID, aInstancePtr); return mInnerWindow->QueryInterface(aIID, aInstancePtr);
} }
@ -1240,6 +1248,15 @@ nsWebShell::OverLink(nsIWebShell* aShell, const PRUnichar* aURLSpec, const PRUni
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
nsWebShell::NewWebShell(nsIWebShell *&aNewWebShell)
{
if (nsnull != mContainer) {
return mContainer->NewWebShell(aNewWebShell);
}
return NS_OK;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1339,10 +1356,14 @@ nsWebShell::GetTarget(const PRUnichar* aName)
nsIWebShell* target = nsnull; nsIWebShell* target = nsnull;
if (name.EqualsIgnoreCase("_blank")) { if (name.EqualsIgnoreCase("_blank")) {
// XXX Need api in nsIWebShellContainer nsIWebShell *shell;
NS_ASSERTION(0, "not implemented yet"); if (NS_OK == NewWebShell(shell))
target = this; target = shell;
NS_ADDREF(target); else
{
//don't know what to do here? MMP
NS_ASSERTION(PR_FALSE, "unable to get new webshell");
}
} }
else if (name.EqualsIgnoreCase("_self")) { else if (name.EqualsIgnoreCase("_self")) {
target = this; target = this;

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

@ -529,6 +529,9 @@ nsBrowserWindow::Init(nsIAppShell* aAppShell,
PRBool aAllowPlugins) PRBool aAllowPlugins)
{ {
mChromeMask = aChromeMask; mChromeMask = aChromeMask;
mAppShell = aAppShell;
mPrefs = aPrefs;
mAllowPlugins = aAllowPlugins;
// Create top level window // Create top level window
nsresult rv = NSRepository::CreateInstance(kWindowCID, nsnull, kIWidgetIID, nsresult rv = NSRepository::CreateInstance(kWindowCID, nsnull, kIWidgetIID,
@ -883,6 +886,38 @@ nsBrowserWindow::OverLink(nsIWebShell* aShell, const PRUnichar* aURLSpec, const
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
nsBrowserWindow::NewWebShell(nsIWebShell *&aNewWebShell)
{
nsNativeBrowserWindow *browser = (nsNativeBrowserWindow *)new nsNativeBrowserWindow();
nsresult rv = NS_OK;
if (nsnull != browser)
{
nsRect bounds;
GetBounds(bounds);
browser->SetApp(mApp);
rv = browser->Init(mAppShell, mPrefs, bounds, mChromeMask, mAllowPlugins);
if (NS_OK == rv)
{
NS_ADDREF(browser);
browser->Show();
nsIWebShell *shell;
rv = browser->GetWebShell(shell);
aNewWebShell = shell;
}
else
browser->Destroy();
}
else
rv = NS_ERROR_OUT_OF_MEMORY;
return rv;
}
//---------------------------------------- //----------------------------------------
// Stream observer implementation // Stream observer implementation

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

@ -89,6 +89,7 @@ public:
NS_IMETHOD ProgressLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aProgress, PRInt32 aProgressMax); NS_IMETHOD ProgressLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aProgress, PRInt32 aProgressMax);
NS_IMETHOD EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aStatus); NS_IMETHOD EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aStatus);
NS_IMETHOD OverLink(nsIWebShell* aShell, const PRUnichar* aURLSpec, const PRUnichar* aTargetSpec); NS_IMETHOD OverLink(nsIWebShell* aShell, const PRUnichar* aURLSpec, const PRUnichar* aTargetSpec);
NS_IMETHOD NewWebShell(nsIWebShell *&aNewWebShell);
// nsINetSupport // nsINetSupport
NS_IMETHOD_(void) Alert(const nsString &aText); NS_IMETHOD_(void) Alert(const nsString &aText);
@ -165,6 +166,11 @@ public:
// "Status bar" // "Status bar"
nsITextWidget* mStatus; nsITextWidget* mStatus;
//for creating more instances
nsIAppShell* mAppShell; //not addref'ed!
nsIPref* mPrefs; //not addref'ed!
PRBool mAllowPlugins;
// Global window collection // Global window collection
static nsVoidArray gBrowsers; static nsVoidArray gBrowsers;
static void AddBrowser(nsBrowserWindow* aBrowser); static void AddBrowser(nsBrowserWindow* aBrowser);