summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Yigit Boyar <yboyar@google.com> 2016-01-25 23:00:42 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2016-01-25 23:00:42 +0000
commitc3bc45ec042dead6e9a7191a5d25ae2867acde25 (patch)
treecb28e32de824f73f9c58947d796759c3a5e2f443
parented090d1729fabce14ab222e4b796217f1663f85d (diff)
parentd62d5e9accc76952d737f9c58a97f898807713e5 (diff)
Merge "Fix requestRectangleOnScreen"
-rw-r--r--core/java/android/view/View.java27
-rw-r--r--core/java/android/view/ViewParent.java4
-rw-r--r--core/java/android/view/ViewRootImpl.java21
3 files changed, 26 insertions, 26 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 6c3f308f6846..dc50e17e1050 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -5795,8 +5795,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* <p>A View should call this if it maintains some notion of which part
* of its content is interesting. For example, a text editing view
* should call this when its cursor moves.
+ * <p>The Rectangle passed into this method should be in the View's content coordinate space.
+ * It should not be affected by which part of the View is currently visible or its scroll
+ * position.
*
- * @param rectangle The rectangle.
+ * @param rectangle The rectangle in the View's content coordinate space
* @return Whether any parent scrolled.
*/
public boolean requestRectangleOnScreen(Rect rectangle) {
@@ -5810,11 +5813,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* <p>A View should call this if it maintains some notion of which part
* of its content is interesting. For example, a text editing view
* should call this when its cursor moves.
- *
+ * <p>The Rectangle passed into this method should be in the View's content coordinate space.
+ * It should not be affected by which part of the View is currently visible or its scroll
+ * position.
* <p>When <code>immediate</code> is set to true, scrolling will not be
* animated.
*
- * @param rectangle The rectangle.
+ * @param rectangle The rectangle in the View's content coordinate space
* @param immediate True to forbid animated scrolling, false otherwise
* @return Whether any parent scrolled.
*/
@@ -5834,24 +5839,16 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
rectangle.set((int) position.left, (int) position.top,
(int) position.right, (int) position.bottom);
- scrolled |= parent.requestChildRectangleOnScreen(child,
- rectangle, immediate);
-
- if (!child.hasIdentityMatrix()) {
- child.getMatrix().mapRect(position);
- }
-
- position.offset(child.mLeft, child.mTop);
+ scrolled |= parent.requestChildRectangleOnScreen(child, rectangle, immediate);
if (!(parent instanceof View)) {
break;
}
- View parentView = (View) parent;
-
- position.offset(-parentView.getScrollX(), -parentView.getScrollY());
+ // move it from child's content coordinate space to parent's content coordinate space
+ position.offset(child.mLeft - child.getScrollX(), child.mTop -child.getScrollY());
- child = parentView;
+ child = (View) parent;
parent = child.getParent();
}
diff --git a/core/java/android/view/ViewParent.java b/core/java/android/view/ViewParent.java
index e9b123b5b9be..1962be86ffb1 100644
--- a/core/java/android/view/ViewParent.java
+++ b/core/java/android/view/ViewParent.java
@@ -266,14 +266,14 @@ public interface ViewParent {
* intercept touch events.
*/
public void requestDisallowInterceptTouchEvent(boolean disallowIntercept);
-
+
/**
* Called when a child of this group wants a particular rectangle to be
* positioned onto the screen. {@link ViewGroup}s overriding this can trust
* that:
* <ul>
* <li>child will be a direct child of this group</li>
- * <li>rectangle will be in the child's coordinates</li>
+ * <li>rectangle will be in the child's content coordinates</li>
* </ul>
*
* <p>{@link ViewGroup}s overriding this should uphold the contract:</p>
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 0d6f36226fa9..5d41477d3c0f 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -6729,16 +6729,19 @@ public final class ViewRootImpl implements ViewParent,
@Override
public boolean requestChildRectangleOnScreen(View child, Rect rectangle, boolean immediate) {
+ if (rectangle == null) {
+ return scrollToRectOrFocus(null, immediate);
+ }
+ rectangle.offset(child.getLeft() - child.getScrollX(),
+ child.getTop() - child.getScrollY());
final boolean scrolled = scrollToRectOrFocus(rectangle, immediate);
- if (rectangle != null) {
- mTempRect.set(rectangle);
- mTempRect.offset(0, -mCurScrollY);
- mTempRect.offset(mAttachInfo.mWindowLeft, mAttachInfo.mWindowTop);
- try {
- mWindowSession.onRectangleOnScreenRequested(mWindow, mTempRect);
- } catch (RemoteException re) {
- /* ignore */
- }
+ mTempRect.set(rectangle);
+ mTempRect.offset(0, -mCurScrollY);
+ mTempRect.offset(mAttachInfo.mWindowLeft, mAttachInfo.mWindowTop);
+ try {
+ mWindowSession.onRectangleOnScreenRequested(mWindow, mTempRect);
+ } catch (RemoteException re) {
+ /* ignore */
}
return scrolled;
}