Fixing the issue with node dimensions rounding in Yoga
Summary: Yoga had a bug in Rounding calculation that caused text nodes dimensions to be rounded up even when the dimensions didn't need rounding Reviewed By: emilsjolander Differential Revision: D5406211 fbshipit-source-id: df1d54ed0805dfc3abbd8f0ceae30f6d8c26d61a
This commit is contained in:
committed by
Facebook Github Bot
parent
7c688cea68
commit
5d75c7c4c8
@@ -3474,8 +3474,12 @@ static void YGRoundToPixelGrid(const YGNodeRef node,
|
|||||||
node->layout.position[YGEdgeTop] =
|
node->layout.position[YGEdgeTop] =
|
||||||
YGRoundValueToPixelGrid(nodeTop, pointScaleFactor, false, textRounding);
|
YGRoundValueToPixelGrid(nodeTop, pointScaleFactor, false, textRounding);
|
||||||
|
|
||||||
const bool hasFractionalWidth = !YGFloatsEqual(fmodf(nodeWidth, 1 / pointScaleFactor), 0);
|
// We multiply dimension by scale factor and if the result is close to the whole number, we don't have any fraction
|
||||||
const bool hasFractionalHeight = !YGFloatsEqual(fmodf(nodeHeight, 1 / pointScaleFactor), 0);
|
// To verify if the result is close to whole number we want to check both floor and ceil numbers
|
||||||
|
const bool hasFractionalWidth = !YGFloatsEqual(fmodf(nodeWidth * pointScaleFactor, 1.0), 0) &&
|
||||||
|
!YGFloatsEqual(fmodf(nodeWidth * pointScaleFactor, 1.0), 1.0);
|
||||||
|
const bool hasFractionalHeight = !YGFloatsEqual(fmodf(nodeHeight * pointScaleFactor, 1.0), 0) &&
|
||||||
|
!YGFloatsEqual(fmodf(nodeHeight * pointScaleFactor, 1.0), 1.0);
|
||||||
|
|
||||||
node->layout.dimensions[YGDimensionWidth] =
|
node->layout.dimensions[YGDimensionWidth] =
|
||||||
YGRoundValueToPixelGrid(
|
YGRoundValueToPixelGrid(
|
||||||
|
Reference in New Issue
Block a user