Bug 718270 - When hiding the VKB on small pages, increase page size to prevent zoom-in. r=pcwalton
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 25 Jan 2012 17:16:03 -0500
changeset 86622 8fe66d9bdc30b11184cc01ddf36a07a283a34293
parent 86621 232d8602bdfac61c66cc42f7aca6320fabb457c0
child 86623 8161e9cd391c4787e8e0fef5a30898ee829aedb9
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspcwalton
bugs718270
milestone12.0a1
Bug 718270 - When hiding the VKB on small pages, increase page size to prevent zoom-in. r=pcwalton
mobile/android/base/gfx/LayerController.java
--- a/mobile/android/base/gfx/LayerController.java
+++ b/mobile/android/base/gfx/LayerController.java
@@ -184,20 +184,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)