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

Commit ab2cf6da authored by Alan Viverette's avatar Alan Viverette
Browse files

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
parent bc3226e2
Loading
Loading
Loading
Loading
+10 −8
Original line number Original line Diff line number Diff line
@@ -5033,8 +5033,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
            child.getMatrix().mapRect(rect);
            child.getMatrix().mapRect(rect);
        }
        }


        int dx = child.mLeft - mScrollX;
        final int dx = child.mLeft - mScrollX;
        int dy = child.mTop - mScrollY;
        final int dy = child.mTop - mScrollY;


        rect.offset(dx, dy);
        rect.offset(dx, dy);


@@ -5052,21 +5052,23 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
            offset.y += dy;
            offset.y += dy;
        }
        }


        final int width = mRight - mLeft;
        final int height = mBottom - mTop;

        boolean rectIsVisible = true;
        boolean rectIsVisible = true;
        if (mParent instanceof ViewGroup && ((ViewGroup)mParent).getClipChildren()) {
        if (mParent instanceof ViewGroup && ((ViewGroup)mParent).getClipChildren()) {
            // clipChildren clips to the child's bounds
            // Clip to bounds.
            rectIsVisible = rect.intersect(0, 0, mRight - mLeft, mBottom - mTop);
            rectIsVisible = rect.intersect(0, 0, width, height);
        }
        }


        if (rectIsVisible && (mGroupFlags & CLIP_TO_PADDING_MASK) == CLIP_TO_PADDING_MASK) {
        if (rectIsVisible && (mGroupFlags & CLIP_TO_PADDING_MASK) == CLIP_TO_PADDING_MASK) {
            // Clip to padding
            // Clip to padding.
            rectIsVisible = rect.intersect(mPaddingLeft, mPaddingTop,
            rectIsVisible = rect.intersect(mPaddingLeft, mPaddingTop,
                    mRight - mLeft - mPaddingLeft - mPaddingRight,
                    width - mPaddingRight, height - mPaddingBottom);
                    mBottom - mTop - mPaddingTop - mPaddingBottom);
        }
        }


        if (rectIsVisible && mClipBounds != null) {
        if (rectIsVisible && mClipBounds != null) {
            // Clip to clipBounds
            // Clip to clipBounds.
            rectIsVisible = rect.intersect(mClipBounds.left, mClipBounds.top, mClipBounds.right,
            rectIsVisible = rect.intersect(mClipBounds.left, mClipBounds.top, mClipBounds.right,
                    mClipBounds.bottom);
                    mClipBounds.bottom);
        }
        }