fix for bug #344040: when warning on "opening too many tabs", only count non-deleted bookmarks (and not folders or separators)

the places version of this fix has already been checked in.  this is the RDF bookmarks version, to keep the trunk in sync with the branch.

r=ben
This commit is contained in:
sspitzer%mozilla.org 2006-07-27 18:17:11 +00:00
Родитель f0d3c660b0
Коммит a76af687ae
1 изменённых файлов: 24 добавлений и 3 удалений

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

@ -644,6 +644,10 @@ var BookmarksCommand = {
if (!aTargetBrowser) if (!aTargetBrowser)
return; return;
// in this case, we can just use |aSelection.length| as "Open in Tabs"
// is only available when you are only selecting multiple bookmarks
// if you selected a folder of bookmarks, we check the number of tabs in
// openGroupBookmark()
if (aTargetBrowser == "tab" && !this._confirmOpenTabs(aSelection.length)) if (aTargetBrowser == "tab" && !this._confirmOpenTabs(aSelection.length))
return; return;
@ -763,10 +767,27 @@ var BookmarksCommand = {
var urlArc = RDF.GetResource(gNC_NS+"URL"); var urlArc = RDF.GetResource(gNC_NS+"URL");
RDFC.Init(BMDS, resource); RDFC.Init(BMDS, resource);
var containerChildren = RDFC.GetElements(); var containerChildren = RDFC.GetElements();
var numTabsToOpen = 0;
if (!this._confirmOpenTabs(RDFC.GetCount())) // we can't just use |RDFC.GetCount()| as that might include
// folders, separators, deleted bookmarks, etc.
while (containerChildren.hasMoreElements()) {
var res = containerChildren.getNext().QueryInterface(kRDFRSCIID);
var type = BookmarksUtils.resolveType(res);
// these are the types in getCommands() that support the
// "bm_openinnewwindow" and "bm_openinnewtab" commands
if (type == "Bookmark" || type == "LivemarkBookmark" ||
type == "ImmutableBookmark" || type == "IEFavorite" ||
type == "FileSystemObject")
numTabsToOpen++;
}
if (!this._confirmOpenTabs(numTabsToOpen))
return; return;
// counting the number of tabs to open modified the
// containerChildren enumerator, so we need to reset it.
containerChildren = RDFC.GetElements();
if (aTargetBrowser == "current" || aTargetBrowser == "tab") { if (aTargetBrowser == "current" || aTargetBrowser == "tab") {
var browser = w.document.getElementById("content"); var browser = w.document.getElementById("content");
var tabPanels = browser.browsers; var tabPanels = browser.browsers;
@ -784,7 +805,7 @@ var BookmarksCommand = {
++index0; ++index0;
} }
var index = index0; var index = index0;
while (containerChildren.hasMoreElements()) { while (containerChildren.hasMoreElements()) {
var res = containerChildren.getNext().QueryInterface(kRDFRSCIID); var res = containerChildren.getNext().QueryInterface(kRDFRSCIID);
var target = BMDS.GetTarget(res, urlArc, true); var target = BMDS.GetTarget(res, urlArc, true);
@ -1008,7 +1029,7 @@ var BookmarksCommand = {
if (aSelection.length != 1) if (aSelection.length != 1)
return; return;
var selType = BookmarksUtils.resolveType (aSelection.item[0]); var selType = BookmarksUtils.resolveType(aSelection.item[0]);
if (selType == "Folder" || selType == "Bookmark" || if (selType == "Folder" || selType == "Bookmark" ||
selType == "PersonalToolbarFolder" || selType == "Livemark") selType == "PersonalToolbarFolder" || selType == "Livemark")
{ {