mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-03 22:48:25 +08:00
Only clip node against its own boundaries IFF clipToBounds() is set to true (i.e. overflow is visible)
Summary: Previously, every node would be clipped by its own boundaries. This made sense, because a) RCTView cannot draw outside of its bounds, so clipping is harmless b) all other node types were not allowed to control overflow behavior, and for them overflow was implicitly set to hidden, which means it should clip. This diff changes the logic so that overflow can be set on any node (image, text, view etc). The change has an important implication that make the diff a little trickier that it could be: AbstractDrawCommand clipping logic needs to be relaxed. Previously, clip bounds were *always* intersected with node bounds, which means that clip rect was always within node rect. This is no longer true, and thus shouldClip() logic needs to be modified. Because of the above, RCTText no longer needs to artificially clip bounds against layout width/height. Note: RCTImage is still not working with overflow: visible correctly (it still always clips). This is fixed in a follow up diff. Reviewed By: ahmedre Differential Revision: D2867849
This commit is contained in:
committed by
Ahmed El-Helw
parent
05e8ff1fe0
commit
674e74a963
@@ -140,7 +140,7 @@ import android.graphics.Canvas;
|
||||
protected abstract void onDraw(Canvas canvas);
|
||||
|
||||
protected boolean shouldClip() {
|
||||
return mLeft != mClipLeft || mTop != mClipTop || mRight != mClipRight || mBottom != mClipBottom;
|
||||
return mLeft < mClipLeft || mTop < mClipTop || mRight > mClipRight || mBottom > mClipBottom;
|
||||
}
|
||||
|
||||
protected void onBoundsChanged() {
|
||||
|
||||
Reference in New Issue
Block a user