bug 217611 - page info can be opened multiple times, patch by Jason Barnabe (jason_barnabe@fastmail.fm), r=me, a=asa

This commit is contained in:
mconnor%steelgryphon.com 2005-04-26 16:55:59 +00:00
Родитель bf13f43de8
Коммит ba5b3b4d3f
2 изменённых файлов: 29 добавлений и 4 удалений

Просмотреть файл

@ -31,6 +31,7 @@
# Joe Hewitt <hewitt@netscape.com> # Joe Hewitt <hewitt@netscape.com>
# Alec Flett <alecf@netscape.com> # Alec Flett <alecf@netscape.com>
# Asaf Romano <mozilla.mano@sent.com> # Asaf Romano <mozilla.mano@sent.com>
# Jason Barnabe <jason_barnabe@fastmail.fm>
# #
# Alternatively, the contents of this file may be used under the terms of # Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or # either the GNU General Public License Version 2 or later (the "GPL"), or
@ -1892,10 +1893,11 @@ function BrowserViewSourceOfURL(url, charset, pageCookie)
// doc=null for regular page info, doc=owner document for frame info. // doc=null for regular page info, doc=owner document for frame info.
function BrowserPageInfo(doc) function BrowserPageInfo(doc)
{ {
window.openDialog("chrome://browser/content/pageInfo.xul", toOpenDialogByTypeAndUrl("Browser:page-info",
"_blank", doc ? doc.location : window.content.document.location,
"chrome,dialog=no", "chrome://browser/content/pageInfo.xul",
doc); "chrome,dialog=no",
doc);
} }
#ifdef DEBUG #ifdef DEBUG
@ -2763,6 +2765,27 @@ function toOpenWindowByType(inType, uri, features)
window.open(uri, "_blank", "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar"); window.open(uri, "_blank", "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar");
} }
function toOpenDialogByTypeAndUrl(inType, relatedUrl, windowUri, features, extraArgument)
{
var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService();
var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator);
var windows = windowManagerInterface.getEnumerator(inType);
// Check for windows matching the url
while (windows.hasMoreElements()) {
var currentWindow = windows.getNext();
if (currentWindow.document.firstChild.getAttribute("relatedUrl") == relatedUrl) {
currentWindow.focus();
return;
}
}
// We didn't find a matching window, so open a new one.
if (features)
window.openDialog(windowUri, "_blank", features, extraArgument);
else
window.openDialog(windowUri, "_blank", "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar", extraArgument);
}
function OpenBrowserWindow() function OpenBrowserWindow()
{ {

Просмотреть файл

@ -290,6 +290,8 @@ function onLoadPageInfo()
} }
document.title = docTitle; document.title = docTitle;
document.getElementById("main-window").setAttribute("relatedUrl", theDocument.location.toString());
// do the easy stuff first // do the easy stuff first
makeGeneralTab(); makeGeneralTab();