diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index 57e1ec53dcc..45ec44891d5 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -177,6 +177,7 @@ public: NS_IMETHOD ProgressLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aProgress, PRInt32 aProgressMax); NS_IMETHOD EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aStatus); NS_IMETHOD OverLink(nsIWebShell* aShell, const PRUnichar* aURLSpec, const PRUnichar* aTargetSpec); + NS_IMETHOD NewWebShell(nsIWebShell *&aNewWebShell); // nsILinkHandler NS_IMETHOD OnLinkClick(nsIFrame* aFrame, @@ -405,8 +406,10 @@ nsWebShell::QueryInterface(REFNSIID aIID, void** aInstancePtr) AddRef(); return NS_OK; } - if (aIID.Equals(kISupportsIID)) { - *aInstancePtr = (void*)(nsISupports*)(nsIWebShell*)this; + if (aIID.Equals(kILinkHandlerIID)) { + //I added this for plugin support of jumping + //through links. maybe there is a better way... MMP + *aInstancePtr = (void*)(nsILinkHandler*)this; AddRef(); return NS_OK; } @@ -415,6 +418,11 @@ nsWebShell::QueryInterface(REFNSIID aIID, void** aInstancePtr) AddRef(); return NS_OK; } + if (aIID.Equals(kISupportsIID)) { + *aInstancePtr = (void*)(nsISupports*)(nsIWebShell*)this; + AddRef(); + return NS_OK; + } if (nsnull != mInnerWindow) { return mInnerWindow->QueryInterface(aIID, aInstancePtr); } @@ -1240,6 +1248,15 @@ nsWebShell::OverLink(nsIWebShell* aShell, const PRUnichar* aURLSpec, const PRUni 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; if (name.EqualsIgnoreCase("_blank")) { - // XXX Need api in nsIWebShellContainer - NS_ASSERTION(0, "not implemented yet"); - target = this; - NS_ADDREF(target); + nsIWebShell *shell; + if (NS_OK == NewWebShell(shell)) + target = shell; + else + { + //don't know what to do here? MMP + NS_ASSERTION(PR_FALSE, "unable to get new webshell"); + } } else if (name.EqualsIgnoreCase("_self")) { target = this; diff --git a/mozilla/webshell/public/nsIWebShell.h b/mozilla/webshell/public/nsIWebShell.h index 5853a2f8546..6566a154063 100644 --- a/mozilla/webshell/public/nsIWebShell.h +++ b/mozilla/webshell/public/nsIWebShell.h @@ -70,6 +70,9 @@ public: NS_IMETHOD OverLink(nsIWebShell* aShell, const PRUnichar* aURLSpec, const PRUnichar* aTargetSpec) = 0; + //instances + NS_IMETHOD NewWebShell(nsIWebShell *&aNewWebShell) = 0; + // Chrome control // NS_IMETHOD SetHistoryIndex(PRInt32 aIndex, PRInt32 aMaxIndex) = 0; diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp index 57e1ec53dcc..45ec44891d5 100644 --- a/mozilla/webshell/src/nsWebShell.cpp +++ b/mozilla/webshell/src/nsWebShell.cpp @@ -177,6 +177,7 @@ public: NS_IMETHOD ProgressLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aProgress, PRInt32 aProgressMax); NS_IMETHOD EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aStatus); NS_IMETHOD OverLink(nsIWebShell* aShell, const PRUnichar* aURLSpec, const PRUnichar* aTargetSpec); + NS_IMETHOD NewWebShell(nsIWebShell *&aNewWebShell); // nsILinkHandler NS_IMETHOD OnLinkClick(nsIFrame* aFrame, @@ -405,8 +406,10 @@ nsWebShell::QueryInterface(REFNSIID aIID, void** aInstancePtr) AddRef(); return NS_OK; } - if (aIID.Equals(kISupportsIID)) { - *aInstancePtr = (void*)(nsISupports*)(nsIWebShell*)this; + if (aIID.Equals(kILinkHandlerIID)) { + //I added this for plugin support of jumping + //through links. maybe there is a better way... MMP + *aInstancePtr = (void*)(nsILinkHandler*)this; AddRef(); return NS_OK; } @@ -415,6 +418,11 @@ nsWebShell::QueryInterface(REFNSIID aIID, void** aInstancePtr) AddRef(); return NS_OK; } + if (aIID.Equals(kISupportsIID)) { + *aInstancePtr = (void*)(nsISupports*)(nsIWebShell*)this; + AddRef(); + return NS_OK; + } if (nsnull != mInnerWindow) { return mInnerWindow->QueryInterface(aIID, aInstancePtr); } @@ -1240,6 +1248,15 @@ nsWebShell::OverLink(nsIWebShell* aShell, const PRUnichar* aURLSpec, const PRUni 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; if (name.EqualsIgnoreCase("_blank")) { - // XXX Need api in nsIWebShellContainer - NS_ASSERTION(0, "not implemented yet"); - target = this; - NS_ADDREF(target); + nsIWebShell *shell; + if (NS_OK == NewWebShell(shell)) + target = shell; + else + { + //don't know what to do here? MMP + NS_ASSERTION(PR_FALSE, "unable to get new webshell"); + } } else if (name.EqualsIgnoreCase("_self")) { target = this; diff --git a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp index f2eb9fd2f4e..c9703449405 100644 --- a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp +++ b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp @@ -529,6 +529,9 @@ nsBrowserWindow::Init(nsIAppShell* aAppShell, PRBool aAllowPlugins) { mChromeMask = aChromeMask; + mAppShell = aAppShell; + mPrefs = aPrefs; + mAllowPlugins = aAllowPlugins; // Create top level window nsresult rv = NSRepository::CreateInstance(kWindowCID, nsnull, kIWidgetIID, @@ -883,6 +886,38 @@ nsBrowserWindow::OverLink(nsIWebShell* aShell, const PRUnichar* aURLSpec, const 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 diff --git a/mozilla/webshell/tests/viewer/nsBrowserWindow.h b/mozilla/webshell/tests/viewer/nsBrowserWindow.h index b4443286e34..fe96e8bc372 100644 --- a/mozilla/webshell/tests/viewer/nsBrowserWindow.h +++ b/mozilla/webshell/tests/viewer/nsBrowserWindow.h @@ -89,6 +89,7 @@ public: NS_IMETHOD ProgressLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aProgress, PRInt32 aProgressMax); NS_IMETHOD EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aStatus); NS_IMETHOD OverLink(nsIWebShell* aShell, const PRUnichar* aURLSpec, const PRUnichar* aTargetSpec); + NS_IMETHOD NewWebShell(nsIWebShell *&aNewWebShell); // nsINetSupport NS_IMETHOD_(void) Alert(const nsString &aText); @@ -165,6 +166,11 @@ public: // "Status bar" nsITextWidget* mStatus; + //for creating more instances + nsIAppShell* mAppShell; //not addref'ed! + nsIPref* mPrefs; //not addref'ed! + PRBool mAllowPlugins; + // Global window collection static nsVoidArray gBrowsers; static void AddBrowser(nsBrowserWindow* aBrowser);