From e8e31823b9bde22eb348fd828d6e5b38a5371833 Mon Sep 17 00:00:00 2001 From: Dave Miller Date: Wed, 23 Mar 2016 12:27:39 -0700 Subject: [PATCH] Fix the clip rect computation for removeClippedSubviews Summary: The computation for calculateClippingRect didn't work if you had a horizontal scroll nested in a vertical scroll view. The fix is to simplify the logic to first intersect the inner view within its parent and then apply transforms (translation by top/left and scroll offset). That now provides the correct clipping rectangle for nested views. Reviewed By: astreet Differential Revision: D3087367 fb-gh-sync-id: efdd430e024c4599189ddb8dbb258fd2b118690f shipit-source-id: efdd430e024c4599189ddb8dbb258fd2b118690f --- .../views/view/ReactClippingViewGroupHelper.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactClippingViewGroupHelper.java b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactClippingViewGroupHelper.java index 0751b9f7a..a5dd0ae82 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactClippingViewGroupHelper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactClippingViewGroupHelper.java @@ -45,12 +45,16 @@ public class ReactClippingViewGroupHelper { ReactClippingViewGroup clippingViewGroup = (ReactClippingViewGroup) parent; if (clippingViewGroup.getRemoveClippedSubviews()) { clippingViewGroup.getClippingRect(sHelperRect); - sHelperRect.offset(-view.getLeft(), -view.getTop()); - view.getDrawingRect(outputRect); - if (!outputRect.intersect(sHelperRect)) { - // rectangles does not intersect -> we should write empty rect to output + // Intersect the view with the parent's rectangle + // This will result in the overlap with coordinates in the parent space + if (!sHelperRect.intersect(view.getLeft(), view.getTop(), view.getRight(), view.getBottom())) { outputRect.setEmpty(); + return; } + // Now we move the coordinates to the View's coordinate space + sHelperRect.offset(-view.getLeft(), -view.getTop()); + sHelperRect.offset(view.getScrollX(), view.getScrollY()); + outputRect.set(sHelperRect); return; } }