Skip to content

Commit

Permalink
use owner's width for resolving the margin and padding for node
Browse files Browse the repository at this point in the history
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-zz authored and facebook-github-bot committed Nov 15, 2019
1 parent ce226c1 commit 1d683fa
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ReactCommon/yoga/yoga/Yoga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1d683fa

Please sign in to comment.