Skip to content

Commit

Permalink
Remove clipChildRectsIfOverflowIsHidden feature flag and associated…
Browse files Browse the repository at this point in the history
… code

Summary:
The flag `clipChildRectsIfOverflowIsHidden` has been set to false for a little over a year. Delete it and associated callsites.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25451696

fbshipit-source-id: a6067b2e25124f6bdef336c2ddead719dd44cca9
  • Loading branch information
JoshuaGross authored and facebook-github-bot committed Dec 10, 2020
1 parent 7f0373d commit c1f9a45
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,6 @@ public class ReactFeatureFlags {
*/
public static boolean useViewManagerDelegatesForCommands = false;

/**
* This react flag enables a custom algorithm for the getChildVisibleRect() method in the classes
* ReactViewGroup, ReactHorizontalScrollView and ReactScrollView.
*
* <p>This new algorithm clip child rects if overflow is set to ViewProps.HIDDEN. More details in
* https://github.com/facebook/react-native/issues/23870 and
* https://github.com/facebook/react-native/pull/26334
*
* <p>The react flag is disabled by default because this is increasing ANRs (T57363204)
*/
public static boolean clipChildRectsIfOverflowIsHidden = false;

/**
* Temporary feature flat to control a fix in the transition to layoutOnlyViews TODO T61185028:
* remove this when bug is fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
package com.facebook.react.uimanager;

import android.graphics.Rect;
import android.graphics.RectF;
import android.view.View;
import android.view.ViewParent;
import javax.annotation.concurrent.NotThreadSafe;
Expand Down Expand Up @@ -57,51 +56,4 @@ public static void calculateClippingRect(View view, Rect outputRect) {
}
view.getDrawingRect(outputRect);
}

public static boolean getChildVisibleRectHelper(
View child, Rect r, android.graphics.Point offset, View parent, String overflow) {
// This is based on the Android ViewGroup implementation, modified to clip child rects
// if overflow is set to ViewProps.HIDDEN. This effectively solves Issue #23870 which
// appears to have been introduced by FLAG_CLIP_CHILDREN being forced false
// regardless of whether clipping is desired.
final RectF rect = new RectF();
rect.set(r);

child.getMatrix().mapRect(rect);

final int dx = child.getLeft() - parent.getScrollX();
final int dy = child.getTop() - parent.getScrollY();

rect.offset(dx, dy);

if (offset != null) {
float[] position = new float[2];
position[0] = offset.x;
position[1] = offset.y;
child.getMatrix().mapPoints(position);
offset.x = Math.round(position[0]) + dx;
offset.y = Math.round(position[1]) + dy;
}

final int width = parent.getRight() - parent.getLeft();
final int height = parent.getBottom() - parent.getTop();

boolean rectIsVisible = true;

ViewParent grandparent = parent.getParent();
if (grandparent == null || ViewProps.HIDDEN.equals(overflow)) {
rectIsVisible = rect.intersect(0, 0, width, height);
}

r.set(
(int) Math.floor(rect.left),
(int) Math.floor(rect.top),
(int) Math.ceil(rect.right),
(int) Math.ceil(rect.bottom));

if (rectIsVisible && grandparent != null) {
rectIsVisible = grandparent.getChildVisibleRect(parent, r, offset);
}
return rectIsVisible;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeMap;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.uimanager.FabricViewStateManager;
import com.facebook.react.uimanager.MeasureSpecAssertions;
import com.facebook.react.uimanager.PixelUtil;
Expand Down Expand Up @@ -546,9 +545,7 @@ public void getClippingRect(Rect outClippingRect) {

@Override
public boolean getChildVisibleRect(View child, Rect r, android.graphics.Point offset) {
return ReactFeatureFlags.clipChildRectsIfOverflowIsHidden
? ReactClippingViewGroupHelper.getChildVisibleRectHelper(child, r, offset, this, mOverflow)
: super.getChildVisibleRect(child, r, offset);
return super.getChildVisibleRect(child, r, offset);
}

private int getSnapInterval() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeMap;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.uimanager.FabricViewStateManager;
import com.facebook.react.uimanager.MeasureSpecAssertions;
import com.facebook.react.uimanager.PixelUtil;
Expand Down Expand Up @@ -383,9 +382,7 @@ public void getClippingRect(Rect outClippingRect) {

@Override
public boolean getChildVisibleRect(View child, Rect r, android.graphics.Point offset) {
return ReactFeatureFlags.clipChildRectsIfOverflowIsHidden
? ReactClippingViewGroupHelper.getChildVisibleRectHelper(child, r, offset, this, mOverflow)
: super.getChildVisibleRect(child, r, offset);
return super.getChildVisibleRect(child, r, offset);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.common.annotations.VisibleForTesting;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.modules.i18nmanager.I18nUtil;
import com.facebook.react.touch.OnInterceptTouchEventListener;
import com.facebook.react.touch.ReactHitSlopView;
Expand Down Expand Up @@ -419,9 +418,7 @@ private void updateSubviewClipStatus(View subview) {

@Override
public boolean getChildVisibleRect(View child, Rect r, android.graphics.Point offset) {
return ReactFeatureFlags.clipChildRectsIfOverflowIsHidden
? ReactClippingViewGroupHelper.getChildVisibleRectHelper(child, r, offset, this, mOverflow)
: super.getChildVisibleRect(child, r, offset);
return super.getChildVisibleRect(child, r, offset);
}

@Override
Expand Down

0 comments on commit c1f9a45

Please sign in to comment.