diff options
| author | Alan Viverette <alanv@google.com> | 2014-11-26 14:34:36 -0800 |
|---|---|---|
| committer | Alan Viverette <alanv@google.com> | 2014-11-26 14:34:36 -0800 |
| commit | ab2cf6dafe1dbc9e7533562f146087901e79f389 (patch) | |
| tree | 91b0b969822a097dd38d40b02373ed7bcfd39a1f /core/java | |
| parent | bc3226e21dfe881bf1ccae62e10b660d97b2b232 (diff) | |
| download | frameworks_base-ab2cf6dafe1dbc9e7533562f146087901e79f389.zip frameworks_base-ab2cf6dafe1dbc9e7533562f146087901e79f389.tar.gz frameworks_base-ab2cf6dafe1dbc9e7533562f146087901e79f389.tar.bz2 | |
Fix visible rect computation for views with padding
Previously, the computation was double-counting the left and top padding
because it was treating the third and fourth Rect.intersect() arguments
as width and height rather than right and bottom.
BUG: 18418091
Change-Id: I2ab669ee5060372ae11cfe804dcc05c7426be1ec
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/view/ViewGroup.java | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index 1a5ff26..1551504 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -5033,8 +5033,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager child.getMatrix().mapRect(rect); } - int dx = child.mLeft - mScrollX; - int dy = child.mTop - mScrollY; + final int dx = child.mLeft - mScrollX; + final int dy = child.mTop - mScrollY; rect.offset(dx, dy); @@ -5052,21 +5052,23 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager offset.y += dy; } + final int width = mRight - mLeft; + final int height = mBottom - mTop; + boolean rectIsVisible = true; if (mParent instanceof ViewGroup && ((ViewGroup)mParent).getClipChildren()) { - // clipChildren clips to the child's bounds - rectIsVisible = rect.intersect(0, 0, mRight - mLeft, mBottom - mTop); + // Clip to bounds. + rectIsVisible = rect.intersect(0, 0, width, height); } if (rectIsVisible && (mGroupFlags & CLIP_TO_PADDING_MASK) == CLIP_TO_PADDING_MASK) { - // Clip to padding + // Clip to padding. rectIsVisible = rect.intersect(mPaddingLeft, mPaddingTop, - mRight - mLeft - mPaddingLeft - mPaddingRight, - mBottom - mTop - mPaddingTop - mPaddingBottom); + width - mPaddingRight, height - mPaddingBottom); } if (rectIsVisible && mClipBounds != null) { - // Clip to clipBounds + // Clip to clipBounds. rectIsVisible = rect.intersect(mClipBounds.left, mClipBounds.top, mClipBounds.right, mClipBounds.bottom); } |
