Implement RemoveClippedSubviews for Nodes

Summary:
RN has an optimization in which a ScrollView (or similar ViewGroups)
can ask to remove clipped subviews from the View hierarchy. This patch
implements this optimization for Nodes, but instead of adding and removing the
Views, it attaches and detaches Views instead.

Note that this patch does not handle overflow: visible. This is addressed in a
stacked patch on top of this patch (to simplify the review process).

Reviewed By: astreet

Differential Revision: D3235050
This commit is contained in:
Ahmed El-Helw
2016-05-13 17:49:34 -07:00
parent 96cb8165c8
commit 5f162ca119
5 changed files with 185 additions and 12 deletions

View File

@@ -18,6 +18,7 @@ import com.facebook.react.uimanager.ReactShadowNode;
import com.facebook.react.uimanager.ReactStylesDiffMap;
import com.facebook.react.uimanager.ViewProps;
import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.views.view.ReactClippingViewGroupHelper;
/**
* FlatShadowNode is a base class for all shadow node used in FlatUIImplementation. It extends
@@ -36,6 +37,8 @@ import com.facebook.react.uimanager.annotations.ReactProp;
private static final String PROP_IMPORTANT_FOR_ACCESSIBILITY = "importantForAccessibility";
private static final String PROP_TEST_ID = "testID";
private static final String PROP_TRANSFORM = "transform";
private static final String PROP_REMOVE_CLIPPED_SUBVIEWS =
ReactClippingViewGroupHelper.PROP_REMOVE_CLIPPED_SUBVIEWS;
private DrawCommand[] mDrawCommands = DrawCommand.EMPTY_ARRAY;
private AttachDetachListener[] mAttachDetachListeners = AttachDetachListener.EMPTY_ARRAY;
@@ -74,7 +77,8 @@ import com.facebook.react.uimanager.annotations.ReactProp;
styles.hasKey(PROP_ACCESSIBILITY_COMPONENT_TYPE) ||
styles.hasKey(PROP_ACCESSIBILITY_LIVE_REGION) ||
styles.hasKey(PROP_TRANSFORM) ||
styles.hasKey(PROP_IMPORTANT_FOR_ACCESSIBILITY)) {
styles.hasKey(PROP_IMPORTANT_FOR_ACCESSIBILITY) ||
styles.hasKey(PROP_REMOVE_CLIPPED_SUBVIEWS)) {
forceMountToView();
}
}
@@ -317,7 +321,7 @@ import com.facebook.react.uimanager.annotations.ReactProp;
}
if (mDrawView == null) {
mDrawView = DrawView.INSTANCE;
mDrawView = new DrawView(getReactTag(), 0, 0, 0, 0);
invalidate();
// reset NodeRegion to allow it getting garbage-collected
@@ -327,7 +331,7 @@ import com.facebook.react.uimanager.annotations.ReactProp;
/* package */ final DrawView collectDrawView(float left, float top, float right, float bottom) {
if (!Assertions.assumeNotNull(mDrawView).clipBoundsMatch(left, top, right, bottom)) {
mDrawView = new DrawView(left, top, right, bottom);
mDrawView = new DrawView(getReactTag(), left, top, right, bottom);
}
return mDrawView;