Webshellwindow implements the new nsIDocumentLoderObserver.

This commit is contained in:
radha%netscape.com 1999-04-06 21:01:51 +00:00
Родитель 711080a640
Коммит 66a9f51d6a
2 изменённых файлов: 96 добавлений и 12 удалений

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

@ -132,6 +132,7 @@ nsWebShellWindow::nsWebShellWindow()
mController = nsnull;
mCallbacks = nsnull;
mContinueModalLoop = PR_FALSE;
mChromeInitialized = PR_FALSE;
}
@ -252,12 +253,7 @@ nsresult nsWebShellWindow::Initialize(nsIWebShellWindow* aParent,
PR_TRUE);
mWebShell->SetContainer(this);
mWebShell->SetObserver((nsIStreamObserver*)anObserver);
nsIDocumentLoader * docLoader;
mWebShell->GetDocumentLoader(docLoader);
if (nsnull != docLoader) {
docLoader->AddObserver((nsIDocumentLoaderObserver *)this);
}
mWebShell->SetDocLoaderObserver(this);
/*
* XXX: How should preferences be supplied to the nsWebShellWindow?
@ -401,6 +397,8 @@ nsWebShellWindow::EndLoadURL(nsIWebShell* aWebShell, const PRUnichar* aURL,
return NS_OK;
}
//----------------------------------------
nsCOMPtr<nsIDOMNode> nsWebShellWindow::FindNamedParentFromDoc(nsIDOMDocument * aDomDoc, const nsString &aName)
{
@ -805,9 +803,7 @@ nsWebShellWindow::DestroyModalDialogEvent(PLEvent *aEvent)
}
//----------------------------------------
//----------------------------------------
//----------------------------------------
//----------------------------------------
// nsIDocumentLoaderObserver implementation
//----------------------------------------
@ -820,6 +816,88 @@ nsWebShellWindow::OnStartDocumentLoad(nsIURL* aURL, const char* aCommand)
NS_IMETHODIMP
nsWebShellWindow::OnEndDocumentLoad(nsIURL* aURL, PRInt32 aStatus)
{
#ifdef DEBUG_MENUSDEL
printf("OnEndDocumentLoad\n");
#endif
/* We get notified every time a page/Frame is loaded. But we need to
* Load the menus, run the startup script etc.. only once. So, Use
* the mChrome Initialized member to check whether chrome should be
* initialized or not - Radha
*/
if (mChromeInitialized)
return NS_OK;
mChromeInitialized = PR_TRUE;
// register as document listener
// this is needed for menus
nsCOMPtr<nsIContentViewer> cv;
mWebShell->GetContentViewer(getter_AddRefs(cv));
if (cv) {
nsCOMPtr<nsIDocumentViewer> docv(do_QueryInterface(cv));
if (!docv)
return NS_OK;
nsCOMPtr<nsIDocument> doc;
docv->GetDocument(*getter_AddRefs(doc));
if (!doc)
return NS_OK;
doc->AddObserver(NS_STATIC_CAST(nsIDocumentObserver*, this));
}
ExecuteStartupCode();
///////////////////////////////
// Find the Menubar DOM and Load the menus, hooking them up to the loaded commands
///////////////////////////////
nsCOMPtr<nsIDOMDocument> menubarDOMDoc(GetNamedDOMDoc(nsAutoString("this"))); // XXX "this" is a small kludge for code reused
if (menubarDOMDoc)
LoadMenus(menubarDOMDoc, mWindow);
SetSizeFromXUL();
SetTitleFromXUL();
#if 0
nsCOMPtr<nsIDOMDocument> toolbarDOMDoc(GetNamedDOMDoc(nsAutoString("browser.toolbar")));
nsCOMPtr<nsIDOMDocument> contentDOMDoc(GetNamedDOMDoc(nsAutoString("browser.webwindow")));
nsCOMPtr<nsIDocument> contentDoc(do_QueryInterface(contentDOMDoc));
nsCOMPtr<nsIDocument> statusDoc(do_QueryInterface(statusDOMDoc));
nsCOMPtr<nsIDocument> toolbarDoc(do_QueryInterface(toolbarDOMDoc));
nsIWebShell* statusWebShell = nsnull;
mWebShell->FindChildWithName(nsAutoString("browser.status"), statusWebShell);
PRInt32 actualStatusHeight = GetDocHeight(statusDoc);
PRInt32 actualToolbarHeight = GetDocHeight(toolbarDoc);
PRInt32 height = 0;
PRInt32 x,y,w,h;
PRInt32 contentHeight;
PRInt32 toolbarHeight;
PRInt32 statusHeight;
mWebShell->GetBounds(x, y, w, h);
toolbarWebShell->GetBounds(x, y, w, toolbarHeight);
contentWebShell->GetBounds(x, y, w, contentHeight);
statusWebShell->GetBounds(x, y, w, statusHeight);
//h = toolbarHeight + contentHeight + statusHeight;
contentHeight = h - actualStatusHeight - actualToolbarHeight;
toolbarWebShell->GetBounds(x, y, w, h);
toolbarWebShell->SetBounds(x, y, w, actualToolbarHeight);
contentWebShell->GetBounds(x, y, w, h);
contentWebShell->SetBounds(x, y, w, contentHeight);
statusWebShell->GetBounds(x, y, w, h);
statusWebShell->SetBounds(x, y, w, actualStatusHeight);
#endif
return NS_OK;
}
@ -957,6 +1035,7 @@ PRInt32 nsWebShellWindow::GetDocHeight(nsIDocument * aDoc)
}
//----------------------------------------
#if 0
NS_IMETHODIMP nsWebShellWindow::OnConnectionsComplete()
{
#ifdef DEBUG_MENUSDEL
@ -1033,6 +1112,8 @@ NS_IMETHODIMP nsWebShellWindow::OnConnectionsComplete()
return NS_OK;
} // nsWebShellWindow::OnConnectionsComplete
#endif /* 0 */
/**

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

@ -62,6 +62,7 @@ public:
// nsISupports interface...
NS_DECL_ISUPPORTS
// nsIWebShellContainer interface...
NS_IMETHOD WillLoadURL(nsIWebShell* aShell,
const PRUnichar* aURL,
@ -79,6 +80,7 @@ public:
const PRUnichar* aURL,
PRInt32 aStatus);
NS_IMETHOD NewWebShell(PRUint32 aChromeMask,
PRBool aVisible,
nsIWebShell *&aNewWebShell);
@ -106,13 +108,13 @@ public:
// nsIDocumentLoaderObserver
NS_IMETHOD OnStartDocumentLoad(nsIURL* aURL, const char* aCommand);
NS_IMETHOD OnEndDocumentLoad(nsIURL *aUrl, PRInt32 aStatus);
NS_IMETHOD OnStartURLLoad(nsIURL* aURL, const char* aContentType, nsIContentViewer* aViewer);
NS_IMETHOD OnStartURLLoad(nsIURL* aURL, const char* aContentType,
nsIContentViewer* aViewer);
NS_IMETHOD OnProgressURLLoad(nsIURL* aURL, PRUint32 aProgress,
PRUint32 aProgressMax);
NS_IMETHOD OnStatusURLLoad(nsIURL* aURL, nsString& aMsg);
NS_IMETHOD OnEndURLLoad(nsIURL* aURL, PRInt32 aStatus);
NS_IMETHOD OnConnectionsComplete();
// nsIDocumentObserver
NS_IMETHOD BeginUpdate(nsIDocument *aDocument);
@ -196,6 +198,7 @@ protected:
nsIWidgetController* mController;
nsIXULWindowCallbacks* mCallbacks;
PRBool mContinueModalLoop;
PRBool mChromeInitialized;
nsVoidArray mMenuDelegates;