| Index: blimp/client/app/android/java/src/org/chromium/blimp/app/BlimpContentsDisplay.java
|
| diff --git a/blimp/client/app/android/java/src/org/chromium/blimp/app/BlimpContentsDisplay.java b/blimp/client/app/android/java/src/org/chromium/blimp/app/BlimpContentsDisplay.java
|
| index 9c6ce5b41d0215f524097de495eb502941779f6c..74c8178194b585ee0889c29dbad846f7e89ac71e 100644
|
| --- a/blimp/client/app/android/java/src/org/chromium/blimp/app/BlimpContentsDisplay.java
|
| +++ b/blimp/client/app/android/java/src/org/chromium/blimp/app/BlimpContentsDisplay.java
|
| @@ -9,7 +9,6 @@ import android.graphics.Color;
|
| import android.graphics.Point;
|
| import android.os.Build;
|
| import android.util.AttributeSet;
|
| -import android.view.MotionEvent;
|
| import android.view.Surface;
|
| import android.view.SurfaceHolder;
|
| import android.view.SurfaceView;
|
| @@ -18,8 +17,7 @@ import android.view.WindowManager;
|
|
|
| import org.chromium.base.annotations.CalledByNative;
|
| import org.chromium.base.annotations.JNINamespace;
|
| -import org.chromium.blimp.app.session.BlimpClientSession;
|
| -import org.chromium.ui.UiUtils;
|
| +import org.chromium.blimp_public.contents.BlimpContents;
|
|
|
| /**
|
| * A {@link View} that will visually represent the Blimp rendered content. This {@link View} starts
|
| @@ -45,10 +43,9 @@ public class BlimpContentsDisplay
|
| /**
|
| * Starts up rendering for this {@link View}. This will start up the native compositor and will
|
| * display it's contents.
|
| - * @param blimpClientSession The {@link BlimpClientSession} that contains the content-lite
|
| - * features required by the native components of the compositor.
|
| + * @param blimpContents The {@link BlimpContents} that represents the web contents.
|
| */
|
| - public void initializeRenderer(BlimpClientSession blimpClientSession) {
|
| + public void initializeRenderer(BlimpEnvironment blimpEnvironment, BlimpContents blimpContents) {
|
| assert mNativeBlimpContentsDisplayPtr == 0;
|
|
|
| WindowManager windowManager =
|
| @@ -59,9 +56,8 @@ public class BlimpContentsDisplay
|
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
| windowManager.getDefaultDisplay().getRealSize(physicalSize);
|
| }
|
| - float deviceScaleFactor = getContext().getResources().getDisplayMetrics().density;
|
| - mNativeBlimpContentsDisplayPtr = nativeInit(blimpClientSession, physicalSize.x,
|
| - physicalSize.y, displaySize.x, displaySize.y, deviceScaleFactor);
|
| + mNativeBlimpContentsDisplayPtr = nativeInit(blimpEnvironment, blimpContents, physicalSize.x,
|
| + physicalSize.y, displaySize.x, displaySize.y);
|
| getHolder().addCallback(this);
|
| setBackgroundColor(Color.WHITE);
|
| setVisibility(VISIBLE);
|
| @@ -88,49 +84,6 @@ public class BlimpContentsDisplay
|
| getContext().getResources().getDisplayMetrics().density);
|
| }
|
|
|
| - // View overrides.
|
| - @Override
|
| - public boolean onTouchEvent(MotionEvent event) {
|
| - // Remove this (integrate with BlimpView).
|
| - if (mNativeBlimpContentsDisplayPtr == 0) return false;
|
| -
|
| - int eventAction = event.getActionMasked();
|
| -
|
| - // Close the IME. It might be open for typing URL into toolbar.
|
| - // TODO(shaktisahu): Detect if the IME was open and return immediately (crbug/606977)
|
| - UiUtils.hideKeyboard(this);
|
| -
|
| - if (!isValidTouchEventActionForNative(eventAction)) return false;
|
| -
|
| - int pointerCount = event.getPointerCount();
|
| -
|
| - float[] touchMajor = {event.getTouchMajor(), pointerCount > 1 ? event.getTouchMajor(1) : 0};
|
| - float[] touchMinor = {event.getTouchMinor(), pointerCount > 1 ? event.getTouchMinor(1) : 0};
|
| -
|
| - for (int i = 0; i < 2; i++) {
|
| - if (touchMajor[i] < touchMinor[i]) {
|
| - float tmp = touchMajor[i];
|
| - touchMajor[i] = touchMinor[i];
|
| - touchMinor[i] = tmp;
|
| - }
|
| - }
|
| -
|
| - boolean consumed = nativeOnTouchEvent(mNativeBlimpContentsDisplayPtr, event,
|
| - event.getEventTime(), eventAction, pointerCount, event.getHistorySize(),
|
| - event.getActionIndex(), event.getX(), event.getY(),
|
| - pointerCount > 1 ? event.getX(1) : 0, pointerCount > 1 ? event.getY(1) : 0,
|
| - event.getPointerId(0), pointerCount > 1 ? event.getPointerId(1) : -1, touchMajor[0],
|
| - touchMajor[1], touchMinor[0], touchMinor[1], event.getOrientation(),
|
| - pointerCount > 1 ? event.getOrientation(1) : 0,
|
| - event.getAxisValue(MotionEvent.AXIS_TILT),
|
| - pointerCount > 1 ? event.getAxisValue(MotionEvent.AXIS_TILT, 1) : 0,
|
| - event.getRawX(), event.getRawY(), event.getToolType(0),
|
| - pointerCount > 1 ? event.getToolType(1) : MotionEvent.TOOL_TYPE_UNKNOWN,
|
| - event.getButtonState(), event.getMetaState());
|
| -
|
| - return consumed;
|
| - }
|
| -
|
| // SurfaceView overrides.
|
| @Override
|
| protected void onFinishInflate() {
|
| @@ -160,17 +113,6 @@ public class BlimpContentsDisplay
|
| nativeOnSurfaceDestroyed(mNativeBlimpContentsDisplayPtr);
|
| }
|
|
|
| - private static boolean isValidTouchEventActionForNative(int eventAction) {
|
| - // Only these actions have any effect on gesture detection. Other
|
| - // actions have no corresponding WebTouchEvent type and may confuse the
|
| - // touch pipline, so we ignore them entirely.
|
| - return eventAction == MotionEvent.ACTION_DOWN || eventAction == MotionEvent.ACTION_UP
|
| - || eventAction == MotionEvent.ACTION_CANCEL
|
| - || eventAction == MotionEvent.ACTION_MOVE
|
| - || eventAction == MotionEvent.ACTION_POINTER_DOWN
|
| - || eventAction == MotionEvent.ACTION_POINTER_UP;
|
| - }
|
| -
|
| @CalledByNative
|
| public void onSwapBuffersCompleted() {
|
| if (getBackground() == null) return;
|
| @@ -179,8 +121,8 @@ public class BlimpContentsDisplay
|
| }
|
|
|
| // Native Methods
|
| - private native long nativeInit(BlimpClientSession blimpClientSession, int physicalWidth,
|
| - int physicalHeight, int displayWidth, int displayHeight, float dpToPixel);
|
| + private native long nativeInit(BlimpEnvironment blimpEnvironment, BlimpContents blimpContents,
|
| + int physicalWidth, int physicalHeight, int displayWidth, int displayHeight);
|
| private native void nativeDestroy(long nativeBlimpContentsDisplay);
|
| private native void nativeOnContentAreaSizeChanged(
|
| long nativeBlimpContentsDisplay, int width, int height, float dpToPx);
|
| @@ -188,11 +130,4 @@ public class BlimpContentsDisplay
|
| long nativeBlimpContentsDisplay, int format, int width, int height, Surface surface);
|
| private native void nativeOnSurfaceCreated(long nativeBlimpContentsDisplay);
|
| private native void nativeOnSurfaceDestroyed(long nativeBlimpContentsDisplay);
|
| - private native boolean nativeOnTouchEvent(long nativeBlimpContentsDisplay, MotionEvent event,
|
| - long timeMs, int action, int pointerCount, int historySize, int actionIndex, float x0,
|
| - float y0, float x1, float y1, int pointerId0, int pointerId1, float touchMajor0,
|
| - float touchMajor1, float touchMinor0, float touchMinor1, float orientation0,
|
| - float orientation1, float tilt0, float tilt1, float rawX, float rawY,
|
| - int androidToolType0, int androidToolType1, int androidButtonState,
|
| - int androidMetaState);
|
| }
|
|
|