Remove usage of Gutters arrays and YGGutter as index (#1406)

Summary:
X-link: https://github.com/facebook/react-native/pull/39597

Pull Request resolved: https://github.com/facebook/yoga/pull/1406

Similar in vain to D49362819, we want to stop exposing pre-resolved CompactValue, and allow enum class usage without becoming annoying.

This also simplifies gap resolution a bit. I moved this to Style, to make it clear we aren't relying on any node state. I plan to do some similar cleanup for other resolution later.

Reviewed By: rshest

Differential Revision: D49530923

fbshipit-source-id: 47b06a7301fb283acc493dba159f496159d59580
This commit is contained in:
Nick Gerleman
2023-10-03 10:08:10 -07:00
committed by Facebook GitHub Bot
parent 07cabca526
commit 4ef28bce24
7 changed files with 39 additions and 63 deletions

View File

@@ -1215,7 +1215,7 @@ static void justifyMainAxis(
node->getLeadingPaddingAndBorder(mainAxis, ownerWidth).unwrap();
const float trailingPaddingAndBorderMain =
node->getTrailingPaddingAndBorder(mainAxis, ownerWidth).unwrap();
const float gap = node->getGapForAxis(mainAxis, ownerWidth);
const float gap = node->getGapForAxis(mainAxis);
// If we are using "at most" rules in the main axis, make sure that
// remainingFreeSpace is 0 when min main dimension is not given
if (measureModeMainDim == MeasureMode::AtMost &&
@@ -1666,8 +1666,8 @@ static void calculateLayoutImpl(
generationCount);
if (childCount > 1) {
totalMainDim += node->getGapForAxis(mainAxis, availableInnerCrossDim) *
static_cast<float>(childCount - 1);
totalMainDim +=
node->getGapForAxis(mainAxis) * static_cast<float>(childCount - 1);
}
const bool mainAxisOverflows =
@@ -1690,8 +1690,7 @@ static void calculateLayoutImpl(
// Accumulated cross dimensions of all lines so far.
float totalLineCrossDim = 0;
const float crossAxisGap =
node->getGapForAxis(crossAxis, availableInnerCrossDim);
const float crossAxisGap = node->getGapForAxis(crossAxis);
// Max main dimension of all the lines.
float maxLineMainDim = 0;

View File

@@ -34,7 +34,7 @@ FlexLine calculateFlexLine(
const FlexDirection mainAxis = resolveDirection(
node->getStyle().flexDirection(), node->resolveDirection(ownerDirection));
const bool isNodeFlexWrap = node->getStyle().flexWrap() != Wrap::NoWrap;
const float gap = node->getGapForAxis(mainAxis, availableInnerWidth);
const float gap = node->getGapForAxis(mainAxis);
// Add items to the current line until it's full or we run out of items.
for (; endOfLineIndex < node->getChildren().size(); endOfLineIndex++) {