зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 4 changesets (bug 1511062) for causing bustage on nsNavHistoryResult.cpp. CLOSED TREE
Backed out changeset ed9ac8c3097b (bug 1511062) Backed out changeset dc8c9488cf1a (bug 1511062) Backed out changeset 2cf6fca33bf3 (bug 1511062) Backed out changeset 87b0bbbcb0e6 (bug 1511062)
This commit is contained in:
Родитель
c01e01528d
Коммит
ead13148c2
|
@ -1818,7 +1818,7 @@ var BookmarkingUI = {
|
|||
if (this._hasBookmarksObserver) {
|
||||
PlacesUtils.bookmarks.removeObserver(this);
|
||||
PlacesUtils.observers.removeListener(
|
||||
["bookmark-added", "bookmark-removed", "bookmark-moved"],
|
||||
["bookmark-added", "bookmark-removed"],
|
||||
this.handlePlacesEvents
|
||||
);
|
||||
}
|
||||
|
@ -1869,7 +1869,7 @@ var BookmarkingUI = {
|
|||
PlacesUtils.bookmarks.addObserver(this);
|
||||
this.handlePlacesEvents = this.handlePlacesEvents.bind(this);
|
||||
PlacesUtils.observers.addListener(
|
||||
["bookmark-added", "bookmark-removed", "bookmark-moved"],
|
||||
["bookmark-added", "bookmark-removed"],
|
||||
this.handlePlacesEvents
|
||||
);
|
||||
this._hasBookmarksObserver = true;
|
||||
|
@ -2221,22 +2221,6 @@ var BookmarkingUI = {
|
|||
isStarUpdateNeeded = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "bookmark-moved":
|
||||
const hasMovedInOutOtherBookmarks =
|
||||
ev.parentGuid === PlacesUtils.bookmarks.unfiledGuid ||
|
||||
ev.oldParentGuid === PlacesUtils.bookmarks.unfiledGuid;
|
||||
if (hasMovedInOutOtherBookmarks) {
|
||||
this.maybeShowOtherBookmarksFolder();
|
||||
}
|
||||
|
||||
const hasMovedInOutToolbar =
|
||||
ev.parentGuid === PlacesUtils.bookmarks.toolbarGuid ||
|
||||
ev.oldParentGuid === PlacesUtils.bookmarks.toolbarGuid;
|
||||
if (hasMovedInOutToolbar) {
|
||||
this.updateEmptyToolbarMessage();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2288,8 +2272,10 @@ var BookmarkingUI = {
|
|||
|
||||
onItemMoved(
|
||||
aItemId,
|
||||
aOldIndex,
|
||||
aNewIndex,
|
||||
aProperty,
|
||||
aIsAnnotationProperty,
|
||||
aNewValue,
|
||||
aLastModified,
|
||||
aItemType,
|
||||
aGuid,
|
||||
oldParentGuid,
|
||||
|
|
|
@ -165,22 +165,31 @@ let observer = new (class extends EventEmitter {
|
|||
guid: event.guid,
|
||||
info: { parentId: event.parentGuid, index: event.index, node },
|
||||
});
|
||||
break;
|
||||
case "bookmark-moved":
|
||||
this.emit("moved", {
|
||||
guid: event.guid,
|
||||
info: {
|
||||
parentId: event.parentGuid,
|
||||
index: event.index,
|
||||
oldParentId: event.oldParentGuid,
|
||||
oldIndex: event.oldIndex,
|
||||
},
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onItemMoved(
|
||||
id,
|
||||
oldParentId,
|
||||
oldIndex,
|
||||
newParentId,
|
||||
newIndex,
|
||||
itemType,
|
||||
guid,
|
||||
oldParentGuid,
|
||||
newParentGuid,
|
||||
source
|
||||
) {
|
||||
let info = {
|
||||
parentId: newParentGuid,
|
||||
index: newIndex,
|
||||
oldParentId: oldParentGuid,
|
||||
oldIndex,
|
||||
};
|
||||
this.emit("moved", { guid, info });
|
||||
}
|
||||
|
||||
onItemChanged(
|
||||
id,
|
||||
prop,
|
||||
|
@ -213,7 +222,7 @@ const decrementListeners = () => {
|
|||
if (!listenerCount) {
|
||||
PlacesUtils.bookmarks.removeObserver(observer);
|
||||
PlacesUtils.observers.removeListener(
|
||||
["bookmark-added", "bookmark-removed", "bookmark-moved"],
|
||||
["bookmark-added", "bookmark-removed"],
|
||||
observer.handlePlacesEvents
|
||||
);
|
||||
}
|
||||
|
@ -224,7 +233,7 @@ const incrementListeners = () => {
|
|||
if (listenerCount == 1) {
|
||||
PlacesUtils.bookmarks.addObserver(observer);
|
||||
PlacesUtils.observers.addListener(
|
||||
["bookmark-added", "bookmark-removed", "bookmark-moved"],
|
||||
["bookmark-added", "bookmark-removed"],
|
||||
observer.handlePlacesEvents
|
||||
);
|
||||
}
|
||||
|
|
|
@ -50,7 +50,9 @@ class BookmarksObserver extends Observer {
|
|||
this.skipTags = true;
|
||||
}
|
||||
|
||||
// Empty functions to make xpconnect happy.
|
||||
// Empty functions to make xpconnect happy
|
||||
onItemMoved() {}
|
||||
|
||||
// Disabled due to performance cost, see Issue 3203 /
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1392267.
|
||||
onItemChanged() {}
|
||||
|
|
|
@ -1092,6 +1092,7 @@ 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();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1174,26 +1174,14 @@ var PlacesUIUtils = {
|
|||
// This listener is for counting new bookmarks
|
||||
let placesUtilsObserversListener = events => {
|
||||
for (let event of events) {
|
||||
switch (event.type) {
|
||||
case "bookmark-added":
|
||||
if (event.parentGuid == PlacesUtils.bookmarks.toolbarGuid) {
|
||||
Services.telemetry.scalarAdd(
|
||||
"browser.engagement.bookmarks_toolbar_bookmark_added",
|
||||
1
|
||||
);
|
||||
}
|
||||
break;
|
||||
case "bookmark-moved":
|
||||
let hasMovedToToolbar =
|
||||
event.parentGuid == PlacesUtils.bookmarks.toolbarGuid &&
|
||||
event.oldParentGuid != PlacesUtils.bookmarks.toolbarGuid;
|
||||
if (hasMovedToToolbar) {
|
||||
Services.telemetry.scalarAdd(
|
||||
"browser.engagement.bookmarks_toolbar_bookmark_added",
|
||||
1
|
||||
);
|
||||
}
|
||||
break;
|
||||
if (
|
||||
event.type == "bookmark-added" &&
|
||||
event.parentGuid == PlacesUtils.bookmarks.toolbarGuid
|
||||
) {
|
||||
Services.telemetry.scalarAdd(
|
||||
"browser.engagement.bookmarks_toolbar_bookmark_added",
|
||||
1
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -1203,8 +1191,10 @@ var PlacesUIUtils = {
|
|||
onItemChanged() {},
|
||||
onItemMoved(
|
||||
aItemId,
|
||||
aOldIndex,
|
||||
aNewIndex,
|
||||
aProperty,
|
||||
aIsAnnotationProperty,
|
||||
aNewValue,
|
||||
aLastModified,
|
||||
aItemType,
|
||||
aGuid,
|
||||
oldParentGuid,
|
||||
|
@ -1224,13 +1214,13 @@ var PlacesUIUtils = {
|
|||
|
||||
this._bookmarkToolbarTelemetryListening = true;
|
||||
PlacesUtils.observers.addListener(
|
||||
["bookmark-added", "bookmark-moved"],
|
||||
["bookmark-added"],
|
||||
placesUtilsObserversListener
|
||||
);
|
||||
PlacesUtils.bookmarks.addObserver(placesUtilsBookmarksObserver);
|
||||
PlacesUtils.registerShutdownFunction(() => {
|
||||
PlacesUtils.observers.removeListener(
|
||||
["bookmark-added", "bookmark-moved"],
|
||||
["bookmark-added"],
|
||||
placesUtilsObserversListener
|
||||
);
|
||||
PlacesUtils.bookmarks.removeObserver(placesUtilsBookmarksObserver);
|
||||
|
|
|
@ -348,11 +348,6 @@ var gEditItemOverlay = {
|
|||
// Observe changes.
|
||||
if (!this._observersAdded) {
|
||||
PlacesUtils.bookmarks.addObserver(this);
|
||||
this.handlePlacesEvents = this.handlePlacesEvents.bind(this);
|
||||
PlacesUtils.observers.addListener(
|
||||
["bookmark-moved"],
|
||||
this.handlePlacesEvents
|
||||
);
|
||||
window.addEventListener("unload", this);
|
||||
this._observersAdded = true;
|
||||
}
|
||||
|
@ -571,10 +566,6 @@ var gEditItemOverlay = {
|
|||
|
||||
if (this._observersAdded) {
|
||||
PlacesUtils.bookmarks.removeObserver(this);
|
||||
PlacesUtils.observers.removeListener(
|
||||
["bookmark-moved"],
|
||||
this.handlePlacesEvents
|
||||
);
|
||||
window.removeEventListener("unload", this);
|
||||
this._observersAdded = false;
|
||||
}
|
||||
|
@ -1135,35 +1126,6 @@ var gEditItemOverlay = {
|
|||
}
|
||||
},
|
||||
|
||||
async handlePlacesEvents(events) {
|
||||
for (const event of events) {
|
||||
switch (event.type) {
|
||||
case "bookmark-moved":
|
||||
if (!this._paneInfo.isItem || this._paneInfo.itemId != event.id) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._paneInfo.parentGuid = event.parentGuid;
|
||||
|
||||
if (
|
||||
!this._paneInfo.visibleRows.has("folderRow") ||
|
||||
event.parentGuid === this._folderMenuList.selectedItem.folderGuid
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Just setting selectItem _does not_ trigger oncommand, so we don't
|
||||
// recurse.
|
||||
const bm = await PlacesUtils.bookmarks.fetch(event.parentGuid);
|
||||
this._folderMenuList.selectedItem = this._getFolderMenuItem(
|
||||
event.parentGuid,
|
||||
bm.title
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
toggleItemCheckbox(item) {
|
||||
// Update the tags field when items are checked/unchecked in the listbox
|
||||
let tags = this._getTagsArrayFromTagsInputField();
|
||||
|
@ -1312,6 +1274,40 @@ var gEditItemOverlay = {
|
|||
break;
|
||||
}
|
||||
},
|
||||
|
||||
onItemMoved(
|
||||
id,
|
||||
oldParentId,
|
||||
oldIndex,
|
||||
newParentId,
|
||||
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", () => {
|
||||
|
|
|
@ -165,14 +165,9 @@ add_task(async function test_move_existing_to_toolbar() {
|
|||
|
||||
let menuList = win.document.getElementById("editBMPanel_folderMenuList");
|
||||
let itemMovedPromise = PlacesTestUtils.waitForNotification(
|
||||
"bookmark-moved",
|
||||
events =>
|
||||
events.some(
|
||||
e =>
|
||||
e.parentGuid === PlacesUtils.bookmarks.toolbarGuid &&
|
||||
e.guid === bm.guid
|
||||
),
|
||||
"places"
|
||||
"onItemMoved",
|
||||
(id, oldParentId, oldIndex, newParentId, newIndex, type, guid) =>
|
||||
newParentId == PlacesUtils.toolbarFolderId && guid == bm.guid
|
||||
);
|
||||
let promisePopup = BrowserTestUtils.waitForEvent(
|
||||
menuList.menupopup,
|
||||
|
|
|
@ -18,9 +18,18 @@ async function openPopupAndSelectFolder(guid, newBookmark = false) {
|
|||
let notificationPromise;
|
||||
if (!newBookmark) {
|
||||
notificationPromise = PlacesTestUtils.waitForNotification(
|
||||
"bookmark-moved",
|
||||
events => events.some(e => guid === e.parentGuid),
|
||||
"places"
|
||||
"onItemMoved",
|
||||
(
|
||||
id,
|
||||
oldParentId,
|
||||
oldIndex,
|
||||
newParentId,
|
||||
newIndex,
|
||||
type,
|
||||
itemGuid,
|
||||
oldParentGuid,
|
||||
newParentGuid
|
||||
) => guid == newParentGuid
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -108,12 +108,18 @@ async function run_drag_test(startBookmarkIndex, insertionIndex) {
|
|||
|
||||
add_task(async function test_simple_move_down() {
|
||||
let moveNotification = PlacesTestUtils.waitForNotification(
|
||||
"bookmark-moved",
|
||||
events =>
|
||||
events.some(
|
||||
e => e.guid === bookmarks[0].guid && e.oldIndex == 0 && e.index == 1
|
||||
),
|
||||
"places"
|
||||
"onItemMoved",
|
||||
(
|
||||
id,
|
||||
oldParentId,
|
||||
oldIndex,
|
||||
newParentId,
|
||||
newIndex,
|
||||
itemType,
|
||||
guid,
|
||||
oldParentGuid,
|
||||
newParentGuid
|
||||
) => guid == bookmarks[0].guid && oldIndex == 0 && newIndex == 1
|
||||
);
|
||||
|
||||
await run_drag_test(0, 2);
|
||||
|
|
|
@ -176,13 +176,9 @@ add_task(async function test_change_location_panel() {
|
|||
let itemGuid = win.gEditItemOverlay._paneInfo.itemGuid;
|
||||
// Make sure we wait for the move to complete.
|
||||
let itemMovedPromise = PlacesTestUtils.waitForNotification(
|
||||
"bookmark-moved",
|
||||
events =>
|
||||
events.some(
|
||||
e =>
|
||||
e.guid === itemGuid && e.parentGuid === PlacesUtils.bookmarks.menuGuid
|
||||
),
|
||||
"places"
|
||||
"onItemMoved",
|
||||
(id, oldParentId, oldIndex, newParentId, newIndex, type, guid) =>
|
||||
newParentId == PlacesUtils.bookmarksMenuFolderId && guid == itemGuid
|
||||
);
|
||||
|
||||
// Wait for the pref to change
|
||||
|
|
|
@ -6,6 +6,7 @@ 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,6 +190,25 @@ var bookmarksObserver = {
|
|||
}
|
||||
},
|
||||
|
||||
onItemMoved(
|
||||
itemId,
|
||||
oldFolderId,
|
||||
oldIndex,
|
||||
newFolderId,
|
||||
newIndex,
|
||||
itemType,
|
||||
guid,
|
||||
oldParentGuid,
|
||||
newParentGuid
|
||||
) {
|
||||
this._notifications.push([
|
||||
"assertItemMoved",
|
||||
newParentGuid,
|
||||
guid,
|
||||
newIndex,
|
||||
]);
|
||||
},
|
||||
|
||||
onItemChanged(
|
||||
itemId,
|
||||
property,
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_PlacesBookmarkMoved_h
|
||||
#define mozilla_dom_PlacesBookmarkMoved_h
|
||||
|
||||
#include "mozilla/dom/PlacesBookmark.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class PlacesBookmarkMoved final : public PlacesBookmark {
|
||||
public:
|
||||
explicit PlacesBookmarkMoved()
|
||||
: PlacesBookmark(PlacesEventType::Bookmark_moved) {}
|
||||
|
||||
static already_AddRefed<PlacesBookmarkMoved> Constructor(
|
||||
const GlobalObject& aGlobal, const PlacesBookmarkMovedInit& aInitDict) {
|
||||
RefPtr<PlacesBookmarkMoved> event = new PlacesBookmarkMoved();
|
||||
event->mId = aInitDict.mId;
|
||||
event->mItemType = aInitDict.mItemType;
|
||||
event->mUrl = aInitDict.mUrl;
|
||||
event->mGuid = aInitDict.mGuid;
|
||||
event->mParentGuid = aInitDict.mParentGuid;
|
||||
event->mIndex = aInitDict.mIndex;
|
||||
event->mOldParentGuid = aInitDict.mOldParentGuid;
|
||||
event->mOldIndex = aInitDict.mOldIndex;
|
||||
event->mSource = aInitDict.mSource;
|
||||
event->mIsTagging = aInitDict.mIsTagging;
|
||||
return event.forget();
|
||||
}
|
||||
|
||||
JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override {
|
||||
return PlacesBookmarkMoved_Binding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
const PlacesBookmarkMoved* AsPlacesBookmarkMoved() const override {
|
||||
return this;
|
||||
}
|
||||
|
||||
int32_t Index() { return mIndex; }
|
||||
int32_t OldIndex() { return mOldIndex; }
|
||||
void GetOldParentGuid(nsCString& aOldParentGuid) {
|
||||
aOldParentGuid = mOldParentGuid;
|
||||
}
|
||||
|
||||
int32_t mIndex;
|
||||
int32_t mOldIndex;
|
||||
nsCString mOldParentGuid;
|
||||
|
||||
private:
|
||||
~PlacesBookmarkMoved() = default;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif
|
|
@ -41,9 +41,6 @@ class PlacesEvent : public nsWrapperCache {
|
|||
virtual const PlacesBookmarkRemoved* AsPlacesBookmarkRemoved() const {
|
||||
return nullptr;
|
||||
}
|
||||
virtual const PlacesBookmarkMoved* AsPlacesBookmarkMoved() const {
|
||||
return nullptr;
|
||||
}
|
||||
virtual const PlacesFavicon* AsPlacesFavicon() const { return nullptr; }
|
||||
virtual const PlacesVisitTitle* AsPlacesVisitTitle() const { return nullptr; }
|
||||
virtual const PlacesHistoryCleared* AsPlacesHistoryCleared() const {
|
||||
|
|
|
@ -220,7 +220,6 @@ EXPORTS.mozilla.dom += [
|
|||
"ParentProcessMessageManager.h",
|
||||
"PlacesBookmark.h",
|
||||
"PlacesBookmarkAddition.h",
|
||||
"PlacesBookmarkMoved.h",
|
||||
"PlacesBookmarkRemoved.h",
|
||||
"PlacesEvent.h",
|
||||
"PlacesFavicon.h",
|
||||
|
|
|
@ -12,14 +12,9 @@ enum PlacesEventType {
|
|||
"bookmark-added",
|
||||
/**
|
||||
* data: PlacesBookmarkRemoved. Fired whenever a bookmark
|
||||
* (or a bookmark folder/separator) is removed.
|
||||
* (or a bookmark folder/separator) is created.
|
||||
*/
|
||||
"bookmark-removed",
|
||||
/**
|
||||
* data: PlacesBookmarkMoved. Fired whenever a bookmark
|
||||
* (or a bookmark folder/separator) is moved.
|
||||
*/
|
||||
"bookmark-moved",
|
||||
/**
|
||||
* data: PlacesFavicon. Fired whenever a favicon changes.
|
||||
*/
|
||||
|
@ -222,42 +217,6 @@ interface PlacesBookmarkRemoved : PlacesBookmark {
|
|||
readonly attribute boolean isDescendantRemoval;
|
||||
};
|
||||
|
||||
dictionary PlacesBookmarkMovedInit {
|
||||
required long long id;
|
||||
required unsigned short itemType;
|
||||
DOMString? url = null;
|
||||
required ByteString guid;
|
||||
required ByteString parentGuid;
|
||||
required long index;
|
||||
required ByteString oldParentGuid;
|
||||
required long oldIndex;
|
||||
required unsigned short source;
|
||||
required boolean isTagging;
|
||||
};
|
||||
|
||||
[ChromeOnly, Exposed=Window]
|
||||
/**
|
||||
* NOTE: Though PlacesBookmarkMoved extends PlacesBookmark,
|
||||
* parentId will not be set. Use parentGuid instead.
|
||||
*/
|
||||
interface PlacesBookmarkMoved : PlacesBookmark {
|
||||
constructor(PlacesBookmarkMovedInit initDict);
|
||||
/**
|
||||
* The item's index in the folder.
|
||||
*/
|
||||
readonly attribute long index;
|
||||
|
||||
/**
|
||||
* The unique ID associated with the item's old parent.
|
||||
*/
|
||||
readonly attribute ByteString oldParentGuid;
|
||||
|
||||
/**
|
||||
* The item's old index in the folder.
|
||||
*/
|
||||
readonly attribute long oldIndex;
|
||||
};
|
||||
|
||||
dictionary PlacesFaviconInit {
|
||||
required DOMString url;
|
||||
required ByteString pageGuid;
|
||||
|
|
|
@ -805,7 +805,7 @@ BookmarksTracker.prototype = {
|
|||
this.handlePlacesEvents.bind(this)
|
||||
);
|
||||
PlacesUtils.observers.addListener(
|
||||
["bookmark-added", "bookmark-removed", "bookmark-moved"],
|
||||
["bookmark-added", "bookmark-removed"],
|
||||
this._placesListener
|
||||
);
|
||||
Svc.Obs.add("bookmarks-restore-begin", this);
|
||||
|
@ -816,7 +816,7 @@ BookmarksTracker.prototype = {
|
|||
onStop() {
|
||||
PlacesUtils.bookmarks.removeObserver(this);
|
||||
PlacesUtils.observers.removeListener(
|
||||
["bookmark-added", "bookmark-removed", "bookmark-moved"],
|
||||
["bookmark-added", "bookmark-removed"],
|
||||
this._placesListener
|
||||
);
|
||||
Svc.Obs.remove("bookmarks-restore-begin", this);
|
||||
|
@ -884,14 +884,6 @@ BookmarksTracker.prototype = {
|
|||
this._log.trace("'bookmark-removed': " + event.id);
|
||||
this._upScore();
|
||||
break;
|
||||
case "bookmark-moved":
|
||||
if (IGNORED_SOURCES.includes(event.source)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._log.trace("'bookmark-moved': " + event.id);
|
||||
this._upScore();
|
||||
break;
|
||||
case "purge-caches":
|
||||
this._log.trace("purge-caches");
|
||||
this._upScore();
|
||||
|
@ -933,6 +925,26 @@ BookmarksTracker.prototype = {
|
|||
);
|
||||
this._upScore();
|
||||
},
|
||||
|
||||
onItemMoved: function BMT_onItemMoved(
|
||||
itemId,
|
||||
oldParent,
|
||||
oldIndex,
|
||||
newParent,
|
||||
newIndex,
|
||||
itemType,
|
||||
guid,
|
||||
oldParentGuid,
|
||||
newParentGuid,
|
||||
source
|
||||
) {
|
||||
if (IGNORED_SOURCES.includes(source)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._log.trace("onItemMoved: " + itemId);
|
||||
this._upScore();
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
* Each successful operation notifies through the nsINavBookmarksObserver
|
||||
* interface. To listen to such notifications you must register using
|
||||
* nsINavBookmarksService addObserver and removeObserver methods.
|
||||
* Note that bookmark addition or order changes won't notify bookmark-moved for
|
||||
* Note that bookmark addition or order changes won't notify onItemMoved for
|
||||
* items that have their indexes changed.
|
||||
* Similarly, lastModified changes not done explicitly (like changing another
|
||||
* property) won't fire an onItemChanged notification for the lastModified
|
||||
|
@ -664,9 +664,7 @@ var Bookmarks = Object.freeze({
|
|||
insertInfos[i] = Object.assign({}, item);
|
||||
}
|
||||
|
||||
if (notifications.length) {
|
||||
PlacesObservers.notifyListeners(notifications);
|
||||
}
|
||||
PlacesObservers.notifyListeners(notifications);
|
||||
|
||||
return insertInfos;
|
||||
})();
|
||||
|
@ -850,8 +848,6 @@ var Bookmarks = Object.freeze({
|
|||
);
|
||||
}
|
||||
|
||||
const notifications = [];
|
||||
|
||||
// Notify onItemChanged to listeners.
|
||||
let observers = PlacesUtils.bookmarks.getObservers();
|
||||
// For lastModified, we only care about the original input, since we
|
||||
|
@ -957,31 +953,24 @@ var Bookmarks = Object.freeze({
|
|||
updatedItem.source,
|
||||
]);
|
||||
}
|
||||
// If the item was moved, notify bookmark-moved.
|
||||
// If the item was moved, notify onItemMoved.
|
||||
if (
|
||||
item.parentGuid != updatedItem.parentGuid ||
|
||||
item.index != updatedItem.index
|
||||
) {
|
||||
notifications.push(
|
||||
new PlacesBookmarkMoved({
|
||||
id: updatedItem._id,
|
||||
itemType: updatedItem.type,
|
||||
url: updatedItem.url && updatedItem.url.href,
|
||||
guid: updatedItem.guid,
|
||||
parentGuid: updatedItem.parentGuid,
|
||||
source: updatedItem.source,
|
||||
index: updatedItem.index,
|
||||
oldParentGuid: item.parentGuid,
|
||||
oldIndex: item.index,
|
||||
isTagging:
|
||||
updatedItem.parentGuid === Bookmarks.tagsGuid ||
|
||||
parent.parentGuid === Bookmarks.tagsGuid,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
if (notifications.length) {
|
||||
PlacesObservers.notifyListeners(notifications);
|
||||
notify(observers, "onItemMoved", [
|
||||
updatedItem._id,
|
||||
item._parentId,
|
||||
item.index,
|
||||
updatedItem._parentId,
|
||||
updatedItem.index,
|
||||
updatedItem.type,
|
||||
updatedItem.guid,
|
||||
item.parentGuid,
|
||||
updatedItem.parentGuid,
|
||||
updatedItem.source,
|
||||
updatedItem.url && updatedItem.url.href,
|
||||
]);
|
||||
}
|
||||
|
||||
// Remove non-enumerable properties.
|
||||
|
@ -1146,7 +1135,6 @@ var Bookmarks = Object.freeze({
|
|||
newParent,
|
||||
syncChangeDelta
|
||||
);
|
||||
info.newParent = newParent;
|
||||
|
||||
// For items moving within the same folder, we have to keep track
|
||||
// of their indexes. Otherwise we run the risk of not correctly
|
||||
|
@ -1187,11 +1175,11 @@ var Bookmarks = Object.freeze({
|
|||
}
|
||||
);
|
||||
|
||||
const notifications = [];
|
||||
|
||||
// Updates complete, time to notify everyone.
|
||||
for (let { updatedItem, existingItem, newParent } of updateInfos) {
|
||||
// If the item was moved, notify bookmark-moved.
|
||||
for (let { updatedItem, existingItem } of updateInfos) {
|
||||
// Notify onItemChanged to listeners.
|
||||
let observers = PlacesUtils.bookmarks.getObservers();
|
||||
// If the item was moved, notify onItemMoved.
|
||||
// We use the updatedItem.index here, rather than currIndex, as the views
|
||||
// need to know where we inserted the item as opposed to where it ended
|
||||
// up.
|
||||
|
@ -1199,31 +1187,24 @@ var Bookmarks = Object.freeze({
|
|||
existingItem.parentGuid != updatedItem.parentGuid ||
|
||||
existingItem.index != updatedItem.index
|
||||
) {
|
||||
notifications.push(
|
||||
new PlacesBookmarkMoved({
|
||||
id: updatedItem._id,
|
||||
itemType: updatedItem.type,
|
||||
url: existingItem.url,
|
||||
guid: updatedItem.guid,
|
||||
parentGuid: updatedItem.parentGuid,
|
||||
source,
|
||||
index: updatedItem.index,
|
||||
oldParentGuid: existingItem.parentGuid,
|
||||
oldIndex: existingItem.index,
|
||||
isTagging:
|
||||
updatedItem.parentGuid === Bookmarks.tagsGuid ||
|
||||
newParent.parentGuid === Bookmarks.tagsGuid,
|
||||
})
|
||||
);
|
||||
notify(observers, "onItemMoved", [
|
||||
updatedItem._id,
|
||||
existingItem._parentId,
|
||||
existingItem.index,
|
||||
updatedItem._parentId,
|
||||
updatedItem.index,
|
||||
updatedItem.type,
|
||||
updatedItem.guid,
|
||||
existingItem.parentGuid,
|
||||
updatedItem.parentGuid,
|
||||
source,
|
||||
existingItem.url,
|
||||
]);
|
||||
}
|
||||
// Remove non-enumerable properties.
|
||||
delete updatedItem.source;
|
||||
}
|
||||
|
||||
if (notifications.length) {
|
||||
PlacesObservers.notifyListeners(notifications);
|
||||
}
|
||||
|
||||
return updateInfos.map(updateInfo =>
|
||||
Object.assign({}, updateInfo.updatedItem)
|
||||
);
|
||||
|
@ -1763,31 +1744,23 @@ var Bookmarks = Object.freeze({
|
|||
options
|
||||
);
|
||||
|
||||
const notifications = [];
|
||||
|
||||
let observers = PlacesUtils.bookmarks.getObservers();
|
||||
// Note that child.index is the old index.
|
||||
for (let i = 0; i < sortedChildren.length; ++i) {
|
||||
let child = sortedChildren[i];
|
||||
notifications.push(
|
||||
new PlacesBookmarkMoved({
|
||||
id: child._id,
|
||||
itemType: child.type,
|
||||
url: child.url && child.url.href,
|
||||
guid: child.guid,
|
||||
parentGuid: child.parentGuid,
|
||||
source: options.source,
|
||||
index: i,
|
||||
oldParentGuid: child.parentGuid,
|
||||
oldIndex: child.index,
|
||||
isTagging:
|
||||
child.parentGuid === Bookmarks.tagsGuid ||
|
||||
parent.parentGuid === Bookmarks.tagsGuid,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
if (notifications.length) {
|
||||
PlacesObservers.notifyListeners(notifications);
|
||||
notify(observers, "onItemMoved", [
|
||||
child._id,
|
||||
child._parentId,
|
||||
child.index,
|
||||
child._parentId,
|
||||
i,
|
||||
child.type,
|
||||
child.guid,
|
||||
child.parentGuid,
|
||||
child.parentGuid,
|
||||
options.source,
|
||||
child.url && child.url.href,
|
||||
]);
|
||||
}
|
||||
})();
|
||||
},
|
||||
|
|
|
@ -2061,6 +2061,7 @@ class BookmarkObserverRecorder {
|
|||
this.signal = signal;
|
||||
this.placesEvents = [];
|
||||
this.guidChangedArgs = [];
|
||||
this.itemMovedArgs = [];
|
||||
this.itemChangedArgs = [];
|
||||
this.shouldInvalidateKeywords = false;
|
||||
}
|
||||
|
@ -2203,14 +2204,13 @@ class BookmarkObserverRecorder {
|
|||
|
||||
MirrorLog.trace("Recording observer notifications for moved items");
|
||||
await this.db.execute(
|
||||
`SELECT b.id, b.guid, b.type, p.guid AS newParentGuid, c.oldParentGuid,
|
||||
`SELECT b.id, b.guid, b.type, p.id AS newParentId, c.oldParentId,
|
||||
p.guid AS newParentGuid, c.oldParentGuid,
|
||||
b.position AS newPosition, c.oldPosition,
|
||||
gp.guid AS grandParentGuid,
|
||||
(SELECT h.url FROM moz_places h WHERE h.id = b.fk) AS url
|
||||
FROM itemsMoved c
|
||||
JOIN moz_bookmarks b ON b.id = c.itemId
|
||||
JOIN moz_bookmarks p ON p.id = b.parent
|
||||
LEFT JOIN moz_bookmarks gp ON gp.id = p.parent
|
||||
${this.orderBy("c.level", "b.parent", "b.position")}`,
|
||||
null,
|
||||
(row, cancel) => {
|
||||
|
@ -2222,12 +2222,13 @@ class BookmarkObserverRecorder {
|
|||
id: row.getResultByName("id"),
|
||||
guid: row.getResultByName("guid"),
|
||||
type: row.getResultByName("type"),
|
||||
newParentId: row.getResultByName("newParentId"),
|
||||
oldParentId: row.getResultByName("oldParentId"),
|
||||
newParentGuid: row.getResultByName("newParentGuid"),
|
||||
oldParentGuid: row.getResultByName("oldParentGuid"),
|
||||
newPosition: row.getResultByName("newPosition"),
|
||||
oldPosition: row.getResultByName("oldPosition"),
|
||||
urlHref: row.getResultByName("url"),
|
||||
grandParentGuid: row.getResultByName("grandParentGuid"),
|
||||
};
|
||||
this.noteItemMoved(info);
|
||||
}
|
||||
|
@ -2323,22 +2324,19 @@ class BookmarkObserverRecorder {
|
|||
}
|
||||
|
||||
noteItemMoved(info) {
|
||||
this.placesEvents.push(
|
||||
new PlacesBookmarkMoved({
|
||||
id: info.id,
|
||||
itemType: info.type,
|
||||
url: info.urlHref,
|
||||
guid: info.guid,
|
||||
parentGuid: info.newParentGuid,
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC,
|
||||
index: info.newPosition,
|
||||
oldParentGuid: info.oldParentGuid,
|
||||
oldIndex: info.oldPosition,
|
||||
isTagging:
|
||||
info.newParentGuid === PlacesUtils.bookmarks.tagsGuid ||
|
||||
info.grandParentGuid === PlacesUtils.bookmarks.tagsGuid,
|
||||
})
|
||||
);
|
||||
this.itemMovedArgs.push([
|
||||
info.id,
|
||||
info.oldParentId,
|
||||
info.oldPosition,
|
||||
info.newParentId,
|
||||
info.newPosition,
|
||||
info.type,
|
||||
info.guid,
|
||||
info.oldParentGuid,
|
||||
info.newParentGuid,
|
||||
PlacesUtils.bookmarks.SOURCES.SYNC,
|
||||
info.urlHref,
|
||||
]);
|
||||
}
|
||||
|
||||
noteItemChanged(info) {
|
||||
|
@ -2419,6 +2417,21 @@ class BookmarkObserverRecorder {
|
|||
PlacesObservers.notifyListeners(this.placesEvents);
|
||||
}
|
||||
|
||||
await Async.yieldingForEach(
|
||||
this.itemMovedArgs,
|
||||
args => {
|
||||
if (this.signal.aborted) {
|
||||
throw new SyncedBookmarksMirror.InterruptedError(
|
||||
"Interrupted before notifying observers for moved items"
|
||||
);
|
||||
}
|
||||
this.notifyObserversWithInfo(observers, "onItemMoved", {
|
||||
isTagging: false,
|
||||
args,
|
||||
});
|
||||
},
|
||||
yieldState
|
||||
);
|
||||
await Async.yieldingForEach(
|
||||
this.itemChangedArgs,
|
||||
args => {
|
||||
|
|
|
@ -22,7 +22,7 @@ function TaggingService() {
|
|||
// Observe bookmarks changes.
|
||||
PlacesUtils.bookmarks.addObserver(this);
|
||||
PlacesUtils.observers.addListener(
|
||||
["bookmark-added", "bookmark-removed", "bookmark-moved"],
|
||||
["bookmark-added", "bookmark-removed"],
|
||||
this.handlePlacesEvents
|
||||
);
|
||||
|
||||
|
@ -327,7 +327,7 @@ TaggingService.prototype = {
|
|||
if (aTopic == TOPIC_SHUTDOWN) {
|
||||
PlacesUtils.bookmarks.removeObserver(this);
|
||||
PlacesUtils.observers.removeListener(
|
||||
["bookmark-added", "bookmark-removed", "bookmark-moved"],
|
||||
["bookmark-added", "bookmark-removed"],
|
||||
this.handlePlacesEvents
|
||||
);
|
||||
Services.obs.removeObserver(this, TOPIC_SHUTDOWN);
|
||||
|
@ -418,15 +418,6 @@ TaggingService.prototype = {
|
|||
}
|
||||
});
|
||||
break;
|
||||
case "bookmark-moved":
|
||||
if (
|
||||
this._tagFolders[event.id] &&
|
||||
PlacesUtils.bookmarks.tagsGuid === event.oldParentGuid &&
|
||||
PlacesUtils.bookmarks.tagsGuid !== event.parentGuid
|
||||
) {
|
||||
delete this._tagFolders[event.id];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -444,6 +435,23 @@ TaggingService.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
onItemMoved: function TS_onItemMoved(
|
||||
aItemId,
|
||||
aOldParent,
|
||||
aOldIndex,
|
||||
aNewParent,
|
||||
aNewIndex,
|
||||
aItemType
|
||||
) {
|
||||
if (
|
||||
this._tagFolders[aItemId] &&
|
||||
PlacesUtils.tagsFolderId == aOldParent &&
|
||||
PlacesUtils.tagsFolderId != aNewParent
|
||||
) {
|
||||
delete this._tagFolders[aItemId];
|
||||
}
|
||||
},
|
||||
|
||||
// nsISupports
|
||||
|
||||
classID: Components.ID("{bbc23860-2553-479d-8b78-94d9038334f7}"),
|
||||
|
|
|
@ -83,6 +83,45 @@ 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 aOldParentId
|
||||
* The id of the old parent.
|
||||
* @param aOldIndex
|
||||
* The old index inside the old parent.
|
||||
* @param aNewParentId
|
||||
* The id of the new 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 long aOldParentId,
|
||||
in long aOldIndex,
|
||||
in long long aNewParentId,
|
||||
in long aNewIndex,
|
||||
in unsigned short aItemType,
|
||||
in ACString aGuid,
|
||||
in ACString aOldParentGuid,
|
||||
in ACString aNewParentGuid,
|
||||
in unsigned short aSource,
|
||||
in AUTF8String aURI);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "mozilla/dom/PlacesVisit.h"
|
||||
#include "mozilla/dom/PlacesVisitRemoved.h"
|
||||
#include "mozilla/dom/PlacesVisitTitle.h"
|
||||
#include "mozilla/dom/PlacesBookmarkMoved.h"
|
||||
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
|
||||
|
@ -2504,20 +2503,18 @@ nsNavHistoryQueryResultNode::OnItemChanged(
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNavHistoryQueryResultNode::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) {
|
||||
nsNavHistoryQueryResultNode::OnItemMoved(
|
||||
int64_t aFolder, int64_t aOldParent, int32_t aOldIndex, int64_t aNewParent,
|
||||
int32_t aNewIndex, uint16_t aItemType, const nsACString& aGUID,
|
||||
const nsACString& aOldParentGUID, const nsACString& aNewParentGUID,
|
||||
uint16_t aSource, const nsACString& aURI) {
|
||||
// 1. The query cannot be affected by the item's position
|
||||
// 2. For the time being, we cannot optimize this not to update
|
||||
// queries which are not restricted to some folders, due to way
|
||||
// sub-queries are updated (see Refresh)
|
||||
if (mLiveUpdate == QUERYUPDATE_COMPLEX_WITH_BOOKMARKS &&
|
||||
aItemType != nsINavBookmarksService::TYPE_SEPARATOR &&
|
||||
!aNewParentGUID.Equals(aOldParentGUID)) {
|
||||
aOldParent != aNewParent) {
|
||||
return Refresh();
|
||||
}
|
||||
return NS_OK;
|
||||
|
@ -2568,7 +2565,7 @@ nsNavHistoryFolderResultNode::nsNavHistoryFolderResultNode(
|
|||
|
||||
nsNavHistoryFolderResultNode::~nsNavHistoryFolderResultNode() {
|
||||
if (mIsRegisteredFolderObserver && mResult)
|
||||
mResult->RemoveBookmarkFolderObserver(this, mTargetFolderGuid);
|
||||
mResult->RemoveBookmarkFolderObserver(this, mTargetFolderItemId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2769,7 +2766,7 @@ nsresult nsNavHistoryFolderResultNode::OnChildrenFilled() {
|
|||
*/
|
||||
void nsNavHistoryFolderResultNode::EnsureRegisteredAsFolderObserver() {
|
||||
if (!mIsRegisteredFolderObserver && mResult) {
|
||||
mResult->AddBookmarkFolderObserver(this, mTargetFolderGuid);
|
||||
mResult->AddBookmarkFolderObserver(this, mTargetFolderItemId);
|
||||
mIsRegisteredFolderObserver = true;
|
||||
}
|
||||
}
|
||||
|
@ -2880,7 +2877,7 @@ void nsNavHistoryFolderResultNode::ClearChildren(bool unregister) {
|
|||
|
||||
bool needsUnregister = unregister && (mContentsValid || mAsyncPendingStmt);
|
||||
if (needsUnregister && mResult && mIsRegisteredFolderObserver) {
|
||||
mResult->RemoveBookmarkFolderObserver(this, mTargetFolderGuid);
|
||||
mResult->RemoveBookmarkFolderObserver(this, mTargetFolderItemId);
|
||||
mIsRegisteredFolderObserver = false;
|
||||
}
|
||||
mContentsValid = false;
|
||||
|
@ -3323,16 +3320,14 @@ nsresult nsNavHistoryFolderResultNode::OnItemVisited(nsIURI* aURI,
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNavHistoryFolderResultNode::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) {
|
||||
MOZ_ASSERT(aOldParentGUID.Equals(mTargetFolderGuid) ||
|
||||
aNewParentGUID.Equals(mTargetFolderGuid),
|
||||
"Got a bookmark message that doesn't belong to us");
|
||||
nsNavHistoryFolderResultNode::OnItemMoved(
|
||||
int64_t aItemId, int64_t aOldParent, int32_t aOldIndex, int64_t aNewParent,
|
||||
int32_t aNewIndex, uint16_t aItemType, const nsACString& aGUID,
|
||||
const nsACString& aOldParentGUID, const nsACString& aNewParentGUID,
|
||||
uint16_t aSource, const nsACString& aURI) {
|
||||
NS_ASSERTION(
|
||||
aOldParent == mTargetFolderItemId || aNewParent == mTargetFolderItemId,
|
||||
"Got a bookmark message that doesn't belong to us");
|
||||
|
||||
RESTART_AND_RETURN_IF_ASYNC_PENDING();
|
||||
|
||||
|
@ -3352,15 +3347,15 @@ nsNavHistoryFolderResultNode::OnItemMoved(int64_t aItemId, int32_t aOldIndex,
|
|||
// example the Library left pane could have refreshed and replaced the
|
||||
// right pane as a consequence. In such a case our contents are already
|
||||
// up-to-date. That's OK.
|
||||
if (node && aNewParentGUID.Equals(mTargetFolderGuid) &&
|
||||
if (node && aNewParent == mTargetFolderItemId &&
|
||||
index == static_cast<uint32_t>(aNewIndex))
|
||||
return NS_OK;
|
||||
if (!node && aOldParentGUID.Equals(mTargetFolderGuid)) return NS_OK;
|
||||
if (!node && aOldParent == mTargetFolderItemId) return NS_OK;
|
||||
|
||||
if (!StartIncrementalUpdate())
|
||||
return NS_OK; // entire container was refreshed for us
|
||||
|
||||
if (aNewParentGUID.Equals(aOldParentGUID)) {
|
||||
if (aOldParent == aNewParent) {
|
||||
// getting moved within the same folder, we don't want to do a remove and
|
||||
// an add because that will lose your tree state.
|
||||
|
||||
|
@ -3389,13 +3384,13 @@ nsNavHistoryFolderResultNode::OnItemMoved(int64_t aItemId, int32_t aOldIndex,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
if (aOldParentGUID.Equals(mTargetFolderGuid)) {
|
||||
OnItemRemoved(aItemId, mTargetFolderItemId, aOldIndex, aItemType, itemURI,
|
||||
aGUID, aOldParentGUID, aSource);
|
||||
if (aOldParent == mTargetFolderItemId) {
|
||||
OnItemRemoved(aItemId, aOldParent, aOldIndex, aItemType, itemURI, aGUID,
|
||||
aOldParentGUID, aSource);
|
||||
}
|
||||
if (aNewParentGUID.Equals(mTargetFolderGuid)) {
|
||||
if (aNewParent == mTargetFolderItemId) {
|
||||
OnItemAdded(
|
||||
aItemId, mTargetFolderItemId, aNewIndex, aItemType, itemURI,
|
||||
aItemId, aNewParent, aNewIndex, aItemType, itemURI,
|
||||
RoundedPRNow(), // This is a dummy dateAdded, not the real value.
|
||||
aGUID, aNewParentGUID, aSource);
|
||||
}
|
||||
|
@ -3489,7 +3484,7 @@ nsNavHistoryResult::~nsNavHistoryResult() {
|
|||
}
|
||||
|
||||
void nsNavHistoryResult::StopObserving() {
|
||||
AutoTArray<PlacesEventType, 7> events;
|
||||
AutoTArray<PlacesEventType, 6> events;
|
||||
events.AppendElement(PlacesEventType::Favicon_changed);
|
||||
if (mIsBookmarksObserver) {
|
||||
nsNavBookmarks* bookmarks = nsNavBookmarks::GetBookmarksService();
|
||||
|
@ -3499,7 +3494,6 @@ void nsNavHistoryResult::StopObserving() {
|
|||
}
|
||||
events.AppendElement(PlacesEventType::Bookmark_added);
|
||||
events.AppendElement(PlacesEventType::Bookmark_removed);
|
||||
events.AppendElement(PlacesEventType::Bookmark_moved);
|
||||
}
|
||||
if (mIsMobilePrefObserver) {
|
||||
Preferences::UnregisterCallback(OnMobilePrefChangedCallback,
|
||||
|
@ -3598,13 +3592,12 @@ void nsNavHistoryResult::AddMobilePrefsObserver(
|
|||
}
|
||||
|
||||
void nsNavHistoryResult::AddBookmarkFolderObserver(
|
||||
nsNavHistoryFolderResultNode* aNode, const nsACString& aFolderGUID) {
|
||||
MOZ_ASSERT(!aFolderGUID.IsEmpty(), "aFolderGUID should not be empty");
|
||||
nsNavHistoryFolderResultNode* aNode, int64_t aFolder) {
|
||||
EnsureIsObservingBookmarks();
|
||||
// Don't add duplicate observers. In some case we don't unregister when
|
||||
// children are cleared (see ClearChildren) and the next FillChildren call
|
||||
// will try to add the observer again.
|
||||
FolderObserverList* list = BookmarkFolderObserversForGUID(aFolderGUID, true);
|
||||
FolderObserverList* list = BookmarkFolderObserversForId(aFolder, true);
|
||||
if (list->IndexOf(aNode) == FolderObserverList::NoIndex) {
|
||||
list->AppendElement(aNode);
|
||||
}
|
||||
|
@ -3620,10 +3613,9 @@ void nsNavHistoryResult::EnsureIsObservingBookmarks() {
|
|||
return;
|
||||
}
|
||||
bookmarks->AddObserver(this, true);
|
||||
AutoTArray<PlacesEventType, 4> events;
|
||||
AutoTArray<PlacesEventType, 3> events;
|
||||
events.AppendElement(PlacesEventType::Bookmark_added);
|
||||
events.AppendElement(PlacesEventType::Bookmark_removed);
|
||||
events.AppendElement(PlacesEventType::Bookmark_moved);
|
||||
// If we're not observing visits yet, also add a page-visited observer to
|
||||
// serve onItemVisited.
|
||||
if (!mIsHistoryObserver && !mIsHistoryDetailsObserver) {
|
||||
|
@ -3650,23 +3642,22 @@ void nsNavHistoryResult::RemoveMobilePrefsObserver(
|
|||
}
|
||||
|
||||
void nsNavHistoryResult::RemoveBookmarkFolderObserver(
|
||||
nsNavHistoryFolderResultNode* aNode, const nsACString& aFolderGUID) {
|
||||
MOZ_ASSERT(!aFolderGUID.IsEmpty(), "aFolderGUID should not be empty");
|
||||
FolderObserverList* list = BookmarkFolderObserversForGUID(aFolderGUID, false);
|
||||
nsNavHistoryFolderResultNode* aNode, int64_t aFolder) {
|
||||
FolderObserverList* list = BookmarkFolderObserversForId(aFolder, false);
|
||||
if (!list) return; // we don't even have an entry for that folder
|
||||
list->RemoveElement(aNode);
|
||||
}
|
||||
|
||||
nsNavHistoryResult::FolderObserverList*
|
||||
nsNavHistoryResult::BookmarkFolderObserversForGUID(
|
||||
const nsACString& aFolderGUID, bool aCreate) {
|
||||
nsNavHistoryResult::BookmarkFolderObserversForId(int64_t aFolderId,
|
||||
bool aCreate) {
|
||||
FolderObserverList* list;
|
||||
if (mBookmarkFolderObservers.Get(aFolderGUID, &list)) return list;
|
||||
if (mBookmarkFolderObservers.Get(aFolderId, &list)) return list;
|
||||
if (!aCreate) return nullptr;
|
||||
|
||||
// need to create a new list
|
||||
list = new FolderObserverList;
|
||||
mBookmarkFolderObservers.InsertOrUpdate(aFolderGUID, list);
|
||||
mBookmarkFolderObservers.InsertOrUpdate(aFolderId, list);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
@ -3833,16 +3824,15 @@ void nsNavHistoryResult::requestRefresh(
|
|||
// Here, it is important that we create a COPY of the observer array. Some
|
||||
// observers will requery themselves, which may cause the observer array to
|
||||
// be modified or added to.
|
||||
#define ENUMERATE_BOOKMARK_FOLDER_OBSERVERS(_folderGUID, _functionCall) \
|
||||
PR_BEGIN_MACRO \
|
||||
FolderObserverList* _fol = \
|
||||
BookmarkFolderObserversForGUID(_folderGUID, false); \
|
||||
if (_fol) { \
|
||||
FolderObserverList _listCopy(_fol->Clone()); \
|
||||
for (uint32_t _fol_i = 0; _fol_i < _listCopy.Length(); ++_fol_i) { \
|
||||
if (_listCopy[_fol_i]) _listCopy[_fol_i]->_functionCall; \
|
||||
} \
|
||||
} \
|
||||
#define ENUMERATE_BOOKMARK_FOLDER_OBSERVERS(_folderId, _functionCall) \
|
||||
PR_BEGIN_MACRO \
|
||||
FolderObserverList* _fol = BookmarkFolderObserversForId(_folderId, false); \
|
||||
if (_fol) { \
|
||||
FolderObserverList _listCopy(_fol->Clone()); \
|
||||
for (uint32_t _fol_i = 0; _fol_i < _listCopy.Length(); ++_fol_i) { \
|
||||
if (_listCopy[_fol_i]) _listCopy[_fol_i]->_functionCall; \
|
||||
} \
|
||||
} \
|
||||
PR_END_MACRO
|
||||
#define ENUMERATE_LIST_OBSERVERS(_listType, _functionCall, _observersList, \
|
||||
_conditionCall) \
|
||||
|
@ -3923,7 +3913,7 @@ nsNavHistoryResult::OnItemChanged(
|
|||
// opened, meaning we cannot optimize this code path for changes done to
|
||||
// folder-nodes.
|
||||
|
||||
FolderObserverList* list = BookmarkFolderObserversForGUID(aParentGUID, false);
|
||||
FolderObserverList* list = BookmarkFolderObserversForId(aParentId, false);
|
||||
if (!list) return NS_OK;
|
||||
|
||||
for (uint32_t i = 0; i < list->Length(); ++i) {
|
||||
|
@ -3950,6 +3940,37 @@ 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, int64_t aOldParent,
|
||||
int32_t aOldIndex, int64_t aNewParent,
|
||||
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(
|
||||
aOldParent, OnItemMoved(aItemId, aOldParent, aOldIndex, aNewParent,
|
||||
aNewIndex, aItemType, aGUID, aOldParentGUID,
|
||||
aNewParentGUID, aSource, aURI));
|
||||
if (aNewParent != aOldParent) {
|
||||
ENUMERATE_BOOKMARK_FOLDER_OBSERVERS(
|
||||
aNewParent, OnItemMoved(aItemId, aOldParent, aOldIndex, aNewParent,
|
||||
aNewIndex, aItemType, aGUID, aOldParentGUID,
|
||||
aNewParentGUID, aSource, aURI));
|
||||
}
|
||||
ENUMERATE_ALL_BOOKMARKS_OBSERVERS(OnItemMoved(
|
||||
aItemId, aOldParent, aOldIndex, aNewParent, aNewIndex, aItemType, aGUID,
|
||||
aOldParentGUID, aNewParentGUID, aSource, aURI));
|
||||
ENUMERATE_HISTORY_OBSERVERS(OnItemMoved(
|
||||
aItemId, aOldParent, aOldIndex, aNewParent, 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,
|
||||
|
@ -4042,7 +4063,7 @@ nsresult nsNavHistoryResult::OnVisit(nsIURI* aURI, int64_t aVisitId,
|
|||
for (int32_t i = 0; i < nodes.Count(); ++i) {
|
||||
nsNavHistoryResultNode* node = nodes[i];
|
||||
ENUMERATE_BOOKMARK_FOLDER_OBSERVERS(
|
||||
node->mParent->mBookmarkGuid, OnItemVisited(aURI, aVisitId, aTime));
|
||||
node->mParent->mItemId, OnItemVisited(aURI, aVisitId, aTime));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4120,7 +4141,7 @@ void nsNavHistoryResult::HandlePlacesEvent(const PlacesEventSequence& aEvents) {
|
|||
}
|
||||
|
||||
ENUMERATE_BOOKMARK_FOLDER_OBSERVERS(
|
||||
item->mParentGuid,
|
||||
item->mParentId,
|
||||
OnItemAdded(item->mId, item->mParentId, item->mIndex,
|
||||
item->mItemType, uri, item->mDateAdded * 1000,
|
||||
item->mGuid, item->mParentGuid, item->mSource));
|
||||
|
@ -4147,7 +4168,7 @@ void nsNavHistoryResult::HandlePlacesEvent(const PlacesEventSequence& aEvents) {
|
|||
continue;
|
||||
}
|
||||
ENUMERATE_BOOKMARK_FOLDER_OBSERVERS(
|
||||
item->mParentGuid,
|
||||
item->mParentId,
|
||||
OnItemRemoved(item->mId, item->mParentId, item->mIndex,
|
||||
item->mItemType, uri, item->mGuid, item->mParentGuid,
|
||||
item->mSource));
|
||||
|
@ -4159,36 +4180,6 @@ void nsNavHistoryResult::HandlePlacesEvent(const PlacesEventSequence& aEvents) {
|
|||
item->mGuid, item->mParentGuid, item->mSource));
|
||||
break;
|
||||
}
|
||||
case PlacesEventType::Bookmark_moved: {
|
||||
const dom::PlacesBookmarkMoved* item = event->AsPlacesBookmarkMoved();
|
||||
if (NS_WARN_IF(!item)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NS_ConvertUTF16toUTF8 url(item->mUrl);
|
||||
|
||||
ENUMERATE_BOOKMARK_FOLDER_OBSERVERS(
|
||||
item->mOldParentGuid,
|
||||
OnItemMoved(item->mId, item->mOldIndex, item->mIndex,
|
||||
item->mItemType, item->mGuid, item->mOldParentGuid,
|
||||
item->mParentGuid, item->mSource, url));
|
||||
if (!item->mParentGuid.Equals(item->mOldParentGuid)) {
|
||||
ENUMERATE_BOOKMARK_FOLDER_OBSERVERS(
|
||||
item->mParentGuid,
|
||||
OnItemMoved(item->mId, item->mOldIndex, item->mIndex,
|
||||
item->mItemType, item->mGuid, item->mOldParentGuid,
|
||||
item->mParentGuid, item->mSource, url));
|
||||
}
|
||||
ENUMERATE_ALL_BOOKMARKS_OBSERVERS(
|
||||
OnItemMoved(item->mId, item->mOldIndex, item->mIndex,
|
||||
item->mItemType, item->mGuid, item->mOldParentGuid,
|
||||
item->mParentGuid, item->mSource, url));
|
||||
ENUMERATE_HISTORY_OBSERVERS(
|
||||
OnItemMoved(item->mId, item->mOldIndex, item->mIndex,
|
||||
item->mItemType, item->mGuid, item->mOldParentGuid,
|
||||
item->mParentGuid, item->mSource, url));
|
||||
break;
|
||||
}
|
||||
case PlacesEventType::Page_title_changed: {
|
||||
const PlacesVisitTitle* titleEvent = event->AsPlacesVisitTitle();
|
||||
if (NS_WARN_IF(!titleEvent)) {
|
||||
|
|
|
@ -89,12 +89,12 @@ class nsNavHistoryResult final
|
|||
|
||||
void AddHistoryObserver(nsNavHistoryQueryResultNode* aNode);
|
||||
void AddBookmarkFolderObserver(nsNavHistoryFolderResultNode* aNode,
|
||||
const nsACString& aFolderGUID);
|
||||
int64_t aFolder);
|
||||
void AddAllBookmarksObserver(nsNavHistoryQueryResultNode* aNode);
|
||||
void AddMobilePrefsObserver(nsNavHistoryQueryResultNode* aNode);
|
||||
void RemoveHistoryObserver(nsNavHistoryQueryResultNode* aNode);
|
||||
void RemoveBookmarkFolderObserver(nsNavHistoryFolderResultNode* aNode,
|
||||
const nsACString& aFolderGUID);
|
||||
int64_t aFolder);
|
||||
void RemoveAllBookmarksObserver(nsNavHistoryQueryResultNode* aNode);
|
||||
void RemoveMobilePrefsObserver(nsNavHistoryQueryResultNode* aNode);
|
||||
void StopObserving();
|
||||
|
@ -137,9 +137,9 @@ class nsNavHistoryResult final
|
|||
QueryObserverList mMobilePrefObservers;
|
||||
|
||||
typedef nsTArray<RefPtr<nsNavHistoryFolderResultNode> > FolderObserverList;
|
||||
nsTHashMap<nsCStringHashKey, FolderObserverList*> mBookmarkFolderObservers;
|
||||
FolderObserverList* BookmarkFolderObserversForGUID(const nsACString& aGUID,
|
||||
bool aCreate);
|
||||
nsTHashMap<nsTrimInt64HashKey, FolderObserverList*> mBookmarkFolderObservers;
|
||||
FolderObserverList* BookmarkFolderObserversForId(int64_t aFolderId,
|
||||
bool aCreate);
|
||||
|
||||
typedef nsTArray<RefPtr<nsNavHistoryContainerResultNode> >
|
||||
ContainerObserverList;
|
||||
|
@ -688,11 +688,6 @@ 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,
|
||||
|
@ -791,11 +786,6 @@ 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;
|
||||
|
||||
|
|
|
@ -107,22 +107,6 @@ function expectPlacesObserverNotifications(
|
|||
});
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "bookmark-moved":
|
||||
notifications.push({
|
||||
type: event.type,
|
||||
id: event.id,
|
||||
itemType: event.itemType,
|
||||
url: event.url,
|
||||
guid: event.guid,
|
||||
parentGuid: event.parentGuid,
|
||||
source: event.source,
|
||||
index: event.index,
|
||||
oldParentGuid: event.oldParentGuid,
|
||||
oldIndex: event.oldIndex,
|
||||
isTagging: event.isTagging,
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -198,7 +198,7 @@ async function testMoveToFolder(details) {
|
|||
|
||||
let observer;
|
||||
if (details.notifications) {
|
||||
observer = expectPlacesObserverNotifications(["bookmark-moved"]);
|
||||
observer = expectNotifications(true);
|
||||
}
|
||||
|
||||
let movedItems = await PlacesUtils.bookmarks.moveToFolder(
|
||||
|
@ -255,17 +255,20 @@ async function testMoveToFolder(details) {
|
|||
let newFolder = notification.newFolder == "folderA" ? folderA : folderB;
|
||||
|
||||
expectedNotifications.push({
|
||||
type: "bookmark-moved",
|
||||
id: await PlacesUtils.promiseItemId(origItem.guid),
|
||||
itemType: PlacesUtils.bookmarks.TYPE_BOOKMARK,
|
||||
url: origItem.url,
|
||||
guid: origItem.guid,
|
||||
parentGuid: newFolder.guid,
|
||||
source: PlacesUtils.bookmarks.SOURCES.DEFAULT,
|
||||
index: notification.newIndex,
|
||||
oldParentGuid: origItem.parentGuid,
|
||||
oldIndex: notification.originalIndex,
|
||||
isTagging: false,
|
||||
name: "onItemMoved",
|
||||
arguments: [
|
||||
await PlacesUtils.promiseItemId(origItem.guid),
|
||||
await PlacesUtils.promiseItemId(origItem.parentGuid),
|
||||
notification.originalIndex,
|
||||
await PlacesUtils.promiseItemId(newFolder.guid),
|
||||
notification.newIndex,
|
||||
PlacesUtils.bookmarks.TYPE_BOOKMARK,
|
||||
origItem.guid,
|
||||
origItem.parentGuid,
|
||||
newFolder.guid,
|
||||
PlacesUtils.bookmarks.SOURCES.DEFAULT,
|
||||
origItem.url,
|
||||
],
|
||||
});
|
||||
}
|
||||
observer.check(expectedNotifications);
|
||||
|
|
|
@ -326,10 +326,10 @@ add_task(async function update_move_same_folder() {
|
|||
url: new URL("http://move.example.com/"),
|
||||
});
|
||||
let bmItemId = await PlacesUtils.promiseItemId(bm.guid);
|
||||
let bmParentId = await PlacesUtils.promiseItemId(bm.parentGuid);
|
||||
let bmOldIndex = bm.index;
|
||||
|
||||
let observer = expectPlacesObserverNotifications(["bookmark-moved"]);
|
||||
|
||||
let observer = expectNotifications();
|
||||
bm = await PlacesUtils.bookmarks.update({
|
||||
guid: bm.guid,
|
||||
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
|
@ -338,23 +338,26 @@ add_task(async function update_move_same_folder() {
|
|||
Assert.equal(bm.index, 0);
|
||||
observer.check([
|
||||
{
|
||||
type: "bookmark-moved",
|
||||
id: bmItemId,
|
||||
itemType: bm.type,
|
||||
url: "http://move.example.com/",
|
||||
guid: bm.guid,
|
||||
parentGuid: bm.parentGuid,
|
||||
source: Ci.nsINavBookmarksService.SOURCE_DEFAULT,
|
||||
index: bm.index,
|
||||
oldParentGuid: bm.parentGuid,
|
||||
oldIndex: bmOldIndex,
|
||||
isTagging: false,
|
||||
name: "onItemMoved",
|
||||
arguments: [
|
||||
bmItemId,
|
||||
bmParentId,
|
||||
bmOldIndex,
|
||||
bmParentId,
|
||||
bm.index,
|
||||
bm.type,
|
||||
bm.guid,
|
||||
bm.parentGuid,
|
||||
bm.parentGuid,
|
||||
Ci.nsINavBookmarksService.SOURCE_DEFAULT,
|
||||
"http://move.example.com/",
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
||||
// Test that we get the right index for DEFAULT_INDEX input.
|
||||
bmOldIndex = 0;
|
||||
observer = expectPlacesObserverNotifications(["bookmark-moved"]);
|
||||
observer = expectNotifications();
|
||||
bm = await PlacesUtils.bookmarks.update({
|
||||
guid: bm.guid,
|
||||
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
|
@ -363,17 +366,20 @@ add_task(async function update_move_same_folder() {
|
|||
Assert.ok(bm.index > 0);
|
||||
observer.check([
|
||||
{
|
||||
type: "bookmark-moved",
|
||||
id: bmItemId,
|
||||
itemType: bm.type,
|
||||
url: bm.url,
|
||||
guid: bm.guid,
|
||||
parentGuid: bm.parentGuid,
|
||||
source: Ci.nsINavBookmarksService.SOURCE_DEFAULT,
|
||||
index: bm.index,
|
||||
oldParentGuid: bm.parentGuid,
|
||||
oldIndex: bmOldIndex,
|
||||
isTagging: false,
|
||||
name: "onItemMoved",
|
||||
arguments: [
|
||||
bmItemId,
|
||||
bmParentId,
|
||||
bmOldIndex,
|
||||
bmParentId,
|
||||
bm.index,
|
||||
bm.type,
|
||||
bm.guid,
|
||||
bm.parentGuid,
|
||||
bm.parentGuid,
|
||||
Ci.nsINavBookmarksService.SOURCE_DEFAULT,
|
||||
bm.url,
|
||||
],
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
@ -389,66 +395,35 @@ add_task(async function update_move_different_folder() {
|
|||
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
});
|
||||
let bmItemId = await PlacesUtils.promiseItemId(bm.guid);
|
||||
let bmOldParentId = await PlacesUtils.promiseItemId(
|
||||
PlacesUtils.bookmarks.unfiledGuid
|
||||
);
|
||||
let bmOldIndex = bm.index;
|
||||
|
||||
const observer = expectPlacesObserverNotifications(["bookmark-moved"]);
|
||||
let observer = expectNotifications();
|
||||
bm = await PlacesUtils.bookmarks.update({
|
||||
guid: bm.guid,
|
||||
parentGuid: folder.guid,
|
||||
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
|
||||
});
|
||||
Assert.equal(bm.index, 0);
|
||||
let bmNewParentId = await PlacesUtils.promiseItemId(folder.guid);
|
||||
observer.check([
|
||||
{
|
||||
type: "bookmark-moved",
|
||||
id: bmItemId,
|
||||
itemType: bm.type,
|
||||
url: "http://move.example.com/",
|
||||
guid: bm.guid,
|
||||
parentGuid: bm.parentGuid,
|
||||
source: Ci.nsINavBookmarksService.SOURCE_DEFAULT,
|
||||
index: bm.index,
|
||||
oldParentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
oldIndex: bmOldIndex,
|
||||
isTagging: false,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
add_task(async function update_move_tag_folder() {
|
||||
let bm = await PlacesUtils.bookmarks.insert({
|
||||
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
|
||||
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
url: new URL("http://move.example.com/"),
|
||||
});
|
||||
let folder = await PlacesUtils.bookmarks.insert({
|
||||
type: PlacesUtils.bookmarks.TYPE_FOLDER,
|
||||
parentGuid: PlacesUtils.bookmarks.tagsGuid,
|
||||
title: "tag",
|
||||
});
|
||||
let bmItemId = await PlacesUtils.promiseItemId(bm.guid);
|
||||
let bmOldIndex = bm.index;
|
||||
|
||||
const observer = expectPlacesObserverNotifications(["bookmark-moved"]);
|
||||
bm = await PlacesUtils.bookmarks.update({
|
||||
guid: bm.guid,
|
||||
parentGuid: folder.guid,
|
||||
index: PlacesUtils.bookmarks.DEFAULT_INDEX,
|
||||
});
|
||||
Assert.equal(bm.index, 0);
|
||||
observer.check([
|
||||
{
|
||||
type: "bookmark-moved",
|
||||
id: bmItemId,
|
||||
itemType: bm.type,
|
||||
url: "http://move.example.com/",
|
||||
guid: bm.guid,
|
||||
parentGuid: bm.parentGuid,
|
||||
source: Ci.nsINavBookmarksService.SOURCE_DEFAULT,
|
||||
index: bm.index,
|
||||
oldParentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
oldIndex: bmOldIndex,
|
||||
isTagging: true,
|
||||
name: "onItemMoved",
|
||||
arguments: [
|
||||
bmItemId,
|
||||
bmOldParentId,
|
||||
bmOldIndex,
|
||||
bmNewParentId,
|
||||
bm.index,
|
||||
bm.type,
|
||||
bm.guid,
|
||||
PlacesUtils.bookmarks.unfiledGuid,
|
||||
bm.parentGuid,
|
||||
Ci.nsINavBookmarksService.SOURCE_DEFAULT,
|
||||
"http://move.example.com/",
|
||||
],
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
@ -912,31 +887,36 @@ add_task(async function reorder_notification() {
|
|||
// Randomly reorder the array.
|
||||
sorted.sort(() => 0.5 - Math.random());
|
||||
|
||||
const observer = expectPlacesObserverNotifications(["bookmark-moved"]);
|
||||
let observer = expectNotifications();
|
||||
await PlacesUtils.bookmarks.reorder(
|
||||
PlacesUtils.bookmarks.unfiledGuid,
|
||||
sorted.map(bm => bm.guid)
|
||||
);
|
||||
|
||||
let expectedNotifications = [];
|
||||
let unfiledBookmarksFolderId = await PlacesUtils.promiseItemId(
|
||||
PlacesUtils.bookmarks.unfiledGuid
|
||||
);
|
||||
for (let i = 0; i < sorted.length; ++i) {
|
||||
let child = sorted[i];
|
||||
let childId = await PlacesUtils.promiseItemId(child.guid);
|
||||
expectedNotifications.push({
|
||||
type: "bookmark-moved",
|
||||
id: childId,
|
||||
itemType: child.type,
|
||||
url: child.url || "",
|
||||
guid: child.guid,
|
||||
parentGuid: child.parentGuid,
|
||||
source: Ci.nsINavBookmarksService.SOURCE_DEFAULT,
|
||||
index: i,
|
||||
oldParentGuid: child.parentGuid,
|
||||
oldIndex: child.index,
|
||||
isTagging: false,
|
||||
name: "onItemMoved",
|
||||
arguments: [
|
||||
childId,
|
||||
unfiledBookmarksFolderId,
|
||||
child.index,
|
||||
unfiledBookmarksFolderId,
|
||||
i,
|
||||
child.type,
|
||||
child.guid,
|
||||
child.parentGuid,
|
||||
child.parentGuid,
|
||||
Ci.nsINavBookmarksService.SOURCE_DEFAULT,
|
||||
child.url,
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
observer.check(expectedNotifications);
|
||||
});
|
||||
|
||||
|
|
|
@ -60,6 +60,9 @@ var gBookmarksObserver = {
|
|||
onItemChanged() {
|
||||
return this.validate("onItemChanged", arguments);
|
||||
},
|
||||
onItemMoved() {
|
||||
return this.validate("onItemMoved", arguments);
|
||||
},
|
||||
|
||||
// nsISupports
|
||||
QueryInterface: ChromeUtils.generateQI(["nsINavBookmarkObserver"]),
|
||||
|
@ -103,6 +106,9 @@ var gBookmarkSkipObserver = {
|
|||
onItemChanged() {
|
||||
return this.validate("onItemChanged", arguments);
|
||||
},
|
||||
onItemMoved() {
|
||||
return this.validate("onItemMoved", arguments);
|
||||
},
|
||||
|
||||
// nsISupports
|
||||
QueryInterface: ChromeUtils.generateQI(["nsINavBookmarkObserver"]),
|
||||
|
@ -121,11 +127,11 @@ add_task(async function setup() {
|
|||
gBookmarkSkipObserver
|
||||
);
|
||||
PlacesUtils.observers.addListener(
|
||||
["bookmark-added", "bookmark-removed", "bookmark-moved"],
|
||||
["bookmark-added", "bookmark-removed"],
|
||||
gBookmarksObserver.handlePlacesEvents
|
||||
);
|
||||
PlacesUtils.observers.addListener(
|
||||
["bookmark-added", "bookmark-removed", "bookmark-moved"],
|
||||
["bookmark-added", "bookmark-removed"],
|
||||
gBookmarkSkipObserver.handlePlacesEvents
|
||||
);
|
||||
});
|
||||
|
@ -486,20 +492,25 @@ add_task(async function onItemChanged_tags_bookmark() {
|
|||
await promise;
|
||||
});
|
||||
|
||||
add_task(async function bookmarkItemMoved_bookmark() {
|
||||
add_task(async function onItemMoved_bookmark() {
|
||||
let bm = await PlacesUtils.bookmarks.fetch({
|
||||
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
index: 0,
|
||||
});
|
||||
let promise = Promise.all([
|
||||
gBookmarkSkipObserver.setup(["bookmark-moved", "bookmark-moved"]),
|
||||
gBookmarkSkipObserver.setup(["onItemMoved", "onItemMoved"]),
|
||||
gBookmarksObserver.setup([
|
||||
{
|
||||
eventType: "bookmark-moved",
|
||||
name: "onItemMoved",
|
||||
args: [
|
||||
{ name: "id", check: v => typeof v == "number" && v > 0 },
|
||||
{ name: "itemId", check: v => typeof v == "number" && v > 0 },
|
||||
{ name: "oldParentId", check: v => v === gUnfiledFolderId },
|
||||
{ name: "oldIndex", check: v => v === 0 },
|
||||
{ name: "index", check: v => v === 0 },
|
||||
{
|
||||
name: "newParentId",
|
||||
check: v => v === PlacesUtils.toolbarFolderId,
|
||||
},
|
||||
{ name: "newIndex", check: v => v === 0 },
|
||||
{
|
||||
name: "itemType",
|
||||
check: v => v === PlacesUtils.bookmarks.TYPE_BOOKMARK,
|
||||
|
@ -513,7 +524,7 @@ add_task(async function bookmarkItemMoved_bookmark() {
|
|||
check: v => typeof v == "string" && PlacesUtils.isValidGuid(v),
|
||||
},
|
||||
{
|
||||
name: "parentGuid",
|
||||
name: "newParentGuid",
|
||||
check: v => typeof v == "string" && PlacesUtils.isValidGuid(v),
|
||||
},
|
||||
{
|
||||
|
@ -525,11 +536,16 @@ add_task(async function bookmarkItemMoved_bookmark() {
|
|||
],
|
||||
},
|
||||
{
|
||||
eventType: "bookmark-moved",
|
||||
name: "onItemMoved",
|
||||
args: [
|
||||
{ name: "id", check: v => typeof v == "number" && v > 0 },
|
||||
{ name: "itemId", check: v => typeof v == "number" && v > 0 },
|
||||
{
|
||||
name: "oldParentId",
|
||||
check: v => v === PlacesUtils.toolbarFolderId,
|
||||
},
|
||||
{ name: "oldIndex", check: v => v === 0 },
|
||||
{ name: "index", check: v => v === 0 },
|
||||
{ name: "newParentId", check: v => v === gUnfiledFolderId },
|
||||
{ name: "newIndex", check: v => v === 0 },
|
||||
{
|
||||
name: "itemType",
|
||||
check: v => v === PlacesUtils.bookmarks.TYPE_BOOKMARK,
|
||||
|
@ -543,7 +559,7 @@ add_task(async function bookmarkItemMoved_bookmark() {
|
|||
check: v => typeof v == "string" && PlacesUtils.isValidGuid(v),
|
||||
},
|
||||
{
|
||||
name: "parentGuid",
|
||||
name: "newParentGuid",
|
||||
check: v => typeof v == "string" && PlacesUtils.isValidGuid(v),
|
||||
},
|
||||
{
|
||||
|
|
|
@ -25,6 +25,7 @@ function promiseOnItemChanged() {
|
|||
return new Promise(resolve => {
|
||||
PlacesUtils.bookmarks.addObserver({
|
||||
onItemRemoved() {},
|
||||
onItemMoved() {},
|
||||
|
||||
onItemChanged() {
|
||||
PlacesUtils.bookmarks.removeObserver(this);
|
||||
|
|
|
@ -722,6 +722,7 @@ function NavBookmarkObserver() {}
|
|||
NavBookmarkObserver.prototype = {
|
||||
onItemRemoved() {},
|
||||
onItemChanged() {},
|
||||
onItemMoved() {},
|
||||
QueryInterface: ChromeUtils.generateQI(["nsINavBookmarkObserver"]),
|
||||
};
|
||||
|
||||
|
|
|
@ -59,6 +59,13 @@ var bookmarksObserver = {
|
|||
this._itemChangedValue = value;
|
||||
this._itemChangedOldValue = oldValue;
|
||||
},
|
||||
onItemMoved(id, oldParent, oldIndex, newParent, newIndex, itemType) {
|
||||
this._itemMovedId = id;
|
||||
this._itemMovedOldParent = oldParent;
|
||||
this._itemMovedOldIndex = oldIndex;
|
||||
this._itemMovedNewParent = newParent;
|
||||
this._itemMovedNewIndex = newIndex;
|
||||
},
|
||||
QueryInterface: ChromeUtils.generateQI(["nsINavBookmarkObserver"]),
|
||||
};
|
||||
|
||||
|
|
|
@ -344,22 +344,6 @@ BookmarkObserver.prototype = {
|
|||
this.notifications.push({ name: "bookmark-removed", params });
|
||||
break;
|
||||
}
|
||||
case "bookmark-moved": {
|
||||
const params = {
|
||||
itemId: event.id,
|
||||
type: event.itemType,
|
||||
urlHref: event.url,
|
||||
source: event.source,
|
||||
guid: event.guid,
|
||||
newIndex: event.index,
|
||||
newParentGuid: event.parentGuid,
|
||||
oldIndex: event.oldIndex,
|
||||
oldParentGuid: event.oldParentGuid,
|
||||
isTagging: event.isTagging,
|
||||
};
|
||||
this.notifications.push({ name: "bookmark-moved", params });
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -393,13 +377,43 @@ BookmarkObserver.prototype = {
|
|||
}
|
||||
this.notifications.push({ name: "onItemChanged", params });
|
||||
},
|
||||
onItemMoved(
|
||||
itemId,
|
||||
oldParentId,
|
||||
oldIndex,
|
||||
newParentId,
|
||||
newIndex,
|
||||
type,
|
||||
guid,
|
||||
oldParentGuid,
|
||||
newParentGuid,
|
||||
source,
|
||||
urlHref
|
||||
) {
|
||||
this.notifications.push({
|
||||
name: "onItemMoved",
|
||||
params: {
|
||||
itemId,
|
||||
oldParentId,
|
||||
oldIndex,
|
||||
newParentId,
|
||||
newIndex,
|
||||
type,
|
||||
guid,
|
||||
oldParentGuid,
|
||||
newParentGuid,
|
||||
source,
|
||||
urlHref,
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
QueryInterface: ChromeUtils.generateQI(["nsINavBookmarkObserver"]),
|
||||
|
||||
check(expectedNotifications) {
|
||||
PlacesUtils.bookmarks.removeObserver(this);
|
||||
PlacesUtils.observers.removeListener(
|
||||
["bookmark-added", "bookmark-removed", "bookmark-moved"],
|
||||
["bookmark-added", "bookmark-removed"],
|
||||
this.handlePlacesEvents
|
||||
);
|
||||
if (!ObjectUtils.deepEqual(this.notifications, expectedNotifications)) {
|
||||
|
@ -417,7 +431,7 @@ function expectBookmarkChangeNotifications(options) {
|
|||
let observer = new BookmarkObserver(options);
|
||||
PlacesUtils.bookmarks.addObserver(observer);
|
||||
PlacesUtils.observers.addListener(
|
||||
["bookmark-added", "bookmark-removed", "bookmark-moved"],
|
||||
["bookmark-added", "bookmark-removed"],
|
||||
observer.handlePlacesEvents
|
||||
);
|
||||
return observer;
|
||||
|
|
|
@ -476,10 +476,12 @@ add_task(async function test_apply_then_revert() {
|
|||
},
|
||||
},
|
||||
{
|
||||
name: "bookmark-moved",
|
||||
name: "onItemMoved",
|
||||
params: {
|
||||
itemId: localItemIds.get("bookmarkEEEE"),
|
||||
oldParentId: PlacesUtils.bookmarksMenuFolderId,
|
||||
oldIndex: 2,
|
||||
newParentId: PlacesUtils.bookmarksMenuFolderId,
|
||||
newIndex: 0,
|
||||
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
|
||||
guid: "bookmarkEEEE",
|
||||
|
@ -487,29 +489,31 @@ add_task(async function test_apply_then_revert() {
|
|||
newParentGuid: PlacesUtils.bookmarks.menuGuid,
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC,
|
||||
urlHref: "http://example.com/e",
|
||||
isTagging: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "bookmark-moved",
|
||||
name: "onItemMoved",
|
||||
params: {
|
||||
itemId: localItemIds.get("folderAAAAAA"),
|
||||
oldParentId: PlacesUtils.bookmarksMenuFolderId,
|
||||
oldIndex: 0,
|
||||
newParentId: PlacesUtils.toolbarFolderId,
|
||||
newIndex: 0,
|
||||
type: PlacesUtils.bookmarks.TYPE_FOLDER,
|
||||
guid: "folderAAAAAA",
|
||||
oldParentGuid: PlacesUtils.bookmarks.menuGuid,
|
||||
newParentGuid: PlacesUtils.bookmarks.toolbarGuid,
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC,
|
||||
urlHref: "",
|
||||
isTagging: false,
|
||||
urlHref: null,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "bookmark-moved",
|
||||
name: "onItemMoved",
|
||||
params: {
|
||||
itemId: localItemIds.get("bookmarkCCCC"),
|
||||
oldParentId: localItemIds.get("folderAAAAAA"),
|
||||
oldIndex: 1,
|
||||
newParentId: localItemIds.get("folderAAAAAA"),
|
||||
newIndex: 0,
|
||||
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
|
||||
guid: "bookmarkCCCC",
|
||||
|
@ -517,14 +521,15 @@ add_task(async function test_apply_then_revert() {
|
|||
newParentGuid: "folderAAAAAA",
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC,
|
||||
urlHref: "http://example.com/c",
|
||||
isTagging: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "bookmark-moved",
|
||||
name: "onItemMoved",
|
||||
params: {
|
||||
itemId: localItemIds.get("bookmarkBBBB"),
|
||||
oldParentId: localItemIds.get("folderAAAAAA"),
|
||||
oldIndex: 0,
|
||||
newParentId: localItemIds.get("folderAAAAAA"),
|
||||
newIndex: 1,
|
||||
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
|
||||
guid: "bookmarkBBBB",
|
||||
|
@ -532,7 +537,6 @@ add_task(async function test_apply_then_revert() {
|
|||
newParentGuid: "folderAAAAAA",
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC,
|
||||
urlHref: "http://example.com/b-remote",
|
||||
isTagging: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
@ -149,10 +149,12 @@ add_task(async function test_value_structure_conflict() {
|
|||
]);
|
||||
observer.check([
|
||||
{
|
||||
name: "bookmark-moved",
|
||||
name: "onItemMoved",
|
||||
params: {
|
||||
itemId: localItemIds.get("bookmarkEEEE"),
|
||||
oldParentId: localItemIds.get("folderDDDDDD"),
|
||||
oldIndex: 1,
|
||||
newParentId: localItemIds.get("folderDDDDDD"),
|
||||
newIndex: 0,
|
||||
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
|
||||
guid: "bookmarkEEEE",
|
||||
|
@ -160,14 +162,15 @@ add_task(async function test_value_structure_conflict() {
|
|||
newParentGuid: "folderDDDDDD",
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC,
|
||||
urlHref: "http://example.com/e",
|
||||
isTagging: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "bookmark-moved",
|
||||
name: "onItemMoved",
|
||||
params: {
|
||||
itemId: localItemIds.get("bookmarkBBBB"),
|
||||
oldParentId: localItemIds.get("folderDDDDDD"),
|
||||
oldIndex: 0,
|
||||
newParentId: localItemIds.get("folderDDDDDD"),
|
||||
newIndex: 1,
|
||||
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
|
||||
guid: "bookmarkBBBB",
|
||||
|
@ -175,7 +178,6 @@ add_task(async function test_value_structure_conflict() {
|
|||
newParentGuid: "folderDDDDDD",
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC,
|
||||
urlHref: "http://example.com/b",
|
||||
isTagging: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -400,40 +402,46 @@ add_task(async function test_move() {
|
|||
]);
|
||||
observer.check([
|
||||
{
|
||||
name: "bookmark-moved",
|
||||
name: "onItemMoved",
|
||||
params: {
|
||||
itemId: localItemIds.get("devFolder___"),
|
||||
oldParentId: PlacesUtils.bookmarksMenuFolderId,
|
||||
oldIndex: 0,
|
||||
newParentId: PlacesUtils.toolbarFolderId,
|
||||
newIndex: 0,
|
||||
type: PlacesUtils.bookmarks.TYPE_FOLDER,
|
||||
guid: "devFolder___",
|
||||
oldParentGuid: PlacesUtils.bookmarks.menuGuid,
|
||||
newParentGuid: PlacesUtils.bookmarks.toolbarGuid,
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC,
|
||||
urlHref: "",
|
||||
isTagging: false,
|
||||
urlHref: null,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "bookmark-moved",
|
||||
name: "onItemMoved",
|
||||
params: {
|
||||
itemId: localItemIds.get("mozFolder___"),
|
||||
oldParentId: localItemIds.get("devFolder___"),
|
||||
oldIndex: 1,
|
||||
newParentId: await PlacesUtils.promiseItemId(
|
||||
PlacesUtils.bookmarks.unfiledGuid
|
||||
),
|
||||
newIndex: 0,
|
||||
type: PlacesUtils.bookmarks.TYPE_FOLDER,
|
||||
guid: "mozFolder___",
|
||||
oldParentGuid: "devFolder___",
|
||||
newParentGuid: PlacesUtils.bookmarks.unfiledGuid,
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC,
|
||||
urlHref: "",
|
||||
isTagging: false,
|
||||
urlHref: null,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "bookmark-moved",
|
||||
name: "onItemMoved",
|
||||
params: {
|
||||
itemId: localItemIds.get("bzBmk_______"),
|
||||
oldParentId: PlacesUtils.bookmarksMenuFolderId,
|
||||
oldIndex: 1,
|
||||
newParentId: localItemIds.get("devFolder___"),
|
||||
newIndex: 0,
|
||||
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
|
||||
guid: "bzBmk_______",
|
||||
|
@ -441,14 +449,15 @@ add_task(async function test_move() {
|
|||
newParentGuid: "devFolder___",
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC,
|
||||
urlHref: "https://bugzilla.mozilla.org/",
|
||||
isTagging: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "bookmark-moved",
|
||||
name: "onItemMoved",
|
||||
params: {
|
||||
itemId: localItemIds.get("wmBmk_______"),
|
||||
oldParentId: localItemIds.get("devFolder___"),
|
||||
oldIndex: 2,
|
||||
newParentId: localItemIds.get("devFolder___"),
|
||||
newIndex: 1,
|
||||
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
|
||||
guid: "wmBmk_______",
|
||||
|
@ -456,14 +465,15 @@ add_task(async function test_move() {
|
|||
newParentGuid: "devFolder___",
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC,
|
||||
urlHref: "https://webmaker.org/",
|
||||
isTagging: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "bookmark-moved",
|
||||
name: "onItemMoved",
|
||||
params: {
|
||||
itemId: localItemIds.get("nightlyBmk__"),
|
||||
oldParentId: localItemIds.get("mozFolder___"),
|
||||
oldIndex: 1,
|
||||
newParentId: localItemIds.get("mozFolder___"),
|
||||
newIndex: 0,
|
||||
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
|
||||
guid: "nightlyBmk__",
|
||||
|
@ -471,14 +481,15 @@ add_task(async function test_move() {
|
|||
newParentGuid: "mozFolder___",
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC,
|
||||
urlHref: "https://nightly.mozilla.org/",
|
||||
isTagging: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "bookmark-moved",
|
||||
name: "onItemMoved",
|
||||
params: {
|
||||
itemId: localItemIds.get("mdnBmk______"),
|
||||
oldParentId: localItemIds.get("devFolder___"),
|
||||
oldIndex: 0,
|
||||
newParentId: localItemIds.get("mozFolder___"),
|
||||
newIndex: 1,
|
||||
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
|
||||
guid: "mdnBmk______",
|
||||
|
@ -486,14 +497,15 @@ add_task(async function test_move() {
|
|||
newParentGuid: "mozFolder___",
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC,
|
||||
urlHref: "https://developer.mozilla.org/",
|
||||
isTagging: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "bookmark-moved",
|
||||
name: "onItemMoved",
|
||||
params: {
|
||||
itemId: localItemIds.get("fxBmk_______"),
|
||||
oldParentId: localItemIds.get("mozFolder___"),
|
||||
oldIndex: 0,
|
||||
newParentId: localItemIds.get("mozFolder___"),
|
||||
newIndex: 2,
|
||||
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
|
||||
guid: "fxBmk_______",
|
||||
|
@ -501,7 +513,6 @@ add_task(async function test_move() {
|
|||
newParentGuid: "mozFolder___",
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC,
|
||||
urlHref: "http://getfirefox.com/",
|
||||
isTagging: false,
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
@ -723,10 +734,12 @@ add_task(async function test_move_into_parent_sibling() {
|
|||
},
|
||||
},
|
||||
{
|
||||
name: "bookmark-moved",
|
||||
name: "onItemMoved",
|
||||
params: {
|
||||
itemId: localItemIds.get("bookmarkBBBB"),
|
||||
oldParentId: localItemIds.get("folderAAAAAA"),
|
||||
oldIndex: 0,
|
||||
newParentId: localItemIds.get("folderCCCCCC"),
|
||||
newIndex: 0,
|
||||
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
|
||||
guid: "bookmarkBBBB",
|
||||
|
@ -734,7 +747,6 @@ add_task(async function test_move_into_parent_sibling() {
|
|||
newParentGuid: "folderCCCCCC",
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC,
|
||||
urlHref: "http://example.com/b",
|
||||
isTagging: false,
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
@ -941,10 +953,12 @@ add_task(async function test_complex_move_with_additions() {
|
|||
},
|
||||
},
|
||||
{
|
||||
name: "bookmark-moved",
|
||||
name: "onItemMoved",
|
||||
params: {
|
||||
itemId: localItemIds.get("bookmarkCCCC"),
|
||||
oldParentId: localItemIds.get("folderAAAAAA"),
|
||||
oldIndex: 1,
|
||||
newParentId: PlacesUtils.bookmarksMenuFolderId,
|
||||
newIndex: 0,
|
||||
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
|
||||
guid: "bookmarkCCCC",
|
||||
|
@ -952,22 +966,22 @@ add_task(async function test_complex_move_with_additions() {
|
|||
newParentGuid: PlacesUtils.bookmarks.menuGuid,
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC,
|
||||
urlHref: "http://example.com/c",
|
||||
isTagging: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "bookmark-moved",
|
||||
name: "onItemMoved",
|
||||
params: {
|
||||
itemId: localItemIds.get("folderAAAAAA"),
|
||||
oldParentId: PlacesUtils.bookmarksMenuFolderId,
|
||||
oldIndex: 0,
|
||||
newParentId: PlacesUtils.toolbarFolderId,
|
||||
newIndex: 0,
|
||||
type: PlacesUtils.bookmarks.TYPE_FOLDER,
|
||||
guid: "folderAAAAAA",
|
||||
oldParentGuid: PlacesUtils.bookmarks.menuGuid,
|
||||
newParentGuid: PlacesUtils.bookmarks.toolbarGuid,
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC,
|
||||
urlHref: "",
|
||||
isTagging: false,
|
||||
urlHref: null,
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
|
|
@ -218,10 +218,12 @@ add_task(async function test_value_combo() {
|
|||
},
|
||||
},
|
||||
{
|
||||
name: "bookmark-moved",
|
||||
name: "onItemMoved",
|
||||
params: {
|
||||
itemId: localItemIds.get("bzBmk_______"),
|
||||
oldParentId: PlacesUtils.toolbarFolderId,
|
||||
oldIndex: 0,
|
||||
newParentId: PlacesUtils.toolbarFolderId,
|
||||
newIndex: 2,
|
||||
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
|
||||
guid: "bzBmk_______",
|
||||
|
@ -229,7 +231,6 @@ add_task(async function test_value_combo() {
|
|||
newParentGuid: PlacesUtils.bookmarks.toolbarGuid,
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC,
|
||||
urlHref: "https://bugzilla.mozilla.org/",
|
||||
isTagging: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -1365,15 +1366,17 @@ add_task(async function test_keywords_complex() {
|
|||
},
|
||||
},
|
||||
{
|
||||
// These `bookmark-moved` notifications aren't necessary: we only moved
|
||||
// These `onItemMoved` notifications aren't necessary: we only moved
|
||||
// (B C D E) to accomodate (A A1 B1), and Places doesn't usually fire move
|
||||
// notifications for repositioned siblings. However, detecting and filtering
|
||||
// these out complicates `noteObserverChanges`, so, for simplicity, we
|
||||
// record and fire the extra notifications.
|
||||
name: "bookmark-moved",
|
||||
name: "onItemMoved",
|
||||
params: {
|
||||
itemId: localItemIds.get("bookmarkBBBB"),
|
||||
oldParentId: PlacesUtils.bookmarksMenuFolderId,
|
||||
oldIndex: 0,
|
||||
newParentId: PlacesUtils.bookmarksMenuFolderId,
|
||||
newIndex: 3,
|
||||
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
|
||||
guid: "bookmarkBBBB",
|
||||
|
@ -1381,14 +1384,15 @@ add_task(async function test_keywords_complex() {
|
|||
newParentGuid: PlacesUtils.bookmarks.menuGuid,
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC,
|
||||
urlHref: "http://example.com/b",
|
||||
isTagging: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "bookmark-moved",
|
||||
name: "onItemMoved",
|
||||
params: {
|
||||
itemId: localItemIds.get("bookmarkCCCC"),
|
||||
oldParentId: PlacesUtils.bookmarksMenuFolderId,
|
||||
oldIndex: 1,
|
||||
newParentId: PlacesUtils.bookmarksMenuFolderId,
|
||||
newIndex: 4,
|
||||
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
|
||||
guid: "bookmarkCCCC",
|
||||
|
@ -1396,14 +1400,15 @@ add_task(async function test_keywords_complex() {
|
|||
newParentGuid: PlacesUtils.bookmarks.menuGuid,
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC,
|
||||
urlHref: "http://example.com/c-remote",
|
||||
isTagging: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "bookmark-moved",
|
||||
name: "onItemMoved",
|
||||
params: {
|
||||
itemId: localItemIds.get("bookmarkDDDD"),
|
||||
oldParentId: PlacesUtils.bookmarksMenuFolderId,
|
||||
oldIndex: 2,
|
||||
newParentId: PlacesUtils.bookmarksMenuFolderId,
|
||||
newIndex: 5,
|
||||
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
|
||||
guid: "bookmarkDDDD",
|
||||
|
@ -1411,14 +1416,15 @@ add_task(async function test_keywords_complex() {
|
|||
newParentGuid: PlacesUtils.bookmarks.menuGuid,
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC,
|
||||
urlHref: "http://example.com/d",
|
||||
isTagging: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "bookmark-moved",
|
||||
name: "onItemMoved",
|
||||
params: {
|
||||
itemId: localItemIds.get("bookmarkEEEE"),
|
||||
oldParentId: PlacesUtils.bookmarksMenuFolderId,
|
||||
oldIndex: 3,
|
||||
newParentId: PlacesUtils.bookmarksMenuFolderId,
|
||||
newIndex: 6,
|
||||
type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
|
||||
guid: "bookmarkEEEE",
|
||||
|
@ -1426,7 +1432,6 @@ add_task(async function test_keywords_complex() {
|
|||
newParentGuid: PlacesUtils.bookmarks.menuGuid,
|
||||
source: PlacesUtils.bookmarks.SOURCES.SYNC,
|
||||
urlHref: "http://example.com/e",
|
||||
isTagging: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
@ -58,16 +58,6 @@ var observer = {
|
|||
index: event.index,
|
||||
itemType: event.itemType,
|
||||
});
|
||||
break;
|
||||
case "bookmark-moved":
|
||||
this.itemsMoved.set(event.guid, {
|
||||
oldParentGuid: event.oldParentGuid,
|
||||
oldIndex: event.oldIndex,
|
||||
newParentGuid: event.parentGuid,
|
||||
newIndex: event.index,
|
||||
itemType: event.itemType,
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -100,6 +90,26 @@ var observer = {
|
|||
};
|
||||
changesForGuid.set(aProperty, change);
|
||||
},
|
||||
|
||||
onItemMoved(
|
||||
aItemId,
|
||||
aOldParent,
|
||||
aOldIndex,
|
||||
aNewParent,
|
||||
aNewIndex,
|
||||
aItemType,
|
||||
aGuid,
|
||||
aOldParentGuid,
|
||||
aNewParentGuid
|
||||
) {
|
||||
this.itemsMoved.set(aGuid, {
|
||||
oldParentGuid: aOldParentGuid,
|
||||
oldIndex: aOldIndex,
|
||||
newParentGuid: aNewParentGuid,
|
||||
newIndex: aNewIndex,
|
||||
itemType: aItemType,
|
||||
});
|
||||
},
|
||||
};
|
||||
observer.reset();
|
||||
|
||||
|
@ -110,13 +120,13 @@ function run_test() {
|
|||
bmsvc.addObserver(observer);
|
||||
observer.handlePlacesEvents = observer.handlePlacesEvents.bind(observer);
|
||||
obsvc.addListener(
|
||||
["bookmark-added", "bookmark-removed", "bookmark-moved"],
|
||||
["bookmark-added", "bookmark-removed"],
|
||||
observer.handlePlacesEvents
|
||||
);
|
||||
registerCleanupFunction(function() {
|
||||
bmsvc.removeObserver(observer);
|
||||
obsvc.removeListener(
|
||||
["bookmark-added", "bookmark-removed", "bookmark-moved"],
|
||||
["bookmark-added", "bookmark-removed"],
|
||||
observer.handlePlacesEvents
|
||||
);
|
||||
});
|
||||
|
|
|
@ -51,6 +51,8 @@ add_task(async function run_test() {
|
|||
}
|
||||
}
|
||||
},
|
||||
|
||||
onItemMoved() {},
|
||||
};
|
||||
PlacesUtils.bookmarks.addObserver(bookmarksObserver);
|
||||
bookmarksObserver.handlePlacesEvents = bookmarksObserver.handlePlacesEvents.bind(
|
||||
|
|
|
@ -427,7 +427,6 @@ module.exports = {
|
|||
Permissions: false,
|
||||
PlacesBookmark: false,
|
||||
PlacesBookmarkAddition: false,
|
||||
PlacesBookmarkMoved: false,
|
||||
PlacesBookmarkRemoved: false,
|
||||
PlacesEvent: false,
|
||||
PlacesHistoryCleared: false,
|
||||
|
|
Загрузка…
Ссылка в новой задаче