зеркало из https://github.com/mozilla/gecko-dev.git
added support for opening new windows with _blank url targets.
This commit is contained in:
Родитель
264a7aab20
Коммит
58241d2492
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче