Improve removeClippedSubviews for overflowing views

Summary:
Historically, removeClippedSubviews for Nodes would not clip views
that overflowed their parent. This patch changes that, so that Nodes can
properly clip views when they are off screen (even if they have descendants
that overflow the bounds of their parent).

This is done by calculating a set of offsets from the actual width and
height of the view, and using those in the clipping calculations.

Reviewed By: sriramramani

Differential Revision: D3409859
This commit is contained in:
Ahmed El-Helw
2016-06-09 13:45:14 -07:00
parent 4bb33f93cd
commit e1ece03593
5 changed files with 88 additions and 29 deletions

View File

@@ -11,6 +11,8 @@ package com.facebook.react.flat;
import javax.annotation.Nullable;
import android.graphics.Rect;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.NoSuchNativeViewException;
@@ -44,19 +46,19 @@ import com.facebook.react.uimanager.UIViewOperationQueue;
private final @Nullable DrawCommand[] mDrawCommands;
private final @Nullable AttachDetachListener[] mAttachDetachListeners;
private final @Nullable NodeRegion[] mNodeRegions;
private final boolean mHasOverflowingElements;
private final Rect mLogicalAdjustment;
private UpdateMountState(
int reactTag,
@Nullable DrawCommand[] drawCommands,
@Nullable AttachDetachListener[] listeners,
@Nullable NodeRegion[] nodeRegions,
boolean hasOverflowingElements) {
Rect logicalAdjustment) {
mReactTag = reactTag;
mDrawCommands = drawCommands;
mAttachDetachListeners = listeners;
mNodeRegions = nodeRegions;
mHasOverflowingElements = hasOverflowingElements;
mLogicalAdjustment = logicalAdjustment;
}
@Override
@@ -66,7 +68,7 @@ import com.facebook.react.uimanager.UIViewOperationQueue;
mDrawCommands,
mAttachDetachListeners,
mNodeRegions,
mHasOverflowingElements);
mLogicalAdjustment);
}
}
@@ -239,13 +241,13 @@ import com.facebook.react.uimanager.UIViewOperationQueue;
@Nullable DrawCommand[] drawCommands,
@Nullable AttachDetachListener[] listeners,
@Nullable NodeRegion[] nodeRegions,
boolean hasOverflowingElements) {
Rect logicalOffset) {
enqueueUIOperation(new UpdateMountState(
reactTag,
drawCommands,
listeners,
nodeRegions,
hasOverflowingElements));
logicalOffset));
}
public void enqueueUpdateViewGroup(int reactTag, int[] viewsToAdd, int[] viewsToDetach) {