--- a/browser/components/places/content/controller.js
+++ b/browser/components/places/content/controller.js
@@ -1309,43 +1309,41 @@ PlacesController.prototype = {
items = PlacesUtils.unwrapNodes(data, type);
} catch (ex) {
// No supported data exists or nodes unwrap failed, just bail out.
return;
}
let itemsToSelect = [];
if (PlacesUIUtils.useAsyncTransactions) {
+ let transactions = [];
if (ip.isTag) {
let urls = items.filter(item => "uri" in item).map(item => Services.io.newURI(item.uri));
- await PlacesTransactions.Tag({ urls, tag: ip.tagName }).transact();
+ transactions.push(PlacesTransactions.Tag({ urls, tag: ip.tagName }));
} else {
- let transactions = [];
-
let insertionIndex = await ip.getIndex();
let doCopy = action == "copy";
let newTransactions = await getTransactionsForTransferItems(
items, insertionIndex, ip.guid, doCopy);
if (newTransactions.length) {
transactions = [...transactions, ...newTransactions];
}
-
- // Note: this._view may be a view or the tree element.
- let resultForBatching = getResultForBatching(this._view);
+ }
+ // Note: this._view may be a view or the tree element.
+ let resultForBatching = getResultForBatching(this._view);
- await PlacesUIUtils.batchUpdatesForNode(resultForBatching,
- transactions.length, async () => {
- await PlacesTransactions.batch(async () => {
- for (let transaction of transactions) {
- let guid = await transaction.transact();
- itemsToSelect.push(await PlacesUtils.promiseItemId(guid));
- }
- });
+ await PlacesUIUtils.batchUpdatesForNode(resultForBatching,
+ transactions.length, async () => {
+ await PlacesTransactions.batch(async () => {
+ for (let transaction of transactions) {
+ let guid = await transaction.transact();
+ itemsToSelect.push(await PlacesUtils.promiseItemId(guid));
+ }
});
- }
+ });
} else {
let transactions = [];
let insertionIndex = await ip.getIndex();
for (let index = insertionIndex, i = 0; i < items.length; ++i) {
if (ip.isTag) {
// Pasting into a tag container means tagging the item, regardless of
// the requested action.
let tagTxn = new PlacesTagURITransaction(NetUtil.newURI(items[i].uri),
@@ -1643,44 +1641,76 @@ var PlacesControllerDragHelper = {
let handled = duplicable.get(flavor);
if (handled.has(data))
continue;
handled.add(data);
}
dtItems.push({flavor, data});
}
- for (let {flavor, data} of dtItems) {
- let nodes;
- if (flavor != TAB_DROP_TYPE) {
- nodes = PlacesUtils.unwrapNodes(data, flavor);
- } else if (data instanceof XULElement && data.localName == "tab" &&
- data.ownerGlobal.isChromeWindow) {
- let uri = data.linkedBrowser.currentURI;
- let spec = uri ? uri.spec : "about:blank";
- nodes = [{ uri: spec,
- title: data.label,
- type: PlacesUtils.TYPE_X_MOZ_URL}];
- } else
- throw new Error("bogus data was passed as a tab");
+ if (PlacesUIUtils.useAsyncTransactions) {
+ let nodes = [];
+ // TODO: When sync transactions are removed, merge the for loop here into the
+ // one above.
+ for (let {flavor, data} of dtItems) {
+ if (flavor != TAB_DROP_TYPE) {
+ nodes = [...nodes, ...PlacesUtils.unwrapNodes(data, flavor)];
+ } else if (data instanceof XULElement && data.localName == "tab" &&
+ data.ownerGlobal.isChromeWindow) {
+ let uri = data.linkedBrowser.currentURI;
+ let spec = uri ? uri.spec : "about:blank";
+ nodes.push({
+ uri: spec,
+ title: data.label,
+ type: PlacesUtils.TYPE_X_MOZ_URL
+ });
+ } else {
+ throw new Error("bogus data was passed as a tab");
+ }
+ }
- if (PlacesUIUtils.useAsyncTransactions) {
- // If dragging over a tag container we should tag the item.
- if (insertionPoint.isTag) {
- let urls = nodes.filter(item => "uri" in item).map(item => item.uri);
- transactions.push(PlacesTransactions.Tag({ urls, tag: tagName }));
+ // If dragging over a tag container we should tag the item.
+ if (insertionPoint.isTag) {
+ let urls = nodes.filter(item => "uri" in item).map(item => item.uri);
+ transactions.push(PlacesTransactions.Tag({ urls, tag: tagName }));
+ } else {
+ let insertionIndex = await insertionPoint.getIndex();
+ let newTransactions = await getTransactionsForTransferItems(
+ nodes, insertionIndex, parentGuid, doCopy);
+ if (newTransactions.length) {
+ transactions = [...transactions, ...newTransactions];
+ }
+ }
+
+ // Check if we actually have something to add, if we don't it probably wasn't
+ // valid, or it was moving to the same location, so just ignore it.
+ if (!transactions.length) {
+ return;
+ }
+ let resultForBatching = getResultForBatching(view);
+ await PlacesUIUtils.batchUpdatesForNode(resultForBatching,
+ transactions.length, async () => {
+ await PlacesTransactions.batch(transactions);
+ });
+ } else {
+ for (let {flavor, data} of dtItems) {
+ let nodes;
+ if (flavor != TAB_DROP_TYPE) {
+ nodes = PlacesUtils.unwrapNodes(data, flavor);
+ } else if (data instanceof XULElement && data.localName == "tab" &&
+ data.ownerGlobal.isChromeWindow) {
+ let uri = data.linkedBrowser.currentURI;
+ let spec = uri ? uri.spec : "about:blank";
+ nodes = [{ uri: spec,
+ title: data.label,
+ type: PlacesUtils.TYPE_X_MOZ_URL}];
} else {
- let insertionIndex = await insertionPoint.getIndex();
- let newTransactions = await getTransactionsForTransferItems(
- nodes, insertionIndex, parentGuid, doCopy);
- if (newTransactions.length) {
- transactions = [...transactions, ...newTransactions];
- }
+ throw new Error("bogus data was passed as a tab");
}
- } else {
+
let movedCount = 0;
for (let unwrapped of nodes) {
let index = await insertionPoint.getIndex();
if (index != -1 && unwrapped.itemGuid) {
// Note: we use the parent from the existing bookmark as the sidebar
// gives us an unwrapped.parent that is actually a query and not the real
// parent.
@@ -1713,33 +1743,27 @@ var PlacesControllerDragHelper = {
"node, reverting to a copy operation.");
doCopy = true;
}
transactions.push(PlacesUIUtils.makeTransaction(unwrapped,
flavor, insertionPoint.itemId,
index, doCopy));
}
}
+
+ // Check if we actually have something to add, if we don't it probably wasn't
+ // valid, or it was moving to the same location, so just ignore it.
+ if (!transactions.length) {
+ return;
+ }
+
+ let txn = new PlacesAggregatedTransaction("DropItems", transactions);
+ PlacesUtils.transactionManager.doTransaction(txn);
}
}
- // Check if we actually have something to add, if we don't it probably wasn't
- // valid, or it was moving to the same location, so just ignore it.
- if (!transactions.length) {
- return;
- }
- if (PlacesUIUtils.useAsyncTransactions) {
- let resultForBatching = getResultForBatching(view);
- await PlacesUIUtils.batchUpdatesForNode(resultForBatching,
- transactions.length, async () => {
- await PlacesTransactions.batch(transactions);
- });
- } else {
- let txn = new PlacesAggregatedTransaction("DropItems", transactions);
- PlacesUtils.transactionManager.doTransaction(txn);
- }
},
/**
* Checks if we can insert into a container.
* @param aContainer
* The container were we are want to drop
* @param aView
* The view generating the request