Chromium Code Reviews| Index: android_webview/java/src/org/chromium/android_webview/PopupTouchHandleDrawable.java |
| diff --git a/content/public/android/java/src/org/chromium/content/browser/input/PopupTouchHandleDrawable.java b/android_webview/java/src/org/chromium/android_webview/PopupTouchHandleDrawable.java |
| similarity index 93% |
| rename from content/public/android/java/src/org/chromium/content/browser/input/PopupTouchHandleDrawable.java |
| rename to android_webview/java/src/org/chromium/android_webview/PopupTouchHandleDrawable.java |
| index dce0644ca968d5776a59fb724a9aae67b72a5d2a..33a91ad24773c0c1f283e7f4b825cae516c61afa 100644 |
| --- a/content/public/android/java/src/org/chromium/content/browser/input/PopupTouchHandleDrawable.java |
| +++ b/android_webview/java/src/org/chromium/android_webview/PopupTouchHandleDrawable.java |
| @@ -1,8 +1,8 @@ |
| -// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -package org.chromium.content.browser.input; |
| +package org.chromium.android_webview; |
| import android.annotation.SuppressLint; |
| import android.content.Context; |
| @@ -19,10 +19,10 @@ import android.widget.PopupWindow; |
| import org.chromium.base.annotations.CalledByNative; |
| import org.chromium.base.annotations.JNINamespace; |
| -import org.chromium.content.browser.ContainerViewObserver; |
| import org.chromium.content.browser.ContentViewCore; |
| import org.chromium.content.browser.PositionObserver; |
| import org.chromium.content.browser.ViewPositionObserver; |
| +import org.chromium.content.browser.input.HandleViewResources; |
| import org.chromium.content_public.browser.GestureStateListener; |
| import org.chromium.ui.touch_selection.TouchHandleOrientation; |
| @@ -36,15 +36,17 @@ import java.lang.reflect.Method; |
| * hierarchy. |
| * |
| */ |
| -@JNINamespace("content") |
| +@JNINamespace("android_webview") |
| public class PopupTouchHandleDrawable extends View { |
| private final PopupWindow mContainer; |
| private final PositionObserver.Listener mParentPositionListener; |
| - private final ContainerViewObserver mParentViewObserver; |
| private ContentViewCore mContentViewCore; |
| private PositionObserver mParentPositionObserver; |
| private Drawable mDrawable; |
| + // The native side of this object. |
| + private final long mNativeDrawable; |
| + |
| // The position of the handle relative to the parent view. |
| private int mPositionX; |
| private int mPositionY; |
| @@ -93,7 +95,7 @@ public class PopupTouchHandleDrawable extends View { |
| private Runnable mInvalidationRunnable; |
| private boolean mHasPendingInvalidate; |
| - private PopupTouchHandleDrawable(ContentViewCore contentViewCore) { |
| + private PopupTouchHandleDrawable(ContentViewCore contentViewCore, double dipScale) { |
| super(contentViewCore.getContainerView().getContext()); |
| mContentViewCore = contentViewCore; |
| mContainer = new PopupWindow(mContentViewCore.getWindowAndroid().getContext().get(), |
| @@ -122,18 +124,6 @@ public class PopupTouchHandleDrawable extends View { |
| updateParentPosition(x, y); |
| } |
| }; |
| - mParentViewObserver = new ContainerViewObserver() { |
| - @Override |
| - public void onContainerViewChanged(ViewGroup newContainerView) { |
| - // If the parent View ever changes, the parent position observer |
| - // must be updated accordingly. |
| - mParentPositionObserver.clearListener(); |
| - mParentPositionObserver = new ViewPositionObserver(newContainerView); |
| - if (mContainer.isShowing()) { |
| - mParentPositionObserver.addListener(mParentPositionListener); |
| - } |
| - } |
| - }; |
| mGestureStateListener = new GestureStateListener() { |
| @Override |
| public void onScrollStarted(int scrollOffsetX, int scrollOffsetY) { |
| @@ -165,7 +155,18 @@ public class PopupTouchHandleDrawable extends View { |
| } |
| }; |
| mContentViewCore.addGestureStateListener(mGestureStateListener); |
| - mContentViewCore.addContainerViewObserver(mParentViewObserver); |
| + mNativeDrawable = nativeInit(contentViewCore, (float) dipScale, |
| + HandleViewResources.getHandleHorizontalPaddingRatio()); |
| + } |
| + |
| + public static PopupTouchHandleDrawable create(ContentViewCore contentViewCore, |
| + double dipScale) { |
| + if (contentViewCore == null) return null; |
|
boliu
2016/08/26 20:28:02
umm, after this is moved to java, it should be cle
Jinsuk Kim
2016/08/26 22:50:50
Done.
|
| + return new PopupTouchHandleDrawable(contentViewCore, dipScale); |
| + } |
| + |
| + public long getNativeDrawable() { |
| + return mNativeDrawable; |
| } |
| private static void setWindowLayoutType(PopupWindow window, int layoutType) { |
| @@ -221,11 +222,6 @@ public class PopupTouchHandleDrawable extends View { |
| } |
| @CalledByNative |
| - private static PopupTouchHandleDrawable create(ContentViewCore contentViewCore) { |
| - return new PopupTouchHandleDrawable(contentViewCore); |
| - } |
| - |
| - @CalledByNative |
| private void setOrientation(int orientation, boolean mirrorVertical, boolean mirrorHorizontal) { |
| assert (orientation >= TouchHandleOrientation.LEFT |
| && orientation <= TouchHandleOrientation.UNDEFINED); |
| @@ -436,7 +432,6 @@ public class PopupTouchHandleDrawable extends View { |
| if (mContentViewCore == null) return; |
| hide(); |
| mContentViewCore.removeGestureStateListener(mGestureStateListener); |
| - mContentViewCore.removeContainerViewObserver(mParentViewObserver); |
| mContentViewCore = null; |
| } |
| @@ -515,4 +510,17 @@ public class PopupTouchHandleDrawable extends View { |
| if (mDrawable == null) return 0; |
| return mDrawable.getIntrinsicHeight(); |
| } |
| + |
| + public void onContainerViewChanged(ViewGroup newContainerView) { |
| + // If the parent View ever changes, the parent position observer |
| + // must be updated accordingly. |
| + mParentPositionObserver.clearListener(); |
| + mParentPositionObserver = new ViewPositionObserver(newContainerView); |
| + if (mContainer.isShowing()) { |
| + mParentPositionObserver.addListener(mParentPositionListener); |
| + } |
| + } |
| + |
| + private native long nativeInit(ContentViewCore contentViewCore, float dipScale, |
| + float horizontalPaddingRatio); |
| } |