Bug 758620 - Clamp scroll port to content size in android fennec. r=kats
☠☠ backed out by 941774f975ac ☠ ☠
authorChris Lord <chrislord.net@gmail.com>
Tue, 26 Jun 2012 14:43:32 +0100
changeset 97694 de70e79ced32b414eca99e219430c20d73b16500
parent 97693 ddd519d0767ed613df103591e62d5412aee02aa0
child 97695 069b6fb2b5c589db304554778d009538ea0bb252
push id22993
push useremorley@mozilla.com
push dateWed, 27 Jun 2012 10:31:27 +0000
treeherdermozilla-central@1a56f1f011c9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs758620
milestone16.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 758620 - Clamp scroll port to content size in android fennec. r=kats Fixed position elements are laid out to the scroll-port size, so setting a scroll port larger than the content size causes fixed position elements to be pushed off of the page.
mobile/android/chrome/content/browser.js
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -2323,21 +2323,27 @@ Tab.prototype = {
     return aDisplayPort;
   },
 
   setViewport: function(aViewport) {
     // Transform coordinates based on zoom
     let x = aViewport.x / aViewport.zoom;
     let y = aViewport.y / aViewport.zoom;
 
-    // Set scroll position
+    // Set scroll position and scroll-port clamping size
+    let [pageWidth, pageHeight] = this.getPageSize(this.browser.contentDocument,
+                                                   aViewport.width, aViewport.height);
+    let scrollPortWidth = Math.min(gScreenWidth / aViewport.zoom, pageWidth);
+    let scrollPortHeight = Math.min(gScreenHeight / aViewport.zoom, pageHeight);
+
     let win = this.browser.contentWindow;
-    win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils).setScrollPositionClampingScrollPortSize(
-        gScreenWidth / aViewport.zoom, gScreenHeight / aViewport.zoom);
+    win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils).
+        setScrollPositionClampingScrollPortSize(scrollPortWidth, scrollPortHeight);
     win.scrollTo(x, y);
+
     this.userScrollPos.x = win.scrollX;
     this.userScrollPos.y = win.scrollY;
     this.setResolution(aViewport.zoom, false);
 
     if (aViewport.displayPort)
       this.setDisplayPort(aViewport.displayPort);
   },