Bug 1302452 - Rip out the filler view inside LayerView since we don't support older Android versions any more. r=rbarker

MozReview-Commit-ID: In4imULuo1t
This commit is contained in:
Kartikaya Gupta 2016-09-14 11:02:37 -04:00
Родитель bf6bdf8c7c
Коммит 7522e70f83
3 изменённых файлов: 10 добавлений и 74 удалений

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

@ -645,7 +645,6 @@ class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
mView.post(new Runnable() {
@Override
public void run() {
event.offsetLocation(0, mView.getSurfaceTranslation());
mView.dispatchTouchEvent(event);
}
});

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

@ -9,6 +9,7 @@ import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import org.mozilla.gecko.AndroidGamepadManager;
import org.mozilla.gecko.animation.ViewHelper;
import org.mozilla.gecko.annotation.RobocopTarget;
import org.mozilla.gecko.annotation.WrapForJNI;
import org.mozilla.gecko.AppConstants;
@ -41,13 +42,12 @@ import android.view.TextureView;
import android.view.View;
import android.view.ViewGroup;
import android.view.InputDevice;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.FrameLayout;
/**
* A view rendered by the layer compositor.
*/
public class LayerView extends ScrollView implements Tabs.OnTabsChangedListener {
public class LayerView extends FrameLayout implements Tabs.OnTabsChangedListener {
private static final String LOGTAG = "GeckoLayerView";
private GeckoLayerClient mLayerClient;
@ -60,12 +60,9 @@ public class LayerView extends ScrollView implements Tabs.OnTabsChangedListener
private SurfaceView mSurfaceView;
private TextureView mTextureView;
private View mFillerView;
private Listener mListener;
private float mSurfaceTranslation;
/* This should only be modified on the Java UI thread. */
private final Overscroll mOverscroll;
@ -244,7 +241,6 @@ public class LayerView extends ScrollView implements Tabs.OnTabsChangedListener
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
requestFocus();
}
event.offsetLocation(0, -mSurfaceTranslation);
if (mToolbarAnimator != null && mToolbarAnimator.onInterceptTouchEvent(event)) {
if (mPanZoomController != null) {
@ -272,8 +268,6 @@ public class LayerView extends ScrollView implements Tabs.OnTabsChangedListener
return false;
}
event.offsetLocation(0, -mSurfaceTranslation);
if (!mLayerClient.isGeckoReady()) {
// If gecko isn't loaded yet, don't try sending events to the
// native code because it's just going to crash
@ -287,8 +281,6 @@ public class LayerView extends ScrollView implements Tabs.OnTabsChangedListener
@Override
public boolean onGenericMotionEvent(MotionEvent event) {
event.offsetLocation(0, -mSurfaceTranslation);
if (AndroidGamepadManager.handleMotionEvent(event)) {
return true;
}
@ -340,25 +332,7 @@ public class LayerView extends ScrollView implements Tabs.OnTabsChangedListener
mSurfaceView = new LayerSurfaceView(getContext(), this);
mSurfaceView.setBackgroundColor(Color.WHITE);
// The "filler" view sits behind the URL bar and should never be
// visible. It exists solely to make this LayerView actually
// scrollable so that we can shift the surface around on the screen.
// Once we drop support for pre-Honeycomb Android versions this
// should not be needed; we can just turn LayerView back into a
// FrameLayout that holds mSurfaceView and nothing else.
mFillerView = new View(getContext()) {
@Override protected void onMeasure(int aWidthSpec, int aHeightSpec) {
setMeasuredDimension(0, Math.round(mToolbarAnimator.getMaxTranslation()));
}
};
mFillerView.setBackgroundColor(Color.RED);
LinearLayout container = new LinearLayout(getContext());
container.setOrientation(LinearLayout.VERTICAL);
container.addView(mFillerView);
container.addView(mSurfaceView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
addView(container, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
addView(mSurfaceView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
SurfaceHolder holder = mSurfaceView.getHolder();
holder.addCallback(new SurfaceListener());
@ -624,45 +598,17 @@ public class LayerView extends ScrollView implements Tabs.OnTabsChangedListener
}
}
@Override
protected void onMeasure(int aWidthSpec, int aHeightSpec) {
super.onMeasure(aWidthSpec, aHeightSpec);
if (mSurfaceView != null) {
// Because of the crazy setup where this LayerView is a ScrollView
// and the SurfaceView is inside a LinearLayout, the SurfaceView
// doesn't get the right information to size itself the way we want.
// We always want it to be the same size as this LayerView, so we
// use a hack to make sure it sizes itself that way.
((LayerSurfaceView)mSurfaceView).overrideSize(getMeasuredWidth(), getMeasuredHeight());
}
}
/* A subclass of SurfaceView to listen to layout changes, as
* View.OnLayoutChangeListener requires API level 11.
*/
private class LayerSurfaceView extends SurfaceView {
private LayerView mParent;
private int mForcedWidth;
private int mForcedHeight;
public LayerSurfaceView(Context aContext, LayerView aParent) {
super(aContext);
mParent = aParent;
}
void overrideSize(int aWidth, int aHeight) {
if (mForcedWidth != aWidth || mForcedHeight != aHeight) {
mForcedWidth = aWidth;
mForcedHeight = aHeight;
requestLayout();
}
}
@Override
protected void onMeasure(int aWidthSpec, int aHeightSpec) {
setMeasuredDimension(mForcedWidth, mForcedHeight);
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
@ -746,22 +692,14 @@ public class LayerView extends ScrollView implements Tabs.OnTabsChangedListener
public void setMaxTranslation(float aMaxTranslation) {
mToolbarAnimator.setMaxTranslation(aMaxTranslation);
if (mFillerView != null) {
mFillerView.requestLayout();
}
}
public void setSurfaceTranslation(float translation) {
// Once we drop support for pre-Honeycomb Android versions, we can
// revert bug 1197811 and just use ViewHelper here.
if (mSurfaceTranslation != translation) {
mSurfaceTranslation = translation;
scrollTo(0, Math.round(mToolbarAnimator.getMaxTranslation() - translation));
}
ViewHelper.setTranslationY(this, translation);
}
public float getSurfaceTranslation() {
return mSurfaceTranslation;
return ViewHelper.getTranslationY(this);
}
@Override

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

@ -124,25 +124,24 @@ public class OverscrollEdgeEffect implements Overscroll {
return;
}
float fillerSize = mView.getDynamicToolbarAnimator().getMaxTranslation();
PointF visibleEnd = mView.getDynamicToolbarAnimator().getVisibleEndOfLayerView();
// If we're pulling an edge, or fading it out, draw!
boolean invalidate = false;
if (!mEdges[TOP].isFinished()) {
invalidate |= draw(mEdges[TOP], canvas, 0, fillerSize, 0);
invalidate |= draw(mEdges[TOP], canvas, 0, 0, 0);
}
if (!mEdges[BOTTOM].isFinished()) {
invalidate |= draw(mEdges[BOTTOM], canvas, visibleEnd.x, fillerSize + visibleEnd.y, 180);
invalidate |= draw(mEdges[BOTTOM], canvas, visibleEnd.x, visibleEnd.y, 180);
}
if (!mEdges[LEFT].isFinished()) {
invalidate |= draw(mEdges[LEFT], canvas, 0, fillerSize + visibleEnd.y, 270);
invalidate |= draw(mEdges[LEFT], canvas, 0, visibleEnd.y, 270);
}
if (!mEdges[RIGHT].isFinished()) {
invalidate |= draw(mEdges[RIGHT], canvas, visibleEnd.x, fillerSize, 90);
invalidate |= draw(mEdges[RIGHT], canvas, visibleEnd.x, 0, 90);
}
// If the edge effect is animating off screen, invalidate.