Bug 705043 - Avoid cutting off Places URI titles unnecessarily. r=mak

This commit is contained in:
Thomas Prip Vestergaard 2011-12-07 16:44:00 -05:00
parent 2a55a7e9fc
commit aaadc452b3
3 changed files with 10 additions and 6 deletions

View File

@ -1339,7 +1339,7 @@ PlacesTreeView.prototype = {
// if they go through the "result" API.
if (PlacesUtils.nodeIsSeparator(node))
return "";
return PlacesUIUtils.getBestTitle(node);
return PlacesUIUtils.getBestTitle(node, true);
case this.COLUMN_TYPE_TAGS:
return node.tags;
case this.COLUMN_TYPE_URI:

View File

@ -719,7 +719,7 @@ var PlacesUIUtils = {
return aUrlString.substr(0, aUrlString.indexOf(":"));
},
getBestTitle: function PUIU_getBestTitle(aNode) {
getBestTitle: function PUIU_getBestTitle(aNode, aDoNotCutTitle) {
var title;
if (!aNode.title && PlacesUtils.uriTypes.indexOf(aNode.type) != -1) {
// if node title is empty, try to set the label using host and filename
@ -729,9 +729,13 @@ var PlacesUIUtils = {
var host = uri.host;
var fileName = uri.QueryInterface(Ci.nsIURL).fileName;
// if fileName is empty, use path to distinguish labels
title = host + (fileName ?
(host ? "/" + this.ellipsis + "/" : "") + fileName :
uri.path);
if (aDoNotCutTitle) {
title = host + uri.path;
} else {
title = host + (fileName ?
(host ? "/" + this.ellipsis + "/" : "") + fileName :
uri.path);
}
}
catch (e) {
// Use (no title) for non-standard URIs (data:, javascript:, ...)

View File

@ -336,7 +336,7 @@ var bookmarksObserver = {
let cellText = tree.view.getCellText(aElementOrTreeIndex,
tree.columns.getColumnAt(0));
if (!aNewValue)
return cellText == PlacesUIUtils.getBestTitle(tree.view.nodeForTreeIndex(aElementOrTreeIndex));
return cellText == PlacesUIUtils.getBestTitle(tree.view.nodeForTreeIndex(aElementOrTreeIndex), true);
return cellText == aNewValue;
}
else {