Bug 738641 - Account for rounding errors when reporting page size from JS to Java. r=Cwiiis a=blassey
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 30 Apr 2012 15:50:50 -0400
changeset 95614 76ffa3c5a28e87d66e69f62ce6170212aa9b9c48
parent 95613 2d7dd84abf1a725c7c31f56dcde1f4d1dc17cf0d
child 95615 025db42287dd8639965da12dc7094f13b95519d2
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersCwiiis, blassey
bugs738641
milestone14.0a2
Bug 738641 - Account for rounding errors when reporting page size from JS to Java. r=Cwiiis a=blassey
mobile/android/chrome/content/browser.js
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -1921,18 +1921,23 @@ Tab.prototype = {
       /* Transform the page width and height based on the zoom factor. */
       pageWidth *= viewport.zoom;
       pageHeight *= viewport.zoom;
 
       /*
        * Avoid sending page sizes of less than screen size before we hit DOMContentLoaded, because
        * this causes the page size to jump around wildly during page load. After the page is loaded,
        * send updates regardless of page size; we'll zoom to fit the content as needed.
+       *
+       * Also, we need to compare the page size returned from getPageSize (in CSS pixels) to the floored
+       * screen size in CSS pixels because the page size returned from getPageSize may also be floored.
        */
-      if (doc.readyState === 'complete' || (pageWidth >= gScreenWidth && pageHeight >= gScreenHeight)) {
+      let pageLargerThanScreen = (cssPageWidth >= Math.floor(viewport.cssWidth))
+                              && (cssPageHeight >= Math.floor(viewport.cssHeight));
+      if (doc.readyState === 'complete' || pageLargerThanScreen) {
         viewport.cssPageWidth = cssPageWidth;
         viewport.cssPageHeight = cssPageHeight;
         viewport.pageWidth = pageWidth;
         viewport.pageHeight = pageHeight;
       }
     }
 
     return viewport;