diff --git a/yoga/algorithm/Baseline.cpp b/yoga/algorithm/Baseline.cpp index 5042074a1e..1cbfbd1883 100644 --- a/yoga/algorithm/Baseline.cpp +++ b/yoga/algorithm/Baseline.cpp @@ -62,4 +62,23 @@ float calculateBaseline(const yoga::Node* node, void* layoutContext) { return baseline + baselineChild->getLayout().position[YGEdgeTop]; } +bool isBaselineLayout(const yoga::Node* node) { + if (isColumn(node->getStyle().flexDirection())) { + return false; + } + if (node->getStyle().alignItems() == YGAlignBaseline) { + return true; + } + const auto childCount = node->getChildCount(); + for (size_t i = 0; i < childCount; i++) { + auto child = node->getChild(i); + if (child->getStyle().positionType() != YGPositionTypeAbsolute && + child->getStyle().alignSelf() == YGAlignBaseline) { + return true; + } + } + + return false; +} + } // namespace facebook::yoga diff --git a/yoga/algorithm/Baseline.h b/yoga/algorithm/Baseline.h index 2e6b015845..71fb3d520d 100644 --- a/yoga/algorithm/Baseline.h +++ b/yoga/algorithm/Baseline.h @@ -15,4 +15,7 @@ namespace facebook::yoga { // Calculate baseline represented as an offset from the top edge of the node. float calculateBaseline(const yoga::Node* node, void* layoutContext); +// Whether any of the children of this node participate in baseline alignment +bool isBaselineLayout(const yoga::Node* node); + } // namespace facebook::yoga diff --git a/yoga/algorithm/CalculateLayout.cpp b/yoga/algorithm/CalculateLayout.cpp index cbd75ee047..78766ede93 100644 --- a/yoga/algorithm/CalculateLayout.cpp +++ b/yoga/algorithm/CalculateLayout.cpp @@ -50,25 +50,6 @@ bool calculateLayoutInternal( const uint32_t depth, const uint32_t generationCount); -static bool isBaselineLayout(const yoga::Node* node) { - if (isColumn(node->getStyle().flexDirection())) { - return false; - } - if (node->getStyle().alignItems() == YGAlignBaseline) { - return true; - } - const auto childCount = node->getChildCount(); - for (size_t i = 0; i < childCount; i++) { - auto child = node->getChild(i); - if (child->getStyle().positionType() != YGPositionTypeAbsolute && - child->getStyle().alignSelf() == YGAlignBaseline) { - return true; - } - } - - return false; -} - static inline float dimensionWithMargin( const yoga::Node* const node, const YGFlexDirection axis,