Bug 718270 - When hiding the VKB on small pages, increase page size to prevent zoom-in. r=pcwalton a=akeybl
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 25 Jan 2012 17:16:03 -0500
changeset 85149 663b6a4cdc3e7c8da096b587ab5bd720e89c57a6
parent 85148 aae024495623458c82c8cb2fb8d1e500b40d2b0c
child 85150 b2fe3c48845be9ca29c5ee0cd79e87cff3680c3d
push id519
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 00:38:35 +0000
treeherdermozilla-beta@788ea1ef610b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspcwalton, akeybl
bugs718270
milestone11.0a2
Bug 718270 - When hiding the VKB on small pages, increase page size to prevent zoom-in. r=pcwalton a=akeybl
mobile/android/base/gfx/LayerController.java
--- a/mobile/android/base/gfx/LayerController.java
+++ b/mobile/android/base/gfx/LayerController.java
@@ -164,20 +164,34 @@ public class LayerController {
      *
      * TODO: Refactor this to use an interface. Expose that interface only to the view and not
      * to the layer client. That way, the layer client won't be tempted to call this, which might
      * result in an infinite loop.
      */
     public void setViewportSize(FloatSize size) {
         // Resize the viewport, and modify its zoom factor so that the page retains proportionally
         // zoomed relative to the screen.
+        float oldHeight = mViewportMetrics.getSize().height;
         float oldWidth = mViewportMetrics.getSize().width;
         float oldZoomFactor = mViewportMetrics.getZoomFactor();
         mViewportMetrics.setSize(size);
 
+        // if the viewport got larger (presumably because the vkb went away), and the page
+        // is smaller than the new viewport size, increase the page size so that the panzoomcontroller
+        // doesn't zoom in to make it fit (bug 718270). this page size change is in anticipation of
+        // gecko increasing the page size to match the new viewport size, which will happen the next
+        // time we get a draw update.
+        if (size.width >= oldWidth && size.height >= oldHeight) {
+            FloatSize pageSize = mViewportMetrics.getPageSize();
+            if (pageSize.width < size.width || pageSize.height < size.height) {
+                mViewportMetrics.setPageSize(new FloatSize(Math.max(pageSize.width, size.width),
+                                                           Math.max(pageSize.height, size.height)));
+            }
+        }
+
         PointF newFocus = new PointF(size.width / 2.0f, size.height / 2.0f);
         float newZoomFactor = size.width * oldZoomFactor / oldWidth;
         mViewportMetrics.scaleTo(newZoomFactor, newFocus);
 
         Log.d(LOGTAG, "setViewportSize: " + mViewportMetrics);
         setForceRedraw();
 
         if (mLayerClient != null)