Fix incorrect pixel-rounding in RCTShadowView.

Reviewed By: emilsjolander

Differential Revision: D4133643

fbshipit-source-id: 28a4408ba8da797138b9e100fa1555ddb0856ceb
This commit is contained in:
Dustin Shahidehpour 2016-11-07 15:45:00 -08:00 committed by Facebook Github Bot
parent 7839a9fd60
commit 4d35f65eb7
1 changed files with 8 additions and 8 deletions

View File

@ -129,7 +129,7 @@ DEFINE_PROCESS_META_PROPS(Border);
//
// After passing in the absolutePosition of {106.667, y}, we do the following calculations:
// absoluteLeft = round(absolutePosition.x + viewPosition.left) = round(106.667 + 0) = 106.5
// absoluteRight = round(absolutePosition.x + viewPosition.left + viewSize.left) + round(106.667 + 0 + 106.667) = 213.5
// absoluteRight = round(absolutePosition.x + viewPosition.left + viewSize.width) + round(106.667 + 0 + 106.667) = 213.5
// width = 213.5 - 106.5 = 107
// You'll notice that this is the same width we calculated for the parent view because we've taken its position into account.
@ -152,22 +152,22 @@ DEFINE_PROCESS_META_PROPS(Border);
}
#endif
CGPoint absoluteTopLeft = {
const CGPoint absoluteTopLeft = {
absolutePosition.x + CSSNodeLayoutGetLeft(node),
absolutePosition.y + CSSNodeLayoutGetTop(node)
};
CGPoint absoluteBottomRight = {
absolutePosition.x + CSSNodeLayoutGetLeft(node) + CSSNodeLayoutGetWidth(node),
absolutePosition.y + CSSNodeLayoutGetTop(node) + CSSNodeLayoutGetHeight(node)
const CGPoint absoluteBottomRight = {
absoluteTopLeft.x + CSSNodeLayoutGetWidth(node),
absoluteTopLeft.y + CSSNodeLayoutGetHeight(node)
};
CGRect frame = {{
const CGRect frame = {{
RCTRoundPixelValue(CSSNodeLayoutGetLeft(node)),
RCTRoundPixelValue(CSSNodeLayoutGetTop(node)),
}, {
RCTRoundPixelValue(absoluteBottomRight.x - absoluteTopLeft.x),
RCTRoundPixelValue(absoluteBottomRight.y - absoluteTopLeft.y)
RCTRoundPixelValue(absoluteBottomRight.x) - RCTRoundPixelValue(absoluteTopLeft.x),
RCTRoundPixelValue(absoluteBottomRight.y) - RCTRoundPixelValue(absoluteTopLeft.y),
}};
if (!CGRectEqualToRect(frame, _frame)) {