Bug 828345 - Maintain aspect ratio for clamping scrollport. r=kats
authorChris Lord <chrislord.net@gmail.com>
Thu, 10 Jan 2013 17:32:44 +0000
changeset 118441 1f3d5f4cc05cda0c371630c5e5df5ebca23af535
parent 118440 934e8b48a5394b3de7b34e1e7fa60539cbd50088
child 118442 8fd79d4c7b17173480f0583b36c4b7d6640145a6
push id24166
push userMs2ger@gmail.com
push dateFri, 11 Jan 2013 13:57:41 +0000
treeherdermozilla-central@63c4b0f66a0c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs828345
milestone21.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 828345 - Maintain aspect ratio for clamping scrollport. r=kats Make sure the clamping scroll-port maintains its aspect ratio on Android. This fixes fixed position elements appearing to jitter after zooming out beyond the page boundaries.
mobile/android/chrome/content/browser.js
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -3111,18 +3111,23 @@ Tab.prototype = {
     return aDisplayPort;
   },
 
   setScrollClampingSize: function(zoom) {
     let viewportWidth = gScreenWidth / zoom;
     let viewportHeight = gScreenHeight / zoom;
     let [pageWidth, pageHeight] = this.getPageSize(this.browser.contentDocument,
                                                    viewportWidth, viewportHeight);
-    let scrollPortWidth = Math.min(viewportWidth, pageWidth);
-    let scrollPortHeight = Math.min(viewportHeight, pageHeight);
+
+    // Make sure the aspect ratio of the screen is maintained when setting
+    // the clamping scroll-port size.
+    let factor = Math.min(viewportWidth / gScreenWidth, pageWidth / gScreenWidth,
+                          viewportHeight / gScreenHeight, pageHeight / gScreenHeight);
+    let scrollPortWidth = gScreenWidth * factor;
+    let scrollPortHeight = gScreenHeight * factor;
 
     let win = this.browser.contentWindow;
     win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils).
         setScrollPositionClampingScrollPortSize(scrollPortWidth, scrollPortHeight);
   },
 
   setViewport: function(aViewport) {
     // Transform coordinates based on zoom