From 249e773aae3176527654711e3423f3b21eafc763 Mon Sep 17 00:00:00 2001 From: "tbogard%aol.net" Date: Fri, 31 Mar 2000 03:36:26 +0000 Subject: [PATCH] Changed the nsIXULBrowserWindow to distinguish between JS status and it's own status. Fixed bugs where pages that set the window.status wouldn't actually end up showing up correctly. Now status has a priority scheme where different status versus links etc take priority. Use the new interfaces on nsPIDOMWindow to get to the properties hanging off the js window object instead of the old separate list. --- xpfe/appshell/public/nsIXULBrowserWindow.idl | 20 +++++- xpfe/appshell/src/nsContentTreeOwner.cpp | 25 +++++--- xpfe/browser/public/nsIXULBrowserWindow.idl | 20 +++++- xpfe/browser/resources/content/navigator.js | 66 ++++++++++++++------ xpfe/browser/src/nsBrowserInstance.cpp | 9 ++- 5 files changed, 105 insertions(+), 35 deletions(-) diff --git a/xpfe/appshell/public/nsIXULBrowserWindow.idl b/xpfe/appshell/public/nsIXULBrowserWindow.idl index 505ac06daff1..b627140ebe78 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 4127436770f1..1ecde4a1acc0 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 505ac06daff1..b627140ebe78 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 091f5e4673e2..b3d1320fd8a9 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 72a355c77bbb..2741c1527133 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; }