Skip to content

Commit 1d683fa

Browse files
use owner's width for resolving the margin and padding for node
Summary: The margin and padding are resolved incorrectly for leaf nodes (nodes with measure function set) if margin and padding are used in percentages. Here we were using node's width instead of container width to calculate the margin and padding. Fixed this to use container's width. ## Changelog: [General][Yoga] : Fixed an issue where margin and padding were resolved incorrectly for leaf nodes (nodes with measure function set) if margin and padding are used in percentages. Reviewed By: alickbass Differential Revision: D17130520 fbshipit-source-id: ac904d432f121973e7739debd9136909b5ca1427
1 parent ce226c1 commit 1d683fa

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

ReactCommon/yoga/yoga/Yoga.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -1670,13 +1670,13 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(
16701670
"Expected node to have custom measure function");
16711671

16721672
const float paddingAndBorderAxisRow =
1673-
YGNodePaddingAndBorderForAxis(node, YGFlexDirectionRow, availableWidth);
1674-
const float paddingAndBorderAxisColumn = YGNodePaddingAndBorderForAxis(
1675-
node, YGFlexDirectionColumn, availableWidth);
1673+
YGNodePaddingAndBorderForAxis(node, YGFlexDirectionRow, ownerWidth);
1674+
const float paddingAndBorderAxisColumn =
1675+
YGNodePaddingAndBorderForAxis(node, YGFlexDirectionColumn, ownerWidth);
16761676
const float marginAxisRow =
1677-
node->getMarginForAxis(YGFlexDirectionRow, availableWidth).unwrap();
1677+
node->getMarginForAxis(YGFlexDirectionRow, ownerWidth).unwrap();
16781678
const float marginAxisColumn =
1679-
node->getMarginForAxis(YGFlexDirectionColumn, availableWidth).unwrap();
1679+
node->getMarginForAxis(YGFlexDirectionColumn, ownerWidth).unwrap();
16801680

16811681
// We want to make sure we don't call measure with negative size
16821682
const float innerWidth = YGFloatIsUndefined(availableWidth)

0 commit comments

Comments
 (0)