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

@@ -21,8 +21,9 @@ import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.common.MapBuilder;
import com.facebook.react.uimanager.PixelUtil;
import com.facebook.react.uimanager.PointerEvents;
import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.uimanager.ViewProps;
import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.views.view.ReactClippingViewGroupHelper;
import com.facebook.react.views.view.ReactDrawableHelper;
/**
@@ -102,6 +103,11 @@ import com.facebook.react.views.view.ReactDrawableHelper;
view.setPointerEvents(parsePointerEvents(pointerEventsStr));
}
@ReactProp(name = ReactClippingViewGroupHelper.PROP_REMOVE_CLIPPED_SUBVIEWS)
public void setRemoveClippedSubviews(FlatViewGroup view, boolean removeClippedSubviews) {
view.setRemoveClippedSubviews(removeClippedSubviews);
}
private static PointerEvents parsePointerEvents(@Nullable String pointerEventsStr) {
if (pointerEventsStr != null) {
switch (pointerEventsStr) {