Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.ViewStructure;
import android.view.animation.Animation;
import androidx.annotation.Nullable;
Expand Down Expand Up @@ -56,6 +57,8 @@
import com.facebook.react.uimanager.style.BorderStyle;
import com.facebook.react.uimanager.style.LogicalEdge;
import com.facebook.react.uimanager.style.Overflow;
import java.util.HashSet;
import java.util.Set;

/**
* Backing for a React View. Has support for borders, but since borders aren't common, lazy
Expand Down Expand Up @@ -409,6 +412,13 @@ private void updateClippingToRect(Rect clippingRect) {
try {
updateSubviewClipStatus(clippingRect, i, clippedSoFar);
} catch (IndexOutOfBoundsException e) {
int realClippedSoFar = 0;
Set<View> uniqueViews = new HashSet<>();
for (int j = 0; j < i; j++) {
realClippedSoFar += isViewClipped(mAllChildren[j]) ? 1 : 0;
uniqueViews.add(mAllChildren[j]);
}

throw new IllegalStateException(
"Invalid clipping state. i="
+ i
Expand All @@ -419,7 +429,11 @@ private void updateClippingToRect(Rect clippingRect) {
+ " allChildrenCount="
+ mAllChildrenCount
+ " recycleCount="
+ mRecycleCount,
+ mRecycleCount
+ " realClippedSoFar="
+ realClippedSoFar
+ " uniqueViewsCount="
+ uniqueViews.size(),
e);
}
if (isViewClipped(mAllChildren[i])) {
Expand Down Expand Up @@ -450,7 +464,9 @@ private void updateSubviewClipStatus(Rect clippingRect, int idx, int clippedSoFa
removeViewInLayout(child);
needUpdateClippingRecursive = true;
} else if (intersects && isViewClipped(child)) {
addViewInLayout(child, idx - clippedSoFar, sDefaultLayoutParam, true);
int adjustedIdx = idx - clippedSoFar;
Assertions.assertCondition(adjustedIdx >= 0);
addViewInLayout(child, adjustedIdx, sDefaultLayoutParam, true);
invalidate();
needUpdateClippingRecursive = true;
} else if (intersects) {
Expand Down Expand Up @@ -694,7 +710,13 @@ public void run() {
* @return {@code true} if the view has been removed from the ViewGroup.
*/
private boolean isViewClipped(View view) {
return view.getParent() == null;
ViewParent parent = view.getParent();
if (parent == null) {
return true;
} else {
Assertions.assertCondition(parent == this);
return false;
}
}

private int indexOfChildInAllChildren(View child) {
Expand Down
Loading