|
19 | 19 |
|
20 | 20 | namespace facebook::react { |
21 | 21 |
|
22 | | -namespace { |
23 | | -inline RawProps filterYogaProps(const RawProps& rawProps) { |
24 | | - const static std::unordered_set<std::string> yogaStylePropNames = { |
25 | | - {"direction", |
26 | | - "flexDirection", |
27 | | - "justifyContent", |
28 | | - "alignContent", |
29 | | - "alignItems", |
30 | | - "alignSelf", |
31 | | - "position", |
32 | | - "flexWrap", |
33 | | - "display", |
34 | | - "flex", |
35 | | - "flexGrow", |
36 | | - "flexShrink", |
37 | | - "flexBasis", |
38 | | - "margin", |
39 | | - "padding", |
40 | | - "rowGap", |
41 | | - "columnGap", |
42 | | - "gap", |
43 | | - // TODO: T163711275 also filter out width/height when SVG no longer read |
44 | | - // them from RawProps |
45 | | - "minWidth", |
46 | | - "maxWidth", |
47 | | - "minHeight", |
48 | | - "maxHeight", |
49 | | - "aspectRatio", |
50 | | - |
51 | | - // edges |
52 | | - "left", |
53 | | - "right", |
54 | | - "top", |
55 | | - "bottom", |
56 | | - "start", |
57 | | - "end", |
58 | | - |
59 | | - // variants of inset |
60 | | - "inset", |
61 | | - "insetStart", |
62 | | - "insetEnd", |
63 | | - "insetInline", |
64 | | - "insetInlineStart", |
65 | | - "insetInlineEnd", |
66 | | - "insetBlock", |
67 | | - "insetBlockEnd", |
68 | | - "insetBlockStart", |
69 | | - "insetVertical", |
70 | | - "insetHorizontal", |
71 | | - "insetTop", |
72 | | - "insetBottom", |
73 | | - "insetLeft", |
74 | | - "insetRight", |
75 | | - |
76 | | - // variants of margin |
77 | | - "marginStart", |
78 | | - "marginEnd", |
79 | | - "marginInline", |
80 | | - "marginInlineStart", |
81 | | - "marginInlineEnd", |
82 | | - "marginBlock", |
83 | | - "marginBlockStart", |
84 | | - "marginBlockEnd", |
85 | | - "marginVertical", |
86 | | - "marginHorizontal", |
87 | | - "marginTop", |
88 | | - "marginBottom", |
89 | | - "marginLeft", |
90 | | - "marginRight", |
91 | | - |
92 | | - // variants of padding |
93 | | - "paddingStart", |
94 | | - "paddingEnd", |
95 | | - "paddingInline", |
96 | | - "paddingInlineStart", |
97 | | - "paddingInlineEnd", |
98 | | - "paddingBlock", |
99 | | - "paddingBlockStart", |
100 | | - "paddingBlockEnd", |
101 | | - "paddingVertical", |
102 | | - "paddingHorizontal", |
103 | | - "paddingTop", |
104 | | - "paddingBottom", |
105 | | - "paddingLeft", |
106 | | - "paddingRight"}}; |
107 | | - |
108 | | - auto filteredRawProps = (folly::dynamic)rawProps; |
109 | | - |
110 | | - auto it = filteredRawProps.items().begin(); |
111 | | - while (it != filteredRawProps.items().end()) { |
112 | | - auto key = it->first.asString(); |
113 | | - if (yogaStylePropNames.find(key) != yogaStylePropNames.end()) { |
114 | | - it = filteredRawProps.erase(it); |
115 | | - } else { |
116 | | - ++it; |
117 | | - } |
118 | | - } |
119 | | - |
120 | | - return RawProps(std::move(filteredRawProps)); |
121 | | -} |
122 | | -} // namespace |
123 | | - |
124 | 22 | YogaStylableProps::YogaStylableProps( |
125 | 23 | const PropsParserContext& context, |
126 | 24 | const YogaStylableProps& sourceProps, |
127 | 25 | const RawProps& rawProps) |
128 | 26 | : Props() { |
129 | | - if (CoreFeatures::excludeYogaFromRawProps) { |
130 | | - const auto filteredRawProps = filterYogaProps(rawProps); |
131 | | - initialize(context, sourceProps, filteredRawProps); |
132 | | - |
133 | | - yogaStyle = CoreFeatures::enablePropIteratorSetter |
134 | | - ? sourceProps.yogaStyle |
135 | | - : convertRawProp(context, filteredRawProps, sourceProps.yogaStyle); |
136 | | - |
137 | | - if (!CoreFeatures::enablePropIteratorSetter) { |
138 | | - convertRawPropAliases(context, sourceProps, filteredRawProps); |
139 | | - } |
140 | | - } else { |
141 | | - initialize(context, sourceProps, rawProps); |
| 27 | + initialize(context, sourceProps, rawProps); |
142 | 28 |
|
143 | | - yogaStyle = CoreFeatures::enablePropIteratorSetter |
144 | | - ? sourceProps.yogaStyle |
145 | | - : convertRawProp(context, rawProps, sourceProps.yogaStyle); |
| 29 | + yogaStyle = CoreFeatures::enablePropIteratorSetter |
| 30 | + ? sourceProps.yogaStyle |
| 31 | + : convertRawProp(context, rawProps, sourceProps.yogaStyle); |
146 | 32 |
|
147 | | - if (!CoreFeatures::enablePropIteratorSetter) { |
148 | | - convertRawPropAliases(context, sourceProps, rawProps); |
149 | | - } |
| 33 | + if (!CoreFeatures::enablePropIteratorSetter) { |
| 34 | + convertRawPropAliases(context, sourceProps, rawProps); |
150 | 35 | } |
151 | 36 | }; |
152 | 37 |
|
|
0 commit comments