| 1013 | } |
| 1014 | |
| 1015 | static void justifyMainAxis( |
| 1016 | yoga::Node* const node, |
| 1017 | FlexLine& flexLine, |
| 1018 | const FlexDirection mainAxis, |
| 1019 | const FlexDirection crossAxis, |
| 1020 | const Direction direction, |
| 1021 | const SizingMode sizingModeMainDim, |
| 1022 | const SizingMode sizingModeCrossDim, |
| 1023 | const float mainAxisOwnerSize, |
| 1024 | const float ownerWidth, |
| 1025 | const float availableInnerMainDim, |
| 1026 | const float availableInnerCrossDim, |
| 1027 | const float availableInnerWidth, |
| 1028 | const bool performLayout) { |
| 1029 | const auto& style = node->style(); |
| 1030 | |
| 1031 | const float leadingPaddingAndBorderMain = |
| 1032 | node->style().computeFlexStartPaddingAndBorder( |
| 1033 | mainAxis, direction, ownerWidth); |
| 1034 | const float trailingPaddingAndBorderMain = |
| 1035 | node->style().computeFlexEndPaddingAndBorder( |
| 1036 | mainAxis, direction, ownerWidth); |
| 1037 | |
| 1038 | const float gap = |
| 1039 | node->style().computeGapForAxis(mainAxis, availableInnerMainDim); |
| 1040 | // If we are using "at most" rules in the main axis, make sure that |
| 1041 | // remainingFreeSpace is 0 when min main dimension is not given |
| 1042 | if (sizingModeMainDim == SizingMode::FitContent && |
| 1043 | flexLine.layout.remainingFreeSpace > 0) { |
| 1044 | if (style.minDimension(dimension(mainAxis)).isDefined() && |
| 1045 | style |
| 1046 | .resolvedMinDimension( |
| 1047 | direction, dimension(mainAxis), mainAxisOwnerSize, ownerWidth) |
| 1048 | .isDefined()) { |
| 1049 | // This condition makes sure that if the size of main dimension(after |
| 1050 | // considering child nodes main dim, leading and trailing padding etc) |
| 1051 | // falls below min dimension, then the remainingFreeSpace is reassigned |
| 1052 | // considering the min dimension |
| 1053 | |
| 1054 | // `minAvailableMainDim` denotes minimum available space in which child |
| 1055 | // can be laid out, it will exclude space consumed by padding and border. |
| 1056 | const float minAvailableMainDim = |
| 1057 | style |
| 1058 | .resolvedMinDimension( |
| 1059 | direction, dimension(mainAxis), mainAxisOwnerSize, ownerWidth) |
| 1060 | .unwrap() - |
| 1061 | leadingPaddingAndBorderMain - trailingPaddingAndBorderMain; |
| 1062 | const float occupiedSpaceByChildNodes = |
| 1063 | availableInnerMainDim - flexLine.layout.remainingFreeSpace; |
| 1064 | flexLine.layout.remainingFreeSpace = yoga::maxOrDefined( |
| 1065 | 0.0f, minAvailableMainDim - occupiedSpaceByChildNodes); |
| 1066 | } else { |
| 1067 | flexLine.layout.remainingFreeSpace = 0; |
| 1068 | } |
| 1069 | } |
| 1070 | |
| 1071 | // In order to position the elements in the main axis, we have two controls. |
| 1072 | // The space between the beginning and the first element and the space between |
no test coverage detected