Bug 1425432 - Maintain original thumbnail aspect ratio for Ctrl-Tab previews. r=jaws
authorDão Gottwald <dao@mozilla.com>
Fri, 15 Dec 2017 13:32:51 +0100
changeset 448603 ac65e767c4f870bf8dbfe9c09fcbe5d13e76f2a8
parent 448602 5ede05405b50adc080dc4d5cbe19ca796d07fb55
child 448604 0e26ab46cbb7a6cff4fc129bf11c3d3cd86b6ab5
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1425432
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1425432 - Maintain original thumbnail aspect ratio for Ctrl-Tab previews. r=jaws MozReview-Commit-ID: F03AHwdplir
browser/base/content/browser-ctrlTab.js
--- a/browser/base/content/browser-ctrlTab.js
+++ b/browser/base/content/browser-ctrlTab.js
@@ -11,22 +11,23 @@
 var tabPreviews = {
   init: function tabPreviews_init() {
     if (this._selectedTab)
       return;
     this._selectedTab = gBrowser.selectedTab;
 
     gBrowser.tabContainer.addEventListener("TabSelect", this);
     gBrowser.tabContainer.addEventListener("SSTabRestored", this);
+  },
 
-    let screenManager = Cc["@mozilla.org/gfx/screenmanager;1"]
-                          .getService(Ci.nsIScreenManager);
-    let left = {}, top = {}, width = {}, height = {};
-    screenManager.primaryScreen.GetRectDisplayPix(left, top, width, height);
-    this.aspectRatio = height.value / width.value;
+  get aspectRatio() {
+    let { PageThumbUtils } = Cu.import("resource://gre/modules/PageThumbUtils.jsm", {});
+    let [ width, height ] = PageThumbUtils.getThumbnailSize(window);
+    delete this.aspectRatio;
+    return this.aspectRatio = height / width;
   },
 
   get: function tabPreviews_get(aTab) {
     let uri = aTab.linkedBrowser.currentURI.spec;
 
     if (aTab.__thumbnail_lastURI &&
         aTab.__thumbnail_lastURI != uri) {
       aTab.__thumbnail = null;