Skip to content

Commit

Permalink
ReactViewGroup - remove sHelperRect (#47588)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #47588

This is unnecessary - we can pass the params directly instead of first populating them in a Rect.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D65843834

fbshipit-source-id: 92bb3faa622bba81792fe92e357bc1667894d4ef
  • Loading branch information
Thomas Nardone authored and facebook-github-bot committed Nov 14, 2024
1 parent e5808f2 commit 184eb17
Showing 1 changed file with 2 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ public class ReactViewGroup extends ViewGroup
private static final int DEFAULT_BACKGROUND_COLOR = Color.TRANSPARENT;
private static final LayoutParams sDefaultLayoutParam = new ViewGroup.LayoutParams(0, 0);
private final Rect mOverflowInset = new Rect();
/* should only be used in {@link #updateClippingToRect} */
private static final Rect sHelperRect = new Rect();

/**
* This listener will be set for child views when removeClippedSubview property is enabled. When
Expand Down Expand Up @@ -192,7 +190,6 @@ private void initView() {
// Set default field values
initView();
mOverflowInset.setEmpty();
sHelperRect.setEmpty();

// Remove any children
removeAllViews();
Expand Down Expand Up @@ -443,10 +440,9 @@ private void updateSubviewClipStatus(Rect clippingRect, int idx, int clippedSoFa
UiThreadUtil.assertOnUiThread();

View child = Assertions.assertNotNull(mAllChildren)[idx];
sHelperRect.set(child.getLeft(), child.getTop(), child.getRight(), child.getBottom());
boolean intersects =
clippingRect.intersects(
sHelperRect.left, sHelperRect.top, sHelperRect.right, sHelperRect.bottom);
child.getLeft(), child.getTop(), child.getRight(), child.getBottom());
boolean needUpdateClippingRecursive = false;
// We never want to clip children that are being animated, as this can easily break layout :
// when layout animation changes size and/or position of views contained inside a listview that
Expand All @@ -471,8 +467,6 @@ private void updateSubviewClipStatus(Rect clippingRect, int idx, int clippedSoFa
}
if (needUpdateClippingRecursive) {
if (child instanceof ReactClippingViewGroup) {
// we don't use {@link sHelperRect} until the end of this loop, therefore it's safe
// to call this method that may write to the same {@link sHelperRect} object.
ReactClippingViewGroup clippingChild = (ReactClippingViewGroup) child;
if (clippingChild.getRemoveClippedSubviews()) {
clippingChild.updateClippingRect();
Expand All @@ -490,10 +484,9 @@ private void updateSubviewClipStatus(View subview) {
Assertions.assertNotNull(mAllChildren);

// do fast check whether intersect state changed
sHelperRect.set(subview.getLeft(), subview.getTop(), subview.getRight(), subview.getBottom());
boolean intersects =
mClippingRect.intersects(
sHelperRect.left, sHelperRect.top, sHelperRect.right, sHelperRect.bottom);
subview.getLeft(), subview.getTop(), subview.getRight(), subview.getBottom());

// If it was intersecting before, should be attached to the parent
boolean oldIntersects = (subview.getParent() != null);
Expand Down

0 comments on commit 184eb17

Please sign in to comment.