Extract isBaselineLayout() (#1375)

Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1375

X-link: https://github.com/facebook/react-native/pull/39400

Moves `isBaselineLayout` out of `CalculateLayout` into `Baseline.h`. This function is called by flex line justification code, which I have been looking at extracting.

Reviewed By: yungsters

Differential Revision: D49177937

fbshipit-source-id: 02c13aa0b02b26cb60ef197473b90e06d53d5f8d
This commit is contained in:
Nick Gerleman
2023-09-12 19:08:55 -07:00
committed by Facebook GitHub Bot
parent 62ba8ebb3d
commit 700be8c8ad
3 changed files with 22 additions and 19 deletions

View File

@@ -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