From 35da41e6c35e1c6af3afe29d6ec41609ab07ca33 Mon Sep 17 00:00:00 2001 From: Adam Powell Date: Wed, 10 Dec 2014 18:59:34 -0800 Subject: [PATCH] Have ViewGroups without a parent clip child visible rects to bounds getChildVisibleRect was enhanced to obey the official contracts for clipping children and clip to padding. Unfortunately this meant that ViewGroups with no parent have no way of checking if they will be clipped to their own bounds and therefore should clip a child rect. Treat orphaned view subtrees as entities that clip to the root view bounds to preserve prior CTS guarantees. Bug 18642973 Change-Id: I9fcbeb0e92cd6715cd9184183d36889614ed0bed --- core/java/android/view/ViewGroup.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index 25a70eb0ecf2b..391f6083ccf38 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -5113,7 +5113,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager final int height = mBottom - mTop; boolean rectIsVisible = true; - if (mParent instanceof ViewGroup && ((ViewGroup)mParent).getClipChildren()) { + if (mParent == null || + (mParent instanceof ViewGroup && ((ViewGroup) mParent).getClipChildren())) { // Clip to bounds. rectIsVisible = rect.intersect(0, 0, width, height); }