| 14 | namespace facebook::yoga { |
| 15 | |
| 16 | FlexLine calculateFlexLine( |
| 17 | yoga::Node* const node, |
| 18 | const Direction ownerDirection, |
| 19 | const float ownerWidth, |
| 20 | const float mainAxisOwnerSize, |
| 21 | const float availableInnerWidth, |
| 22 | const float availableInnerMainDim, |
| 23 | Node::LayoutableChildren::Iterator& iterator, |
| 24 | const size_t lineCount) { |
| 25 | std::vector<yoga::Node*> itemsInFlow; |
| 26 | itemsInFlow.reserve(node->getChildCount()); |
| 27 | |
| 28 | float sizeConsumed = 0.0f; |
| 29 | float totalFlexGrowFactors = 0.0f; |
| 30 | float totalFlexShrinkScaledFactors = 0.0f; |
| 31 | size_t numberOfAutoMargins = 0; |
| 32 | yoga::Node* firstElementInLine = nullptr; |
| 33 | |
| 34 | float sizeConsumedIncludingMinConstraint = 0; |
| 35 | const Direction direction = node->resolveDirection(ownerDirection); |
| 36 | const FlexDirection mainAxis = |
| 37 | resolveDirection(node->style().flexDirection(), direction); |
| 38 | const bool isNodeFlexWrap = node->style().flexWrap() != Wrap::NoWrap; |
| 39 | const float gap = |
| 40 | node->style().computeGapForAxis(mainAxis, availableInnerMainDim); |
| 41 | |
| 42 | const auto childrenEnd = node->getLayoutChildren().end(); |
| 43 | // Add items to the current line until it's full or we run out of items. |
| 44 | for (; iterator != childrenEnd; iterator++) { |
| 45 | auto child = *iterator; |
| 46 | if (child->style().display() == Display::None || |
| 47 | child->style().positionType() == PositionType::Absolute) { |
| 48 | continue; |
| 49 | } |
| 50 | |
| 51 | if (firstElementInLine == nullptr) { |
| 52 | firstElementInLine = child; |
| 53 | } |
| 54 | |
| 55 | if (child->style().flexStartMarginIsAuto(mainAxis, ownerDirection)) { |
| 56 | numberOfAutoMargins++; |
| 57 | } |
| 58 | if (child->style().flexEndMarginIsAuto(mainAxis, ownerDirection)) { |
| 59 | numberOfAutoMargins++; |
| 60 | } |
| 61 | |
| 62 | child->setLineIndex(lineCount); |
| 63 | const float childMarginMainAxis = |
| 64 | child->style().computeMarginForAxis(mainAxis, availableInnerWidth); |
| 65 | const float childLeadingGapMainAxis = |
| 66 | child == firstElementInLine ? 0.0f : gap; |
| 67 | const float flexBasisWithMinAndMaxConstraints = |
| 68 | boundAxisWithinMinAndMax( |
| 69 | child, |
| 70 | direction, |
| 71 | mainAxis, |
| 72 | child->getLayout().computedFlexBasis, |
| 73 | mainAxisOwnerSize, |
no test coverage detected