mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Implement overflow:visible/hidden attribute (defaults to visible)
Summary: Prior to this patch DrawCommands weren't get clipped by parent DrawCommands at all. For example, a <View> element with size 200x200 with overflow:hidden should clip its child which is 400x400, but this didn't happen. However, if parent <View> would mount to an Android View, it would clip the child regardless of the overflow attribute value (because Android Views always clip whatever is drawing inside that View against its boundaries). This diff is fixing these issue, implementing overflow attribute support and making clipping behavior consistent between nodes that mount to View and nodes that don't. Reviewed By: ahmedre Differential Revision: D2768643
This commit is contained in:
1 parent
f738b598d8
commit
6f06f76e38
11 files changed
+249
-35
No files matched your search
@@ -47,6 +47,7 @@ import com.facebook.react.uimanager.ViewProps;
|
||||
private boolean mBackingViewIsCreated;
|
||||
private @Nullable DrawBackgroundColor mDrawBackground;
|
||||
private int mMoveToIndexInParent;
|
||||
private boolean mIsOverflowVisible = true;
|
||||
|
||||
/* package */ void handleUpdateProperties(CatalystStylesDiffMap styles) {
|
||||
if (!mountsToView()) {
|
||||
@@ -72,13 +73,21 @@ import com.facebook.react.uimanager.ViewProps;
|
||||
float left,
|
||||
float top,
|
||||
float right,
|
||||
float bottom) {
|
||||
float bottom,
|
||||
float clipLeft,
|
||||
float clipTop,
|
||||
float clipRight,
|
||||
float clipBottom) {
|
||||
if (mDrawBackground != null) {
|
||||
mDrawBackground = (DrawBackgroundColor) mDrawBackground.updateBoundsAndFreeze(
|
||||
left,
|
||||
top,
|
||||
right,
|
||||
bottom);
|
||||
bottom,
|
||||
clipLeft,
|
||||
clipTop,
|
||||
clipRight,
|
||||
clipBottom);
|
||||
stateBuilder.addDrawCommand(mDrawBackground);
|
||||
}
|
||||
}
|
||||
@@ -89,6 +98,16 @@ import com.facebook.react.uimanager.ViewProps;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@ReactProp(name = "overflow")
|
||||
public void setOverflow(String overflow) {
|
||||
mIsOverflowVisible = "visible".equals(overflow);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public final boolean isOverflowVisible() {
|
||||
return mIsOverflowVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getScreenX() {
|
||||
return mViewLeft;
|
||||
|
||||
Reference in new issue
Block a user