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

@@ -180,17 +180,11 @@ void nodeToString(
appendEdges(str, "padding", style.padding());
appendEdges(str, "border", style.border());
if (yoga::Node::computeColumnGap(
style.gap(), CompactValue::ofUndefined()) !=
yoga::Node::computeColumnGap(
yoga::Node{}.getStyle().gap(), CompactValue::ofUndefined())) {
appendNumberIfNotUndefined(
str, "column-gap", style.gap()[YGGutterColumn]);
}
if (yoga::Node::computeRowGap(style.gap(), CompactValue::ofUndefined()) !=
yoga::Node::computeRowGap(
yoga::Node{}.getStyle().gap(), CompactValue::ofUndefined())) {
appendNumberIfNotUndefined(str, "row-gap", style.gap()[YGGutterRow]);
if (!style.gap(YGGutterAll).isUndefined()) {
appendNumberIfNotUndefined(str, "gap", style.gap(YGGutterAll));
} else {
appendNumberIfNotUndefined(str, "column-gap", style.gap(YGGutterColumn));
appendNumberIfNotUndefined(str, "row-gap", style.gap(YGGutterRow));
}
appendNumberIfNotAuto(str, "width", style.dimension(Dimension::Width));