Bug 1415994 - 1. Don't report screen size in GeckoLayerClient; r=rbarker
We don't actually use the screen size through GeckoLayerClient anymore.
Getting rid of it lets us get rid of the Context field in
GeckoLayerClient as well.
MozReview-Commit-ID: GM1jlhAZm4T
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
@@ -5,35 +5,31 @@
package org.mozilla.gecko.gfx;
import org.mozilla.gecko.annotation.RobocopTarget;
import org.mozilla.gecko.annotation.WrapForJNI;
import org.mozilla.gecko.EventDispatcher;
import org.mozilla.gecko.util.GeckoBundle;
-import android.content.Context;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.PointF;
import android.graphics.RectF;
import android.os.SystemClock;
-import android.util.DisplayMetrics;
import android.util.Log;
import android.view.InputDevice;
import android.view.MotionEvent;
import java.util.ArrayList;
class GeckoLayerClient implements LayerView.Listener
{
private static final String LOGTAG = "GeckoLayerClient";
- private final Context mContext;
- private IntSize mScreenSize;
private IntSize mWindowSize;
private boolean mForceRedraw;
private boolean mImeWasEnabledOnLastResize;
/* The current viewport metrics.
* This is volatile so that we can read and write to it from different threads.
* We avoid synchronization to make getting the viewport metrics from
@@ -60,26 +56,23 @@ class GeckoLayerClient implements LayerV
* have the first-paint flag set, and the second paint happens concurrently with the
* composite for the first paint, then this flag may be set to true prematurely. Fixing this
* is possible but risky; see https://bugzilla.mozilla.org/show_bug.cgi?id=797615#c751
*/
private volatile boolean mContentDocumentIsDisplayed;
private SynthesizedEventState mPointerState;
- public GeckoLayerClient(Context context, LayerView view) {
+ public GeckoLayerClient(LayerView view) {
// we can fill these in with dummy values because they are always written
// to before being read
- mContext = context;
- mScreenSize = new IntSize(0, 0);
mWindowSize = new IntSize(0, 0);
mForceRedraw = true;
- DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
- mViewportMetrics = new ImmutableViewportMetrics(displayMetrics)
+ mViewportMetrics = new ImmutableViewportMetrics()
.setViewportSize(view.getWidth(), view.getHeight());
mToolbarAnimator = new DynamicToolbarAnimator(this);
mPanZoomController = PanZoomController.Factory.create(view);
mView = view;
mView.setListener(this);
mContentDocumentIsDisplayed = true;
}
@@ -169,43 +162,33 @@ class GeckoLayerClient implements LayerV
}
DynamicToolbarAnimator getDynamicToolbarAnimator() {
return mToolbarAnimator;
}
/* Informs Gecko that the screen size has changed. */
private void sendResizeEventIfNecessary(boolean force) {
- DisplayMetrics metrics = mContext.getResources().getDisplayMetrics();
-
- IntSize newScreenSize = new IntSize(metrics.widthPixels, metrics.heightPixels);
IntSize newWindowSize = new IntSize(mViewportMetrics.viewportRectWidth,
mViewportMetrics.viewportRectHeight);
- boolean screenSizeChanged = !mScreenSize.equals(newScreenSize);
boolean windowSizeChanged = !mWindowSize.equals(newWindowSize);
- if (!force && !screenSizeChanged && !windowSizeChanged) {
+ if (!force && !windowSizeChanged) {
return;
}
- mScreenSize = newScreenSize;
mWindowSize = newWindowSize;
- if (screenSizeChanged) {
- Log.d(LOGTAG, "Screen-size changed to " + mScreenSize);
- }
-
if (windowSizeChanged) {
Log.d(LOGTAG, "Window-size changed to " + mWindowSize);
}
if (mView != null) {
- mView.notifySizeChanged(mWindowSize.width, mWindowSize.height,
- mScreenSize.width, mScreenSize.height);
+ mView.notifySizeChanged(mWindowSize.width, mWindowSize.height);
}
}
@WrapForJNI(calledFrom = "gecko")
void contentDocumentChanged() {
mContentDocumentIsDisplayed = false;
}
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/ImmutableViewportMetrics.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/ImmutableViewportMetrics.java
@@ -2,17 +2,16 @@
* 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 android.graphics.PointF;
import android.graphics.RectF;
-import android.util.DisplayMetrics;
/**
* ImmutableViewportMetrics are used to store the viewport metrics
* in way that we can access a version of them from multiple threads
* without having to take a lock
*/
public class ImmutableViewportMetrics {
@@ -20,21 +19,21 @@ public class ImmutableViewportMetrics {
// because Java doesn't have the concept of const classes
public final float viewportRectLeft;
public final float viewportRectTop;
public final int viewportRectWidth;
public final int viewportRectHeight;
public final float zoomFactor;
- public ImmutableViewportMetrics(DisplayMetrics metrics) {
- viewportRectLeft = 0;
- viewportRectTop = 0;
- viewportRectWidth = metrics.widthPixels;
- viewportRectHeight = metrics.heightPixels;
+ public ImmutableViewportMetrics() {
+ viewportRectLeft = 0;
+ viewportRectTop = 0;
+ viewportRectWidth = 0;
+ viewportRectHeight = 0;
zoomFactor = 1.0f;
}
private ImmutableViewportMetrics(
float aViewportRectLeft, float aViewportRectTop, int aViewportRectWidth,
int aViewportRectHeight, float aZoomFactor)
{
viewportRectLeft = aViewportRectLeft;
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/LayerView.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/LayerView.java
@@ -118,18 +118,17 @@ public class LayerView extends FrameLayo
@Override protected native void disposeNative();
// Gecko thread sets its Java instances; does not block UI thread.
@WrapForJNI(calledFrom = "any", dispatchTo = "gecko")
/* package */ native void attachToJava(GeckoLayerClient layerClient,
NativePanZoomController npzc);
@WrapForJNI(calledFrom = "any", dispatchTo = "gecko")
- /* package */ native void onSizeChanged(int windowWidth, int windowHeight,
- int screenWidth, int screenHeight);
+ /* package */ native void onSizeChanged(int windowWidth, int windowHeight);
// Gecko thread creates compositor; blocks UI thread.
@WrapForJNI(calledFrom = "ui", dispatchTo = "proxy")
/* package */ native void createCompositor(int width, int height, Object surface);
// Gecko thread pauses compositor; blocks UI thread.
@WrapForJNI(calledFrom = "ui", dispatchTo = "current")
/* package */ native void syncPauseCompositor();
@@ -300,17 +299,17 @@ public class LayerView extends FrameLayo
mDrawListeners = new ArrayList<DrawListener>();
}
public LayerView(Context context) {
this(context, null);
}
public void initializeView() {
- mLayerClient = new GeckoLayerClient(getContext(), this);
+ mLayerClient = new GeckoLayerClient(this);
if (mOverscroll != null) {
mLayerClient.setOverscrollHandler(mOverscroll);
}
mPanZoomController = mLayerClient.getPanZoomController();
mToolbarAnimator = mLayerClient.getDynamicToolbarAnimator();
mToolbarAnimator.notifyCompositorCreated(mCompositor);
@@ -627,18 +626,18 @@ public class LayerView extends FrameLayo
mListener.surfaceChanged();
}
if (mOverscroll != null) {
mOverscroll.setSize(width, height);
}
}
- void notifySizeChanged(int windowWidth, int windowHeight, int screenWidth, int screenHeight) {
- mCompositor.onSizeChanged(windowWidth, windowHeight, screenWidth, screenHeight);
+ void notifySizeChanged(int windowWidth, int windowHeight) {
+ mCompositor.onSizeChanged(windowWidth, windowHeight);
}
void serverSurfaceDestroyed() {
ThreadUtils.assertOnUiThread();
// We need to coordinate with Gecko when pausing composition, to ensure
// that Gecko never executes a draw event while the compositor is paused.
// This is sent synchronously to make sure that we don't attempt to use
--- a/widget/android/GeneratedJNIWrappers.h
+++ b/widget/android/GeneratedJNIWrappers.h
@@ -4063,22 +4063,20 @@ public:
};
struct OnSizeChanged_t {
typedef Compositor Owner;
typedef void ReturnType;
typedef void SetterType;
typedef mozilla::jni::Args<
int32_t,
- int32_t,
- int32_t,
int32_t> Args;
static constexpr char name[] = "onSizeChanged";
static constexpr char signature[] =
- "(IIII)V";
+ "(II)V";
static const bool isStatic = false;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
static const mozilla::jni::CallingThread callingThread =
mozilla::jni::CallingThread::ANY;
static const mozilla::jni::DispatchTarget dispatchTarget =
mozilla::jni::DispatchTarget::GECKO;
};
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -916,18 +916,17 @@ public:
// Set the first-paint flag so that we (re-)link any new Java objects
// to Gecko, co-ordinate viewports, etc.
if (RefPtr<CompositorBridgeChild> bridge = mWindow->GetCompositorBridgeChild()) {
bridge->SendForceIsFirstPaint();
}
}
- void OnSizeChanged(int32_t aWindowWidth, int32_t aWindowHeight,
- int32_t aScreenWidth, int32_t aScreenHeight)
+ void OnSizeChanged(int32_t aWindowWidth, int32_t aWindowHeight)
{
MOZ_ASSERT(NS_IsMainThread());
if (!mWindow) {
return; // Already shut down.
}
if (aWindowWidth != mWindow->mBounds.width ||
aWindowHeight != mWindow->mBounds.height) {