diff --git a/ReactCommon/yoga/yoga/Yoga.c b/ReactCommon/yoga/yoga/Yoga.c index 5ed9e1af0..96c6c5a5d 100644 --- a/ReactCommon/yoga/yoga/Yoga.c +++ b/ReactCommon/yoga/yoga/Yoga.c @@ -3456,11 +3456,22 @@ static void YGRoundToPixelGrid(const YGNodeRef node, node->layout.position[YGEdgeTop] = YGRoundValueToPixelGrid(nodeTop, pointScaleFactor, false, textRounding); + const bool hasFractionalWidth = !YGFloatsEqual(fmodf(nodeWidth, 1.0), 0); + const bool hasFractionalHeight = !YGFloatsEqual(fmodf(nodeHeight, 1.0), 0); + node->layout.dimensions[YGDimensionWidth] = - YGRoundValueToPixelGrid(absoluteNodeRight, pointScaleFactor, textRounding, false) - + YGRoundValueToPixelGrid( + absoluteNodeRight, + pointScaleFactor, + (textRounding && hasFractionalWidth), + (textRounding && !hasFractionalWidth)) - YGRoundValueToPixelGrid(absoluteNodeLeft, pointScaleFactor, false, textRounding); node->layout.dimensions[YGDimensionHeight] = - YGRoundValueToPixelGrid(absoluteNodeBottom, pointScaleFactor, textRounding, false) - + YGRoundValueToPixelGrid( + absoluteNodeBottom, + pointScaleFactor, + (textRounding && hasFractionalHeight), + (textRounding && !hasFractionalHeight)) - YGRoundValueToPixelGrid(absoluteNodeTop, pointScaleFactor, false, textRounding); const uint32_t childCount = YGNodeListCount(node->children);