Skip to content

Commit

Permalink
Simplify getting padding + border for cross axis in algorithm (facebo…
Browse files Browse the repository at this point in the history
…ok#1437)

Summary:
Pull Request resolved: facebook#1437

X-link: facebook/react-native#41208

Reading through the sizing logic and this seemed a bit redundant/confusing. Lets use the same function we just used for the main axis for the cross axis as well so people do not think its special. Also we will need one less variable. The reason this was done it seems is because we need the leading padding + border elsewhere so this is technically a few less steps but this is cleaner

Differential Revision: https://www.internalfb.com/diff/D50704177?entry_point=27

fbshipit-source-id: a52075273676955889ddd80494ac34b1094ef04e
  • Loading branch information
Joe Vilches authored and facebook-github-bot committed Nov 7, 2023
1 parent 9286007 commit b2c652b
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions yoga/algorithm/CalculateLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1612,12 +1612,10 @@ static void calculateLayoutImpl(

const float paddingAndBorderAxisMain =
paddingAndBorderForAxis(node, mainAxis, ownerWidth);
const float paddingAndBorderAxisCross =
paddingAndBorderForAxis(node, crossAxis, ownerWidth);
const float leadingPaddingAndBorderCross =
node->getInlineStartPaddingAndBorder(crossAxis, direction, ownerWidth);
const float trailingPaddingAndBorderCross =
node->getInlineEndPaddingAndBorder(crossAxis, direction, ownerWidth);
const float paddingAndBorderAxisCross =
leadingPaddingAndBorderCross + trailingPaddingAndBorderCross;

MeasureMode measureModeMainDim =
isMainAxisRow ? widthMeasureMode : heightMeasureMode;
Expand Down

0 comments on commit b2c652b

Please sign in to comment.