зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1413843 - Improve speed of operations when pasting to the left-hand library pane by getting the right-hand pane to use for batching. r=mak
MozReview-Commit-ID: 2Q1rIpIhmmM --HG-- extra : rebase_source : 77239ba65f050a4272e58bf7d5d16bfd54ca6933
This commit is contained in:
Родитель
9a34044063
Коммит
3c55451f9e
|
@ -1328,14 +1328,18 @@ PlacesController.prototype = {
|
||||||
transactions = [...transactions, ...newTransactions];
|
transactions = [...transactions, ...newTransactions];
|
||||||
}
|
}
|
||||||
|
|
||||||
await PlacesUIUtils.batchUpdatesForNode(this._view.result, transactions.length, async () => {
|
// Note: this._view may be a view or the tree element.
|
||||||
await PlacesTransactions.batch(async () => {
|
let resultForBatching = getResultForBatching(this._view);
|
||||||
for (let transaction of transactions) {
|
|
||||||
let guid = await transaction.transact();
|
await PlacesUIUtils.batchUpdatesForNode(resultForBatching,
|
||||||
itemsToSelect.push(await PlacesUtils.promiseItemId(guid));
|
transactions.length, async () => {
|
||||||
}
|
await PlacesTransactions.batch(async () => {
|
||||||
|
for (let transaction of transactions) {
|
||||||
|
let guid = await transaction.transact();
|
||||||
|
itemsToSelect.push(await PlacesUtils.promiseItemId(guid));
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let transactions = [];
|
let transactions = [];
|
||||||
|
@ -1609,9 +1613,8 @@ var PlacesControllerDragHelper = {
|
||||||
* @param {Object} insertionPoint The insertion point where the items should
|
* @param {Object} insertionPoint The insertion point where the items should
|
||||||
* be dropped.
|
* be dropped.
|
||||||
* @param {Object} dt The dataTransfer information for the drop.
|
* @param {Object} dt The dataTransfer information for the drop.
|
||||||
* @param {Object} view The tree view where this object is being
|
* @param {Object} view The view or the tree element. This allows
|
||||||
* dropped to. This allows batching to take
|
* batching to take place.
|
||||||
* place.
|
|
||||||
*/
|
*/
|
||||||
async onDrop(insertionPoint, dt, view) {
|
async onDrop(insertionPoint, dt, view) {
|
||||||
let doCopy = ["copy", "link"].includes(dt.dropEffect);
|
let doCopy = ["copy", "link"].includes(dt.dropEffect);
|
||||||
|
@ -1723,9 +1726,11 @@ var PlacesControllerDragHelper = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (PlacesUIUtils.useAsyncTransactions) {
|
if (PlacesUIUtils.useAsyncTransactions) {
|
||||||
await PlacesUIUtils.batchUpdatesForNode(view && view.result, transactions.length, async () => {
|
let resultForBatching = getResultForBatching(view);
|
||||||
await PlacesTransactions.batch(transactions);
|
await PlacesUIUtils.batchUpdatesForNode(resultForBatching,
|
||||||
});
|
transactions.length, async () => {
|
||||||
|
await PlacesTransactions.batch(transactions);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
let txn = new PlacesAggregatedTransaction("DropItems", transactions);
|
let txn = new PlacesAggregatedTransaction("DropItems", transactions);
|
||||||
PlacesUtils.transactionManager.doTransaction(txn);
|
PlacesUtils.transactionManager.doTransaction(txn);
|
||||||
|
@ -1810,6 +1815,30 @@ function goDoPlacesCommand(aCommand) {
|
||||||
controller.doCommand(aCommand);
|
controller.doCommand(aCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This gets the most appropriate item for using for batching. In the case of multiple
|
||||||
|
* views being related, the method returns the most expensive result to batch.
|
||||||
|
* For example, if it detects the left-hand library pane, then it will look for
|
||||||
|
* and return the reference to the right-hand pane.
|
||||||
|
*
|
||||||
|
* @param {Object} viewOrElement The item to check.
|
||||||
|
* @return {Object} Will return the best result node to batch, or null
|
||||||
|
* if one could not be found.
|
||||||
|
*/
|
||||||
|
function getResultForBatching(viewOrElement) {
|
||||||
|
if (viewOrElement && viewOrElement instanceof Ci.nsIDOMElement &&
|
||||||
|
viewOrElement.id === "placesList") {
|
||||||
|
// Note: fall back to the existing item if we can't find the right-hane pane.
|
||||||
|
viewOrElement = document.getElementById("placeContent") || viewOrElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (viewOrElement && viewOrElement.result) {
|
||||||
|
return viewOrElement.result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes a set of transfer items and returns transactions to insert or
|
* Processes a set of transfer items and returns transactions to insert or
|
||||||
* move them.
|
* move them.
|
||||||
|
|
|
@ -1453,7 +1453,7 @@ PlacesTreeView.prototype = {
|
||||||
// since this information is specific to the tree view.
|
// since this information is specific to the tree view.
|
||||||
let ip = this._getInsertionPoint(aRow, aOrientation);
|
let ip = this._getInsertionPoint(aRow, aOrientation);
|
||||||
if (ip) {
|
if (ip) {
|
||||||
PlacesControllerDragHelper.onDrop(ip, aDataTransfer, this)
|
PlacesControllerDragHelper.onDrop(ip, aDataTransfer, this._tree.element)
|
||||||
.catch(Components.utils.reportError)
|
.catch(Components.utils.reportError)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// We should only clear the drop target once
|
// We should only clear the drop target once
|
||||||
|
|
Загрузка…
Ссылка в новой задаче