| Index: ui/android/java/src/org/chromium/ui/base/ViewAndroidDelegate.java
|
| diff --git a/ui/android/java/src/org/chromium/ui/base/ViewAndroidDelegate.java b/ui/android/java/src/org/chromium/ui/base/ViewAndroidDelegate.java
|
| index d99f612d6b2770436574b97a96f73aef32a66a33..93148f752bf05f12b6e6dbeeb824443fb6820185 100644
|
| --- a/ui/android/java/src/org/chromium/ui/base/ViewAndroidDelegate.java
|
| +++ b/ui/android/java/src/org/chromium/ui/base/ViewAndroidDelegate.java
|
| @@ -8,14 +8,17 @@ import android.annotation.TargetApi;
|
| import android.content.ClipData;
|
| import android.graphics.Bitmap;
|
| import android.os.Build;
|
| +import android.view.PointerIcon;
|
| import android.view.View;
|
| import android.view.ViewGroup;
|
| import android.widget.FrameLayout.LayoutParams;
|
| import android.widget.ImageView;
|
|
|
| import org.chromium.base.ApiCompatibilityUtils;
|
| +import org.chromium.base.VisibleForTesting;
|
| import org.chromium.base.annotations.CalledByNative;
|
| import org.chromium.base.annotations.JNINamespace;
|
| +import org.chromium.blink_public.web.WebCursorInfoType;
|
|
|
| /**
|
| * Class to acquire, position, and remove anchor views from the implementing View.
|
| @@ -99,6 +102,152 @@ public abstract class ViewAndroidDelegate {
|
| new View.DragShadowBuilder(imageView), null, View.DRAG_FLAG_GLOBAL);
|
| }
|
|
|
| + @VisibleForTesting
|
| + @CalledByNative
|
| + public void onCursorChangedToCustom(Bitmap customCursorBitmap, int hotspotX, int hotspotY) {
|
| + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
| + PointerIcon icon = PointerIcon.create(customCursorBitmap, hotspotX, hotspotY);
|
| + updatePointerIcon(icon);
|
| + }
|
| + }
|
| +
|
| + @VisibleForTesting
|
| + @CalledByNative
|
| + public void onCursorChanged(int cursorType) {
|
| + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) return;
|
| +
|
| + int pointerIconType = PointerIcon.TYPE_ARROW;
|
| + switch (cursorType) {
|
| + case WebCursorInfoType.TYPE_NONE:
|
| + pointerIconType = PointerIcon.TYPE_NULL;
|
| + break;
|
| + case WebCursorInfoType.TYPE_POINTER:
|
| + pointerIconType = PointerIcon.TYPE_ARROW;
|
| + break;
|
| + case WebCursorInfoType.TYPE_CONTEXT_MENU:
|
| + pointerIconType = PointerIcon.TYPE_CONTEXT_MENU;
|
| + break;
|
| + case WebCursorInfoType.TYPE_HAND:
|
| + pointerIconType = PointerIcon.TYPE_HAND;
|
| + break;
|
| + case WebCursorInfoType.TYPE_HELP:
|
| + pointerIconType = PointerIcon.TYPE_HELP;
|
| + break;
|
| + case WebCursorInfoType.TYPE_WAIT:
|
| + pointerIconType = PointerIcon.TYPE_WAIT;
|
| + break;
|
| + case WebCursorInfoType.TYPE_CELL:
|
| + pointerIconType = PointerIcon.TYPE_CELL;
|
| + break;
|
| + case WebCursorInfoType.TYPE_CROSS:
|
| + pointerIconType = PointerIcon.TYPE_CROSSHAIR;
|
| + break;
|
| + case WebCursorInfoType.TYPE_I_BEAM:
|
| + pointerIconType = PointerIcon.TYPE_TEXT;
|
| + break;
|
| + case WebCursorInfoType.TYPE_VERTICAL_TEXT:
|
| + pointerIconType = PointerIcon.TYPE_VERTICAL_TEXT;
|
| + break;
|
| + case WebCursorInfoType.TYPE_ALIAS:
|
| + pointerIconType = PointerIcon.TYPE_ALIAS;
|
| + break;
|
| + case WebCursorInfoType.TYPE_COPY:
|
| + pointerIconType = PointerIcon.TYPE_COPY;
|
| + break;
|
| + case WebCursorInfoType.TYPE_NO_DROP:
|
| + pointerIconType = PointerIcon.TYPE_NO_DROP;
|
| + break;
|
| + case WebCursorInfoType.TYPE_COLUMN_RESIZE:
|
| + pointerIconType = PointerIcon.TYPE_HORIZONTAL_DOUBLE_ARROW;
|
| + break;
|
| + case WebCursorInfoType.TYPE_ROW_RESIZE:
|
| + pointerIconType = PointerIcon.TYPE_VERTICAL_DOUBLE_ARROW;
|
| + break;
|
| + case WebCursorInfoType.TYPE_NORTH_EAST_SOUTH_WEST_RESIZE:
|
| + pointerIconType = PointerIcon.TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW;
|
| + break;
|
| + case WebCursorInfoType.TYPE_NORTH_WEST_SOUTH_EAST_RESIZE:
|
| + pointerIconType = PointerIcon.TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW;
|
| + break;
|
| + case WebCursorInfoType.TYPE_ZOOM_IN:
|
| + pointerIconType = PointerIcon.TYPE_ZOOM_IN;
|
| + break;
|
| + case WebCursorInfoType.TYPE_ZOOM_OUT:
|
| + pointerIconType = PointerIcon.TYPE_ZOOM_OUT;
|
| + break;
|
| + case WebCursorInfoType.TYPE_GRAB:
|
| + pointerIconType = PointerIcon.TYPE_GRAB;
|
| + break;
|
| + case WebCursorInfoType.TYPE_GRABBING:
|
| + pointerIconType = PointerIcon.TYPE_GRABBING;
|
| + break;
|
| + // TODO(jaebaek): set types correctly
|
| + // after fixing http://crbug.com/584424.
|
| + case WebCursorInfoType.TYPE_EAST_WEST_RESIZE:
|
| + pointerIconType = PointerIcon.TYPE_HORIZONTAL_DOUBLE_ARROW;
|
| + break;
|
| + case WebCursorInfoType.TYPE_NORTH_SOUTH_RESIZE:
|
| + pointerIconType = PointerIcon.TYPE_VERTICAL_DOUBLE_ARROW;
|
| + break;
|
| + case WebCursorInfoType.TYPE_EAST_RESIZE:
|
| + pointerIconType = PointerIcon.TYPE_HORIZONTAL_DOUBLE_ARROW;
|
| + break;
|
| + case WebCursorInfoType.TYPE_NORTH_RESIZE:
|
| + pointerIconType = PointerIcon.TYPE_VERTICAL_DOUBLE_ARROW;
|
| + break;
|
| + case WebCursorInfoType.TYPE_NORTH_EAST_RESIZE:
|
| + pointerIconType = PointerIcon.TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW;
|
| + break;
|
| + case WebCursorInfoType.TYPE_NORTH_WEST_RESIZE:
|
| + pointerIconType = PointerIcon.TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW;
|
| + break;
|
| + case WebCursorInfoType.TYPE_SOUTH_RESIZE:
|
| + pointerIconType = PointerIcon.TYPE_VERTICAL_DOUBLE_ARROW;
|
| + break;
|
| + case WebCursorInfoType.TYPE_SOUTH_EAST_RESIZE:
|
| + pointerIconType = PointerIcon.TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW;
|
| + break;
|
| + case WebCursorInfoType.TYPE_SOUTH_WEST_RESIZE:
|
| + pointerIconType = PointerIcon.TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW;
|
| + break;
|
| + case WebCursorInfoType.TYPE_WEST_RESIZE:
|
| + pointerIconType = PointerIcon.TYPE_HORIZONTAL_DOUBLE_ARROW;
|
| + break;
|
| + case WebCursorInfoType.TYPE_PROGRESS:
|
| + pointerIconType = PointerIcon.TYPE_WAIT;
|
| + break;
|
| + case WebCursorInfoType.TYPE_NOT_ALLOWED:
|
| + pointerIconType = PointerIcon.TYPE_NO_DROP;
|
| + break;
|
| + case WebCursorInfoType.TYPE_MOVE:
|
| + case WebCursorInfoType.TYPE_MIDDLE_PANNING:
|
| + pointerIconType = PointerIcon.TYPE_ALL_SCROLL;
|
| + break;
|
| + case WebCursorInfoType.TYPE_EAST_PANNING:
|
| + case WebCursorInfoType.TYPE_NORTH_PANNING:
|
| + case WebCursorInfoType.TYPE_NORTH_EAST_PANNING:
|
| + case WebCursorInfoType.TYPE_NORTH_WEST_PANNING:
|
| + case WebCursorInfoType.TYPE_SOUTH_PANNING:
|
| + case WebCursorInfoType.TYPE_SOUTH_EAST_PANNING:
|
| + case WebCursorInfoType.TYPE_SOUTH_WEST_PANNING:
|
| + case WebCursorInfoType.TYPE_WEST_PANNING:
|
| + assert false : "These pointer icon types are not supported";
|
| + break;
|
| + case WebCursorInfoType.TYPE_CUSTOM:
|
| + assert false : "onCursorChangedToCustom must be called instead";
|
| + break;
|
| + }
|
| + ViewGroup containerView = getContainerView();
|
| + PointerIcon icon = PointerIcon.getSystemIcon(containerView.getContext(), pointerIconType);
|
| + updatePointerIcon(icon);
|
| + }
|
| +
|
| + /**
|
| + * Set mouse cursor type for Android N or upper version of Android.
|
| + * @param icon The type of mouse cursor to be updated.
|
| + */
|
| + public abstract void updatePointerIcon(PointerIcon icon);
|
| +
|
| /**
|
| * Called whenever the background color of the page changes as notified by Blink.
|
| * @param color The new ARGB color of the page background.
|
| @@ -158,6 +307,13 @@ public abstract class ViewAndroidDelegate {
|
| public ViewGroup getContainerView() {
|
| return mContainerView;
|
| }
|
| +
|
| + @Override
|
| + public void updatePointerIcon(PointerIcon icon) {
|
| + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
| + getContainerView().setPointerIcon(icon);
|
| + }
|
| + }
|
| }.init(containerView);
|
| }
|
| }
|
|
|