Skip to content

Commit c574fd0

Browse files
sganovAndroid (Google) Code Review
authored andcommitted
Merge "Fixing implementation of View.requestRectangleOnScreen(Rect, boolean)." into jb-mr1-dev
2 parents 2fa10c6 + ee6c6ae commit c574fd0

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

core/java/android/view/View.java

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import android.graphics.Shader;
4040
import android.graphics.drawable.ColorDrawable;
4141
import android.graphics.drawable.Drawable;
42-
import android.hardware.display.DisplayManager;
4342
import android.hardware.display.DisplayManagerGlobal;
4443
import android.os.Bundle;
4544
import android.os.Handler;
@@ -4275,25 +4274,42 @@ public boolean requestRectangleOnScreen(Rect rectangle) {
42754274
* @return Whether any parent scrolled.
42764275
*/
42774276
public boolean requestRectangleOnScreen(Rect rectangle, boolean immediate) {
4277+
if (mAttachInfo == null) {
4278+
return false;
4279+
}
4280+
42784281
View child = this;
4282+
4283+
RectF position = mAttachInfo.mTmpTransformRect;
4284+
position.set(rectangle);
4285+
42794286
ViewParent parent = mParent;
42804287
boolean scrolled = false;
42814288
while (parent != null) {
4289+
rectangle.set((int) position.left, (int) position.top,
4290+
(int) position.right, (int) position.bottom);
4291+
42824292
scrolled |= parent.requestChildRectangleOnScreen(child,
42834293
rectangle, immediate);
42844294

4285-
// offset rect so next call has the rectangle in the
4286-
// coordinate system of its direct child.
4287-
rectangle.offset(child.getLeft(), child.getTop());
4288-
rectangle.offset(-child.getScrollX(), -child.getScrollY());
4295+
if (!child.hasIdentityMatrix()) {
4296+
child.getMatrix().mapRect(position);
4297+
}
4298+
4299+
position.offset(child.mLeft, child.mTop);
42894300

42904301
if (!(parent instanceof View)) {
42914302
break;
42924303
}
42934304

4294-
child = (View) parent;
4305+
View parentView = (View) parent;
4306+
4307+
position.offset(-parentView.getScrollX(), -parentView.getScrollY());
4308+
4309+
child = parentView;
42954310
parent = child.getParent();
42964311
}
4312+
42974313
return scrolled;
42984314
}
42994315

0 commit comments

Comments
 (0)