Bug 738641 - Account for rounding errors when reporting page size from JS to Java. r=Cwiiis
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 30 Apr 2012 15:50:50 -0400
changeset 92744 5ca3b86976c9a1010a3663c3b2741008b59df89a
parent 92743 0e2658794e06408c4b68b3eaf1002a751a92b854
child 92745 bc56a41ebfb86b0222d02d8216c5c90cae84583a
push id8851
push userkgupta@mozilla.com
push dateMon, 30 Apr 2012 19:51:11 +0000
treeherdermozilla-inbound@5ca3b86976c9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersCwiiis
bugs738641
milestone15.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 738641 - Account for rounding errors when reporting page size from JS to Java. r=Cwiiis
mobile/android/chrome/content/browser.js
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -1919,18 +1919,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;