Bug 242046 Make the JS status handler a property of the XUL window, should speed up calls to set window.status r=jag sr=jst moa=mscott

This commit is contained in:
neil%parkwaycc.co.uk 2004-08-21 14:47:51 +00:00
parent 347734a288
commit 658c2f1a92
8 changed files with 58 additions and 13 deletions

View File

@ -358,6 +358,12 @@ function prepareForStartup()
// initialize observers and listeners
window.XULBrowserWindow = new nsBrowserStatusHandler();
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIDocShellTreeItem).treeOwner
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIXULWindow)
.XULBrowserWindow = window.XULBrowserWindow;
window.browserContentListener =
new nsBrowserContentListener(window, gBrowser);
@ -621,6 +627,12 @@ function Shutdown()
window.XULBrowserWindow.destroy();
window.XULBrowserWindow = null;
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIDocShellTreeItem).treeOwner
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIXULWindow)
.XULBrowserWindow = null;
window.browserContentListener.close();
// Close the app core.

View File

@ -129,7 +129,12 @@ function CreateMailWindowGlobals()
// set the JS implementation of status feedback before creating the c++ one..
window.MsgStatusFeedback = new nsMsgStatusFeedback();
// double register the status feedback object as the xul browser window implementation
window.XULBrowserWindow = window.MsgStatusFeedback;
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIDocShellTreeItem).treeOwner
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIXULWindow)
.XULBrowserWindow = window.MsgStatusFeedback;
statusFeedback = Components.classes[statusFeedbackContractID].createInstance();
statusFeedback = statusFeedback.QueryInterface(Components.interfaces.nsIMsgStatusFeedback);

View File

@ -148,7 +148,12 @@ function CreateMailWindowGlobals()
// set the JS implementation of status feedback before creating the c++ one..
window.MsgStatusFeedback = new nsMsgStatusFeedback();
// double register the status feedback object as the xul browser window implementation
window.XULBrowserWindow = window.MsgStatusFeedback;
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIDocShellTreeItem).treeOwner
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIXULWindow)
.XULBrowserWindow = window.MsgStatusFeedback;
statusFeedback = Components.classes[statusFeedbackContractID].createInstance();
statusFeedback = statusFeedback.QueryInterface(Components.interfaces.nsIMsgStatusFeedback);

View File

@ -45,8 +45,9 @@
interface nsIDocShell;
interface nsIDocShellTreeItem;
interface nsIXULBrowserWindow;
[scriptable, uuid(D9CB00E0-CA39-11d3-B029-00A024FFC08C)]
[scriptable, uuid(5d72a699-a252-4161-a45f-e7d35e78b7f3)]
interface nsIXULWindow : nsISupports
{
/**
@ -124,5 +125,7 @@ interface nsIXULWindow : nsISupports
@return the newly minted window
*/
nsIXULWindow createNewWindow(in PRInt32 aChromeFlags);
attribute nsIXULBrowserWindow XULBrowserWindow;
};

View File

@ -57,7 +57,6 @@
#include "nsIAuthPrompt.h"
#include "nsIWindowMediator.h"
#include "nsIXULBrowserWindow.h"
#include "nsPIDOMWindow.h"
// Needed for nsIDocument::FlushPendingNotifications(...)
#include "nsIDOMDocument.h"
@ -355,15 +354,8 @@ nsContentTreeOwner::GetPersistence(PRBool* aPersistPosition,
NS_IMETHODIMP nsContentTreeOwner::SetStatus(PRUint32 aStatusType, const PRUnichar* aStatus)
{
nsCOMPtr<nsIDOMWindowInternal> domWindow;
mXULWindow->GetWindowDOMWindow(getter_AddRefs(domWindow));
nsCOMPtr<nsPIDOMWindow> piDOMWindow(do_QueryInterface(domWindow));
if(!piDOMWindow)
return NS_OK;
nsCOMPtr<nsISupports> xpConnectObj;
piDOMWindow->GetObjectProperty(NS_LITERAL_STRING("XULBrowserWindow").get(), getter_AddRefs(xpConnectObj));
nsCOMPtr<nsIXULBrowserWindow> xulBrowserWindow(do_QueryInterface(xpConnectObj));
nsCOMPtr<nsIXULBrowserWindow> xulBrowserWindow;
mXULWindow->GetXULBrowserWindow(getter_AddRefs(xulBrowserWindow));
if (xulBrowserWindow)
{
@ -389,9 +381,11 @@ NS_IMETHODIMP nsContentTreeOwner::SetStatus(PRUint32 aStatusType, const PRUnicha
// force the flushing...
//
// XXXbz no, this is nasty because we're flushing at all!
nsCOMPtr<nsIDOMWindowInternal> domWindow;
nsCOMPtr<nsIDOMDocument> domDoc;
nsCOMPtr<nsIDocument> doc;
mXULWindow->GetWindowDOMWindow(getter_AddRefs(domWindow));
domWindow->GetDocument(getter_AddRefs(domDoc));
doc = do_QueryInterface(domDoc);

View File

@ -2063,6 +2063,18 @@ void nsXULWindow::PersistentAttributesDirty(PRUint32 aDirtyFlags) {
mPersistentAttributesDirty |= aDirtyFlags & mPersistentAttributesMask;
}
NS_IMETHODIMP nsXULWindow::GetXULBrowserWindow(nsIXULBrowserWindow * *aXULBrowserWindow)
{
NS_IF_ADDREF(*aXULBrowserWindow = mXULBrowserWindow);
return NS_OK;
}
NS_IMETHODIMP nsXULWindow::SetXULBrowserWindow(nsIXULBrowserWindow * aXULBrowserWindow)
{
mXULBrowserWindow = aXULBrowserWindow;
return NS_OK;
}
//*****************************************************************************
// nsXULWindow: Accessors
//*****************************************************************************

View File

@ -63,6 +63,7 @@
#include "nsIPrompt.h"
#include "nsIAuthPrompt.h"
#include "nsGUIEvent.h"
#include "nsIXULBrowserWindow.h"
// nsXULWindow
@ -140,6 +141,7 @@ protected:
nsCOMPtr<nsIWeakReference> mParentWindow;
nsCOMPtr<nsIPrompt> mPrompter;
nsCOMPtr<nsIAuthPrompt> mAuthPrompter;
nsCOMPtr<nsIXULBrowserWindow> mXULBrowserWindow;
nsVoidArray mContentShells;
nsresult mModalStatus;
PRPackedBool mContinueModalLoop;

View File

@ -474,6 +474,12 @@ function Startup()
// initialize observers and listeners
window.XULBrowserWindow = new nsBrowserStatusHandler();
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIDocShellTreeItem).treeOwner
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIXULWindow)
.XULBrowserWindow = window.XULBrowserWindow;
addPrefListener(gButtonPrefListener);
addPrefListener(gTabStripPrefListener);
@ -737,6 +743,12 @@ function Shutdown()
window.XULBrowserWindow.destroy();
window.XULBrowserWindow = null;
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIDocShellTreeItem).treeOwner
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIXULWindow)
.XULBrowserWindow = null;
BrowserFlushBookmarksAndHistory();