Bug 1258470 - 1. Remove RTL and ZoomConstraints variables from gfx; r=rbarker

We no longer send viewport metadata, so we don't actually make use of
the RTL and ZoomConstraints variables we keep in Java. There is a single
usage of an RTL flag in ImmutableViewportMetrics.offsetViewportByAndClamp,
but I think the two branches are equivalent, so the RTL flag is not needed
there either.
This commit is contained in:
Jim Chen 2016-09-14 12:43:35 -04:00
Родитель 9f0a0cfe9f
Коммит bdb35912c7
8 изменённых файлов: 11 добавлений и 154 удалений

Просмотреть файл

@ -72,8 +72,6 @@ public class Tab {
private int mFaviconLoadId;
private String mContentType;
private boolean mHasTouchListeners;
private ZoomConstraints mZoomConstraints;
private boolean mIsRTL;
private final ArrayList<View> mPluginViews;
private int mState;
private Bitmap mThumbnailBitmap;
@ -137,7 +135,6 @@ public class Tab {
mSiteIdentity = new SiteIdentity();
mHistoryIndex = -1;
mContentType = "";
mZoomConstraints = new ZoomConstraints(false);
mPluginViews = new ArrayList<View>();
mState = shouldShowProgress(url) ? STATE_LOADING : STATE_SUCCESS;
mLoadProgress = LOAD_PROGRESS_INIT;
@ -412,22 +409,6 @@ public class Tab {
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;
}
@ -649,7 +630,6 @@ public class Tab {
setHasOpenSearch(false);
mSiteIdentity.reset();
setSiteLogins(null);
setZoomConstraints(new ZoomConstraints(true));
setHasTouchListeners(false);
setErrorType(ErrorType.NONE);
setLoadProgressIfLoading(LOAD_PROGRESS_LOCATION_CHANGE);

Просмотреть файл

@ -108,7 +108,6 @@ public class Tabs implements GeckoEventListener {
"Tab:Added",
"Tab:Close",
"Tab:Select",
"Tab:LoadedFromCache",
"Content:LocationChange",
"Content:SecurityChange",
"Content:StateChange",
@ -120,7 +119,6 @@ public class Tabs implements GeckoEventListener {
"Link:Feed",
"Link:OpenSearch",
"DesktopMode:Changed",
"Tab:ViewportMetadata",
"Tab:StreamStart",
"Tab:StreamStop",
"Tab:AudioPlayingChange",
@ -561,10 +559,6 @@ public class Tabs implements GeckoEventListener {
} else if (event.equals("DesktopMode:Changed")) {
tab.setDesktopMode(message.getBoolean("desktopMode"));
notifyListeners(tab, TabEvents.DESKTOP_MODE_CHANGE);
} else if (event.equals("Tab:ViewportMetadata")) {
tab.setZoomConstraints(new ZoomConstraints(message));
tab.setIsRTL(message.getBoolean("isRTL"));
notifyListeners(tab, TabEvents.VIEWPORT_CHANGE);
} else if (event.equals("Tab:StreamStart")) {
tab.setRecording(true);
notifyListeners(tab, TabEvents.RECORDING_CHANGE);
@ -631,7 +625,6 @@ public class Tabs implements GeckoEventListener {
LINK_FEED,
SECURITY_CHANGE,
DESKTOP_MODE_CHANGE,
VIEWPORT_CHANGE,
RECORDING_CHANGE,
BOOKMARK_ADDED,
BOOKMARK_REMOVED,

Просмотреть файл

@ -291,7 +291,6 @@ geckoview_java_files = [
'sqlite/SQLiteBridgeException.java',
'TouchEventInterceptor.java',
'widget/SwipeDismissListViewTouchListener.java',
'ZoomConstraints.java',
]
gbjar = add_java_jar('gecko-browser')

Просмотреть файл

@ -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;
}
}

Просмотреть файл

@ -9,9 +9,6 @@ import org.mozilla.gecko.annotation.RobocopTarget;
import org.mozilla.gecko.annotation.WrapForJNI;
import org.mozilla.gecko.GeckoAppShell;
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;
@ -127,10 +124,6 @@ class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
mViewportMetrics = new ImmutableViewportMetrics(displayMetrics)
.setViewportSize(view.getWidth(), view.getHeight());
Tab tab = Tabs.getInstance().getSelectedTab();
if (tab != null) {
mViewportMetrics = mViewportMetrics.setIsRTL(tab.getIsRTL());
}
mFrameMetrics = mViewportMetrics;
@ -329,13 +322,6 @@ class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
return mContentDocumentIsDisplayed;
}
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
@ -348,16 +334,13 @@ class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
synchronized (getLock()) {
ImmutableViewportMetrics currentMetrics = getViewportMetrics();
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

Просмотреть файл

@ -35,7 +35,6 @@ public class ImmutableViewportMetrics {
public final int viewportRectHeight;
public final float zoomFactor;
public final boolean isRTL;
public ImmutableViewportMetrics(DisplayMetrics metrics) {
viewportRectLeft = pageRectLeft = cssPageRectLeft = 0;
@ -45,31 +44,17 @@ public class ImmutableViewportMetrics {
pageRectRight = cssPageRectRight = metrics.widthPixels;
pageRectBottom = cssPageRectBottom = metrics.heightPixels;
zoomFactor = 1.0f;
isRTL = false;
}
/** This constructor is used by native code in AndroidJavaWrappers.cpp, be
* careful when modifying the signature.
*/
@WrapForJNI(calledFrom = "gecko")
public ImmutableViewportMetrics(float aPageRectLeft, float aPageRectTop,
float aPageRectRight, float aPageRectBottom, float aCssPageRectLeft,
float aCssPageRectTop, float aCssPageRectRight, float aCssPageRectBottom,
float aViewportRectLeft, float aViewportRectTop, int aViewportRectWidth,
int aViewportRectHeight, float aZoomFactor)
{
this(aPageRectLeft, aPageRectTop,
aPageRectRight, aPageRectBottom, aCssPageRectLeft,
aCssPageRectTop, aCssPageRectRight, aCssPageRectBottom,
aViewportRectLeft, aViewportRectTop, aViewportRectWidth,
aViewportRectHeight, aZoomFactor, false);
}
private ImmutableViewportMetrics(float aPageRectLeft, float aPageRectTop,
float aPageRectRight, float aPageRectBottom, float aCssPageRectLeft,
float aCssPageRectTop, float aCssPageRectRight, float aCssPageRectBottom,
float aViewportRectLeft, float aViewportRectTop, int aViewportRectWidth,
int aViewportRectHeight, float aZoomFactor, boolean aIsRTL)
int aViewportRectHeight, float aZoomFactor)
{
pageRectLeft = aPageRectLeft;
pageRectTop = aPageRectTop;
@ -84,7 +69,6 @@ public class ImmutableViewportMetrics {
viewportRectWidth = aViewportRectWidth;
viewportRectHeight = aViewportRectHeight;
zoomFactor = aZoomFactor;
isRTL = aIsRTL;
}
public float getWidth() {
@ -164,8 +148,7 @@ public class ImmutableViewportMetrics {
FloatUtils.interpolate(viewportRectTop, to.viewportRectTop, t),
(int)FloatUtils.interpolate(viewportRectWidth, to.viewportRectWidth, t),
(int)FloatUtils.interpolate(viewportRectHeight, to.viewportRectHeight, t),
FloatUtils.interpolate(zoomFactor, to.zoomFactor, t),
t >= 0.5 ? to.isRTL : isRTL);
FloatUtils.interpolate(zoomFactor, to.zoomFactor, t));
}
public ImmutableViewportMetrics setViewportSize(int width, int height) {
@ -177,7 +160,7 @@ public class ImmutableViewportMetrics {
pageRectLeft, pageRectTop, pageRectRight, pageRectBottom,
cssPageRectLeft, cssPageRectTop, cssPageRectRight, cssPageRectBottom,
viewportRectLeft, viewportRectTop, width, height,
zoomFactor, isRTL);
zoomFactor);
}
public ImmutableViewportMetrics setViewportOrigin(float newOriginX, float newOriginY) {
@ -185,7 +168,7 @@ public class ImmutableViewportMetrics {
pageRectLeft, pageRectTop, pageRectRight, pageRectBottom,
cssPageRectLeft, cssPageRectTop, cssPageRectRight, cssPageRectBottom,
newOriginX, newOriginY, viewportRectWidth, viewportRectHeight,
zoomFactor, isRTL);
zoomFactor);
}
public ImmutableViewportMetrics setZoomFactor(float newZoomFactor) {
@ -193,7 +176,7 @@ public class ImmutableViewportMetrics {
pageRectLeft, pageRectTop, pageRectRight, pageRectBottom,
cssPageRectLeft, cssPageRectTop, cssPageRectRight, cssPageRectBottom,
viewportRectLeft, viewportRectTop, viewportRectWidth, viewportRectHeight,
newZoomFactor, isRTL);
newZoomFactor);
}
public ImmutableViewportMetrics offsetViewportBy(float dx, float dy) {
@ -201,11 +184,6 @@ public class ImmutableViewportMetrics {
}
public ImmutableViewportMetrics offsetViewportByAndClamp(float dx, float dy) {
if (isRTL) {
return setViewportOrigin(
Math.min(pageRectRight - getWidth(), Math.max(viewportRectLeft + dx, pageRectLeft)),
Math.max(pageRectTop, Math.min(viewportRectTop + dy, pageRectBottom - getHeight())));
}
return setViewportOrigin(
Math.max(pageRectLeft, Math.min(viewportRectLeft + dx, pageRectRight - getWidth())),
Math.max(pageRectTop, Math.min(viewportRectTop + dy, pageRectBottom - getHeight())));
@ -216,7 +194,7 @@ public class ImmutableViewportMetrics {
pageRect.left, pageRect.top, pageRect.right, pageRect.bottom,
cssPageRect.left, cssPageRect.top, cssPageRect.right, cssPageRect.bottom,
viewportRectLeft, viewportRectTop, viewportRectWidth, viewportRectHeight,
zoomFactor, isRTL);
zoomFactor);
}
public ImmutableViewportMetrics setPageRectFrom(ImmutableViewportMetrics aMetrics) {
@ -230,18 +208,6 @@ public class ImmutableViewportMetrics {
return setPageRect(RectUtils.scale(css, zoomFactor), css);
}
public ImmutableViewportMetrics setIsRTL(boolean aIsRTL) {
if (isRTL == aIsRTL) {
return this;
}
return new ImmutableViewportMetrics(
pageRectLeft, pageRectTop, pageRectRight, pageRectBottom,
cssPageRectLeft, cssPageRectTop, cssPageRectRight, cssPageRectBottom,
viewportRectLeft, viewportRectTop, viewportRectWidth, viewportRectHeight,
zoomFactor, aIsRTL);
}
/* This will set the zoom factor and re-scale page-size and viewport offset
* accordingly. The given focus will remain at the same point on the screen
* after scaling.
@ -263,7 +229,7 @@ public class ImmutableViewportMetrics {
newPageRectLeft, newPageRectTop, newPageRectRight, newPageRectBottom,
cssPageRectLeft, cssPageRectTop, cssPageRectRight, cssPageRectBottom,
origin.x, origin.y, viewportRectWidth, viewportRectHeight,
newZoomFactor, isRTL);
newZoomFactor);
}
/** Clamps the viewport to remain within the page rect. */
@ -287,7 +253,7 @@ public class ImmutableViewportMetrics {
pageRectLeft, pageRectTop, pageRectRight, pageRectBottom,
cssPageRectLeft, cssPageRectTop, cssPageRectRight, cssPageRectBottom,
newViewport.left, newViewport.top, viewportRectWidth, viewportRectHeight,
zoomFactor, isRTL);
zoomFactor);
}
public boolean fuzzyEquals(ImmutableViewportMetrics other) {
@ -311,6 +277,6 @@ public class ImmutableViewportMetrics {
+ viewportRectWidth + "x" + viewportRectHeight + ") p=(" + pageRectLeft + ","
+ pageRectTop + "," + pageRectRight + "," + pageRectBottom + ") c=("
+ cssPageRectLeft + "," + cssPageRectTop + "," + cssPageRectRight + ","
+ cssPageRectBottom + ") z=" + zoomFactor + ", rtl=" + isRTL;
+ cssPageRectBottom + ") z=" + zoomFactor;
}
}

Просмотреть файл

@ -19,10 +19,7 @@ import org.mozilla.gecko.GeckoAccessibility;
import org.mozilla.gecko.GeckoAppShell;
import org.mozilla.gecko.GeckoThread;
import org.mozilla.gecko.mozglue.JNIObject;
import org.mozilla.gecko.Tab;
import org.mozilla.gecko.Tabs;
import org.mozilla.gecko.util.ThreadUtils;
import org.mozilla.gecko.ZoomConstraints;
import android.content.Context;
import android.graphics.Canvas;
@ -47,7 +44,7 @@ import android.widget.FrameLayout;
/**
* A view rendered by the layer compositor.
*/
public class LayerView extends FrameLayout implements Tabs.OnTabsChangedListener {
public class LayerView extends FrameLayout {
private static final String LOGTAG = "GeckoLayerView";
private GeckoLayerClient mLayerClient;
@ -169,7 +166,6 @@ public class LayerView extends FrameLayout implements Tabs.OnTabsChangedListener
} else {
mOverscroll = null;
}
Tabs.registerOnTabsChangedListener(this);
}
public LayerView(Context context) {
@ -223,7 +219,6 @@ public class LayerView extends FrameLayout implements Tabs.OnTabsChangedListener
if (mRenderer != null) {
mRenderer.destroy();
}
Tabs.unregisterOnTabsChangedListener(this);
}
@Override
@ -374,10 +369,6 @@ public class LayerView extends FrameLayout implements Tabs.OnTabsChangedListener
}
}
public void setIsRTL(boolean aIsRTL) {
mLayerClient.setIsRTL(aIsRTL);
}
public void requestRender() {
if (mCompositorCreated) {
mCompositor.syncInvalidateAndScheduleComposite();
@ -702,13 +693,6 @@ public class LayerView extends FrameLayout implements Tabs.OnTabsChangedListener
return ViewHelper.getTranslationY(this);
}
@Override
public void onTabChanged(Tab tab, Tabs.TabEvents msg, String data) {
if (msg == Tabs.TabEvents.VIEWPORT_CHANGE && Tabs.getInstance().isSelectedTab(tab) && mLayerClient != null) {
setIsRTL(tab.getIsRTL());
}
}
// Public hooks for dynamic toolbar translation
public interface DynamicToolbarListener {

Просмотреть файл

@ -5,8 +5,6 @@
package org.mozilla.gecko.gfx;
import org.mozilla.gecko.ZoomConstraints;
import android.graphics.Matrix;
import android.graphics.PointF;