Index: chrome/android/java/src/org/chromium/chrome/browser/coordinator/CoordinatorLayoutForPointer.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/coordinator/CoordinatorLayoutForPointer.java b/chrome/android/java/src/org/chromium/chrome/browser/coordinator/CoordinatorLayoutForPointer.java |
new file mode 100644 |
index 0000000000000000000000000000000000000000..afe375bae34f829520665eaa21898bfd0ab27743 |
--- /dev/null |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/coordinator/CoordinatorLayoutForPointer.java |
@@ -0,0 +1,41 @@ |
+// Copyright 2017 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.chrome.browser.coordinator; |
+ |
+import android.content.Context; |
+import android.os.Build; |
+import android.support.design.widget.CoordinatorLayout; |
+import android.util.AttributeSet; |
+import android.view.MotionEvent; |
+import android.view.PointerIcon; |
+ |
+/** |
+ * This class extends a {@link CoordinatorLayout} which is the parent of |
Ted C
2017/07/21 00:15:25
wrap comments at 100 chars in java land
jaebaek
2017/07/21 10:03:04
Done.
|
+ * {@link CompositorViewHolder} in Android view hierarchy. The main |
+ * purpose of this class is to correctly determine the pointer icon that |
+ * must be applied according to a mouse motion event. |
mdjones
2017/07/20 21:49:06
nit: Mention this is needed because the default an
jaebaek
2017/07/21 10:03:04
Done.
|
+ */ |
+public class CoordinatorLayoutForPointer extends CoordinatorLayout { |
+ public CoordinatorLayoutForPointer(Context context) { |
Ted C
2017/07/21 00:15:25
we should only need the second constructor for inf
jaebaek
2017/07/21 10:03:04
Done.
|
+ super(context); |
+ } |
+ |
+ public CoordinatorLayoutForPointer(Context context, AttributeSet attrs) { |
+ super(context, attrs); |
+ } |
+ |
+ @Override |
+ public PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex) { |
Ted C
2017/07/21 00:15:25
I believe this got fixed in N-MR1 (b/34114031).
S
jaebaek
2017/07/21 10:03:04
I want to check the updated code, but I cannot acc
|
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) return null; |
+ |
+ final int childrenCount = getChildCount(); |
+ for (int i = childrenCount - 1; i >= 0; --i) { |
+ if (getChildAt(i).getVisibility() != VISIBLE) continue; |
+ PointerIcon icon = getChildAt(i).onResolvePointerIcon(event, pointerIndex); |
Ted C
2017/07/21 18:45:31
this doesn't actually check that the mouse cursor
mdjones
2017/07/21 20:42:28
With the assumption that this layout is always mat
jaebaek
2017/07/24 07:34:11
Ah .. it's my mistake. I added bound check here. I
|
+ if (icon != null) return icon; |
+ } |
+ return null; |
+ } |
+} |