From 5477ffbc1910cdfaa6f7abdd5d0b7eb22dad6e7b Mon Sep 17 00:00:00 2001 From: Jim Chen Date: Mon, 4 Dec 2017 11:50:20 -0500 Subject: [PATCH] Bug 1416330 - 2. Stop using LayerView in GeckoView; r=rbarker Implement the setSurfaceBackgroundColor functionality in a new coverUntilFirstPaint method. Because we no longer rely on any LayerView functionality, GeckoView now inherits directly from FrameLayout. MozReview-Commit-ID: 3xgWsgk64GM --HG-- extra : rebase_source : 1185e40456ffce6c40676230e6f921dd0f3cbc3e --- .../java/org/mozilla/gecko/GeckoView.java | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoView.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoView.java index e8a7b077c56f..c834d404ca39 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoView.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoView.java @@ -7,8 +7,8 @@ package org.mozilla.gecko; import org.mozilla.gecko.gfx.DynamicToolbarAnimator; +import org.mozilla.gecko.gfx.NativePanZoomController; import org.mozilla.gecko.gfx.GeckoDisplay; -import org.mozilla.gecko.gfx.LayerView; import android.content.Context; import android.graphics.Canvas; @@ -32,8 +32,9 @@ import android.view.accessibility.AccessibilityManager; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputConnection; import android.view.inputmethod.InputMethodManager; +import android.widget.FrameLayout; -public class GeckoView extends LayerView { +public class GeckoView extends FrameLayout { private static final String LOGTAG = "GeckoView"; private static final boolean DEBUG = false; @@ -178,10 +179,16 @@ public class GeckoView extends LayerView { mSurfaceView.getHolder().addCallback(mDisplay); } - @Override - public void setSurfaceBackgroundColor(final int newColor) { + /** + * Set a color to cover the display surface while a document is being shown. The color + * is automatically cleared once the new document starts painting. Set to + * Color.TRANSPARENT to undo the cover. + * + * @param color Cover color. + */ + public void coverUntilFirstPaint(final int color) { if (mSurfaceView != null) { - mSurfaceView.setBackgroundColor(newColor); + mSurfaceView.setBackgroundColor(color); } } @@ -219,6 +226,13 @@ public class GeckoView extends LayerView { session.getPanZoomController().setScrollFactor(0.075f * metrics.densityDpi); } + session.getCompositorController().setFirstPaintCallback(new Runnable() { + @Override + public void run() { + coverUntilFirstPaint(Color.TRANSPARENT); + } + }); + mSession = session; } @@ -234,6 +248,10 @@ public class GeckoView extends LayerView { return mSession.getSettings(); } + public NativePanZoomController getPanZoomController() { + return mSession.getPanZoomController(); + } + public DynamicToolbarAnimator getDynamicToolbarAnimator() { return mSession.getDynamicToolbarAnimator(); } @@ -248,7 +266,6 @@ public class GeckoView extends LayerView { mSession.openWindow(getContext().getApplicationContext()); } mSession.attachView(this); - attachCompositor(mSession); super.onAttachedToWindow(); } @@ -410,12 +427,6 @@ public class GeckoView extends LayerView { mInputConnectionListener.onKeyMultiple(keyCode, repeatCount, event); } - @Override - public boolean isIMEEnabled() { - return mInputConnectionListener != null && - mInputConnectionListener.isIMEEnabled(); - } - @Override public void dispatchDraw(final Canvas canvas) { super.dispatchDraw(canvas);