diff --git a/xpfe/appshell/public/nsIXULBrowserWindow.idl b/xpfe/appshell/public/nsIXULBrowserWindow.idl index 505ac06daff..b627140ebe7 100644 --- a/xpfe/appshell/public/nsIXULBrowserWindow.idl +++ b/xpfe/appshell/public/nsIXULBrowserWindow.idl @@ -31,8 +31,24 @@ [scriptable, uuid(46B4015C-0121-11d4-9877-00C04FA0D27A)] interface nsIXULBrowserWindow : nsISupports { - void setStatus(in wstring status); - void setDefaultStatus(in wstring status); + /* + Sets the status according to JS' version of status. + */ + void setJSStatus(in wstring status); + + /* + Sets the default status according to JS' version of default status. + */ + void setJSDefaultStatus(in wstring status); + + /* + Tells the object implementing this function what link we are currently over. + */ void setOverLink(in wstring link); + + /* + Tells the browser window what to use for the default status text. + */ + void setDefaultStatus(in wstring status); }; diff --git a/xpfe/appshell/src/nsContentTreeOwner.cpp b/xpfe/appshell/src/nsContentTreeOwner.cpp index 4127436770f..1ecde4a1acc 100644 --- a/xpfe/appshell/src/nsContentTreeOwner.cpp +++ b/xpfe/appshell/src/nsContentTreeOwner.cpp @@ -36,6 +36,7 @@ #include "nsIPrompt.h" #include "nsIWindowMediator.h" #include "nsIXULBrowserWindow.h" +#include "nsPIDOMWindow.h" // CIDs static NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID); @@ -196,15 +197,17 @@ NS_IMETHODIMP nsContentTreeOwner::SetJSStatus(const PRUnichar* aStatus) { nsCOMPtr domWindow; mXULWindow->GetWindowDOMWindow(getter_AddRefs(domWindow)); - if(!domWindow) + nsCOMPtr piDOMWindow(do_QueryInterface(domWindow)); + if(!piDOMWindow) return NS_OK; nsCOMPtr xpConnectObj; - domWindow->GetXPConnectObject("XULBrowserWindow", getter_AddRefs(xpConnectObj)); - nsCOMPtr xulBrowserWindow(do_QueryInterface(xpConnectObj)); + nsAutoString xulBrowserWinId("XULBrowserWindow"); + piDOMWindow->GetXPConnectObject(xulBrowserWinId.GetUnicode(), getter_AddRefs(xpConnectObj)); + nsCOMPtr xulBrowserWindow(do_QueryInterface(xpConnectObj)); if(xulBrowserWindow) - xulBrowserWindow->SetStatus(aStatus); + xulBrowserWindow->SetJSStatus(aStatus); return NS_OK; } @@ -212,15 +215,17 @@ NS_IMETHODIMP nsContentTreeOwner::SetJSDefaultStatus(const PRUnichar* aStatus) { nsCOMPtr domWindow; mXULWindow->GetWindowDOMWindow(getter_AddRefs(domWindow)); - if(!domWindow) + nsCOMPtr piDOMWindow(do_QueryInterface(domWindow)); + if(!piDOMWindow) return NS_OK; nsCOMPtr xpConnectObj; - domWindow->GetXPConnectObject("XULBrowserWindow", getter_AddRefs(xpConnectObj)); + nsAutoString xulBrowserWinId("XULBrowserWindow"); + piDOMWindow->GetXPConnectObject(xulBrowserWinId.GetUnicode(), getter_AddRefs(xpConnectObj)); nsCOMPtr xulBrowserWindow(do_QueryInterface(xpConnectObj)); if(xulBrowserWindow) - xulBrowserWindow->SetDefaultStatus(aStatus); + xulBrowserWindow->SetJSDefaultStatus(aStatus); return NS_OK; } @@ -228,11 +233,13 @@ NS_IMETHODIMP nsContentTreeOwner::SetOverLink(const PRUnichar* aLink) { nsCOMPtr domWindow; mXULWindow->GetWindowDOMWindow(getter_AddRefs(domWindow)); - if(!domWindow) + nsCOMPtr piDOMWindow(do_QueryInterface(domWindow)); + if(!piDOMWindow) return NS_OK; nsCOMPtr xpConnectObj; - domWindow->GetXPConnectObject("XULBrowserWindow", getter_AddRefs(xpConnectObj)); + nsAutoString xulBrowserWinId("XULBrowserWindow"); + piDOMWindow->GetXPConnectObject(xulBrowserWinId.GetUnicode(), getter_AddRefs(xpConnectObj)); nsCOMPtr xulBrowserWindow(do_QueryInterface(xpConnectObj)); if(xulBrowserWindow) diff --git a/xpfe/browser/public/nsIXULBrowserWindow.idl b/xpfe/browser/public/nsIXULBrowserWindow.idl index 505ac06daff..b627140ebe7 100644 --- a/xpfe/browser/public/nsIXULBrowserWindow.idl +++ b/xpfe/browser/public/nsIXULBrowserWindow.idl @@ -31,8 +31,24 @@ [scriptable, uuid(46B4015C-0121-11d4-9877-00C04FA0D27A)] interface nsIXULBrowserWindow : nsISupports { - void setStatus(in wstring status); - void setDefaultStatus(in wstring status); + /* + Sets the status according to JS' version of status. + */ + void setJSStatus(in wstring status); + + /* + Sets the default status according to JS' version of default status. + */ + void setJSDefaultStatus(in wstring status); + + /* + Tells the object implementing this function what link we are currently over. + */ void setOverLink(in wstring link); + + /* + Tells the browser window what to use for the default status text. + */ + void setDefaultStatus(in wstring status); }; diff --git a/xpfe/browser/resources/content/navigator.js b/xpfe/browser/resources/content/navigator.js index 091f5e4673e..b3d1320fd8a 100644 --- a/xpfe/browser/resources/content/navigator.js +++ b/xpfe/browser/resources/content/navigator.js @@ -40,10 +40,12 @@ catch (ex) { } var appCore = null; - var defaultStatus = bundle.GetStringFromName( "defaultStatus" ); + var defaultStatus = bundle.GetStringFromName( "defaultStatus" ); + var jsStatus = null; + var jsDefaultStatus = null; + var overLink = null; var explicitURL = false; var statusTextFld = null; - var xulBrowserWin = null; function UpdateHistory(event) @@ -149,6 +151,23 @@ function createBrowserInstance() } } +function UpdateStatusField() +{ + var text = defaultStatus; + + if(jsStatus) + text = jsStatus; + else if(overLink) + text = overLink; + else if(jsDefaultStatus) + text = jsDefaultStatus; + + if(!statusTextFld) + statusTextFld = document.getElementById("statusText"); + + statusTextFld.setAttribute("value", text); +} + function nsXULBrowserWindow() { } @@ -161,35 +180,43 @@ nsXULBrowserWindow.prototype = return this; throw Components.results.NS_NOINTERFACE; }, - setStatus : function(status) + setJSStatus : function(status) { if(status == "") - status = defaultStatus; - if(!statusTextFld) - statusTextFld = document.getElementById("statusText"); - - statusTextFld.setAttribute("value", status); + jsStatus = null; + else + jsStatus = status; + UpdateStatusField(); + }, + setJSDefaultStatus : function(status) + { + if(status == "") + jsDefaultStatus = null; + else + jsDefaultStatus = status; + UpdateStatusField(); }, setDefaultStatus : function(status) { - //XXX Should do something here. + if(status == "") + defaultStatus = null; + else + defaultStatus = status; + UpdateStatusField(); }, setOverLink : function(link) { if(link == "") - link = defaultStatus; - - if(!statusTextFld) - statusTextFld = document.getElementById("statusText"); - - statusTextFld.setAttribute("value", link); + overLink = null; + else + overLink = link; + UpdateStatusField(); } } function Startup() { - xulBrowserWin = new nsXULBrowserWindow(); - window.addXPConnectObject("XULBrowserWindow", xulBrowserWin); + window.XULBrowserWindow = new nsXULBrowserWindow(); // TileWindow(); // Make sure window fits on screen initially //FitToScreen(); @@ -1012,8 +1039,9 @@ function BrowserEditBookmarks() var elapsed = ( (new Date()).getTime() - startTime ) / 1000; var msg = bundle.GetStringFromName("nv_done") + " (" + elapsed + " secs)"; dump( msg + "\n" ); - xulBrowserWin.setStatus(msg); - defaultStatus = msg; + defaultStatus = msg; + UpdateStatusField(); + window.XULBrowserWindow.setDefaultStatus(msg); // Turn progress meter off. meter.setAttribute("mode","normal"); } diff --git a/xpfe/browser/src/nsBrowserInstance.cpp b/xpfe/browser/src/nsBrowserInstance.cpp index 72a355c77bb..2741c152713 100644 --- a/xpfe/browser/src/nsBrowserInstance.cpp +++ b/xpfe/browser/src/nsBrowserInstance.cpp @@ -33,6 +33,7 @@ #include "nsIDocShellTreeItem.h" #include "nsIWebNavigation.h" #include "nsIXULBrowserWindow.h" +#include "nsPIDOMWindow.h" // Use this trick temporarily, to minimize delta to nsBrowserAppCore.cpp. #define nsBrowserAppCore nsBrowserInstance @@ -1632,15 +1633,17 @@ NS_IMETHODIMP nsBrowserAppCore::OnStatusURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, nsString& aMsg) { - if(!mDOMWindow) + nsCOMPtr piDOMWindow(do_QueryInterface(mDOMWindow)); + if(!piDOMWindow) return NS_OK; nsCOMPtr xpConnectObj; - mDOMWindow->GetXPConnectObject("XULBrowserWindow", getter_AddRefs(xpConnectObj)); + nsAutoString xulBrowserWinId("XULBrowserWindow"); + piDOMWindow->GetXPConnectObject(xulBrowserWinId.GetUnicode(), getter_AddRefs(xpConnectObj)); nsCOMPtr xulBrowserWindow(do_QueryInterface(xpConnectObj)); if(xulBrowserWindow) - xulBrowserWindow->SetStatus(aMsg.GetUnicode()); + xulBrowserWindow->SetDefaultStatus(aMsg.GetUnicode()); return NS_OK; }