зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1250203 - Re-populate recent bookmarks when a bookmark gets deleted while the menu is open. r=mak
This commit is contained in:
Родитель
53f074e796
Коммит
ab3bd282d9
|
@ -1379,6 +1379,19 @@ var BookmarkingUI = {
|
|||
this._populateRecentBookmarks(aHeaderItem, aExtraCSSClass);
|
||||
};
|
||||
|
||||
this._recentlyBookmarkedObserver = {
|
||||
QueryInterface: XPCOMUtils.generateQI([
|
||||
Ci.nsINavBookmarkObserver,
|
||||
Ci.nsISupportsWeakReference
|
||||
])
|
||||
};
|
||||
this._recentlyBookmarkedObserver.onItemRemoved = () => {
|
||||
// Update the menu when a bookmark has been removed.
|
||||
// The native menubar on Mac doesn't support live update, so this won't
|
||||
// work there.
|
||||
this._populateRecentBookmarks(aHeaderItem, aExtraCSSClass);
|
||||
};
|
||||
|
||||
let updatePlacesContextMenu = (shouldHidePrefUI = false) => {
|
||||
let prefEnabled = !shouldHidePrefUI && Services.prefs.getBoolPref(this.RECENTLY_BOOKMARKED_PREF);
|
||||
document.getElementById("placesContext_showRecentlyBookmarked").hidden = shouldHidePrefUI || prefEnabled;
|
||||
|
@ -1402,12 +1415,15 @@ var BookmarkingUI = {
|
|||
updatePlacesContextMenu(true);
|
||||
|
||||
Services.prefs.removeObserver(this.RECENTLY_BOOKMARKED_PREF, prefObserver, false);
|
||||
PlacesUtils.bookmarks.removeObserver(this._recentlyBookmarkedObserver);
|
||||
this._recentlyBookmarkedObserver = null;
|
||||
placesContextMenu.removeEventListener("popupshowing", onPlacesContextMenuShowing);
|
||||
bookmarksMenu.removeEventListener("popuphidden", onBookmarksMenuHidden);
|
||||
}
|
||||
};
|
||||
|
||||
Services.prefs.addObserver(this.RECENTLY_BOOKMARKED_PREF, prefObserver, false);
|
||||
PlacesUtils.bookmarks.addObserver(this._recentlyBookmarkedObserver, true);
|
||||
placesContextMenu.addEventListener("popupshowing", onPlacesContextMenuShowing);
|
||||
bookmarksMenu.addEventListener("popuphidden", onBookmarksMenuHidden);
|
||||
},
|
||||
|
|
Загрузка…
Ссылка в новой задаче