Remove duplicate functionality of nsIBrowserWindow and nsIWebShellContainer.

This commit is contained in:
joki%netscape.com 1998-09-09 01:19:11 +00:00
Родитель faf263bb06
Коммит 2e0dcce305
11 изменённых файлов: 125 добавлений и 136 удалений

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

@ -43,6 +43,7 @@
#include "nsIRefreshUrl.h"
#include "nsITimer.h"
#include "jsurl.h"
#include "nsIBrowserWindow.h"
#include "prlog.h"
@ -182,7 +183,6 @@ public:
NS_IMETHOD BeginLoadURL(nsIWebShell* aShell, const PRUnichar* aURL);
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
@ -291,6 +291,7 @@ static NS_DEFINE_IID(kIDocumentLoaderObserverIID, NS_IDOCUMENT_LOADER_OBSERVER_I
static NS_DEFINE_IID(kIDocumentViewerIID, NS_IDOCUMENT_VIEWER_IID);
static NS_DEFINE_IID(kRefreshURLIID, NS_IREFRESHURL_IID);
static NS_DEFINE_IID(kIWebShellContainerIID, NS_IWEB_SHELL_CONTAINER_IID);
static NS_DEFINE_IID(kIBrowserWindowIID, NS_IBROWSER_WINDOW_IID);
// XXX not sure
static NS_DEFINE_IID(kILinkHandlerIID, NS_ILINKHANDLER_IID);
@ -1210,10 +1211,22 @@ nsWebShell::SetTitle(const PRUnichar* aTitle)
mTitle = aTitle;
// Title's set on the top level web-shell are passed ont to the container
if (nsnull == mParent) {
if (nsnull != mContainer) {
mContainer->SetTitle(aTitle);
nsIWebShell *rootWebShell;
GetRootWebShell(rootWebShell);
if (nsnull != rootWebShell) {
nsIWebShellContainer *rootContainer;
rootWebShell->GetContainer(rootContainer);
if (nsnull != rootContainer) {
nsIBrowserWindow *browserWindow;
if (NS_OK == rootContainer->QueryInterface(kIBrowserWindowIID, (void**)&browserWindow)) {
browserWindow->SetTitle(aTitle);
NS_RELEASE(browserWindow);
}
NS_RELEASE(rootContainer);
}
NS_RELEASE(rootWebShell);
}
return NS_OK;
@ -1271,15 +1284,6 @@ nsWebShell::EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aStat
return NS_OK;
}
NS_IMETHODIMP
nsWebShell::OverLink(nsIWebShell* aShell, const PRUnichar* aURLSpec, const PRUnichar* aTargetSpec)
{
if (nsnull != mContainer) {
return mContainer->OverLink(aShell, aURLSpec, aTargetSpec);
}
return NS_OK;
}
NS_IMETHODIMP
nsWebShell::NewWebShell(nsIWebShell *&aNewWebShell)
{
@ -1455,9 +1459,22 @@ fputs("Was '", stdout); fputs(mOverURL, stdout); fputs("' '", stdout); fputs(mOv
mOverURL = aURLSpec;
mOverTarget = aTargetSpec;
// XXX: Should the IWebShell being passed out be the target WebShell?
if (nsnull != mContainer) {
mContainer->OverLink(this, aURLSpec, aTargetSpec);
// Get the browser window and setStatus
nsIWebShell *rootWebShell;
GetRootWebShell(rootWebShell);
if (nsnull != rootWebShell) {
nsIWebShellContainer *rootContainer;
rootWebShell->GetContainer(rootContainer);
if (nsnull != rootContainer) {
nsIBrowserWindow *browserWindow;
if (NS_OK == rootContainer->QueryInterface(kIBrowserWindowIID, (void**)&browserWindow)) {
browserWindow->SetStatus(aURLSpec);
NS_RELEASE(browserWindow);
}
NS_RELEASE(rootContainer);
}
NS_RELEASE(rootWebShell);
}
}
return NS_OK;

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

@ -1023,52 +1023,61 @@ GlobalWindowImpl::Open(JSContext *cx,
mChrome = (PRUint32)~0;
}
nsIBrowserWindow *mNewWindow, *mBrowser;
nsIScriptGlobalObject *mNewGlobalObject = nsnull;
nsIBrowserWindow *newWindow = nsnull;
nsIScriptGlobalObject *newGlobalObject = nsnull;
nsIWebShell *newWebShell;
nsIWebShellContainer *webShellContainer, *newContainer;
/* XXX check for existing window of same name. If exists, set url and
* update chrome */
if (NS_OK == mWebShell->GetContainer(webShellContainer)) {
if (NS_OK == webShellContainer->NewWebShell(newWebShell)) {
if (NS_OK == newWebShell->GetContainer(newContainer) && nsnull != newContainer) {
newContainer->QueryInterface(kIBrowserWindowIID, (void**)&newWindow);
NS_RELEASE(newContainer);
}
}
NS_RELEASE(webShellContainer);
}
if (NS_OK == GetBrowserWindowInterface(mBrowser)) {
mBrowser->OpenWindow(mChrome, mNewWindow);
mNewWindow->LoadURL(mAbsURL);
if (nsnull != newWindow) {
//How should we do default size/pos
mNewWindow->SizeTo(mWidth ? mWidth : 620, mHeight ? mHeight : 400);
mNewWindow->MoveTo(mLeft, mTop);
mNewWindow->Show();
newWindow->SetChrome(mChrome);
newWindow->SizeTo(mWidth ? mWidth : 620, mHeight ? mHeight : 400);
newWindow->MoveTo(mLeft, mTop);
NS_RELEASE(mBrowser);
newWebShell->LoadURL(mAbsURL);
newWindow->Show();
/* Get win obj */
nsIWebShell *mNewWebShell = nsnull;
nsIScriptContextOwner *mNewContextOwner = nsnull;
nsIScriptContextOwner *newContextOwner = nsnull;
if (NS_OK != mNewWindow->GetWebShell(mNewWebShell) ||
NS_OK != mNewWebShell->QueryInterface(kIScriptContextOwnerIID, (void**)&mNewContextOwner) ||
NS_OK != mNewContextOwner->GetScriptGlobalObject(&mNewGlobalObject)) {
if (NS_OK != newWebShell->QueryInterface(kIScriptContextOwnerIID, (void**)&newContextOwner) ||
NS_OK != newContextOwner->GetScriptGlobalObject(&newGlobalObject)) {
NS_IF_RELEASE(mNewWindow);
NS_IF_RELEASE(mNewWebShell);
NS_IF_RELEASE(mNewContextOwner);
NS_IF_RELEASE(newWindow);
NS_IF_RELEASE(newWebShell);
NS_IF_RELEASE(newContextOwner);
return NS_ERROR_FAILURE;
}
mNewWebShell->SetName(mName);
newWebShell->SetName(mName);
NS_RELEASE(mNewWindow);
NS_RELEASE(mNewWebShell);
NS_RELEASE(mNewContextOwner);
NS_RELEASE(newWindow);
NS_RELEASE(newWebShell);
NS_RELEASE(newContextOwner);
}
nsIDOMWindow *mNewDOMWindow;
if (nsnull != mNewGlobalObject && NS_OK == mNewGlobalObject->QueryInterface(kIDOMWindowIID, (void**)&mNewDOMWindow)) {
*aReturn = mNewDOMWindow;
nsIDOMWindow *newDOMWindow;
if (nsnull != newGlobalObject && NS_OK == newGlobalObject->QueryInterface(kIDOMWindowIID, (void**)&newDOMWindow)) {
*aReturn = newDOMWindow;
}
/* Set opener */
mNewGlobalObject->SetOpenerWindow(this);
newGlobalObject->SetOpenerWindow(this);
NS_IF_RELEASE(mNewGlobalObject);
NS_IF_RELEASE(newGlobalObject);
return NS_OK;
}
@ -1378,6 +1387,9 @@ GlobalWindowImpl::HandleDOMEvent(nsIPresContext& aPresContext,
}
//Capturing stage
/*if (mEventCapturer) {
mEventCapturer->HandleDOMEvent(aPresContext, aEvent, aDOMEvent, aFlags, aEventStatus);
}*/
//Local handling stage
if (nsnull != mListenerManager) {

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

@ -57,20 +57,6 @@ nsresult CWebShellContainer::QueryInterface(const nsIID& aIID, void** aInstanceP
return NS_NOINTERFACE;
}
NS_IMETHODIMP
CWebShellContainer::SetTitle(const PRUnichar* aTitle)
{
m_sTitle = aTitle;
return NS_OK;
}
NS_IMETHODIMP
CWebShellContainer::GetTitle(PRUnichar** aResult)
{
*aResult = m_sTitle;
return NS_OK;
}
NS_IMETHODIMP
CWebShellContainer::WillLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsLoadType aReason)
{
@ -107,16 +93,6 @@ CWebShellContainer::EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt
return NS_OK;
}
NS_IMETHODIMP
CWebShellContainer::OverLink(nsIWebShell* aShell, const PRUnichar* aURLSpec, const PRUnichar* aTargetSpec)
{
// if (nsnull != mStatus)
// {
// mStatus->SetText(aURLSpec);
// }
return NS_OK;
}
NS_IMETHODIMP
CWebShellContainer::NewWebShell(nsIWebShell *&aNewWebShell)
{

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

@ -18,13 +18,10 @@ public:
NS_DECL_ISUPPORTS
// nsIWebShellContainer
NS_IMETHOD SetTitle(const PRUnichar* aTitle);
NS_IMETHOD GetTitle(PRUnichar** aResult);
NS_IMETHOD WillLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsLoadType aReason);
NS_IMETHOD BeginLoadURL(nsIWebShell* aShell, const PRUnichar* aURL);
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);
};

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

@ -72,14 +72,10 @@ public:
NS_IMETHOD Close() = 0;
NS_IMETHOD OpenWindow(PRUint32 aNewChromeMask, nsIBrowserWindow*& aNewWindow) = 0;
NS_IMETHOD ChangeChrome(PRUint32 aNewChromeMask) = 0;
NS_IMETHOD SetChrome(PRUint32 aNewChromeMask) = 0;
NS_IMETHOD GetChrome(PRUint32& aChromeMaskResult) = 0;
NS_IMETHOD LoadURL(const PRUnichar* aURL) = 0;
NS_IMETHOD SetTitle(const PRUnichar* aTitle) = 0;
NS_IMETHOD GetTitle(PRUnichar** aResult) = 0;

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

@ -56,10 +56,6 @@ typedef enum {
// Container for web shell's
class nsIWebShellContainer : public nsISupports {
public:
NS_IMETHOD SetTitle(const PRUnichar* aTitle) = 0;
NS_IMETHOD GetTitle(PRUnichar** aResult) = 0;
// History control
NS_IMETHOD WillLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsLoadType aReason) = 0;
NS_IMETHOD BeginLoadURL(nsIWebShell* aShell, const PRUnichar* aURL) = 0;
@ -68,13 +64,10 @@ public:
NS_IMETHOD ProgressLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aProgress, PRInt32 aProgressMax) = 0;
NS_IMETHOD EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aStatus) = 0;
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;
// NS_IMETHOD SetHistoryIndex(PRInt32 aIndex, PRInt32 aMaxIndex) = 0;
// Link traversing control
};

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

@ -43,6 +43,7 @@
#include "nsIRefreshUrl.h"
#include "nsITimer.h"
#include "jsurl.h"
#include "nsIBrowserWindow.h"
#include "prlog.h"
@ -182,7 +183,6 @@ public:
NS_IMETHOD BeginLoadURL(nsIWebShell* aShell, const PRUnichar* aURL);
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
@ -291,6 +291,7 @@ static NS_DEFINE_IID(kIDocumentLoaderObserverIID, NS_IDOCUMENT_LOADER_OBSERVER_I
static NS_DEFINE_IID(kIDocumentViewerIID, NS_IDOCUMENT_VIEWER_IID);
static NS_DEFINE_IID(kRefreshURLIID, NS_IREFRESHURL_IID);
static NS_DEFINE_IID(kIWebShellContainerIID, NS_IWEB_SHELL_CONTAINER_IID);
static NS_DEFINE_IID(kIBrowserWindowIID, NS_IBROWSER_WINDOW_IID);
// XXX not sure
static NS_DEFINE_IID(kILinkHandlerIID, NS_ILINKHANDLER_IID);
@ -1210,10 +1211,22 @@ nsWebShell::SetTitle(const PRUnichar* aTitle)
mTitle = aTitle;
// Title's set on the top level web-shell are passed ont to the container
if (nsnull == mParent) {
if (nsnull != mContainer) {
mContainer->SetTitle(aTitle);
nsIWebShell *rootWebShell;
GetRootWebShell(rootWebShell);
if (nsnull != rootWebShell) {
nsIWebShellContainer *rootContainer;
rootWebShell->GetContainer(rootContainer);
if (nsnull != rootContainer) {
nsIBrowserWindow *browserWindow;
if (NS_OK == rootContainer->QueryInterface(kIBrowserWindowIID, (void**)&browserWindow)) {
browserWindow->SetTitle(aTitle);
NS_RELEASE(browserWindow);
}
NS_RELEASE(rootContainer);
}
NS_RELEASE(rootWebShell);
}
return NS_OK;
@ -1271,15 +1284,6 @@ nsWebShell::EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aStat
return NS_OK;
}
NS_IMETHODIMP
nsWebShell::OverLink(nsIWebShell* aShell, const PRUnichar* aURLSpec, const PRUnichar* aTargetSpec)
{
if (nsnull != mContainer) {
return mContainer->OverLink(aShell, aURLSpec, aTargetSpec);
}
return NS_OK;
}
NS_IMETHODIMP
nsWebShell::NewWebShell(nsIWebShell *&aNewWebShell)
{
@ -1455,9 +1459,22 @@ fputs("Was '", stdout); fputs(mOverURL, stdout); fputs("' '", stdout); fputs(mOv
mOverURL = aURLSpec;
mOverTarget = aTargetSpec;
// XXX: Should the IWebShell being passed out be the target WebShell?
if (nsnull != mContainer) {
mContainer->OverLink(this, aURLSpec, aTargetSpec);
// Get the browser window and setStatus
nsIWebShell *rootWebShell;
GetRootWebShell(rootWebShell);
if (nsnull != rootWebShell) {
nsIWebShellContainer *rootContainer;
rootWebShell->GetContainer(rootContainer);
if (nsnull != rootContainer) {
nsIBrowserWindow *browserWindow;
if (NS_OK == rootContainer->QueryInterface(kIBrowserWindowIID, (void**)&browserWindow)) {
browserWindow->SetStatus(aURLSpec);
NS_RELEASE(browserWindow);
}
NS_RELEASE(rootContainer);
}
NS_RELEASE(rootWebShell);
}
}
return NS_OK;

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

@ -349,7 +349,7 @@ nsBrowserWindow::DispatchMenuItem(PRInt32 aID)
url.Append("/test");
url.Append(ix, 10);
url.Append(".html");
LoadURL(url);
mWebShell->LoadURL(url);
}
break;
case JS_CONSOLE:
@ -455,7 +455,7 @@ nsBrowserWindow::DoFileOpen()
PR_snprintf(lpszFileURL, sum, "%s%s", FILE_PROTOCOL, szFile);
// Ask the Web widget to load the file URL
LoadURL(nsString(lpszFileURL));
mWebShell->LoadURL(nsString(lpszFileURL));
delete lpszFileURL;
}
}
@ -1072,13 +1072,7 @@ nsBrowserWindow::Close()
}
NS_IMETHODIMP
nsBrowserWindow::OpenWindow(PRUint32 aNewChromeMask, nsIBrowserWindow*& aNewWindow)
{
return mApp->OpenWindow(aNewChromeMask, aNewWindow);
}
NS_IMETHODIMP
nsBrowserWindow::ChangeChrome(PRUint32 aChromeMask)
nsBrowserWindow::SetChrome(PRUint32 aChromeMask)
{
// XXX write me
mChromeMask = aChromeMask;
@ -1092,12 +1086,6 @@ nsBrowserWindow::GetChrome(PRUint32& aChromeMaskResult)
return NS_OK;
}
NS_IMETHODIMP
nsBrowserWindow::LoadURL(const PRUnichar* aURL)
{
return mWebShell->LoadURL(aURL, nsnull);
}
NS_IMETHODIMP
nsBrowserWindow::GetWebShell(nsIWebShell*& aResult)
{
@ -1175,15 +1163,6 @@ nsBrowserWindow::EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32
return NS_OK;
}
NS_IMETHODIMP
nsBrowserWindow::OverLink(nsIWebShell* aShell, const PRUnichar* aURLSpec, const PRUnichar* aTargetSpec)
{
if (nsnull != mStatus) {
mStatus->SetText(aURLSpec);
}
return NS_OK;
}
NS_IMETHODIMP
nsBrowserWindow::NewWebShell(nsIWebShell *&aNewWebShell)
{

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

@ -72,10 +72,8 @@ public:
NS_IMETHOD Show();
NS_IMETHOD Hide();
NS_IMETHOD Close();
NS_IMETHOD OpenWindow(PRUint32 aNewChromeMask, nsIBrowserWindow*& aNewWindow);
NS_IMETHOD ChangeChrome(PRUint32 aNewChromeMask);
NS_IMETHOD SetChrome(PRUint32 aNewChromeMask);
NS_IMETHOD GetChrome(PRUint32& aChromeMaskResult);
NS_IMETHOD LoadURL(const PRUnichar* aURL);
NS_IMETHOD SetTitle(const PRUnichar* aTitle);
NS_IMETHOD GetTitle(PRUnichar** aResult);
NS_IMETHOD SetStatus(const PRUnichar* aStatus);
@ -93,7 +91,6 @@ public:
NS_IMETHOD BeginLoadURL(nsIWebShell* aShell, const PRUnichar* aURL);
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

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

@ -434,7 +434,7 @@ nsViewerApp::OpenWindow()
mCrawler->Start();
}
else {
bw->LoadURL(mStartURL);
bw->GoTo(mStartURL);
}
return NS_OK;
@ -977,7 +977,7 @@ nsEventStatus PR_CALLBACK HandleSiteEvent(nsGUIEvent *aEvent)
if (gWinData) {
nsString urlStr(gTop100List[--gTop100Pointer]);
mSiteLabel->SetLabel(urlStr);
gWinData->LoadURL(urlStr);
gWinData->GoTo(urlStr);
}
} else {
mSitePrevBtn->Enable(PR_FALSE);
@ -991,7 +991,7 @@ nsEventStatus PR_CALLBACK HandleSiteEvent(nsGUIEvent *aEvent)
if (gWinData) {
nsString urlStr(gTop100List[gTop100Pointer]);
mSiteLabel->SetLabel(urlStr);
gWinData->LoadURL(urlStr);
gWinData->GoTo(urlStr);
}
mSitePrevBtn->Enable(PR_TRUE);
} else {
@ -1126,7 +1126,7 @@ PRBool CreateSiteDialog(nsIWidget * aParent)
mSitePrevBtn->Enable(PR_FALSE);
if (gWinData) {
nsString urlStr(gTop100List[gTop100Pointer]);
gWinData->LoadURL(urlStr);
gWinData->GoTo(urlStr);
mSiteLabel->SetLabel(urlStr);
}

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

@ -590,7 +590,12 @@ nsWebCrawler::LoadNextURL()
mPendingURLs.RemoveElementAt(0);
if (OkToLoad(*url)) {
RecordLoadedURL(*url);
mBrowser->LoadURL(*url);
nsIWebShell* webShell;
mBrowser->GetWebShell(webShell);
webShell->LoadURL(*url);
NS_RELEASE(webShell);
if (mMaxPages > 0) {
--mMaxPages;
}