don't clip if ui and react view hierarchies are different

Reviewed By: mmmulani

Differential Revision: D4088498

fbshipit-source-id: ec08e4e68d327fc770c944c274bb9f367daba6d2
This commit is contained in:
Martin Kralik 2016-11-11 05:22:44 -08:00 committed by Facebook Github Bot
parent 625c8cb83c
commit d5e067f244
1 changed files with 13 additions and 6 deletions

View File

@ -295,9 +295,7 @@
if (!CGRectIntersectsRect(self.frame, clippingRectForSuperview)) {
// we are clipped
if (self.superview) {
[self removeFromSuperview];
}
clipView(self);
} else {
// we are not clipped
if (!self.superview) {
@ -330,7 +328,6 @@
clipRect = CGRectIntersection(clipRect, self.bounds);
}
for (UIView *subview in self.sortedReactSubviews) {
// TODO inserting subviews based on react subviews is not safe if react hierarchy doesn't match view hierarchy
if (CGRectIntersectsRect(subview.frame, clipRect)) {
if (!subview.superview) {
if (lastSubview) {
@ -342,7 +339,18 @@
lastSubview = subview;
[subview rct_clipSubviewsWithAncestralClipRect:[self convertRect:clipRect toView:subview]];
} else {
[subview removeFromSuperview];
clipView(subview);
}
}
}
static void clipView(UIView *view)
{
// we are clipped
if (view.superview) {
// We don't clip if react hierarchy doesn't match uiview hierarchy, since we could get into inconsistent state.
if (view.reactSuperview == view.superview) {
[view removeFromSuperview];
}
}
}
@ -380,7 +388,6 @@
- (void)rct_updateSubviewsWithNextClippingView:(UIView *)clippingView
{
for (UIView *subview in self.sortedReactSubviews) {
// TODO inserting subviews based on react subviews is not safe if react hierarchy doesn't match view hierarchy
if (!clippingView) {
[self addSubview:subview];
}