Properly invalidate FlatViewGroup with width or height equal to 0

Summary: View.invalidate() will not actually invalidate a View if it has width or height equal to 0. This is causing problems with overflow: visible. A quick fix applied here is to invalidate slightly larger region that the View bounds to bypass the optimization.

Reviewed By: ahmedre

Differential Revision: D2800920
This commit is contained in:
Denis Koroskin 2016-01-05 12:58:47 -08:00 committed by Ahmed El-Helw
parent b10474c333
commit 2e773a2cb1
1 changed files with 16 additions and 0 deletions

View File

@ -215,6 +215,20 @@ import com.facebook.react.uimanager.ReactPointerEventsView;
}
}
@Override
public void invalidate() {
// By default, invalidate() only invalidates the View's boundaries, which works great in most
// cases but may fail with overflow: visible (i.e. View clipping disabled) when View width or
// height is 0. This is because invalidate() has an optimization where it will not invalidate
// empty Views at all. A quick fix is to invalidate a slightly larger region to make sure we
// never hit that optimization.
//
// Another thing to note is that this may not work correctly with software rendering because
// in software, Android tracks dirty regions to redraw. We would need to collect information
// about all children boundaries (recursively) to track dirty region precisely.
invalidate(0, 0, getWidth() + 1, getHeight() + 1);
}
/**
* We override this to allow developers to determine whether they need offscreen alpha compositing
* or not. See the documentation of needsOffscreenAlphaCompositing in View.js.
@ -358,6 +372,8 @@ import com.facebook.react.uimanager.ReactPointerEventsView;
for (int viewToDetach : viewsToDetach) {
removeDetachedView(viewResolver.getView(viewToDetach), false);
}
invalidate();
}
/* package */ void processLayoutRequest() {