Backing out bug 305667 and reopening it. Item selection disappearing in <richlistbox> when no file naming dialog is used before download manager appears for a save. Patch by Doron Rosenber. r=mconnor, a=asa

This commit is contained in:
aaronleventhal%moonset.net 2005-08-27 13:12:04 +00:00
Родитель 42b0a50c9d
Коммит 61ae9e722d
3 изменённых файлов: 16 добавлений и 101 удалений

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

@ -60,9 +60,6 @@
<![CDATA[
var x = document.getAnonymousElementByAttribute(this, "anonid", "main-box");
this.scrollBoxObject = x.boxObject.QueryInterface(Components.interfaces.nsIScrollBoxObject);
// add a template build listener
this.builder.addListener(this._builder());
]]>
</constructor>
@ -88,54 +85,6 @@
</getter>
</property>
<method name="_builder">
<body>
<![CDATA[
var myThis = this;
return {
item: null,
willRebuild : function(builder) {},
didRebuild : function(builder) {
myThis._refreshSelection()
}
}
]]>
</body>
</method>
<method name="_refreshSelection">
<body>
<![CDATA[
// cache the selected index
var selectedIndex = this._selectedIndex;
// refreshes selection. Called for example when a template rebuild
// happens.
if (this.selectedItem && this.selectedItem.hasAttribute("id")) {
var id = this.selectedItem.getAttribute("id");
var item = document.getElementById(id);
// if we find no item, clear selection so that the code at the bottom
// takes over
if (item)
this.selectedItem = item;
else
this.clearSelection();
}
// if no id or the id no longer exists (above code fails)
if (!this.selectedItem) {
// if the selectedIndex is larger than the row count, select the last
// item.
if (selectedIndex >= this.getRowCount())
this.selectedIndex = this.getRowCount() - 1;
else
this.selectedIndex = selectedIndex;
}
]]>
</body>
</method>
<method name="fireActiveItemEvent">
<body>
<![CDATA[
@ -149,7 +98,6 @@
</body>
</method>
<field name="_selectedIndex">-1</field>
<property name="selectedIndex">
<getter>
<![CDATA[
@ -179,10 +127,8 @@
} else if (val >= 0) {
// only set if we get an item returned
var item = this.getItemAtIndex(val);
if (item) {
if (item)
this.selectedItem = item
this._selectedIndex = val;
}
}
]]>
</setter>
@ -206,7 +152,6 @@
this.fireActiveItemEvent();
}
this._selectedIndex = this.getIndexOf(val);
this._fireOnSelect();
]]>
</setter>
@ -216,7 +161,6 @@
<body>
<![CDATA[
this.selectedItem = null;
this._selectedIndex = -1;
]]>
</body>
</method>
@ -270,26 +214,6 @@
</body>
</method>
<method name="getIndexOf">
<parameter name="aElement"/>
<body>
<![CDATA[
var run = 0;
var index = -1;
var children = this.children;
while (children[run] != aElement && run < children.length) {
run++;
}
if (children[run] == aElement)
index = run;
return index;
]]>
</body>
</method>
<method name="init">
<body>
<![CDATA[

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

@ -270,39 +270,15 @@ function onDownloadCancel(aEvent)
function onDownloadPause(aEvent)
{
var selectedIndex = gDownloadsView.selectedIndex;
var uri = aEvent.target.id;
gDownloadManager.pauseDownload(uri);
setRDFProperty(uri, "DownloadStatus", aEvent.target.getAttribute("status-internal"));
setRDFProperty(uri, "ProgressPercent", aEvent.target.getAttribute("progress"));
// now reset the richlistbox
gDownloadsView.clearSelection();
var rowCount = gDownloadsView.getRowCount();
if (selectedIndex >= rowCount)
gDownloadsView.selectedIndex = rowCount - 1;
else
gDownloadsView.selectedIndex = selectedIndex;
gDownloadsView.selectedItem.focus();
}
function onDownloadResume(aEvent)
{
var selectedIndex = gDownloadsView.selectedIndex;
gDownloadManager.resumeDownload(aEvent.target.id);
// now reset the richlistbox
gDownloadsView.clearSelection();
var rowCount = gDownloadsView.getRowCount();
if (selectedIndex >= rowCount)
gDownloadsView.selectedIndex = rowCount - 1;
else
gDownloadsView.selectedIndex = selectedIndex
gDownloadsView.selectedItem.focus();
}
function onDownloadRemove(aEvent)
@ -310,6 +286,16 @@ function onDownloadRemove(aEvent)
if (aEvent.target.removable) {
var selectedIndex = gDownloadsView.selectedIndex;
gDownloadManager.removeDownload(aEvent.target.id);
// now reset the richlistbox since the template was rebuilt
gDownloadsView.clearSelection();
if (selectedIndex >= gDownloadsView.getRowCount())
gDownloadsView.selectedIndex = selectedIndex - 1;
else
gDownloadsView.selectedIndex = selectedIndex;
gDownloadsView.focus();
gDownloadViewController.onCommandUpdate();
}
}

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

@ -1033,6 +1033,7 @@ var gExtensionsViewController = {
var movingID = aSelectedItem.id;
var moveTopID = gExtensionsView.children[0].id;
gExtensionManager.moveToIndexOf(movingID, moveTopID);
gExtensionsView.selectedItem = document.getElementById(movingID);
},
cmd_moveup: function (aSelectedItem)
@ -1040,6 +1041,7 @@ var gExtensionsViewController = {
var movingID = aSelectedItem.id;
var moveAboveID = aSelectedItem.previousSibling.id;
gExtensionManager.moveToIndexOf(movingID, moveAboveID);
gExtensionsView.selectedItem = document.getElementById(movingID);
},
cmd_movedn: function (aSelectedItem)
@ -1047,6 +1049,7 @@ var gExtensionsViewController = {
var movingID = aSelectedItem.id;
var moveBelowID = aSelectedItem.nextSibling.id;
gExtensionManager.moveToIndexOf(movingID, moveBelowID);
gExtensionsView.selectedItem = document.getElementById(movingID);
},
cmd_update: function (aSelectedItem)
@ -1118,11 +1121,13 @@ var gExtensionsViewController = {
cmd_disable: function (aSelectedItem)
{
gExtensionManager.disableItem(getIDFromResourceURI(aSelectedItem.id));
gExtensionsView.selectedItem = document.getElementById(aSelectedItem.id);
},
cmd_enable: function (aSelectedItem)
{
gExtensionManager.enableItem(getIDFromResourceURI(aSelectedItem.id));
gExtensionsView.selectedItem = document.getElementById(aSelectedItem.id);
#ifdef MOZ_PHOENIX
}
}