slot 0.0.1
A real time UI render framework
载入中...
搜索中...
未找到
Align.h
浏览该文件的文档.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#pragma once
9
10#include <yoga/Yoga.h>
11
13#include <yoga/node/Node.h>
14
15namespace facebook::yoga {
16
18 const yoga::Node* node,
19 const yoga::Node* child) {
20 const Align align = child->style().alignSelf() == Align::Auto
21 ? node->style().alignItems()
22 : child->style().alignSelf();
23
24 if (node->style().display() == Display::Flex && align == Align::Baseline &&
25 isColumn(node->style().flexDirection())) {
26 return Align::FlexStart;
27 }
28
29 return align;
30}
31
33 const yoga::Node* node,
34 const yoga::Node* child) {
35 return child->style().justifySelf() == Justify::Auto
36 ? node->style().justifyItems()
37 : child->style().justifySelf();
38}
39
44constexpr Align fallbackAlignment(Align align) {
45 switch (align) {
46 // Fallback to flex-start
48 case Align::Stretch:
49 return Align::FlexStart;
50
51 // Fallback to safe center. TODO (T208209388): This should be aligned to
52 // Start instead of FlexStart (for row-reverse containers)
55 return Align::FlexStart;
56 default:
57 return align;
58 }
59}
60
66 switch (align) {
67 // Fallback to flex-start
69 // TODO: Support `justify-content: stretch`
70 // case Justify::Stretch:
71 return Justify::FlexStart;
72
73 // Fallback to safe center. TODO (T208209388): This should be aligned to
74 // Start instead of FlexStart (for row-reverse containers)
77 return Justify::FlexStart;
78 default:
79 return align;
80 }
81}
82
83} // namespace facebook::yoga
Definition Benchmark.cpp:19
constexpr Align fallbackAlignment(Align align)
Definition Align.h:44
Justify
Definition Justify.h:18
Align
Definition Align.h:18
Justify resolveChildJustification(const yoga::Node *node, const yoga::Node *child)
Definition Align.h:32
Align resolveChildAlignment(const yoga::Node *node, const yoga::Node *child)
Definition Align.h:17
bool isColumn(const FlexDirection flexDirection)
Definition FlexDirection.h:26