Backed out changeset bcd726a4a258 (bug 725268)

This commit is contained in:
Tim Taubert 2012-02-09 11:47:08 +01:00
Родитель a6606c307e
Коммит ff04332f87
5 изменённых файлов: 65 добавлений и 69 удалений

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

@ -77,8 +77,11 @@ let gBrowserThumbnails = {
},
_capture: function Thumbnails_capture(aBrowser) {
if (this._shouldCapture(aBrowser))
this._pageThumbs.captureAndStore(aBrowser);
if (this._shouldCapture(aBrowser)) {
this._pageThumbs.capture(aBrowser.contentWindow, function (aInputStream) {
this._pageThumbs.store(aBrowser.currentURI.spec, aInputStream);
}.bind(this));
}
},
_delayedCapture: function Thumbnails_delayedCapture(aBrowser) {

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

@ -135,24 +135,16 @@ let gTransformation = {
* callback - the callback to call when finished
*/
rearrangeSites: function Transformation_rearrangeSites(aSites, aOptions) {
let batch;
let cells = gGrid.cells;
let callback = aOptions && aOptions.callback;
let unfreeze = aOptions && aOptions.unfreeze;
let batch = new Batch(function () {
if (aOptions && "callback" in aOptions)
aOptions.callback();
gGrid.unlock();
});
if (callback) {
batch = new Batch(callback);
callback = function () batch.pop();
}
gGrid.lock();
aSites.forEach(function (aSite, aIndex) {
// Do not re-arrange empty cells or the dragged site.
if (!aSite || aSite == gDrag.draggedSite)

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

@ -20,34 +20,29 @@ let gUpdater = {
// Find all sites that remain in the grid.
let sites = this._findRemainingSites(links);
Grid.lock();
let self = this;
// Remove sites that are no longer in the grid.
this._removeLegacySites(sites, function () {
// Freeze all site positions so that we can move their DOM nodes around
// without any visual impact.
this._freezeSitePositions(sites);
self._freezeSitePositions(sites);
// Move the sites' DOM nodes to their new position in the DOM. This will
// have no visual effect as all the sites have been frozen and will
// remain in their current position.
this._moveSiteNodes(sites);
self._moveSiteNodes(sites);
// Now it's time to animate the sites actually moving to their new
// positions.
this._rearrangeSites(sites, function () {
self._rearrangeSites(sites, function () {
// Try to fill empty cells and finish.
this._fillEmptyCells(links, function () {
gGrid.unlock();
if (aCallback)
aCallback();
});
self._fillEmptyCells(links, aCallback);
// Update other pages that might be open to keep them synced.
gAllPages.update(gPage);
}.bind(this));
}.bind(this));
});
});
},
/**

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

@ -104,42 +104,43 @@ let PageThumbs = {
},
/**
* Captures a thumbnail for the given browser and stores it to the cache.
* @param aBrowser The browser to capture a thumbnail for.
* @param aCallback The function to be called when finished (optional).
* Stores the image data contained in the given canvas to the underlying
* storage.
* @param aKey The key to use for the storage.
* @param aInputStream The input stream containing the image data.
* @param aCallback The function to be called when the canvas data has been
* stored (optional).
*/
captureAndStore: function PageThumbs_captureAndStore(aBrowser, aCallback) {
this.capture(aBrowser.contentWindow, function (aInputStream) {
let telemetryStoreTime = new Date();
store: function PageThumbs_store(aKey, aInputStream, aCallback) {
let telemetryStoreTime = new Date();
function finish(aSuccessful) {
if (aSuccessful) {
Services.telemetry.getHistogramById("FX_THUMBNAILS_STORE_TIME_MS")
.add(new Date() - telemetryStoreTime);
}
if (aCallback)
aCallback(aSuccessful);
function finish(aSuccessful) {
if (aSuccessful) {
Services.telemetry.getHistogramById("FX_THUMBNAILS_STORE_TIME_MS")
.add(new Date() - telemetryStoreTime);
}
// Get a writeable cache entry.
PageThumbsCache.getWriteEntry(aBrowser.currentURI.spec, function (aEntry) {
if (!aEntry) {
finish(false);
return;
}
if (aCallback)
aCallback(aSuccessful);
}
let outputStream = aEntry.openOutputStream(0);
// Get a writeable cache entry.
PageThumbsCache.getWriteEntry(aKey, function (aEntry) {
if (!aEntry) {
finish(false);
return;
}
// Write the image data to the cache entry.
NetUtil.asyncCopy(aInputStream, outputStream, function (aResult) {
let success = Components.isSuccessCode(aResult);
if (success)
aEntry.markValid();
let outputStream = aEntry.openOutputStream(0);
aEntry.close();
finish(success);
});
// Write the image data to the cache entry.
NetUtil.asyncCopy(aInputStream, outputStream, function (aResult) {
let success = Components.isSuccessCode(aResult);
if (success)
aEntry.markValid();
aEntry.close();
finish(success);
});
});
},

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

@ -94,29 +94,34 @@ function whenLoaded(aElement, aCallback) {
* @param aMessage The info message to print when comparing the pixel color.
*/
function captureAndCheckColor(aRed, aGreen, aBlue, aMessage) {
let browser = gBrowser.selectedBrowser;
let window = gBrowser.selectedTab.linkedBrowser.contentWindow;
// Capture the screenshot.
PageThumbs.captureAndStore(browser, function () {
let width = 100, height = 100;
let thumb = PageThumbs.getThumbnailURL(browser.currentURI.spec, width, height);
PageThumbs.capture(window, function (aData) {
let key = Date.now();
getXULDocument(function (aDocument) {
let htmlns = "http://www.w3.org/1999/xhtml";
let img = aDocument.createElementNS(htmlns, "img");
img.setAttribute("src", thumb);
// Store the thumbnail in the cache.
PageThumbs.store(key, aData, function () {
let width = 100, height = 100;
let thumb = PageThumbs.getThumbnailURL(key, width, height);
whenLoaded(img, function () {
let canvas = aDocument.createElementNS(htmlns, "canvas");
canvas.setAttribute("width", width);
canvas.setAttribute("height", height);
getXULDocument(function (aDocument) {
let htmlns = "http://www.w3.org/1999/xhtml";
let img = aDocument.createElementNS(htmlns, "img");
img.setAttribute("src", thumb);
// Draw the image to a canvas and compare the pixel color values.
let ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0, width, height);
checkCanvasColor(ctx, aRed, aGreen, aBlue, aMessage);
whenLoaded(img, function () {
let canvas = aDocument.createElementNS(htmlns, "canvas");
canvas.setAttribute("width", width);
canvas.setAttribute("height", height);
next();
// Draw the image to a canvas and compare the pixel color values.
let ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0, width, height);
checkCanvasColor(ctx, aRed, aGreen, aBlue, aMessage);
next();
});
});
});
});