Bug 1090609 - don't disable open in tabs when there's only one item there, r=mak

This commit is contained in:
Gijs Kruitbosch 2014-11-03 10:44:47 +00:00
parent c261255d96
commit 1be87a6e14
4 changed files with 5 additions and 9 deletions

View File

@ -636,7 +636,7 @@ PlacesController.prototype = {
if (!openContainerInTabsItem.hidden) {
var containerToUse = this._view.selectedNode || this._view.result.root;
if (PlacesUtils.nodeIsContainer(containerToUse)) {
if (!PlacesUtils.hasChildURIs(containerToUse, true)) {
if (!PlacesUtils.hasChildURIs(containerToUse)) {
openContainerInTabsItem.disabled = true;
// Ensure that we don't display the menu if nothing is enabled:
usableItemCount--;

View File

@ -40,7 +40,7 @@ var SidebarUtils = {
var openInTabs = isContainer &&
(aEvent.button == 1 ||
(aEvent.button == 0 && modifKey)) &&
PlacesUtils.hasChildURIs(tbo.view.nodeForTreeIndex(cell.row), true);
PlacesUtils.hasChildURIs(tbo.view.nodeForTreeIndex(cell.row));
if (aEvent.button == 0 && isContainer && !openInTabs) {
tbo.view.toggleOpenState(cell.row);

View File

@ -956,7 +956,7 @@ this.PlacesUtils = {
* The container node to search through.
* @returns true if the node contains uri nodes, false otherwise.
*/
hasChildURIs: function PU_hasChildURIs(aNode, aMultiple=false) {
hasChildURIs: function PU_hasChildURIs(aNode) {
if (!this.nodeIsContainer(aNode))
return false;
@ -972,14 +972,11 @@ this.PlacesUtils = {
root.containerOpen = true;
}
let foundFirst = !aMultiple;
let found = false;
for (let i = 0; i < root.childCount && !found; i++) {
let child = root.getChild(i);
if (this.nodeIsURI(child)) {
found = foundFirst;
foundFirst = true;
}
if (this.nodeIsURI(child))
found = true;
}
if (!wasOpen) {

View File

@ -165,7 +165,6 @@ function check_uri_nodes(aQuery, aOptions, aExpectedURINodes) {
root.containerOpen = true;
var node = root.getChild(0);
do_check_eq(PU.hasChildURIs(node), aExpectedURINodes > 0);
do_check_eq(PU.hasChildURIs(node, true), aExpectedURINodes > 1);
do_check_eq(PU.getURLsForContainerNode(node).length, aExpectedURINodes);
root.containerOpen = false;
}