зеркало из https://github.com/mozilla/pjs.git
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.
This commit is contained in:
Родитель
8fb55eec52
Коммит
3d5fa0a660
|
@ -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);
|
||||
};
|
||||
|
||||
|
|
|
@ -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<nsIDOMWindow> domWindow;
|
||||
mXULWindow->GetWindowDOMWindow(getter_AddRefs(domWindow));
|
||||
if(!domWindow)
|
||||
nsCOMPtr<nsPIDOMWindow> piDOMWindow(do_QueryInterface(domWindow));
|
||||
if(!piDOMWindow)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsISupports> xpConnectObj;
|
||||
domWindow->GetXPConnectObject("XULBrowserWindow", getter_AddRefs(xpConnectObj));
|
||||
nsCOMPtr<nsIXULBrowserWindow> xulBrowserWindow(do_QueryInterface(xpConnectObj));
|
||||
nsAutoString xulBrowserWinId("XULBrowserWindow");
|
||||
piDOMWindow->GetXPConnectObject(xulBrowserWinId.GetUnicode(), getter_AddRefs(xpConnectObj));
|
||||
|
||||
nsCOMPtr<nsIXULBrowserWindow> 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<nsIDOMWindow> domWindow;
|
||||
mXULWindow->GetWindowDOMWindow(getter_AddRefs(domWindow));
|
||||
if(!domWindow)
|
||||
nsCOMPtr<nsPIDOMWindow> piDOMWindow(do_QueryInterface(domWindow));
|
||||
if(!piDOMWindow)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsISupports> xpConnectObj;
|
||||
domWindow->GetXPConnectObject("XULBrowserWindow", getter_AddRefs(xpConnectObj));
|
||||
nsAutoString xulBrowserWinId("XULBrowserWindow");
|
||||
piDOMWindow->GetXPConnectObject(xulBrowserWinId.GetUnicode(), getter_AddRefs(xpConnectObj));
|
||||
nsCOMPtr<nsIXULBrowserWindow> 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<nsIDOMWindow> domWindow;
|
||||
mXULWindow->GetWindowDOMWindow(getter_AddRefs(domWindow));
|
||||
if(!domWindow)
|
||||
nsCOMPtr<nsPIDOMWindow> piDOMWindow(do_QueryInterface(domWindow));
|
||||
if(!piDOMWindow)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsISupports> xpConnectObj;
|
||||
domWindow->GetXPConnectObject("XULBrowserWindow", getter_AddRefs(xpConnectObj));
|
||||
nsAutoString xulBrowserWinId("XULBrowserWindow");
|
||||
piDOMWindow->GetXPConnectObject(xulBrowserWinId.GetUnicode(), getter_AddRefs(xpConnectObj));
|
||||
nsCOMPtr<nsIXULBrowserWindow> xulBrowserWindow(do_QueryInterface(xpConnectObj));
|
||||
|
||||
if(xulBrowserWindow)
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
||||
|
|
|
@ -41,9 +41,11 @@ catch (ex) {
|
|||
|
||||
var appCore = null;
|
||||
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;
|
||||
UpdateStatusField();
|
||||
window.XULBrowserWindow.setDefaultStatus(msg);
|
||||
// Turn progress meter off.
|
||||
meter.setAttribute("mode","normal");
|
||||
}
|
||||
|
|
|
@ -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<nsPIDOMWindow> piDOMWindow(do_QueryInterface(mDOMWindow));
|
||||
if(!piDOMWindow)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsISupports> xpConnectObj;
|
||||
mDOMWindow->GetXPConnectObject("XULBrowserWindow", getter_AddRefs(xpConnectObj));
|
||||
nsAutoString xulBrowserWinId("XULBrowserWindow");
|
||||
piDOMWindow->GetXPConnectObject(xulBrowserWinId.GetUnicode(), getter_AddRefs(xpConnectObj));
|
||||
nsCOMPtr<nsIXULBrowserWindow> xulBrowserWindow(do_QueryInterface(xpConnectObj));
|
||||
|
||||
if(xulBrowserWindow)
|
||||
xulBrowserWindow->SetStatus(aMsg.GetUnicode());
|
||||
xulBrowserWindow->SetDefaultStatus(aMsg.GetUnicode());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче