Skip to content

Commit 15179f1

Browse files
Nikita2kfacebook-github-bot
authored andcommitted
Fixed fractional border width on iOS
Summary: Incorrect render for borders that are not proportional to device pixel: borders get stretched and become significantly bigger than expected. Rdar: http://www.openradar.me/15959788 Incorrect render for borders that are not proportional to device pixel: borders get stretched and become significantly bigger than expected. Rdar: http://www.openradar.me/15959788 Reviewed By: shergin Differential Revision: D6317674 fbshipit-source-id: 6bc331447458583a02c0e56d0d011a31d31d70a8
1 parent 5aa1fb3 commit 15179f1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

React/Views/RCTBorderDrawing.m

+14
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ RCTCornerInsets RCTGetCornerInsets(RCTCornerRadii cornerRadii,
5959
};
6060
}
6161

62+
static UIEdgeInsets RCTRoundInsetsToPixel(UIEdgeInsets edgeInsets) {
63+
edgeInsets.top = RCTRoundPixelValue(edgeInsets.top);
64+
edgeInsets.bottom = RCTRoundPixelValue(edgeInsets.bottom);
65+
edgeInsets.left = RCTRoundPixelValue(edgeInsets.left);
66+
edgeInsets.right = RCTRoundPixelValue(edgeInsets.right);
67+
68+
return edgeInsets;
69+
}
70+
6271
static void RCTPathAddEllipticArc(CGMutablePathRef path,
6372
const CGAffineTransform *m,
6473
CGPoint origin,
@@ -195,6 +204,11 @@ static CGContextRef RCTUIGraphicsBeginImageContext(CGSize size, CGColorRef backg
195204
const BOOL hasCornerRadii = RCTCornerRadiiAreAboveThreshold(cornerRadii);
196205
const RCTCornerInsets cornerInsets = RCTGetCornerInsets(cornerRadii, borderInsets);
197206

207+
// Incorrect render for borders that are not proportional to device pixel: borders get stretched and become
208+
// significantly bigger than expected.
209+
// Rdar: http://www.openradar.me/15959788
210+
borderInsets = RCTRoundInsetsToPixel(borderInsets);
211+
198212
const BOOL makeStretchable =
199213
(borderInsets.left + cornerInsets.topLeft.width +
200214
borderInsets.right + cornerInsets.bottomRight.width <= viewSize.width) &&

0 commit comments

Comments
 (0)