зеркало из https://github.com/mozilla/gecko-dev.git
Webshellwindow implements the new nsIDocumentLoderObserver.
This commit is contained in:
Родитель
711080a640
Коммит
66a9f51d6a
|
@ -132,6 +132,7 @@ nsWebShellWindow::nsWebShellWindow()
|
||||||
mController = nsnull;
|
mController = nsnull;
|
||||||
mCallbacks = nsnull;
|
mCallbacks = nsnull;
|
||||||
mContinueModalLoop = PR_FALSE;
|
mContinueModalLoop = PR_FALSE;
|
||||||
|
mChromeInitialized = PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -252,12 +253,7 @@ nsresult nsWebShellWindow::Initialize(nsIWebShellWindow* aParent,
|
||||||
PR_TRUE);
|
PR_TRUE);
|
||||||
mWebShell->SetContainer(this);
|
mWebShell->SetContainer(this);
|
||||||
mWebShell->SetObserver((nsIStreamObserver*)anObserver);
|
mWebShell->SetObserver((nsIStreamObserver*)anObserver);
|
||||||
|
mWebShell->SetDocLoaderObserver(this);
|
||||||
nsIDocumentLoader * docLoader;
|
|
||||||
mWebShell->GetDocumentLoader(docLoader);
|
|
||||||
if (nsnull != docLoader) {
|
|
||||||
docLoader->AddObserver((nsIDocumentLoaderObserver *)this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXX: How should preferences be supplied to the nsWebShellWindow?
|
* XXX: How should preferences be supplied to the nsWebShellWindow?
|
||||||
|
@ -401,6 +397,8 @@ nsWebShellWindow::EndLoadURL(nsIWebShell* aWebShell, const PRUnichar* aURL,
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------
|
//----------------------------------------
|
||||||
nsCOMPtr<nsIDOMNode> nsWebShellWindow::FindNamedParentFromDoc(nsIDOMDocument * aDomDoc, const nsString &aName)
|
nsCOMPtr<nsIDOMNode> nsWebShellWindow::FindNamedParentFromDoc(nsIDOMDocument * aDomDoc, const nsString &aName)
|
||||||
{
|
{
|
||||||
|
@ -805,9 +803,7 @@ nsWebShellWindow::DestroyModalDialogEvent(PLEvent *aEvent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------
|
|
||||||
//----------------------------------------
|
|
||||||
//----------------------------------------
|
|
||||||
//----------------------------------------
|
//----------------------------------------
|
||||||
// nsIDocumentLoaderObserver implementation
|
// nsIDocumentLoaderObserver implementation
|
||||||
//----------------------------------------
|
//----------------------------------------
|
||||||
|
@ -820,6 +816,88 @@ nsWebShellWindow::OnStartDocumentLoad(nsIURL* aURL, const char* aCommand)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsWebShellWindow::OnEndDocumentLoad(nsIURL* aURL, PRInt32 aStatus)
|
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;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -957,6 +1035,7 @@ PRInt32 nsWebShellWindow::GetDocHeight(nsIDocument * aDoc)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------
|
//----------------------------------------
|
||||||
|
#if 0
|
||||||
NS_IMETHODIMP nsWebShellWindow::OnConnectionsComplete()
|
NS_IMETHODIMP nsWebShellWindow::OnConnectionsComplete()
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_MENUSDEL
|
#ifdef DEBUG_MENUSDEL
|
||||||
|
@ -1033,6 +1112,8 @@ NS_IMETHODIMP nsWebShellWindow::OnConnectionsComplete()
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
} // nsWebShellWindow::OnConnectionsComplete
|
} // nsWebShellWindow::OnConnectionsComplete
|
||||||
|
#endif /* 0 */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -62,6 +62,7 @@ public:
|
||||||
// nsISupports interface...
|
// nsISupports interface...
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
|
|
||||||
|
|
||||||
// nsIWebShellContainer interface...
|
// nsIWebShellContainer interface...
|
||||||
NS_IMETHOD WillLoadURL(nsIWebShell* aShell,
|
NS_IMETHOD WillLoadURL(nsIWebShell* aShell,
|
||||||
const PRUnichar* aURL,
|
const PRUnichar* aURL,
|
||||||
|
@ -79,6 +80,7 @@ public:
|
||||||
const PRUnichar* aURL,
|
const PRUnichar* aURL,
|
||||||
PRInt32 aStatus);
|
PRInt32 aStatus);
|
||||||
|
|
||||||
|
|
||||||
NS_IMETHOD NewWebShell(PRUint32 aChromeMask,
|
NS_IMETHOD NewWebShell(PRUint32 aChromeMask,
|
||||||
PRBool aVisible,
|
PRBool aVisible,
|
||||||
nsIWebShell *&aNewWebShell);
|
nsIWebShell *&aNewWebShell);
|
||||||
|
@ -106,14 +108,14 @@ public:
|
||||||
// nsIDocumentLoaderObserver
|
// nsIDocumentLoaderObserver
|
||||||
NS_IMETHOD OnStartDocumentLoad(nsIURL* aURL, const char* aCommand);
|
NS_IMETHOD OnStartDocumentLoad(nsIURL* aURL, const char* aCommand);
|
||||||
NS_IMETHOD OnEndDocumentLoad(nsIURL *aUrl, PRInt32 aStatus);
|
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,
|
NS_IMETHOD OnProgressURLLoad(nsIURL* aURL, PRUint32 aProgress,
|
||||||
PRUint32 aProgressMax);
|
PRUint32 aProgressMax);
|
||||||
NS_IMETHOD OnStatusURLLoad(nsIURL* aURL, nsString& aMsg);
|
NS_IMETHOD OnStatusURLLoad(nsIURL* aURL, nsString& aMsg);
|
||||||
NS_IMETHOD OnEndURLLoad(nsIURL* aURL, PRInt32 aStatus);
|
NS_IMETHOD OnEndURLLoad(nsIURL* aURL, PRInt32 aStatus);
|
||||||
|
|
||||||
NS_IMETHOD OnConnectionsComplete();
|
|
||||||
|
|
||||||
// nsIDocumentObserver
|
// nsIDocumentObserver
|
||||||
NS_IMETHOD BeginUpdate(nsIDocument *aDocument);
|
NS_IMETHOD BeginUpdate(nsIDocument *aDocument);
|
||||||
NS_IMETHOD EndUpdate(nsIDocument *aDocument);
|
NS_IMETHOD EndUpdate(nsIDocument *aDocument);
|
||||||
|
@ -196,6 +198,7 @@ protected:
|
||||||
nsIWidgetController* mController;
|
nsIWidgetController* mController;
|
||||||
nsIXULWindowCallbacks* mCallbacks;
|
nsIXULWindowCallbacks* mCallbacks;
|
||||||
PRBool mContinueModalLoop;
|
PRBool mContinueModalLoop;
|
||||||
|
PRBool mChromeInitialized;
|
||||||
|
|
||||||
nsVoidArray mMenuDelegates;
|
nsVoidArray mMenuDelegates;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче