From bd4d33b8bf645e4658067a188e8112052a1bae8e Mon Sep 17 00:00:00 2001 From: Tim Taubert Date: Wed, 25 Jan 2012 22:47:39 +0100 Subject: [PATCH] Bug 497543 - Part 5 - Don't capture thumbnails while the page is scrolled; r=dietrich --- browser/base/content/browser-thumbnails.js | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/browser/base/content/browser-thumbnails.js b/browser/base/content/browser-thumbnails.js index 59a6f743a4d..de05b4ccae7 100644 --- a/browser/base/content/browser-thumbnails.js +++ b/browser/base/content/browser-thumbnails.js @@ -51,15 +51,16 @@ let gBrowserThumbnails = { handleEvent: function Thumbnails_handleEvent(aEvent) { switch (aEvent.type) { + case "scroll": + let browser = aEvent.currentTarget; + if (this._timeouts.has(browser)) + this._delayedCapture(browser); + break; case "TabSelect": this._delayedCapture(aEvent.target.linkedBrowser); break; case "TabClose": { - let browser = aEvent.target.linkedBrowser; - if (this._timeouts.has(browser)) { - clearTimeout(this._timeouts.get(browser)); - this._timeouts.delete(browser); - } + this._clearTimeout(aEvent.target.linkedBrowser); break; } } @@ -85,9 +86,11 @@ let gBrowserThumbnails = { _delayedCapture: function Thumbnails_delayedCapture(aBrowser) { if (this._timeouts.has(aBrowser)) clearTimeout(this._timeouts.get(aBrowser)); + else + aBrowser.addEventListener("scroll", this, true); let timeout = setTimeout(function () { - this._timeouts.delete(aBrowser); + this._clearTimeout(aBrowser); this._capture(aBrowser); }.bind(this), this._captureDelayMS); @@ -115,5 +118,13 @@ let gBrowserThumbnails = { // Not a http channel, we just assume a success status code. return true; } + }, + + _clearTimeout: function Thumbnails_clearTimeout(aBrowser) { + if (this._timeouts.has(aBrowser)) { + aBrowser.removeEventListener("scroll", this, false); + clearTimeout(this._timeouts.get(aBrowser)); + this._timeouts.delete(aBrowser); + } } };