Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: border rendering problem in Android #36129

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,9 @@ private void updatePath() {
}

mInnerBottomLeftCorner.x = mInnerClipTempRectForBorderRadius.left;
mInnerBottomLeftCorner.y = mInnerClipTempRectForBorderRadius.bottom * -2;
mInnerBottomLeftCorner.y = borderWidth.bottom != 0
? mInnerClipTempRectForBorderRadius.bottom * -2
: mInnerClipTempRectForBorderRadius.bottom;

getEllipseIntersectionWithLine(
// Ellipse Bounds
Expand Down Expand Up @@ -963,7 +965,9 @@ private void updatePath() {
}

mInnerBottomRightCorner.x = mInnerClipTempRectForBorderRadius.right;
mInnerBottomRightCorner.y = mInnerClipTempRectForBorderRadius.bottom * -2;
mInnerBottomRightCorner.y = borderWidth.bottom != 0
Copy link
Member

@javache javache Feb 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain why don't need this logic for mInnerTopLeftCorner and mInnerTopRightCorner?

Copy link
Contributor Author

@BeeMargarida BeeMargarida Feb 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it can be added (my bad, I kinda had tunnel vision). In the cases where this bug happened it won't cause any difference though, because mInnerClipTempRectForBorderRadius.top was always 0. Do you want me to make a commit adding the same logic to mInnerTopLeftCorner and mInnerTopRightCorner?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it doesn't make a difference, we shouldn't add it. So you're saying we don't need similar logic for the top corners?

Copy link
Contributor Author

@BeeMargarida BeeMargarida Feb 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not totally sure. From what I saw from the code, mInnerClipTempRectForBorderRadius is set based on the getBounds of the drawable. In cases where the bounds don't change, top will always be 0. Is there any possibility of the bounds changing in this case?

Update: ah, there is if we change the size of drawable...I'll test it (nvm, not the case, from what I can tell top will always remain 0)

? mInnerClipTempRectForBorderRadius.bottom * -2
: mInnerClipTempRectForBorderRadius.bottom;

getEllipseIntersectionWithLine(
// Ellipse Bounds
Expand Down
38 changes: 37 additions & 1 deletion packages/rn-tester/js/examples/View/ViewExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ exports.examples = [
title: 'Rounded Borders',
render(): React.Node {
return (
<View style={{flexDirection: 'row'}}>
<View style={{flexDirection: 'row', flexWrap: 'wrap'}}>
<View
style={{
width: 50,
Expand Down Expand Up @@ -474,6 +474,42 @@ exports.examples = [
marginRight: 10,
}}
/>
<View
style={{
width: 50,
height: 50,
borderLeftWidth: 6,
borderTopWidth: 6,
borderTopLeftRadius: 20,
}}
/>
<View
style={{
width: 50,
height: 50,
borderRightWidth: 6,
borderTopWidth: 6,
borderTopRightRadius: 20,
}}
/>
<View
style={{
width: 50,
height: 50,
borderBottomWidth: 6,
borderLeftWidth: 6,
borderBottomLeftRadius: 20,
}}
/>
<View
style={{
width: 50,
height: 50,
borderBottomWidth: 6,
borderRightWidth: 6,
borderBottomRightRadius: 20,
}}
/>
</View>
);
},
Expand Down