am c574fd04: Merge "Fixing implementation of View.requestRectangleOnScreen(Rect, boolean)." into jb-mr1-dev

* commit 'c574fd04cc192fa30af5dd065c5d0cd4c50f8db4':
  Fixing implementation of View.requestRectangleOnScreen(Rect, boolean).
This commit is contained in:
Svetoslav Ganov
2012-09-11 12:18:21 -07:00
committed by Android Git Automerger

View File

@@ -39,7 +39,6 @@ import android.graphics.Region;
import android.graphics.Shader; import android.graphics.Shader;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.hardware.display.DisplayManager;
import android.hardware.display.DisplayManagerGlobal; import android.hardware.display.DisplayManagerGlobal;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
@@ -4275,25 +4274,42 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* @return Whether any parent scrolled. * @return Whether any parent scrolled.
*/ */
public boolean requestRectangleOnScreen(Rect rectangle, boolean immediate) { public boolean requestRectangleOnScreen(Rect rectangle, boolean immediate) {
if (mAttachInfo == null) {
return false;
}
View child = this; View child = this;
RectF position = mAttachInfo.mTmpTransformRect;
position.set(rectangle);
ViewParent parent = mParent; ViewParent parent = mParent;
boolean scrolled = false; boolean scrolled = false;
while (parent != null) { while (parent != null) {
rectangle.set((int) position.left, (int) position.top,
(int) position.right, (int) position.bottom);
scrolled |= parent.requestChildRectangleOnScreen(child, scrolled |= parent.requestChildRectangleOnScreen(child,
rectangle, immediate); rectangle, immediate);
// offset rect so next call has the rectangle in the if (!child.hasIdentityMatrix()) {
// coordinate system of its direct child. child.getMatrix().mapRect(position);
rectangle.offset(child.getLeft(), child.getTop()); }
rectangle.offset(-child.getScrollX(), -child.getScrollY());
position.offset(child.mLeft, child.mTop);
if (!(parent instanceof View)) { if (!(parent instanceof View)) {
break; break;
} }
child = (View) parent; View parentView = (View) parent;
position.offset(-parentView.getScrollX(), -parentView.getScrollY());
child = parentView;
parent = child.getParent(); parent = child.getParent();
} }
return scrolled; return scrolled;
} }