22
22
#include < yoga/algorithm/FlexDirection.h>
23
23
#include < yoga/algorithm/FlexLine.h>
24
24
#include < yoga/algorithm/PixelGrid.h>
25
- #include < yoga/algorithm/ResolveValue.h>
26
25
#include < yoga/algorithm/SizingMode.h>
27
26
#include < yoga/debug/AssertFatal.h>
28
27
#include < yoga/debug/Log.h>
@@ -52,15 +51,14 @@ bool calculateLayoutInternal(
52
51
const uint32_t generationCount);
53
52
54
53
static void constrainMaxSizeForMode (
55
- const yoga::Node* const node,
56
- const enum FlexDirection axis,
57
- const float ownerAxisSize,
58
- const float ownerWidth,
59
- SizingMode* mode,
60
- float * size) {
54
+ const yoga::Node* node,
55
+ FlexDirection axis,
56
+ float ownerAxisSize,
57
+ float ownerWidth,
58
+ /* in_out */ SizingMode* mode,
59
+ /* in_out */ float * size) {
61
60
const FloatOptional maxSize =
62
- yoga::resolveValue (
63
- node->getStyle ().maxDimension (dimension (axis)), ownerAxisSize) +
61
+ node->getStyle ().maxDimension (dimension (axis)).resolve (ownerAxisSize) +
64
62
FloatOptional (node->getMarginForAxis (axis, ownerWidth));
65
63
switch (*mode) {
66
64
case SizingMode::StretchFit:
@@ -103,7 +101,7 @@ static void computeFlexBasisForChild(
103
101
SizingMode childHeightSizingMode;
104
102
105
103
const FloatOptional resolvedFlexBasis =
106
- yoga::resolveValue ( child->resolveFlexBasisPtr (), mainAxisownerSize);
104
+ child->resolveFlexBasisPtr (). resolve ( mainAxisownerSize);
107
105
const bool isRowStyleDimDefined =
108
106
child->styleDefinesDimension (FlexDirection::Row, ownerWidth);
109
107
const bool isColumnStyleDimDefined =
@@ -125,16 +123,14 @@ static void computeFlexBasisForChild(
125
123
paddingAndBorderForAxis (child, FlexDirection::Row, ownerWidth));
126
124
127
125
child->setLayoutComputedFlexBasis (yoga::maxOrDefined (
128
- yoga::resolveValue (
129
- child->getResolvedDimension (Dimension::Width), ownerWidth),
126
+ child->getResolvedDimension (Dimension::Width).resolve (ownerWidth),
130
127
paddingAndBorder));
131
128
} else if (!isMainAxisRow && isColumnStyleDimDefined) {
132
129
// The height is definite, so use that as the flex basis.
133
130
const FloatOptional paddingAndBorder = FloatOptional (
134
131
paddingAndBorderForAxis (child, FlexDirection::Column, ownerWidth));
135
132
child->setLayoutComputedFlexBasis (yoga::maxOrDefined (
136
- yoga::resolveValue (
137
- child->getResolvedDimension (Dimension::Height), ownerHeight),
133
+ child->getResolvedDimension (Dimension::Height).resolve (ownerHeight),
138
134
paddingAndBorder));
139
135
} else {
140
136
// Compute the flex basis and hypothetical main size (i.e. the clamped flex
@@ -149,18 +145,16 @@ static void computeFlexBasisForChild(
149
145
child->getMarginForAxis (FlexDirection::Column, ownerWidth);
150
146
151
147
if (isRowStyleDimDefined) {
152
- childWidth =
153
- yoga::resolveValue (
154
- child->getResolvedDimension (Dimension::Width), ownerWidth)
155
- .unwrap () +
148
+ childWidth = child->getResolvedDimension (Dimension::Width)
149
+ .resolve (ownerWidth)
150
+ .unwrap () +
156
151
marginRow;
157
152
childWidthSizingMode = SizingMode::StretchFit;
158
153
}
159
154
if (isColumnStyleDimDefined) {
160
- childHeight =
161
- yoga::resolveValue (
162
- child->getResolvedDimension (Dimension::Height), ownerHeight)
163
- .unwrap () +
155
+ childHeight = child->getResolvedDimension (Dimension::Height)
156
+ .resolve (ownerHeight)
157
+ .unwrap () +
164
158
marginColumn;
165
159
childHeightSizingMode = SizingMode::StretchFit;
166
160
}
@@ -477,13 +471,13 @@ static float calculateAvailableInnerDimension(
477
471
// We want to make sure our available height does not violate min and max
478
472
// constraints
479
473
const FloatOptional minDimensionOptional =
480
- yoga::resolveValue ( node->getStyle ().minDimension (dimension), ownerDim);
474
+ node->getStyle ().minDimension (dimension). resolve ( ownerDim);
481
475
const float minInnerDim = minDimensionOptional.isUndefined ()
482
476
? 0 .0f
483
477
: minDimensionOptional.unwrap () - paddingAndBorder;
484
478
485
479
const FloatOptional maxDimensionOptional =
486
- yoga::resolveValue ( node->getStyle ().maxDimension (dimension), ownerDim);
480
+ node->getStyle ().maxDimension (dimension). resolve ( ownerDim);
487
481
488
482
const float maxInnerDim = maxDimensionOptional.isUndefined ()
489
483
? FLT_MAX
@@ -700,9 +694,8 @@ static float distributeFreeSpaceSecondPass(
700
694
: SizingMode::FitContent;
701
695
} else {
702
696
childCrossSize =
703
- yoga::resolveValue (
704
- currentLineChild->getResolvedDimension (dimension (crossAxis)),
705
- availableInnerCrossDim)
697
+ currentLineChild->getResolvedDimension (dimension (crossAxis))
698
+ .resolve (availableInnerCrossDim)
706
699
.unwrap () +
707
700
marginCross;
708
701
const bool isLoosePercentageMeasurement =
@@ -954,8 +947,8 @@ static void justifyMainAxis(
954
947
if (sizingModeMainDim == SizingMode::FitContent &&
955
948
flexLine.layout .remainingFreeSpace > 0 ) {
956
949
if (style.minDimension (dimension (mainAxis)).isDefined () &&
957
- yoga::resolveValue (
958
- style. minDimension ( dimension (mainAxis)), mainAxisownerSize)
950
+ style. minDimension ( dimension (mainAxis))
951
+ . resolve ( mainAxisownerSize)
959
952
.isDefined ()) {
960
953
// This condition makes sure that if the size of main dimension(after
961
954
// considering child nodes main dim, leading and trailing padding etc)
@@ -964,10 +957,9 @@ static void justifyMainAxis(
964
957
965
958
// `minAvailableMainDim` denotes minimum available space in which child
966
959
// can be laid out, it will exclude space consumed by padding and border.
967
- const float minAvailableMainDim =
968
- yoga::resolveValue (
969
- style.minDimension (dimension (mainAxis)), mainAxisownerSize)
970
- .unwrap () -
960
+ const float minAvailableMainDim = style.minDimension (dimension (mainAxis))
961
+ .resolve (mainAxisownerSize)
962
+ .unwrap () -
971
963
leadingPaddingAndBorderMain - trailingPaddingAndBorderMain;
972
964
const float occupiedSpaceByChildNodes =
973
965
availableInnerMainDim - flexLine.layout .remainingFreeSpace ;
@@ -1446,20 +1438,16 @@ static void calculateLayoutImpl(
1446
1438
if (sizingModeMainDim != SizingMode::StretchFit) {
1447
1439
const auto & style = node->getStyle ();
1448
1440
const float minInnerWidth =
1449
- yoga::resolveValue (style.minDimension (Dimension::Width), ownerWidth)
1450
- .unwrap () -
1441
+ style.minDimension (Dimension::Width).resolve (ownerWidth).unwrap () -
1451
1442
paddingAndBorderAxisRow;
1452
1443
const float maxInnerWidth =
1453
- yoga::resolveValue (style.maxDimension (Dimension::Width), ownerWidth)
1454
- .unwrap () -
1444
+ style.maxDimension (Dimension::Width).resolve (ownerWidth).unwrap () -
1455
1445
paddingAndBorderAxisRow;
1456
1446
const float minInnerHeight =
1457
- yoga::resolveValue (style.minDimension (Dimension::Height), ownerHeight)
1458
- .unwrap () -
1447
+ style.minDimension (Dimension::Height).resolve (ownerHeight).unwrap () -
1459
1448
paddingAndBorderAxisColumn;
1460
1449
const float maxInnerHeight =
1461
- yoga::resolveValue (style.maxDimension (Dimension::Height), ownerHeight)
1462
- .unwrap () -
1450
+ style.maxDimension (Dimension::Height).resolve (ownerHeight).unwrap () -
1463
1451
paddingAndBorderAxisColumn;
1464
1452
1465
1453
const float minInnerMainDim =
@@ -2431,17 +2419,15 @@ void calculateLayout(
2431
2419
const auto & style = node->getStyle ();
2432
2420
if (node->styleDefinesDimension (FlexDirection::Row, ownerWidth)) {
2433
2421
width =
2434
- (yoga::resolveValue (
2435
- node->getResolvedDimension (dimension (FlexDirection::Row)),
2436
- ownerWidth)
2422
+ (node->getResolvedDimension (dimension (FlexDirection::Row))
2423
+ .resolve (ownerWidth)
2437
2424
.unwrap () +
2438
2425
node->getMarginForAxis (FlexDirection::Row, ownerWidth));
2439
2426
widthSizingMode = SizingMode::StretchFit;
2440
- } else if (yoga::resolveValue (
2441
- style. maxDimension (Dimension::Width), ownerWidth)
2427
+ } else if (style. maxDimension (Dimension::Width)
2428
+ . resolve ( ownerWidth)
2442
2429
.isDefined ()) {
2443
- width = yoga::resolveValue (style.maxDimension (Dimension::Width), ownerWidth)
2444
- .unwrap ();
2430
+ width = style.maxDimension (Dimension::Width).resolve (ownerWidth).unwrap ();
2445
2431
widthSizingMode = SizingMode::FitContent;
2446
2432
} else {
2447
2433
width = ownerWidth;
@@ -2453,18 +2439,16 @@ void calculateLayout(
2453
2439
SizingMode heightSizingMode = SizingMode::MaxContent;
2454
2440
if (node->styleDefinesDimension (FlexDirection::Column, ownerHeight)) {
2455
2441
height =
2456
- (yoga::resolveValue (
2457
- node->getResolvedDimension (dimension (FlexDirection::Column)),
2458
- ownerHeight)
2442
+ (node->getResolvedDimension (dimension (FlexDirection::Column))
2443
+ .resolve (ownerHeight)
2459
2444
.unwrap () +
2460
2445
node->getMarginForAxis (FlexDirection::Column, ownerWidth));
2461
2446
heightSizingMode = SizingMode::StretchFit;
2462
- } else if (yoga::resolveValue (
2463
- style. maxDimension (Dimension::Height), ownerHeight)
2447
+ } else if (style. maxDimension (Dimension::Height)
2448
+ . resolve ( ownerHeight)
2464
2449
.isDefined ()) {
2465
2450
height =
2466
- yoga::resolveValue (style.maxDimension (Dimension::Height), ownerHeight)
2467
- .unwrap ();
2451
+ style.maxDimension (Dimension::Height).resolve (ownerHeight).unwrap ();
2468
2452
heightSizingMode = SizingMode::FitContent;
2469
2453
} else {
2470
2454
height = ownerHeight;
0 commit comments