Bug 1511062: Remove onItemMoved from nsINavBookmarkObserver. r=mak

Depends on D102574

Differential Revision: https://phabricator.services.mozilla.com/D102575
This commit is contained in:
Daisuke Akatsuka 2021-05-06 02:29:44 +00:00
Родитель 459dae23fa
Коммит 3ddb5240c2
18 изменённых файлов: 11 добавлений и 227 удалений

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

@ -181,25 +181,6 @@ let observer = new (class extends EventEmitter {
}
}
onItemMoved(
id,
oldIndex,
newIndex,
itemType,
guid,
oldParentGuid,
newParentGuid,
source
) {
let info = {
parentId: newParentGuid,
index: newIndex,
oldParentId: oldParentGuid,
oldIndex,
};
this.emit("moved", { guid, info });
}
onItemChanged(
id,
prop,

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

@ -50,9 +50,7 @@ class BookmarksObserver extends Observer {
this.skipTags = true;
}
// Empty functions to make xpconnect happy
onItemMoved() {}
// Empty functions to make xpconnect happy.
// Disabled due to performance cost, see Issue 3203 /
// https://bugzilla.mozilla.org/show_bug.cgi?id=1392267.
onItemChanged() {}

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

@ -1092,7 +1092,6 @@ describe("PlacesFeed", () => {
});
describe("Other empty methods (to keep code coverage happy)", () => {
it("should have a various empty functions for xpconnect happiness", () => {
observer.onItemMoved();
observer.onItemChanged();
});
});

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

@ -1312,38 +1312,6 @@ var gEditItemOverlay = {
break;
}
},
onItemMoved(
id,
oldIndex,
newIndex,
type,
guid,
oldParentGuid,
newParentGuid
) {
if (!this._paneInfo.isItem || this._paneInfo.itemId != id) {
return;
}
this._paneInfo.parentGuid = newParentGuid;
if (
!this._paneInfo.visibleRows.has("folderRow") ||
newParentGuid == this._folderMenuList.selectedItem.folderGuid
) {
return;
}
// Just setting selectItem _does not_ trigger oncommand, so we don't
// recurse.
PlacesUtils.bookmarks.fetch(newParentGuid).then(bm => {
this._folderMenuList.selectedItem = this._getFolderMenuItem(
newParentGuid,
bm.title
);
});
},
};
XPCOMUtils.defineLazyGetter(gEditItemOverlay, "_folderTree", () => {

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

@ -6,7 +6,6 @@ add_task(async function() {
function promiseOnItemChanged() {
return new Promise(resolve => {
PlacesUtils.bookmarks.addObserver({
onItemMoved() {},
onItemChanged(id, property, isAnno, value) {
PlacesUtils.bookmarks.removeObserver(this);
resolve({ property, value });

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

@ -190,23 +190,6 @@ var bookmarksObserver = {
}
},
onItemMoved(
itemId,
oldIndex,
newIndex,
itemType,
guid,
oldParentGuid,
newParentGuid
) {
this._notifications.push([
"assertItemMoved",
newParentGuid,
guid,
newIndex,
]);
},
onItemChanged(
itemId,
property,

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

@ -933,24 +933,6 @@ BookmarksTracker.prototype = {
);
this._upScore();
},
onItemMoved: function BMT_onItemMoved(
itemId,
oldIndex,
newIndex,
itemType,
guid,
oldParentGuid,
newParentGuid,
source
) {
if (IGNORED_SOURCES.includes(source)) {
return;
}
this._log.trace("onItemMoved: " + itemId);
this._upScore();
},
};
/**

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

@ -444,24 +444,6 @@ TaggingService.prototype = {
}
},
onItemMoved: function TS_onItemMoved(
aItemId,
aOldIndex,
aNewIndex,
aItemType,
aGuid,
aOldParentGuid,
aNewParentGuid
) {
if (
this._tagFolders[aItemId] &&
PlacesUtils.bookmarks.tagsGuid == aOldParentGuid &&
PlacesUtils.bookmarks.tagsGuid != aNewParentGuid
) {
delete this._tagFolders[aItemId];
}
},
// nsISupports
classID: Components.ID("{bbc23860-2553-479d-8b78-94d9038334f7}"),

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

@ -83,39 +83,6 @@ interface nsINavBookmarkObserver : nsISupports
in ACString aParentGuid,
in AUTF8String aOldValue,
in unsigned short aSource);
/**
* Notifies that an item has been moved.
*
* @param aItemId
* The id of the item that was moved.
* @param aOldIndex
* The old index inside the old parent.
* @param aNewIndex
* The index inside the new parent.
* @param aItemType
* The type of the item to be removed (see TYPE_* constants below).
* @param aGuid
* The unique ID associated with the item.
* @param aOldParentGuid
* The unique ID associated with the old item's parent.
* @param aNewParentGuid
* The unique ID associated with the new item's parent.
* @param aSource
* A change source constant from nsINavBookmarksService::SOURCE_*,
* passed to the method that notifies the observer.
* @param aURI
* The URI for this bookmark.
*/
void onItemMoved(in long long aItemId,
in long aOldIndex,
in long aNewIndex,
in unsigned short aItemType,
in ACString aGuid,
in ACString aOldParentGuid,
in ACString aNewParentGuid,
in unsigned short aSource,
in AUTF8String aURI);
};
/**

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

@ -3950,36 +3950,6 @@ nsNavHistoryResult::OnItemChanged(
return NS_OK;
}
/**
* Need to notify both the source and the destination folders (if they are
* different).
*/
NS_IMETHODIMP
nsNavHistoryResult::OnItemMoved(int64_t aItemId, int32_t aOldIndex,
int32_t aNewIndex, uint16_t aItemType,
const nsACString& aGUID,
const nsACString& aOldParentGUID,
const nsACString& aNewParentGUID,
uint16_t aSource, const nsACString& aURI) {
ENUMERATE_BOOKMARK_FOLDER_OBSERVERS(
aOldParentGUID,
OnItemMoved(aItemId, aOldIndex, aNewIndex, aItemType, aGUID,
aOldParentGUID, aNewParentGUID, aSource, aURI));
if (!aNewParentGUID.Equals(aOldParentGUID)) {
ENUMERATE_BOOKMARK_FOLDER_OBSERVERS(
aNewParentGUID,
OnItemMoved(aItemId, aOldIndex, aNewIndex, aItemType, aGUID,
aOldParentGUID, aNewParentGUID, aSource, aURI));
}
ENUMERATE_ALL_BOOKMARKS_OBSERVERS(
OnItemMoved(aItemId, aOldIndex, aNewIndex, aItemType, aGUID,
aOldParentGUID, aNewParentGUID, aSource, aURI));
ENUMERATE_HISTORY_OBSERVERS(OnItemMoved(aItemId, aOldIndex, aNewIndex,
aItemType, aGUID, aOldParentGUID,
aNewParentGUID, aSource, aURI));
return NS_OK;
}
nsresult nsNavHistoryResult::OnVisit(nsIURI* aURI, int64_t aVisitId,
PRTime aTime, uint32_t aTransitionType,
const nsACString& aGUID, bool aHidden,

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

@ -688,6 +688,11 @@ class nsNavHistoryQueryResultNode final
uint16_t aItemType, nsIURI* aURI,
const nsACString& aGUID, const nsACString& aParentGUID,
uint16_t aSource);
nsresult OnItemMoved(int64_t aFolder, int32_t aOldIndex, int32_t aNewIndex,
uint16_t aItemType, const nsACString& aGUID,
const nsACString& aOldParentGUID,
const nsACString& aNewParentGUID, uint16_t aSource,
const nsACString& aURI);
// The internal version has an output aAdded parameter, it is incremented by
// query nodes when the visited uri belongs to them. If no such query exists,
@ -786,6 +791,11 @@ class nsNavHistoryFolderResultNode final
uint16_t aItemType, nsIURI* aURI,
const nsACString& aGUID, const nsACString& aParentGUID,
uint16_t aSource);
nsresult OnItemMoved(int64_t aFolder, int32_t aOldIndex, int32_t aNewIndex,
uint16_t aItemType, const nsACString& aGUID,
const nsACString& aOldParentGUID,
const nsACString& aNewParentGUID, uint16_t aSource,
const nsACString& aURI);
nsresult OnItemVisited(nsIURI* aURI, int64_t aVisitId, PRTime aTime);
virtual void OnRemoving() override;

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

@ -60,9 +60,6 @@ var gBookmarksObserver = {
onItemChanged() {
return this.validate("onItemChanged", arguments);
},
onItemMoved() {
return this.validate("onItemMoved", arguments);
},
// nsISupports
QueryInterface: ChromeUtils.generateQI(["nsINavBookmarkObserver"]),
@ -106,9 +103,6 @@ var gBookmarkSkipObserver = {
onItemChanged() {
return this.validate("onItemChanged", arguments);
},
onItemMoved() {
return this.validate("onItemMoved", arguments);
},
// nsISupports
QueryInterface: ChromeUtils.generateQI(["nsINavBookmarkObserver"]),

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

@ -25,7 +25,6 @@ function promiseOnItemChanged() {
return new Promise(resolve => {
PlacesUtils.bookmarks.addObserver({
onItemRemoved() {},
onItemMoved() {},
onItemChanged() {
PlacesUtils.bookmarks.removeObserver(this);

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

@ -722,7 +722,6 @@ function NavBookmarkObserver() {}
NavBookmarkObserver.prototype = {
onItemRemoved() {},
onItemChanged() {},
onItemMoved() {},
QueryInterface: ChromeUtils.generateQI(["nsINavBookmarkObserver"]),
};

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

@ -59,7 +59,6 @@ var bookmarksObserver = {
this._itemChangedValue = value;
this._itemChangedOldValue = oldValue;
},
onItemMoved() {},
QueryInterface: ChromeUtils.generateQI(["nsINavBookmarkObserver"]),
};

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

@ -393,32 +393,6 @@ BookmarkObserver.prototype = {
}
this.notifications.push({ name: "onItemChanged", params });
},
onItemMoved(
itemId,
oldIndex,
newIndex,
type,
guid,
oldParentGuid,
newParentGuid,
source,
urlHref
) {
this.notifications.push({
name: "onItemMoved",
params: {
itemId,
oldIndex,
newIndex,
type,
guid,
oldParentGuid,
newParentGuid,
source,
urlHref,
},
});
},
QueryInterface: ChromeUtils.generateQI(["nsINavBookmarkObserver"]),

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

@ -100,24 +100,6 @@ var observer = {
};
changesForGuid.set(aProperty, change);
},
onItemMoved(
aItemId,
aOldIndex,
aNewIndex,
aItemType,
aGuid,
aOldParentGuid,
aNewParentGuid
) {
this.itemsMoved.set(aGuid, {
oldParentGuid: aOldParentGuid,
oldIndex: aOldIndex,
newParentGuid: aNewParentGuid,
newIndex: aNewIndex,
itemType: aItemType,
});
},
};
observer.reset();

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

@ -51,8 +51,6 @@ add_task(async function run_test() {
}
}
},
onItemMoved() {},
};
PlacesUtils.bookmarks.addObserver(bookmarksObserver);
bookmarksObserver.handlePlacesEvents = bookmarksObserver.handlePlacesEvents.bind(