Bug 575558 - New empty named bookmarks in the toolbar display the URL instead. r=dietrich

This commit is contained in:
Marco Bonardo 2010-06-30 23:24:05 +02:00
parent 641a367e54
commit dded36fc44
2 changed files with 15 additions and 3 deletions

View File

@ -495,7 +495,15 @@ PlacesViewBase.prototype = {
if (elt.localName == "menupopup")
elt = elt.parentNode;
elt.label = aNewTitle || PlacesUIUtils.getBestTitle(aPlacesNode);
if (!aNewTitle && elt.localName != "toolbarbutton") {
// Many users consider toolbars as shortcuts containers, so explicitly
// allow empty labels on toolbarbuttons. For any other element try to be
// smarter, guessing a title from the uri.
elt.label = PlacesUIUtils.getBestTitle(aPlacesNode);
}
else {
elt.label = aNewTitle;
}
},
nodeRemoved:

View File

@ -104,7 +104,7 @@ function startTest() {
PlacesUtils._uri("place:"),
bs.DEFAULT_INDEX,
"bm2");
bs.setItemTitle(id, "bm2_edited");
bs.setItemTitle(id, "");
addedBookmarks.push(id);
id = bs.insertSeparator(bs.bookmarksMenuFolder, bs.DEFAULT_INDEX);
addedBookmarks.push(id);
@ -135,7 +135,7 @@ function startTest() {
PlacesUtils._uri("place:"),
bs.DEFAULT_INDEX,
"tb2");
bs.setItemTitle(id, "tb2_edited");
bs.setItemTitle(id, "");
addedBookmarks.push(id);
id = bs.insertSeparator(bs.toolbarFolder, bs.DEFAULT_INDEX);
addedBookmarks.push(id);
@ -285,9 +285,13 @@ var bookmarksObserver = {
var tree = sidebar.contentDocument.getElementById("bookmarks-view");
let cellText = tree.view.getCellText(aElementOrTreeIndex,
tree.columns.getColumnAt(0));
if (!aNewValue)
return cellText == PlacesUIUtils.getBestTitle(tree.view.nodeForTreeIndex(aElementOrTreeIndex));
return cellText == aNewValue;
}
else {
if (!aNewValue && aElementOrTreeIndex.localName != "toolbarbutton")
return aElementOrTreeIndex.label == PlacesUIUtils.getBestTitle(aElementOrTreeIndex._placesNode);
return aElementOrTreeIndex.label == aNewValue;
}
};