RN: Add Support for overflow on Android (Take 2)

Summary:
Adds support for the `overflow` style property on React Native for Android.

This is the second attempt to do this. See 6110a4cc75 (D8666509) for the first attempt.

Similar to the first attempt, this sets `setClipChildren(false)` by default on all `ViewGroup` instances. However, this differs in how it implements `overflow: hidden`. Instead of conditionally setting `setClipChildren`, this manually clips children to the `ViewGroup`'s bounds  (which was incidentally what we were doing for background + border radius already).

Reviewed By: achen1

Differential Revision: D8690805

fbshipit-source-id: 58757825cd9d138c18c8758918d85b4ca1915f87
This commit is contained in:
Tim Yung
2018-06-29 12:07:02 -07:00
committed by Facebook Github Bot
parent cfce6ee9d7
commit b81c8b51fc
2 changed files with 19 additions and 12 deletions

View File

@@ -113,6 +113,7 @@ public class ReactViewGroup extends ViewGroup implements
public ReactViewGroup(Context context) {
super(context);
setClipChildren(false);
mDrawingOrderHelper = new ViewGroupDrawingOrderHelper(this);
}
@@ -689,12 +690,14 @@ public class ReactViewGroup extends ViewGroup implements
}
break;
case ViewProps.HIDDEN:
if (mReactBackgroundDrawable != null) {
float left = 0f;
float top = 0f;
float right = getWidth();
float bottom = getHeight();
float left = 0f;
float top = 0f;
float right = getWidth();
float bottom = getHeight();
boolean hasClipPath = false;
if (mReactBackgroundDrawable != null) {
final RectF borderWidth = mReactBackgroundDrawable.getDirectionAwareBorderInsets();
if (borderWidth.top > 0
@@ -817,10 +820,13 @@ public class ReactViewGroup extends ViewGroup implements
},
Path.Direction.CW);
canvas.clipPath(mPath);
} else {
canvas.clipRect(new RectF(left, top, right, bottom));
hasClipPath = true;
}
}
if (!hasClipPath) {
canvas.clipRect(new RectF(left, top, right, bottom));
}
break;
default:
break;