Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/browser/base/content/browser-thumbnails.js b/browser/base/content/browser-thumbnails.js
- --- a/browser/base/content/browser-thumbnails.js
- +++ b/browser/base/content/browser-thumbnails.js
- @@ -104,21 +104,16 @@ var gBrowserThumbnails = {
- this._activityStreamEnabled =
- Services.prefs.getBoolPref(this.PREF_ACTIVITY_STREAM_ENABLED);
- // Get the new top sites
- XPCOMUtils.defineLazyGetter(this, "_topSiteURLs", getTopSiteURLs);
- break;
- }
- },
- - /**
- - * clearTopSiteURLCache is only ever called if we've created an nsITimer,
- - * which only happens if we've loaded the tiles top sites. Therefore we only
- - * need to clear the tiles top sites (and not activity stream's top sites)
- - */
- clearTopSiteURLCache: function Thumbnails_clearTopSiteURLCache() {
- if (this._topSiteURLsRefreshTimer) {
- this._topSiteURLsRefreshTimer.cancel();
- this._topSiteURLsRefreshTimer = null;
- }
- // Delete the defined property
- delete this._topSiteURLs;
- XPCOMUtils.defineLazyGetter(this, "_topSiteURLs", getTopSiteURLs);
- @@ -142,19 +137,29 @@ var gBrowserThumbnails = {
- if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP &&
- aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK)
- this._delayedCapture(aBrowser);
- },
- async _capture(aBrowser) {
- // Only capture about:newtab top sites.
- const topSites = await this._topSiteURLs;
- - if (!aBrowser.currentURI ||
- - topSites.indexOf(aBrowser.currentURI.spec) == -1)
- + const index = topSites.map(l => l.url).indexOf(aBrowser.currentURI.spec);
- +
- + // if this is not a top site, do not collect a screenshot
- + if (!aBrowser.currentURI || index == -1)
- return;
- +
- + // at this point we know it's a top site, but now we check if it has a rich
- + // icon already, and if so we don't bother getting a screenshot
- + if (topSites[index].hasRichIcon)
- + return;
- +
- + // at this point we know it's a top site and we don't have a rich icon to show
- + // so it's ok to get a screenshot for this site
- this._shouldCapture(aBrowser, function(aResult) {
- if (aResult) {
- PageThumbs.captureAndStoreIfStale(aBrowser);
- }
- });
- },
- _delayedCapture: function Thumbnails_delayedCapture(aBrowser) {
- @@ -207,29 +212,29 @@ var gBrowserThumbnails = {
- } else {
- // idle callback dispatched
- window.cancelIdleCallback(timeoutData.id);
- }
- }
- };
- async function getTopSiteURLs() {
- + // The _topSiteURLs getter can be expensive to run, but its return value can
- + // change frequently on new profiles, so as a compromise we cache its return
- + // value as a lazy getter for 1 minute every time it's called.
- + gBrowserThumbnails._topSiteURLsRefreshTimer =
- + Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
- + gBrowserThumbnails._topSiteURLsRefreshTimer.initWithCallback(gBrowserThumbnails,
- + 60 * 1000,
- + Ci.nsITimer.TYPE_ONE_SHOT);
- let sites = [];
- if (gBrowserThumbnails._activityStreamEnabled) {
- sites = await NewTabUtils.activityStreamLinks.getTopSites();
- } else {
- - // The _topSiteURLs getter can be expensive to run, but its return value can
- - // change frequently on new profiles, so as a compromise we cache its return
- - // value as a lazy getter for 1 minute every time it's called.
- - gBrowserThumbnails._topSiteURLsRefreshTimer =
- - Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
- - gBrowserThumbnails._topSiteURLsRefreshTimer.initWithCallback(gBrowserThumbnails,
- - 60 * 1000,
- - Ci.nsITimer.TYPE_ONE_SHOT);
- sites = NewTabUtils.links.getLinks();
- }
- return sites.reduce((urls, link) => {
- - if (link) urls.push(link.url);
- + if (link) urls.push({url: link.url, hasRichIcon: link.faviconSize >= 96});
- return urls;
- }, []);
- }
- XPCOMUtils.defineLazyGetter(gBrowserThumbnails, "_topSiteURLs", getTopSiteURLs);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement