Bug 1398471 - Read data from DataTransfer before yielding, r=gijs

Previously the code looped and yielded between each loop. This caused the
DataTransfer to be cleared before the read completed.

This splits the loop into 2 sections such that we read all important data from
the DataTransfer before it is cleared.
This commit is contained in:
Michael Layzell 2017-09-11 13:44:04 -04:00
Родитель cf998634b8
Коммит c24551af0d
1 изменённых файлов: 7 добавлений и 0 удалений

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

@ -1598,6 +1598,10 @@ var PlacesControllerDragHelper = {
duplicable.set(PlacesUtils.TYPE_UNICODE, new Set());
duplicable.set(PlacesUtils.TYPE_X_MOZ_URL, new Set());
// Collect all data from the DataTransfer before processing it, as the
// DataTransfer is only valid during the synchronous handling of the `drop`
// event handler callback.
let dtItems = [];
for (let i = 0; i < dropCount; ++i) {
let flavor = this.getFirstValidFlavor(dt.mozTypesAt(i));
if (!flavor)
@ -1610,7 +1614,10 @@ var PlacesControllerDragHelper = {
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);