Index: content/public/android/java/src/org/chromium/content/browser/input/PopupTouchHandleDrawable.java |
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/PopupTouchHandleDrawable.java b/content/public/android/java/src/org/chromium/content/browser/input/PopupTouchHandleDrawable.java |
index 8d68dec508e005f667ccb4a217df24a9d35b9e3a..820f38e1603d6b0e777da42bd395dd1efdbcd4d4 100644 |
--- a/content/public/android/java/src/org/chromium/content/browser/input/PopupTouchHandleDrawable.java |
+++ b/content/public/android/java/src/org/chromium/content/browser/input/PopupTouchHandleDrawable.java |
@@ -8,8 +8,11 @@ import android.annotation.SuppressLint; |
import android.content.Context; |
import android.graphics.Canvas; |
import android.graphics.drawable.Drawable; |
+import android.os.Build; |
import android.view.MotionEvent; |
import android.view.View; |
+import android.view.ViewGroup; |
+import android.view.WindowManager; |
import android.view.animation.AnimationUtils; |
import android.widget.PopupWindow; |
@@ -19,6 +22,8 @@ import org.chromium.content.browser.PositionObserver; |
import org.chromium.ui.touch_selection.TouchHandleOrientation; |
import java.lang.ref.WeakReference; |
+import java.lang.reflect.InvocationTargetException; |
+import java.lang.reflect.Method; |
/** |
* View that displays a selection or insertion handle for text editing. |
@@ -116,6 +121,9 @@ public class PopupTouchHandleDrawable extends View { |
mContainer.setSplitTouchEnabled(true); |
mContainer.setClippingEnabled(false); |
mContainer.setAnimationStyle(0); |
+ mContainer.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT); |
+ mContainer.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); |
+ setWindowLayoutType(mContainer, WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL); |
mAlpha = 1.f; |
mVisible = getVisibility() == VISIBLE; |
mParentPositionListener = new PositionObserver.Listener() { |
@@ -126,6 +134,21 @@ public class PopupTouchHandleDrawable extends View { |
}; |
} |
+ private static void setWindowLayoutType(PopupWindow window, int layoutType) { |
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { |
+ window.setWindowLayoutType(layoutType); |
+ return; |
+ } |
+ |
+ try { |
+ Method setWindowLayoutTypeMethod = |
+ PopupWindow.class.getMethod("setWindowLayoutType", int.class); |
+ setWindowLayoutTypeMethod.invoke(window, layoutType); |
+ } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException |
+ | RuntimeException e) { |
+ } |
+ } |
+ |
@SuppressLint("ClickableViewAccessibility") |
@Override |
public boolean onTouchEvent(MotionEvent event) { |