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
This commit is contained in:
Nikita Tuk 2017-11-21 11:48:37 -08:00 коммит произвёл Facebook Github Bot
Родитель 5aa1fb3ff3
Коммит 15179f1798
1 изменённых файлов: 14 добавлений и 0 удалений

Просмотреть файл

@ -59,6 +59,15 @@ RCTCornerInsets RCTGetCornerInsets(RCTCornerRadii cornerRadii,
};
}
static UIEdgeInsets RCTRoundInsetsToPixel(UIEdgeInsets edgeInsets) {
edgeInsets.top = RCTRoundPixelValue(edgeInsets.top);
edgeInsets.bottom = RCTRoundPixelValue(edgeInsets.bottom);
edgeInsets.left = RCTRoundPixelValue(edgeInsets.left);
edgeInsets.right = RCTRoundPixelValue(edgeInsets.right);
return edgeInsets;
}
static void RCTPathAddEllipticArc(CGMutablePathRef path,
const CGAffineTransform *m,
CGPoint origin,
@ -195,6 +204,11 @@ static UIImage *RCTGetSolidBorderImage(RCTCornerRadii cornerRadii,
const BOOL hasCornerRadii = RCTCornerRadiiAreAboveThreshold(cornerRadii);
const RCTCornerInsets cornerInsets = RCTGetCornerInsets(cornerRadii, borderInsets);
// 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
borderInsets = RCTRoundInsetsToPixel(borderInsets);
const BOOL makeStretchable =
(borderInsets.left + cornerInsets.topLeft.width +
borderInsets.right + cornerInsets.bottomRight.width <= viewSize.width) &&