merge fx-team to m-c
authorTim Taubert <tim.taubert@gmx.de>
Mon, 12 Dec 2011 15:23:14 +0100
changeset 84080 33984b2775542b6b82d0d0fd0c94080b94fd82ab
parent 84079 a3002672881e30a184aaab87a77d779a8abe6256 (current diff)
parent 84077 73979783bac9a681856af5feae6093b8a3f9a412 (diff)
child 84081 fd241426865cfe9574246190f4705be162e58155
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)
milestone11.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
merge fx-team to m-c
--- a/mobile/android/base/gfx/ViewportMetrics.java
+++ b/mobile/android/base/gfx/ViewportMetrics.java
@@ -43,23 +43,26 @@ import android.graphics.PointF;
 import android.graphics.Rect;
 import android.graphics.RectF;
 import org.mozilla.gecko.FloatUtils;
 import org.mozilla.gecko.gfx.FloatSize;
 import org.mozilla.gecko.gfx.LayerController;
 import org.mozilla.gecko.gfx.RectUtils;
 import org.json.JSONException;
 import org.json.JSONObject;
+import org.json.JSONStringer;
 import android.util.Log;
 
 /**
  * ViewportMetrics manages state and contains some utility functions related to
  * the page viewport for the Gecko layer client to use.
  */
 public class ViewportMetrics {
+    private static final String LOGTAG = "GeckoViewportMetrics";
+
     private FloatSize mPageSize;
     private RectF mViewportRect;
     private PointF mViewportOffset;
     private float mZoomFactor;
 
     public ViewportMetrics() {
         mPageSize = new FloatSize(LayerController.TILE_WIDTH,
                                   LayerController.TILE_HEIGHT);
@@ -227,21 +230,27 @@ public class ViewportMetrics {
         result.mPageSize = mPageSize.interpolate(to.mPageSize, t);
         result.mZoomFactor = FloatUtils.interpolate(mZoomFactor, to.mZoomFactor, t);
         result.mViewportRect = RectUtils.interpolate(mViewportRect, to.mViewportRect, t);
         result.mViewportOffset = PointUtils.interpolate(mViewportOffset, to.mViewportOffset, t);
         return result;
     }
 
     public String toJSON() {
-        return "{ \"x\" : " + mViewportRect.left +
-               ", \"y\" : " + mViewportRect.top +
-               ", \"width\" : " + mViewportRect.width() +
-               ", \"height\" : " + mViewportRect.height() +
-               ", \"pageWidth\" : " + mPageSize.width +
-               ", \"pageHeight\" : " + mPageSize.height +
-               ", \"offsetX\" : " + mViewportOffset.x +
-               ", \"offsetY\" : " + mViewportOffset.y +
-               ", \"zoom\" : " + mZoomFactor +
-               " }";
+        try {
+            return new JSONStringer().object()
+                .key("x").value(mViewportRect.left)
+                .key("y").value(mViewportRect.top)
+                .key("width").value(mViewportRect.width())
+                .key("height").value(mViewportRect.height())
+                .key("pageWidth").value(mPageSize.width)
+                .key("pageHeight").value(mPageSize.height)
+                .key("offsetX").value(mViewportOffset.x)
+                .key("offsetY").value(mViewportOffset.y)
+                .key("zoom").value(mZoomFactor)
+                .endObject().toString();
+        } catch (JSONException je) {
+            Log.e(LOGTAG, "Error serializing viewportmetrics", je);
+            return "";
+        }
     }
 }
 
--- a/mobile/android/base/ui/PanZoomController.java
+++ b/mobile/android/base/ui/PanZoomController.java
@@ -806,21 +806,21 @@ public class PanZoomController
         ViewportMetrics viewportMetrics = new ViewportMetrics(mController.getViewportMetrics());
 
         /* First, we adjust the zoom factor so that we can make no overscrolled area visible. */
         float zoomFactor = viewportMetrics.getZoomFactor();
         FloatSize pageSize = viewportMetrics.getPageSize();
         RectF viewport = viewportMetrics.getViewport();
 
         float minZoomFactor = 0.0f;
-        if (viewport.width() > pageSize.width) {
+        if (viewport.width() > pageSize.width && pageSize.width > 0) {
             float scaleFactor = viewport.width() / pageSize.width;
             minZoomFactor = (float)Math.max(minZoomFactor, zoomFactor * scaleFactor);
         }
-        if (viewport.height() > pageSize.height) {
+        if (viewport.height() > pageSize.height && pageSize.height > 0) {
             float scaleFactor = viewport.height() / pageSize.height;
             minZoomFactor = (float)Math.max(minZoomFactor, zoomFactor * scaleFactor);
         }
 
         if (!FloatUtils.fuzzyEquals(minZoomFactor, 0.0f)) {
             PointF center = new PointF(viewport.width() / 2.0f, viewport.height() / 2.0f);
             viewportMetrics.scaleTo(minZoomFactor, center);
         } else if (zoomFactor > MAX_ZOOM) {