mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: Changelog: [Internal] Include FlexLayout C++ source to ReactCommons Reviewed By: d16r, NickGerleman Differential Revision: D38716145 fbshipit-source-id: 0ca2ab040e72168f2f1b479609b6cda2787eba66
46 lines
1.1 KiB
C++
46 lines
1.1 KiB
C++
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#include "FlexboxAlgorithm.h"
|
|
|
|
namespace facebook {
|
|
namespace flexlayout {
|
|
namespace algo {
|
|
|
|
FLEX_LAYOUT_EXPORT auto IsBaselineNode(
|
|
const FlexBoxStyle& node,
|
|
const FlexItemStyleBase& flexItemStyle) -> bool {
|
|
if (FlexDirectionIsColumn(node.flexDirection)) {
|
|
return false;
|
|
}
|
|
return ResolveAlignment(flexItemStyle.alignSelf, node.alignItems) ==
|
|
AlignItems::Baseline;
|
|
}
|
|
|
|
FLEX_LAYOUT_EXPORT auto ResolveAlignment(
|
|
AlignSelf alignSelf,
|
|
AlignItems alignItems) -> AlignItems {
|
|
switch (alignSelf) {
|
|
case AlignSelf::Auto:
|
|
return alignItems;
|
|
case AlignSelf::FlexStart:
|
|
return AlignItems::FlexStart;
|
|
case AlignSelf::Center:
|
|
return AlignItems::Center;
|
|
case AlignSelf::FlexEnd:
|
|
return AlignItems::FlexEnd;
|
|
case AlignSelf::Stretch:
|
|
return AlignItems::Stretch;
|
|
case AlignSelf::Baseline:
|
|
return AlignItems::Baseline;
|
|
}
|
|
}
|
|
|
|
} // namespace algo
|
|
} // namespace flexlayout
|
|
} // namespace facebook
|