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..6ecc0731cc3f882060332ebdbbd16d50f067467a 100644 |
--- a/ui/android/java/src/org/chromium/ui/base/ViewAndroidDelegate.java |
+++ b/ui/android/java/src/org/chromium/ui/base/ViewAndroidDelegate.java |
@@ -8,6 +8,7 @@ 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; |
@@ -99,6 +100,115 @@ public abstract class ViewAndroidDelegate { |
new View.DragShadowBuilder(imageView), null, View.DRAG_FLAG_GLOBAL); |
} |
+ @CalledByNative |
+ private void onCursorChangedToCustom(Bitmap customCursorBitmap, int hotspotX, int hotspotY) { |
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { |
+ getContainerView().getRootView().setPointerIcon( |
+ PointerIcon.create(customCursorBitmap, hotspotX, hotspotY)); |
+ } |
+ } |
+ |
+ @CalledByNative |
+ public void onCursorChanged(int cursorType) { |
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { |
aelias_OOO_until_Jul13
2017/05/17 04:47:15
"if ( < N ) return;" to reduce indentation
Jinsuk Kim
2017/05/17 04:49:50
Do early return to avoid too long if.
if (INT < N
jaebaek
2017/05/18 01:44:28
Done.
jaebaek
2017/05/18 01:44:29
Done.
|
+ ViewGroup containerView = getContainerView(); |
Jinsuk Kim
2017/05/17 04:49:50
Define variables for the root view and the context
jaebaek
2017/05/18 01:44:29
Done.
|
+ switch (cursorType) { |
+ case CursorType.NULL: |
+ containerView.getRootView().setPointerIcon(PointerIcon.getSystemIcon( |
+ containerView.getContext(), PointerIcon.TYPE_NULL)); |
aelias_OOO_until_Jul13
2017/05/17 04:47:15
You can avoid some boilerplate duplication here by
jaebaek
2017/05/18 01:44:29
Done.
|
+ break; |
+ case CursorType.ARROW: |
+ containerView.getRootView().setPointerIcon(PointerIcon.getSystemIcon( |
+ containerView.getContext(), PointerIcon.TYPE_ARROW)); |
+ break; |
+ case CursorType.CONTEXT_MENU: |
+ containerView.getRootView().setPointerIcon(PointerIcon.getSystemIcon( |
+ containerView.getContext(), PointerIcon.TYPE_CONTEXT_MENU)); |
+ break; |
+ case CursorType.HAND: |
+ containerView.getRootView().setPointerIcon(PointerIcon.getSystemIcon( |
+ containerView.getContext(), PointerIcon.TYPE_HAND)); |
+ break; |
+ case CursorType.HELP: |
+ containerView.getRootView().setPointerIcon(PointerIcon.getSystemIcon( |
+ containerView.getContext(), PointerIcon.TYPE_HELP)); |
+ break; |
+ case CursorType.WAIT: |
+ containerView.getRootView().setPointerIcon(PointerIcon.getSystemIcon( |
+ containerView.getContext(), PointerIcon.TYPE_WAIT)); |
+ break; |
+ case CursorType.CELL: |
+ containerView.getRootView().setPointerIcon(PointerIcon.getSystemIcon( |
+ containerView.getContext(), PointerIcon.TYPE_CELL)); |
+ break; |
+ case CursorType.CROSSHAIR: |
+ containerView.getRootView().setPointerIcon(PointerIcon.getSystemIcon( |
+ containerView.getContext(), PointerIcon.TYPE_CROSSHAIR)); |
+ break; |
+ case CursorType.TEXT: |
+ containerView.getRootView().setPointerIcon(PointerIcon.getSystemIcon( |
+ containerView.getContext(), PointerIcon.TYPE_TEXT)); |
+ break; |
+ case CursorType.VERTICAL_TEXT: |
+ containerView.getRootView().setPointerIcon(PointerIcon.getSystemIcon( |
+ containerView.getContext(), PointerIcon.TYPE_VERTICAL_TEXT)); |
+ break; |
+ case CursorType.ALIAS: |
+ containerView.getRootView().setPointerIcon(PointerIcon.getSystemIcon( |
+ containerView.getContext(), PointerIcon.TYPE_ALIAS)); |
+ break; |
+ case CursorType.COPY: |
+ containerView.getRootView().setPointerIcon(PointerIcon.getSystemIcon( |
+ containerView.getContext(), PointerIcon.TYPE_COPY)); |
+ break; |
+ case CursorType.NO_DROP: |
+ containerView.getRootView().setPointerIcon(PointerIcon.getSystemIcon( |
+ containerView.getContext(), PointerIcon.TYPE_NO_DROP)); |
+ break; |
+ case CursorType.ALL_SCROLL: |
+ containerView.getRootView().setPointerIcon(PointerIcon.getSystemIcon( |
+ containerView.getContext(), PointerIcon.TYPE_ALL_SCROLL)); |
+ break; |
+ case CursorType.HORIZONTAL_DOUBLE_ARROW: |
+ containerView.getRootView().setPointerIcon(PointerIcon.getSystemIcon( |
+ containerView.getContext(), PointerIcon.TYPE_HORIZONTAL_DOUBLE_ARROW)); |
+ break; |
+ case CursorType.VERTICAL_DOUBLE_ARROW: |
+ containerView.getRootView().setPointerIcon(PointerIcon.getSystemIcon( |
+ containerView.getContext(), PointerIcon.TYPE_VERTICAL_DOUBLE_ARROW)); |
+ break; |
+ case CursorType.TOP_RIGHT_DIAGONAL_DOUBLE_ARROW: |
+ containerView.getRootView().setPointerIcon( |
+ PointerIcon.getSystemIcon(containerView.getContext(), |
+ PointerIcon.TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW)); |
+ break; |
+ case CursorType.TOP_LEFT_DIAGONAL_DOUBLE_ARROW: |
+ containerView.getRootView().setPointerIcon( |
+ PointerIcon.getSystemIcon(containerView.getContext(), |
+ PointerIcon.TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW)); |
+ break; |
+ case CursorType.ZOOM_IN: |
+ containerView.getRootView().setPointerIcon(PointerIcon.getSystemIcon( |
+ containerView.getContext(), PointerIcon.TYPE_ZOOM_IN)); |
+ break; |
+ case CursorType.ZOOM_OUT: |
+ containerView.getRootView().setPointerIcon(PointerIcon.getSystemIcon( |
+ containerView.getContext(), PointerIcon.TYPE_ZOOM_OUT)); |
+ break; |
+ case CursorType.GRAB: |
+ containerView.getRootView().setPointerIcon(PointerIcon.getSystemIcon( |
+ containerView.getContext(), PointerIcon.TYPE_GRAB)); |
+ break; |
+ case CursorType.GRABBING: |
+ containerView.getRootView().setPointerIcon(PointerIcon.getSystemIcon( |
+ containerView.getContext(), PointerIcon.TYPE_GRABBING)); |
+ break; |
+ default: |
aelias_OOO_until_Jul13
2017/05/17 04:47:15
Please exhaustively list all remaining WebCursorIn
jaebaek
2017/05/18 01:44:29
I listed all WebCursorInfo types and default for e
|
+ break; |
+ } |
+ } |
+ } |
+ |
/** |
* Called whenever the background color of the page changes as notified by Blink. |
* @param color The new ARGB color of the page background. |