mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Avoid returning mutable Path in CSSBackgroundDrawable (#44733)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/44733 We are returning a Path to callers, which shouldn't be mutated. This isn't really safe. Return a copy to external callers instead, if they need a path to work with. Changelog: [Internal] Reviewed By: rshest Differential Revision: D57996157 fbshipit-source-id: 53cd95df6e2641d946f7c3fef40f6449b16ca5cb
This commit is contained in:
committed by
Facebook GitHub Bot
parent
869eebe02d
commit
a1f68dbfb4
+5
-4
@@ -319,7 +319,7 @@ public class CSSBackgroundDrawable extends Drawable {
|
||||
public @Nullable Path getBorderBoxPath() {
|
||||
if (hasRoundedBorders()) {
|
||||
updatePath();
|
||||
return Preconditions.checkNotNull(mOuterClipPathForBorderRadius);
|
||||
return new Path(Preconditions.checkNotNull(mOuterClipPathForBorderRadius));
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -332,7 +332,7 @@ public class CSSBackgroundDrawable extends Drawable {
|
||||
public @Nullable Path getPaddingBoxPath() {
|
||||
if (hasRoundedBorders()) {
|
||||
updatePath();
|
||||
return Preconditions.checkNotNull(mInnerClipPathForBorderRadius);
|
||||
return new Path(Preconditions.checkNotNull(mInnerClipPathForBorderRadius));
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -356,7 +356,7 @@ public class CSSBackgroundDrawable extends Drawable {
|
||||
canvas.save();
|
||||
|
||||
// Clip outer border
|
||||
canvas.clipPath(Preconditions.checkNotNull(getBorderBoxPath()), Region.Op.INTERSECT);
|
||||
canvas.clipPath(Preconditions.checkNotNull(mOuterClipPathForBorderRadius), Region.Op.INTERSECT);
|
||||
|
||||
// Draws the View without its border first (with background color fill)
|
||||
int useColor = ColorUtils.setAlphaComponent(mColor, getOpacity());
|
||||
@@ -415,7 +415,8 @@ public class CSSBackgroundDrawable extends Drawable {
|
||||
mPaint.setStyle(Paint.Style.FILL);
|
||||
|
||||
// Clip inner border
|
||||
canvas.clipPath(Preconditions.checkNotNull(getPaddingBoxPath()), Region.Op.DIFFERENCE);
|
||||
canvas.clipPath(
|
||||
Preconditions.checkNotNull(mInnerClipPathForBorderRadius), Region.Op.DIFFERENCE);
|
||||
|
||||
final boolean isRTL = getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
|
||||
int colorStart = getBorderColor(Spacing.START);
|
||||
|
||||
Reference in New Issue
Block a user