reverting D5917111

Reviewed By: zjj010104

Differential Revision: D5961716

fbshipit-source-id: 0efaf38380b0b2e9440375ce0a7623a543f3fbd0
This commit is contained in:
Wenting Hu 2017-10-02 19:46:12 -07:00 committed by Facebook Github Bot
parent 9cd095eae8
commit f368287347
3 changed files with 8 additions and 66 deletions

View File

@ -9,6 +9,11 @@
package com.facebook.react.views.view; package com.facebook.react.views.view;
import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.Locale;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.ColorFilter; import android.graphics.ColorFilter;
@ -21,13 +26,10 @@ import android.graphics.Rect;
import android.graphics.RectF; import android.graphics.RectF;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build; import android.os.Build;
import com.facebook.yoga.YogaConstants;
import com.facebook.react.common.annotations.VisibleForTesting; import com.facebook.react.common.annotations.VisibleForTesting;
import com.facebook.react.uimanager.FloatUtil; import com.facebook.react.uimanager.FloatUtil;
import com.facebook.react.uimanager.Spacing; import com.facebook.react.uimanager.Spacing;
import com.facebook.yoga.YogaConstants;
import java.util.Arrays;
import java.util.Locale;
import javax.annotation.Nullable;
/** /**
* A subclass of {@link Drawable} used for background of {@link ReactViewGroup}. It supports * A subclass of {@link Drawable} used for background of {@link ReactViewGroup}. It supports
@ -228,10 +230,6 @@ public class ReactViewBackgroundDrawable extends Drawable {
} }
} }
public float getRadius() {
return mBorderRadius;
}
public void setColor(int color) { public void setColor(int color) {
mColor = color; mColor = color;
invalidateSelf(); invalidateSelf();
@ -335,8 +333,9 @@ public class ReactViewBackgroundDrawable extends Drawable {
mPaint.setPathEffect(mPathEffectForBorderStyle); mPaint.setPathEffect(mPathEffectForBorderStyle);
} }
/** For rounded borders we use default "borderWidth" property. */ /** For rounded borders we use default "borderWidth" property. */
public float getFullBorderWidth() { private float getFullBorderWidth() {
return (mBorderWidth != null && !YogaConstants.isUndefined(mBorderWidth.getRaw(Spacing.ALL))) ? return (mBorderWidth != null && !YogaConstants.isUndefined(mBorderWidth.getRaw(Spacing.ALL))) ?
mBorderWidth.getRaw(Spacing.ALL) : 0f; mBorderWidth.getRaw(Spacing.ALL) : 0f;
} }

View File

@ -10,11 +10,8 @@
package com.facebook.react.views.view; package com.facebook.react.views.view;
import android.content.Context; import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Path;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable; import android.graphics.drawable.LayerDrawable;
import android.os.Build; import android.os.Build;
@ -34,7 +31,6 @@ import com.facebook.react.uimanager.ReactClippingViewGroupHelper;
import com.facebook.react.uimanager.ReactPointerEventsView; import com.facebook.react.uimanager.ReactPointerEventsView;
import com.facebook.react.uimanager.ReactZIndexedViewGroup; import com.facebook.react.uimanager.ReactZIndexedViewGroup;
import com.facebook.react.uimanager.ViewGroupDrawingOrderHelper; import com.facebook.react.uimanager.ViewGroupDrawingOrderHelper;
import com.facebook.yoga.YogaConstants;
import javax.annotation.Nullable; import javax.annotation.Nullable;
/** /**
@ -104,7 +100,6 @@ public class ReactViewGroup extends ViewGroup implements
private @Nullable OnInterceptTouchEventListener mOnInterceptTouchEventListener; private @Nullable OnInterceptTouchEventListener mOnInterceptTouchEventListener;
private boolean mNeedsOffscreenAlphaCompositing = false; private boolean mNeedsOffscreenAlphaCompositing = false;
private final ViewGroupDrawingOrderHelper mDrawingOrderHelper; private final ViewGroupDrawingOrderHelper mDrawingOrderHelper;
private @Nullable Path mPath;
public ReactViewGroup(Context context) { public ReactViewGroup(Context context) {
super(context); super(context);
@ -590,11 +585,6 @@ public class ReactViewGroup extends ViewGroup implements
mHitSlopRect = rect; mHitSlopRect = rect;
} }
public void setOverflow(String overflow) {
mOverflow = overflow;
invalidate();
}
/** /**
* Set the background for the view or remove the background. It calls {@link * Set the background for the view or remove the background. It calls {@link
* #setBackground(Drawable)} or {@link #setBackgroundDrawable(Drawable)} based on the sdk version. * #setBackground(Drawable)} or {@link #setBackgroundDrawable(Drawable)} based on the sdk version.
@ -609,46 +599,4 @@ public class ReactViewGroup extends ViewGroup implements
super.setBackgroundDrawable(drawable); super.setBackgroundDrawable(drawable);
} }
} }
@Override
protected void dispatchDraw(Canvas canvas) {
if (mOverflow != null) {
switch (mOverflow) {
case "visible":
if (mPath != null) {
mPath.rewind();
}
break;
case "hidden":
if (mReactBackgroundDrawable != null) {
float left = 0f;
float top = 0f;
float right = getWidth();
float bottom = getHeight();
if (mReactBackgroundDrawable.getFullBorderWidth() != 0f) {
float borderWidth = mReactBackgroundDrawable.getFullBorderWidth();
left += borderWidth;
top += borderWidth;
right -= borderWidth;
bottom -= borderWidth;
}
float radius = mReactBackgroundDrawable.getRadius();
if (radius != YogaConstants.UNDEFINED) {
if (mPath == null) {
mPath = new Path();
}
mPath.rewind();
mPath.addRoundRect(
new RectF(left, top, right, bottom), radius, radius, Path.Direction.CW);
canvas.clipPath(mPath);
}
}
break;
default:
break;
}
}
super.dispatchDraw(canvas);
}
} }

View File

@ -163,11 +163,6 @@ public class ReactViewManager extends ViewGroupManager<ReactViewGroup> {
// handled in NativeViewHierarchyOptimizer // handled in NativeViewHierarchyOptimizer
} }
@ReactProp(name = ViewProps.OVERFLOW)
public void setOverflow(ReactViewGroup view, String overflow) {
view.setOverflow(overflow);
}
@Override @Override
public String getName() { public String getName() {
return REACT_CLASS; return REACT_CLASS;