Skip to content
Permalink
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
  • Loading branch information
SidharthGuglani authored and facebook-github-bot committed Nov 15, 2019
1 parent ce226c1 commit 1d683faf1dc89e4950e7e1f5c5a67f9a7ca1ee24
Showing 1 changed file with 5 additions and 5 deletions.
@@ -1670,13 +1670,13 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(
"Expected node to have custom measure function");

const float paddingAndBorderAxisRow =
YGNodePaddingAndBorderForAxis(node, YGFlexDirectionRow, availableWidth);
const float paddingAndBorderAxisColumn = YGNodePaddingAndBorderForAxis(
node, YGFlexDirectionColumn, availableWidth);
YGNodePaddingAndBorderForAxis(node, YGFlexDirectionRow, ownerWidth);
const float paddingAndBorderAxisColumn =
YGNodePaddingAndBorderForAxis(node, YGFlexDirectionColumn, ownerWidth);
const float marginAxisRow =
node->getMarginForAxis(YGFlexDirectionRow, availableWidth).unwrap();
node->getMarginForAxis(YGFlexDirectionRow, ownerWidth).unwrap();
const float marginAxisColumn =
node->getMarginForAxis(YGFlexDirectionColumn, availableWidth).unwrap();
node->getMarginForAxis(YGFlexDirectionColumn, ownerWidth).unwrap();

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

0 comments on commit 1d683fa

Please sign in to comment.