From ede1c3e8e1705dc6e91c16ae635e182a0db1468a Mon Sep 17 00:00:00 2001 From: Tim Taubert Date: Fri, 14 Feb 2014 11:15:51 +0100 Subject: [PATCH] Bug 895359 - Pass draggedSite to updateGrid() to avoid intermittent Windows failures r=jaws --- browser/base/content/newtab/drop.js | 4 ++-- browser/base/content/newtab/transformations.js | 5 +++-- browser/base/content/newtab/updater.js | 13 +++---------- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/browser/base/content/newtab/drop.js b/browser/base/content/newtab/drop.js index 7363396e81e4..57e2d75af10c 100644 --- a/browser/base/content/newtab/drop.js +++ b/browser/base/content/newtab/drop.js @@ -57,7 +57,7 @@ let gDrop = { this._cancelDelayedArrange(); // Update the grid and move all sites to their new places. - gUpdater.updateGrid(); + gUpdater.updateGrid(gDrag.draggedSite); }, /** @@ -145,6 +145,6 @@ let gDrop = { if (aCell) sites = gDropPreview.rearrange(aCell); - gTransformation.rearrangeSites(sites, {unfreeze: !aCell}); + gTransformation.rearrangeSites(sites, gDrag.draggedSite, {unfreeze: !aCell}); } }; diff --git a/browser/base/content/newtab/transformations.js b/browser/base/content/newtab/transformations.js index 3e711c90e307..8a4eb951c4b9 100644 --- a/browser/base/content/newtab/transformations.js +++ b/browser/base/content/newtab/transformations.js @@ -137,10 +137,11 @@ let gTransformation = { * Rearranges a given array of sites and moves them to their new positions or * fades in/out new/removed sites. * @param aSites An array of sites to rearrange. + * @param aDraggedSite The currently dragged site, may be null. * @param aOptions Set of options (see below). * unfreeze - unfreeze the site after rearranging */ - rearrangeSites: function (aSites, aOptions) { + rearrangeSites: function (aSites, aDraggedSite, aOptions) { let self = this; let cells = gGrid.cells; let unfreeze = aOptions && aOptions.unfreeze; @@ -149,7 +150,7 @@ let gTransformation = { let index = 0; for (let site of aSites) { - if (site && site !== gDrag.draggedSite) { + if (site && site !== aDraggedSite) { if (!cells[index]) { // The site disappeared from the grid, hide it. yield self.hideSite(site); diff --git a/browser/base/content/newtab/updater.js b/browser/base/content/newtab/updater.js index 8225906d1b4f..563384f8f63d 100644 --- a/browser/base/content/newtab/updater.js +++ b/browser/base/content/newtab/updater.js @@ -13,7 +13,7 @@ let gUpdater = { * Updates the current grid according to its pinned and blocked sites. * This removes old, moves existing and creates new sites to fill gaps. */ - updateGrid: function Updater_updateGrid() { + updateGrid: function Updater_updateGrid(draggedSite = null) { let links = gLinks.getLinks().slice(0, gGrid.cells.length); // Find all sites that remain in the grid. @@ -32,7 +32,8 @@ let gUpdater = { // Now it's time to animate the sites actually moving to their new // positions. - this._rearrangeSites(sites).then(() => { + let opts = {unfreeze: true}; + gTransformation.rearrangeSites(sites, draggedSite, opts).then(() => { // Try to fill empty cells and finish. this._fillEmptyCells(links); @@ -106,14 +107,6 @@ let gUpdater = { }, this); }, - /** - * Rearranges the given sites and slides them to their new positions. - * @param aSites The array of sites to re-arrange. - */ - _rearrangeSites: function (aSites) { - return gTransformation.rearrangeSites(aSites, {unfreeze: true}); - }, - /** * Removes all sites from the grid that are not in the given links array or * exceed the grid.