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 =
@@ -1748,9 +1736,8 @@ static void calculateLayoutImpl(
1748
1736
const float unclampedCrossDim = sizingModeCrossDim == SizingMode::StretchFit
1749
1737
? availableInnerCrossDim + paddingAndBorderAxisCross
1750
1738
: node->styleDefinesDimension (crossAxis, crossAxisownerSize)
1751
- ? yoga::resolveValue (
1752
- node->getResolvedDimension (dimension (crossAxis)),
1753
- crossAxisownerSize)
1739
+ ? node->getResolvedDimension (dimension (crossAxis))
1740
+ .resolve (crossAxisownerSize)
1754
1741
.unwrap ()
1755
1742
: totalLineCrossDim + paddingAndBorderAxisCross;
1756
1743
@@ -2442,17 +2429,15 @@ void calculateLayout(
2442
2429
const auto & style = node->getStyle ();
2443
2430
if (node->styleDefinesDimension (FlexDirection::Row, ownerWidth)) {
2444
2431
width =
2445
- (yoga::resolveValue (
2446
- node->getResolvedDimension (dimension (FlexDirection::Row)),
2447
- ownerWidth)
2432
+ (node->getResolvedDimension (dimension (FlexDirection::Row))
2433
+ .resolve (ownerWidth)
2448
2434
.unwrap () +
2449
2435
node->getMarginForAxis (FlexDirection::Row, ownerWidth));
2450
2436
widthSizingMode = SizingMode::StretchFit;
2451
- } else if (yoga::resolveValue (
2452
- style. maxDimension (Dimension::Width), ownerWidth)
2437
+ } else if (style. maxDimension (Dimension::Width)
2438
+ . resolve ( ownerWidth)
2453
2439
.isDefined ()) {
2454
- width = yoga::resolveValue (style.maxDimension (Dimension::Width), ownerWidth)
2455
- .unwrap ();
2440
+ width = style.maxDimension (Dimension::Width).resolve (ownerWidth).unwrap ();
2456
2441
widthSizingMode = SizingMode::FitContent;
2457
2442
} else {
2458
2443
width = ownerWidth;
@@ -2464,18 +2449,16 @@ void calculateLayout(
2464
2449
SizingMode heightSizingMode = SizingMode::MaxContent;
2465
2450
if (node->styleDefinesDimension (FlexDirection::Column, ownerHeight)) {
2466
2451
height =
2467
- (yoga::resolveValue (
2468
- node->getResolvedDimension (dimension (FlexDirection::Column)),
2469
- ownerHeight)
2452
+ (node->getResolvedDimension (dimension (FlexDirection::Column))
2453
+ .resolve (ownerHeight)
2470
2454
.unwrap () +
2471
2455
node->getMarginForAxis (FlexDirection::Column, ownerWidth));
2472
2456
heightSizingMode = SizingMode::StretchFit;
2473
- } else if (yoga::resolveValue (
2474
- style. maxDimension (Dimension::Height), ownerHeight)
2457
+ } else if (style. maxDimension (Dimension::Height)
2458
+ . resolve ( ownerHeight)
2475
2459
.isDefined ()) {
2476
2460
height =
2477
- yoga::resolveValue (style.maxDimension (Dimension::Height), ownerHeight)
2478
- .unwrap ();
2461
+ style.maxDimension (Dimension::Height).resolve (ownerHeight).unwrap ();
2479
2462
heightSizingMode = SizingMode::FitContent;
2480
2463
} else {
2481
2464
height = ownerHeight;
0 commit comments