Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c3bc45ec authored by Yigit Boyar's avatar Yigit Boyar Committed by Android (Google) Code Review
Browse files

Merge "Fix requestRectangleOnScreen"

parents ed090d17 d62d5e9a
Loading
Loading
Loading
Loading
+12 −15
Original line number Diff line number Diff line
@@ -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();
        }
+2 −2
Original line number Diff line number Diff line
@@ -273,7 +273,7 @@ public interface ViewParent {
     * 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>
+12 −9
Original line number Diff line number Diff line
@@ -6729,8 +6729,12 @@ 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);
@@ -6739,7 +6743,6 @@ public final class ViewRootImpl implements ViewParent,
        } catch (RemoteException re) {
            /* ignore */
        }
        }
        return scrolled;
    }