зеркало из https://github.com/mozilla/gecko-dev.git
Bug 227053 history sidebar issues: gHistoryStatus has no properties; correctly extract the hostname from a url; don't leak observers r=timeless sr=alecf
This commit is contained in:
Родитель
fc11e70a19
Коммит
c17702b3da
|
@ -30,7 +30,9 @@
|
||||||
|
|
||||||
<page id="history-panel" orient="vertical"
|
<page id="history-panel" orient="vertical"
|
||||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||||
onload="HistoryCommonInit();" elementtofocus="historyTree">
|
onload="HistoryCommonInit();"
|
||||||
|
onunload="HistoryPanelUnload();"
|
||||||
|
elementtofocus="historyTree">
|
||||||
<stringbundle id="historyBundle"
|
<stringbundle id="historyBundle"
|
||||||
src="chrome://communicator/locale/history/history.properties"/>
|
src="chrome://communicator/locale/history/history.properties"/>
|
||||||
<commandset id="selectEditMenuItems">
|
<commandset id="selectEditMenuItems">
|
||||||
|
|
|
@ -42,6 +42,7 @@ var gLastHostname;
|
||||||
var gLastDomain;
|
var gLastDomain;
|
||||||
var gGlobalHistory;
|
var gGlobalHistory;
|
||||||
var gPrefService;
|
var gPrefService;
|
||||||
|
var gIOService;
|
||||||
var gDeleteByHostname;
|
var gDeleteByHostname;
|
||||||
var gDeleteByDomain;
|
var gDeleteByDomain;
|
||||||
var gHistoryBundle;
|
var gHistoryBundle;
|
||||||
|
@ -49,12 +50,6 @@ var gHistoryStatus;
|
||||||
var gHistoryGrouping = "";
|
var gHistoryGrouping = "";
|
||||||
var gWindowManager = null;
|
var gWindowManager = null;
|
||||||
|
|
||||||
function HistoryWindowInit()
|
|
||||||
{
|
|
||||||
HistoryCommonInit();
|
|
||||||
gHistoryTree.focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
function HistoryCommonInit()
|
function HistoryCommonInit()
|
||||||
{
|
{
|
||||||
gHistoryTree = document.getElementById("historyTree");
|
gHistoryTree = document.getElementById("historyTree");
|
||||||
|
@ -113,9 +108,19 @@ function HistoryCommonInit()
|
||||||
}
|
}
|
||||||
|
|
||||||
SortInNewDirection(find_sort_direction(find_sort_column()));
|
SortInNewDirection(find_sort_direction(find_sort_column()));
|
||||||
|
|
||||||
|
if (gHistoryStatus)
|
||||||
|
gHistoryTree.focus();
|
||||||
gHistoryTree.treeBoxObject.view.selection.select(0);
|
gHistoryTree.treeBoxObject.view.selection.select(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function HistoryPanelUnload()
|
||||||
|
{
|
||||||
|
var pb = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
|
||||||
|
var pbi = pb.QueryInterface(Components.interfaces.nsIPrefBranchInternal);
|
||||||
|
pbi.removeObserver("browser.history.grouping", groupObserver, false);
|
||||||
|
}
|
||||||
|
|
||||||
function updateHistoryCommands()
|
function updateHistoryCommands()
|
||||||
{
|
{
|
||||||
goUpdateCommand("cmd_deleteByHostname");
|
goUpdateCommand("cmd_deleteByHostname");
|
||||||
|
@ -149,27 +154,24 @@ function historyOnSelect()
|
||||||
var match;
|
var match;
|
||||||
var currentIndex = gHistoryTree.currentIndex;
|
var currentIndex = gHistoryTree.currentIndex;
|
||||||
var rowIsContainer = gHistoryGrouping != "none" && currentIndex >= 0 && isContainer(gHistoryTree, currentIndex);
|
var rowIsContainer = gHistoryGrouping != "none" && currentIndex >= 0 && isContainer(gHistoryTree, currentIndex);
|
||||||
var url = rowIsContainer ? gHistoryTree.treeBoxObject.view.getCellText(currentIndex, "URL") : null;
|
var url = rowIsContainer ? "" : gHistoryTree.treeBoxObject.view.getCellText(currentIndex, "URL");
|
||||||
|
|
||||||
if (url) {
|
if (url) {
|
||||||
// matches scheme://(hostname)...
|
if (!gIOService)
|
||||||
match = url.match(/^.*?:\/\/(?:([^\/:]*)(?::([^\/:]*))?@)?([^\/:]*)(?::([^\/:]*))?(.*)$/);
|
gIOService = Components.classes['@mozilla.org/network/io-service;1']
|
||||||
|
.getService(Components.interfaces.nsIIOService);
|
||||||
|
try {
|
||||||
|
gLastHostname = gIOService.newURI(url, null, null).host;
|
||||||
|
// matches the last foo.bar in foo.bar or baz.foo.bar
|
||||||
|
match = gLastHostname.match(/([^.]+\.[^.]+$)/);
|
||||||
|
if (match)
|
||||||
|
gLastDomain = match[1];
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
|
||||||
if (match && match.length>1)
|
if (gHistoryStatus)
|
||||||
gLastHostname = match[3];
|
|
||||||
|
|
||||||
gHistoryStatus.label = url;
|
gHistoryStatus.label = url;
|
||||||
}
|
|
||||||
else {
|
|
||||||
gHistoryStatus.label = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gLastHostname) {
|
|
||||||
// matches the last foo.bar in foo.bar or baz.foo.bar
|
|
||||||
match = gLastHostname.match(/([^.]+\.[^.]+$)/);
|
|
||||||
if (match)
|
|
||||||
gLastDomain = match[1];
|
|
||||||
}
|
|
||||||
document.commandDispatcher.updateCommands("select");
|
document.commandDispatcher.updateCommands("select");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
<!DOCTYPE window SYSTEM "chrome://communicator/locale/history/history.dtd" >
|
<!DOCTYPE window SYSTEM "chrome://communicator/locale/history/history.dtd" >
|
||||||
|
|
||||||
<window title="&historyWindowTitle.label;" id="history-window"
|
<window title="&historyWindowTitle.label;" id="history-window"
|
||||||
onload="HistoryWindowInit();"
|
onload="HistoryCommonInit();"
|
||||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||||
width="500" height="400"
|
width="500" height="400"
|
||||||
persist="width height screenX screenY sizemode"
|
persist="width height screenX screenY sizemode"
|
||||||
|
|
Загрузка…
Ссылка в новой задаче