Bug 898877 - Ensure that viewport resizing behaviour due to dynamic toolbar is consistent. r=Cwiiis
authorKartikaya Gupta <kgupta@mozilla.com>
Fri, 16 Aug 2013 08:42:32 -0400
changeset 143000 f9d39959fc55d35e54047eedf86eb74d2fea0c46
parent 142999 ae2f8afea26071d56c4311722e6ef2135005350f
child 143001 7e8931d11672c944f96695a866cd9edbceadc3bb
push idunknown
push userunknown
push dateunknown
reviewersCwiiis
bugs898877
milestone26.0a1
Bug 898877 - Ensure that viewport resizing behaviour due to dynamic toolbar is consistent. r=Cwiiis In browser.js were two pieces of code that determined whether or not the CSS viewport size should include the margins. These two pieces of code were inconsistent in that one used rounding while the other used a fuzz. Also, one of them subtracted gViewportMargins from gScreenHeight while the other added them. This patch makes the two pieces of code consistent, and updates them to use a fuzz so that the CSS viewport is enlarged only when dealing with pages that are equal to or larger than the screen (with the toolbar hidden).
mobile/android/chrome/content/browser.js
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -3271,25 +3271,23 @@ Tab.prototype = {
     // the threshold of screen + margins, in case it's sizing itself relative
     // to the viewport.
     let viewport = this.getViewport();
     let pageWidth = viewport.pageRight - viewport.pageLeft;
     let pageHeight = viewport.pageBottom - viewport.pageTop;
     let remeasureNeeded = false;
 
     if (hasHorizontalMargins) {
-      let screenWidth = gScreenWidth + gViewportMargins.left + gViewportMargins.right;
-      let viewportShouldExcludeHorizontalMargins = (Math.round(pageWidth) <= screenWidth);
+      let viewportShouldExcludeHorizontalMargins = (pageWidth <= gScreenWidth - 0.5);
       if (viewportShouldExcludeHorizontalMargins != this.viewportExcludesHorizontalMargins) {
         remeasureNeeded = true;
       }
     }
     if (hasVerticalMargins) {
-      let screenHeight = gScreenHeight + gViewportMargins.top + gViewportMargins.bottom;
-      let viewportShouldExcludeVerticalMargins = (Math.round(pageHeight) <= screenHeight);
+      let viewportShouldExcludeVerticalMargins = (pageHeight <= gScreenHeight - 0.5);
       if (viewportShouldExcludeVerticalMargins != this.viewportExcludesVerticalMargins) {
         remeasureNeeded = true;
       }
     }
 
     if (remeasureNeeded) {
       if (!this.viewportMeasureCallback) {
         this.viewportMeasureCallback = setTimeout(function() {