Bug 640768 - Ensure thumbnails don't extend beyond content. [r=mfinkle]
authorWes Johnston <wjohnston@mozilla.com>
Fri, 18 Mar 2011 11:41:12 -0700
changeset 67525 06a900cf0e063b21bb0b47f1f954ddd6733e880f
parent 67524 583ba213e3a602b1c3845eb91ec114ec295b7aae
child 67526 69caa95952e5d6fc410de0e6eff907daf636c98c
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs640768
Bug 640768 - Ensure thumbnails don't extend beyond content. [r=mfinkle]
mobile/chrome/content/tabs.xml
--- a/mobile/chrome/content/tabs.xml
+++ b/mobile/chrome/content/tabs.xml
@@ -61,17 +61,27 @@
         <body>
           <![CDATA[
             const tabWidth = 104;
             const tabHeight = 65;
 
             let ratio = tabHeight / tabWidth;
             if (browser.contentDocumentWidth > 0)
               width = Math.min(width, browser.contentDocumentWidth);
-            height = width * ratio;
+
+            if (browser.contentDocumentHeight > 0)
+              height = Math.min(height, browser.contentDocumentHeight);
+
+            let newHeight = width * ratio;
+            if (height >= newHeight) {
+              height = newHeight;
+            } else {
+              // the browser aspect ratio does not match the tabs aspect ratio
+              width = height / ratio;
+            }
 
             let thumbnail = this.thumbnail;
             thumbnail.removeAttribute("empty");
 
             // Recreate the canvas as it may be tainted and not useable for remote pages
             if (thumbnail.hasAttribute("restored")) {
               thumbnail.removeAttribute("restored");
               thumbnail = this.thumbnail.cloneNode(false);