Bug 1258470 - Part 3: Remove zoom constraints and RTL flag. draft
authorNick Alexander <nalexander@mozilla.com>
Thu, 23 Jun 2016 11:50:41 -0700
changeset 380995 7bbc493d4480356fa29d46629a20e5b75b13df51
parent 380994 5ba4e0d2b6bfe10df53ee30966ca419c00220d3c
child 380996 3052f52a5658b72815116d3a57b2a6dd92ac61d8
push id21383
push usernalexander@mozilla.com
push dateFri, 24 Jun 2016 00:16:43 +0000
bugs1258470
milestone50.0a1
Bug 1258470 - Part 3: Remove zoom constraints and RTL flag. The previous patch removed the only setter of mZoomConstraints and mIsRTL. It's not clear to me how RTL is handled in this tangled code, but this should work for now. MozReview-Commit-ID: 7JiEJWsto4o
mobile/android/base/java/org/mozilla/gecko/Tab.java
mobile/android/base/java/org/mozilla/gecko/ZoomConstraints.java
mobile/android/base/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
mobile/android/base/java/org/mozilla/gecko/gfx/LayerView.java
mobile/android/base/java/org/mozilla/gecko/gfx/PanZoomTarget.java
mobile/android/base/moz.build
--- a/mobile/android/base/java/org/mozilla/gecko/Tab.java
+++ b/mobile/android/base/java/org/mozilla/gecko/Tab.java
@@ -67,18 +67,16 @@ public class Tab {
     private final int mParentId;
     // Indicates the url was loaded from a source external to the app. This will be cleared
     // when the user explicitly loads a new url (e.g. clicking a link is not explicit).
     private final boolean mExternal;
     private boolean mBookmark;
     private int mFaviconLoadId;
     private String mContentType;
     private boolean mHasTouchListeners;
-    private ZoomConstraints mZoomConstraints;
-    private boolean mIsRTL;
     private final ArrayList<View> mPluginViews;
     private final HashMap<Object, Layer> mPluginLayers;
     private int mBackgroundColor;
     private int mState;
     private Bitmap mThumbnailBitmap;
     private boolean mDesktopMode;
     private boolean mEnteringReaderMode;
     private final Context mAppContext;
@@ -132,17 +130,16 @@ public class Tab {
         mBaseDomain = "";
         mUserRequested = "";
         mExternal = external;
         mParentId = parentId;
         mTitle = title == null ? "" : title;
         mSiteIdentity = new SiteIdentity();
         mHistoryIndex = -1;
         mContentType = "";
-        mZoomConstraints = new ZoomConstraints(false);
         mPluginViews = new ArrayList<View>();
         mPluginLayers = new HashMap<Object, Layer>();
         mState = shouldShowProgress(url) ? STATE_LOADING : STATE_SUCCESS;
         mLoadProgress = LOAD_PROGRESS_INIT;
 
         // At startup, the background is set to a color specified by LayerView
         // when the LayerView is created. Shortly after, this background color
         // will be used before the tab's content is shown.
@@ -408,32 +405,16 @@ public class Tab {
         if (mState != Tab.STATE_LOADING)
             mEnteringReaderMode = false;
     }
 
     public int getState() {
         return mState;
     }
 
-    public void setZoomConstraints(ZoomConstraints constraints) {
-        mZoomConstraints = constraints;
-    }
-
-    public ZoomConstraints getZoomConstraints() {
-        return mZoomConstraints;
-    }
-
-    public void setIsRTL(boolean aIsRTL) {
-        mIsRTL = aIsRTL;
-    }
-
-    public boolean getIsRTL() {
-        return mIsRTL;
-    }
-
     public void setHasTouchListeners(boolean aValue) {
         mHasTouchListeners = aValue;
     }
 
     public boolean getHasTouchListeners() {
         return mHasTouchListeners;
     }
 
@@ -683,17 +664,16 @@ public class Tab {
         setContentType(message.getString("contentType"));
         updateUserRequested(message.getString("userRequested"));
         mBaseDomain = message.optString("baseDomain");
 
         setHasFeeds(false);
         setHasOpenSearch(false);
         mSiteIdentity.reset();
         setSiteLogins(null);
-        setZoomConstraints(new ZoomConstraints(true));
         setHasTouchListeners(false);
         setBackgroundColor(DEFAULT_BACKGROUND_COLOR);
         setErrorType(ErrorType.NONE);
         setLoadProgressIfLoading(LOAD_PROGRESS_LOCATION_CHANGE);
 
         Tabs.getInstance().notifyListeners(this, Tabs.TabEvents.LOCATION_CHANGE, oldUrl);
     }
 
deleted file mode 100644
--- a/mobile/android/base/java/org/mozilla/gecko/ZoomConstraints.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-package org.mozilla.gecko;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-public final class ZoomConstraints {
-    private final boolean mAllowZoom;
-    private final boolean mAllowDoubleTapZoom;
-    private final float mMinZoom;
-    private final float mMaxZoom;
-
-    public ZoomConstraints(boolean allowZoom) {
-        mAllowZoom = allowZoom;
-        mAllowDoubleTapZoom = allowZoom;
-        mMinZoom = 0.0f;
-        mMaxZoom = 0.0f;
-    }
-
-    ZoomConstraints(JSONObject message) throws JSONException {
-        mAllowZoom = message.getBoolean("allowZoom");
-        mAllowDoubleTapZoom = message.getBoolean("allowDoubleTapZoom");
-        mMinZoom = (float)message.getDouble("minZoom");
-        mMaxZoom = (float)message.getDouble("maxZoom");
-    }
-
-    public final boolean getAllowZoom() {
-        return mAllowZoom;
-    }
-
-    public final boolean getAllowDoubleTapZoom() {
-        return mAllowDoubleTapZoom;
-    }
-
-    public final float getMinZoom() {
-        return mMinZoom;
-    }
-
-    public final float getMaxZoom() {
-        return mMaxZoom;
-    }
-}
--- a/mobile/android/base/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
+++ b/mobile/android/base/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
@@ -7,17 +7,16 @@ package org.mozilla.gecko.gfx;
 
 import org.mozilla.gecko.annotation.RobocopTarget;
 import org.mozilla.gecko.annotation.WrapForJNI;
 import org.mozilla.gecko.GeckoAppShell;
 import org.mozilla.gecko.GeckoEvent;
 import org.mozilla.gecko.gfx.LayerView.DrawListener;
 import org.mozilla.gecko.Tab;
 import org.mozilla.gecko.Tabs;
-import org.mozilla.gecko.ZoomConstraints;
 import org.mozilla.gecko.EventDispatcher;
 import org.mozilla.gecko.util.FloatUtils;
 import org.mozilla.gecko.AppConstants;
 
 import android.content.Context;
 import android.graphics.PointF;
 import android.graphics.RectF;
 import android.os.SystemClock;
@@ -86,18 +85,16 @@ class GeckoLayerClient implements LayerV
      * 1) reading mViewportMetrics from any thread is fine without synchronization
      * 2) writing to mViewportMetrics requires synchronizing on the layer controller object
      * 3) whenever reading multiple fields from mViewportMetrics without synchronization (i.e. in
      *    case 1 above) you should always first grab a local copy of the reference, and then use
      *    that because mViewportMetrics might get reassigned in between reading the different
      *    fields. */
     private volatile ImmutableViewportMetrics mViewportMetrics;
 
-    private ZoomConstraints mZoomConstraints;
-
     private volatile boolean mGeckoIsReady;
 
     private final PanZoomController mPanZoomController;
     private final DynamicToolbarAnimator mToolbarAnimator;
     private final LayerView mView;
 
     /* This flag is true from the time that browser.js detects a first-paint is about to start,
      * to the time that we receive the first-paint composite notification from the compositor.
@@ -122,23 +119,16 @@ class GeckoLayerClient implements LayerV
         mCurrentViewTransform = new ViewTransform(0, 0, 1);
         mProgressiveUpdateData = new ProgressiveUpdateData();
         mProgressiveUpdateDisplayPort = new DisplayPortMetrics();
 
         mForceRedraw = true;
         DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
         mViewportMetrics = new ImmutableViewportMetrics(displayMetrics)
                            .setViewportSize(view.getWidth(), view.getHeight());
-        mZoomConstraints = new ZoomConstraints(false);
-
-        Tab tab = Tabs.getInstance().getSelectedTab();
-        if (tab != null) {
-            mZoomConstraints = tab.getZoomConstraints();
-            mViewportMetrics = mViewportMetrics.setIsRTL(tab.getIsRTL());
-        }
 
         mFrameMetrics = mViewportMetrics;
 
         mDrawListeners = new ArrayList<DrawListener>();
         mToolbarAnimator = new DynamicToolbarAnimator(this);
         mPanZoomController = PanZoomController.Factory.create(this, view, eventDispatcher);
         mView = view;
         mView.setListener(this);
@@ -549,27 +539,16 @@ class GeckoLayerClient implements LayerV
         // Abort drawing stale low-precision content if there's a more recent
         // display-port in the pipeline.
         if (lowPrecision && !aHasPendingNewThebesContent) {
           mProgressiveUpdateData.abort = true;
         }
         return mProgressiveUpdateData;
     }
 
-    void setZoomConstraints(ZoomConstraints constraints) {
-        mZoomConstraints = constraints;
-    }
-
-    void setIsRTL(boolean aIsRTL) {
-        synchronized (getLock()) {
-            ImmutableViewportMetrics newMetrics = getViewportMetrics().setIsRTL(aIsRTL);
-            setViewportMetrics(newMetrics, false);
-        }
-    }
-
     /** The compositor invokes this function just before compositing a frame where the document
       * is different from the document composited on the last frame. In these cases, the viewport
       * information we have in Java is no longer valid and needs to be replaced with the new
       * viewport information provided. setPageRect will never be invoked on the same frame that
       * this function is invoked on; and this function will always be called prior to syncViewportInfo.
       */
     @WrapForJNI(allowMultithread = true)
     public void setFirstPaintViewport(float offsetX, float offsetY, float zoom,
@@ -580,34 +559,32 @@ class GeckoLayerClient implements LayerV
             Tab tab = Tabs.getInstance().getSelectedTab();
 
             RectF cssPageRect = new RectF(cssPageLeft, cssPageTop, cssPageRight, cssPageBottom);
             RectF pageRect = RectUtils.scaleAndRound(cssPageRect, zoom);
 
             final ImmutableViewportMetrics newMetrics = currentMetrics
                 .setViewportOrigin(offsetX, offsetY)
                 .setZoomFactor(zoom)
-                .setPageRect(pageRect, cssPageRect)
-                .setIsRTL(tab != null ? tab.getIsRTL() : false);
+                .setPageRect(pageRect, cssPageRect);
             // Since we have switched to displaying a different document, we need to update any
             // viewport-related state we have lying around. This includes mGeckoViewport and
             // mViewportMetrics. Usually this information is updated via handleViewportMessage
             // while we remain on the same document.
             post(new Runnable() {
                 @Override
                 public void run() {
                     mGeckoViewport = newMetrics;
                 }
             });
 
             setViewportMetrics(newMetrics);
 
             if (tab != null) {
                 mView.setBackgroundColor(tab.getBackgroundColor());
-                setZoomConstraints(tab.getZoomConstraints());
             }
 
             // At this point, we have just switched to displaying a different document than we
             // we previously displaying. This means we need to abort any panning/zooming animations
             // that are in progress and send an updated display port request to browser.js as soon
             // as possible. The call to PanZoomController.abortAnimation accomplishes this by calling the
             // forceRedraw function, which sends the viewport to gecko. The display port request is
             // actually a full viewport update, which is fine because if browser.js has somehow moved to
@@ -997,22 +974,16 @@ class GeckoLayerClient implements LayerV
     /** Implementation of PanZoomTarget */
     @Override
     public ImmutableViewportMetrics getViewportMetrics() {
         return mViewportMetrics;
     }
 
     /** Implementation of PanZoomTarget */
     @Override
-    public ZoomConstraints getZoomConstraints() {
-        return mZoomConstraints;
-    }
-
-    /** Implementation of PanZoomTarget */
-    @Override
     public FullScreenState getFullScreenState() {
         return mView.getFullScreenState();
     }
 
     /** Implementation of PanZoomTarget */
     @Override
     public PointF getVisibleEndOfLayerView() {
         return mToolbarAnimator.getVisibleEndOfLayerView();
--- a/mobile/android/base/java/org/mozilla/gecko/gfx/LayerView.java
+++ b/mobile/android/base/java/org/mozilla/gecko/gfx/LayerView.java
@@ -13,17 +13,16 @@ import org.mozilla.gecko.annotation.Robo
 import org.mozilla.gecko.annotation.WrapForJNI;
 import org.mozilla.gecko.AppConstants;
 import org.mozilla.gecko.AppConstants.Versions;
 import org.mozilla.gecko.EventDispatcher;
 import org.mozilla.gecko.GeckoAccessibility;
 import org.mozilla.gecko.GeckoAppShell;
 import org.mozilla.gecko.GeckoEvent;
 import org.mozilla.gecko.GeckoThread;
-import org.mozilla.gecko.ZoomConstraints;
 
 import android.content.Context;
 import android.graphics.Canvas;
 import android.graphics.Color;
 import android.graphics.Point;
 import android.graphics.PointF;
 import android.graphics.Rect;
 import android.graphics.SurfaceTexture;
--- a/mobile/android/base/java/org/mozilla/gecko/gfx/PanZoomTarget.java
+++ b/mobile/android/base/java/org/mozilla/gecko/gfx/PanZoomTarget.java
@@ -1,23 +1,20 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.gfx;
 
-import org.mozilla.gecko.ZoomConstraints;
-
 import android.graphics.PointF;
 import android.graphics.RectF;
 
 public interface PanZoomTarget {
     public ImmutableViewportMetrics getViewportMetrics();
-    public ZoomConstraints getZoomConstraints();
     public FullScreenState getFullScreenState();
     public PointF getVisibleEndOfLayerView();
 
     public void setAnimationTarget(ImmutableViewportMetrics viewport);
     public void setViewportMetrics(ImmutableViewportMetrics viewport);
     public void scrollBy(float dx, float dy);
     public void panZoomStopped();
     /** This triggers an (asynchronous) viewport update/redraw. */
--- a/mobile/android/base/moz.build
+++ b/mobile/android/base/moz.build
@@ -657,17 +657,16 @@ gbjar.sources += ['java/org/mozilla/geck
     'widget/RoundedCornerLayout.java',
     'widget/SiteLogins.java',
     'widget/SquaredImageView.java',
     'widget/SquaredRelativeLayout.java',
     'widget/SwipeDismissListViewTouchListener.java',
     'widget/TabThumbnailWrapper.java',
     'widget/ThumbnailView.java',
     'widget/TwoWayView.java',
-    'ZoomConstraints.java',
     'ZoomedView.java',
 ]]
 # The following sources are checked in to version control but
 # generated by a script (java/org/mozilla/gecko/widget/themed/generate_themed_views.py).
 # If you're editing this list, make sure to edit that script.
 gbjar.sources += ['java/org/mozilla/gecko/' + x for x in [
     'widget/themed/ThemedEditText.java',
     'widget/themed/ThemedFrameLayout.java',