react-native-windows 0.82.1 → 0.82.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Microsoft.ReactNative/Base/CxxReactIncludes.h +11 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +52 -2
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +70 -49
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +4 -1
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/WindowsTextLayoutManager.cpp +7 -2
- package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +1 -1
- package/Microsoft.ReactNative/Pch/pch.h +2 -0
- package/Microsoft.ReactNative/ReactHost/CrashManager.cpp +5 -0
- package/Microsoft.ReactNative/ReactHost/ReactNativeHeaders.h +1 -0
- package/PropertySheets/External/Microsoft.ReactNative.Composition.CppLib.props +10 -0
- package/PropertySheets/External/Microsoft.ReactNative.Uwp.CppLib.props +10 -0
- package/PropertySheets/Generated/PackageVersion.g.props +3 -3
- package/ReactCommon/ReactCommon.vcxproj +10 -10
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/Instance.cpp +379 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSExecutor.cpp +47 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSIndexedRAMBundle.cpp +143 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/MethodCall.cpp +98 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/ModuleRegistry.cpp +254 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/NativeToJsBridge.cpp +9 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/RAMBundleRegistry.cpp +91 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/ReactMarker.cpp +147 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsiexecutor/jsireact/JSIExecutor.cpp +622 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsiexecutor/jsireact/JSINativeModules.cpp +121 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/webperformance/NativePerformance.cpp +409 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/BaseViewProps.cpp +628 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/EventDispatcher.cpp +79 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/EventQueueProcessor.cpp +138 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/uimanager/UIManager.cpp +732 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp +687 -0
- package/Shared/Shared.vcxitems +9 -9
- package/package.json +1 -1
- package/templates/cpp-app/windows/MyApp/MyApp.vcxproj +2 -0
package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/BaseViewProps.cpp
ADDED
|
@@ -0,0 +1,628 @@
|
|
|
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
|
+
#include "BaseViewProps.h"
|
|
9
|
+
|
|
10
|
+
#include <algorithm>
|
|
11
|
+
|
|
12
|
+
#include <react/featureflags/ReactNativeFeatureFlags.h>
|
|
13
|
+
#include <react/renderer/components/view/BoxShadowPropsConversions.h>
|
|
14
|
+
#include <react/renderer/components/view/FilterPropsConversions.h>
|
|
15
|
+
#include <react/renderer/components/view/conversions.h>
|
|
16
|
+
#include <react/renderer/components/view/primitives.h>
|
|
17
|
+
#include <react/renderer/components/view/propsConversions.h>
|
|
18
|
+
#include <react/renderer/core/graphicsConversions.h>
|
|
19
|
+
#include <react/renderer/core/propsConversions.h>
|
|
20
|
+
#include <react/renderer/debug/debugStringConvertibleUtils.h>
|
|
21
|
+
#include <react/renderer/graphics/ValueUnit.h>
|
|
22
|
+
|
|
23
|
+
namespace facebook::react {
|
|
24
|
+
|
|
25
|
+
namespace {
|
|
26
|
+
|
|
27
|
+
std::array<float, 3> getTranslateForTransformOrigin(
|
|
28
|
+
float viewWidth,
|
|
29
|
+
float viewHeight,
|
|
30
|
+
TransformOrigin transformOrigin) {
|
|
31
|
+
float viewCenterX = viewWidth / 2;
|
|
32
|
+
float viewCenterY = viewHeight / 2;
|
|
33
|
+
|
|
34
|
+
std::array<float, 3> origin = {viewCenterX, viewCenterY, transformOrigin.z};
|
|
35
|
+
|
|
36
|
+
for (size_t i = 0; i < transformOrigin.xy.size(); ++i) {
|
|
37
|
+
auto& currentOrigin = transformOrigin.xy[i];
|
|
38
|
+
if (currentOrigin.unit == UnitType::Point) {
|
|
39
|
+
origin[i] = currentOrigin.value;
|
|
40
|
+
} else if (currentOrigin.unit == UnitType::Percent) {
|
|
41
|
+
origin[i] =
|
|
42
|
+
((i == 0) ? viewWidth : viewHeight) * currentOrigin.value / 100.0f;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
float newTranslateX = -viewCenterX + origin[0];
|
|
47
|
+
float newTranslateY = -viewCenterY + origin[1];
|
|
48
|
+
float newTranslateZ = origin[2];
|
|
49
|
+
|
|
50
|
+
return std::array{newTranslateX, newTranslateY, newTranslateZ};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
} // namespace
|
|
54
|
+
|
|
55
|
+
BaseViewProps::BaseViewProps(
|
|
56
|
+
const PropsParserContext& context,
|
|
57
|
+
const BaseViewProps& sourceProps,
|
|
58
|
+
const RawProps& rawProps,
|
|
59
|
+
const std::function<bool(const std::string&)>& filterObjectKeys)
|
|
60
|
+
: YogaStylableProps(context, sourceProps, rawProps, filterObjectKeys),
|
|
61
|
+
AccessibilityProps(context, sourceProps, rawProps),
|
|
62
|
+
opacity(
|
|
63
|
+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
64
|
+
? sourceProps.opacity
|
|
65
|
+
: convertRawProp(
|
|
66
|
+
context,
|
|
67
|
+
rawProps,
|
|
68
|
+
"opacity",
|
|
69
|
+
sourceProps.opacity,
|
|
70
|
+
(Float)1.0)),
|
|
71
|
+
backgroundColor(
|
|
72
|
+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
73
|
+
? sourceProps.backgroundColor
|
|
74
|
+
: convertRawProp(
|
|
75
|
+
context,
|
|
76
|
+
rawProps,
|
|
77
|
+
"backgroundColor",
|
|
78
|
+
sourceProps.backgroundColor,
|
|
79
|
+
{})),
|
|
80
|
+
borderRadii(
|
|
81
|
+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
82
|
+
? sourceProps.borderRadii
|
|
83
|
+
: convertRawProp(
|
|
84
|
+
context,
|
|
85
|
+
rawProps,
|
|
86
|
+
"border",
|
|
87
|
+
"Radius",
|
|
88
|
+
sourceProps.borderRadii,
|
|
89
|
+
{})),
|
|
90
|
+
borderColors(
|
|
91
|
+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
92
|
+
? sourceProps.borderColors
|
|
93
|
+
: convertRawProp(
|
|
94
|
+
context,
|
|
95
|
+
rawProps,
|
|
96
|
+
"border",
|
|
97
|
+
"Color",
|
|
98
|
+
sourceProps.borderColors,
|
|
99
|
+
{})),
|
|
100
|
+
borderCurves(
|
|
101
|
+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
102
|
+
? sourceProps.borderCurves
|
|
103
|
+
: convertRawProp(
|
|
104
|
+
context,
|
|
105
|
+
rawProps,
|
|
106
|
+
"border",
|
|
107
|
+
"Curve",
|
|
108
|
+
sourceProps.borderCurves,
|
|
109
|
+
{})),
|
|
110
|
+
borderStyles(
|
|
111
|
+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
112
|
+
? sourceProps.borderStyles
|
|
113
|
+
: convertRawProp(
|
|
114
|
+
context,
|
|
115
|
+
rawProps,
|
|
116
|
+
"border",
|
|
117
|
+
"Style",
|
|
118
|
+
sourceProps.borderStyles,
|
|
119
|
+
{})),
|
|
120
|
+
outlineColor(
|
|
121
|
+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
122
|
+
? sourceProps.outlineColor
|
|
123
|
+
: convertRawProp(
|
|
124
|
+
context,
|
|
125
|
+
rawProps,
|
|
126
|
+
"outlineColor",
|
|
127
|
+
sourceProps.outlineColor,
|
|
128
|
+
{})),
|
|
129
|
+
outlineOffset(
|
|
130
|
+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
131
|
+
? sourceProps.outlineOffset
|
|
132
|
+
: convertRawProp(
|
|
133
|
+
context,
|
|
134
|
+
rawProps,
|
|
135
|
+
"outlineOffset",
|
|
136
|
+
sourceProps.outlineOffset,
|
|
137
|
+
{})),
|
|
138
|
+
outlineStyle(
|
|
139
|
+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
140
|
+
? sourceProps.outlineStyle
|
|
141
|
+
: convertRawProp(
|
|
142
|
+
context,
|
|
143
|
+
rawProps,
|
|
144
|
+
"outlineStyle",
|
|
145
|
+
sourceProps.outlineStyle,
|
|
146
|
+
{})),
|
|
147
|
+
outlineWidth(
|
|
148
|
+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
149
|
+
? sourceProps.outlineWidth
|
|
150
|
+
: convertRawProp(
|
|
151
|
+
context,
|
|
152
|
+
rawProps,
|
|
153
|
+
"outlineWidth",
|
|
154
|
+
sourceProps.outlineWidth,
|
|
155
|
+
{})),
|
|
156
|
+
shadowColor(
|
|
157
|
+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
158
|
+
? sourceProps.shadowColor
|
|
159
|
+
: convertRawProp(
|
|
160
|
+
context,
|
|
161
|
+
rawProps,
|
|
162
|
+
"shadowColor",
|
|
163
|
+
sourceProps.shadowColor,
|
|
164
|
+
{})),
|
|
165
|
+
shadowOffset(
|
|
166
|
+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
167
|
+
? sourceProps.shadowOffset
|
|
168
|
+
: convertRawProp(
|
|
169
|
+
context,
|
|
170
|
+
rawProps,
|
|
171
|
+
"shadowOffset",
|
|
172
|
+
sourceProps.shadowOffset,
|
|
173
|
+
{})),
|
|
174
|
+
shadowOpacity(
|
|
175
|
+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
176
|
+
? sourceProps.shadowOpacity
|
|
177
|
+
: convertRawProp(
|
|
178
|
+
context,
|
|
179
|
+
rawProps,
|
|
180
|
+
"shadowOpacity",
|
|
181
|
+
sourceProps.shadowOpacity,
|
|
182
|
+
{})),
|
|
183
|
+
shadowRadius(
|
|
184
|
+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
185
|
+
? sourceProps.shadowRadius
|
|
186
|
+
: convertRawProp(
|
|
187
|
+
context,
|
|
188
|
+
rawProps,
|
|
189
|
+
"shadowRadius",
|
|
190
|
+
sourceProps.shadowRadius,
|
|
191
|
+
{})),
|
|
192
|
+
cursor(
|
|
193
|
+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
194
|
+
? sourceProps.cursor
|
|
195
|
+
: convertRawProp(
|
|
196
|
+
context,
|
|
197
|
+
rawProps,
|
|
198
|
+
"cursor",
|
|
199
|
+
sourceProps.cursor,
|
|
200
|
+
{})),
|
|
201
|
+
boxShadow(
|
|
202
|
+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
203
|
+
? sourceProps.boxShadow
|
|
204
|
+
: convertRawProp(
|
|
205
|
+
context,
|
|
206
|
+
rawProps,
|
|
207
|
+
"boxShadow",
|
|
208
|
+
sourceProps.boxShadow,
|
|
209
|
+
{})),
|
|
210
|
+
filter(
|
|
211
|
+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
212
|
+
? sourceProps.filter
|
|
213
|
+
: convertRawProp(
|
|
214
|
+
context,
|
|
215
|
+
rawProps,
|
|
216
|
+
"filter",
|
|
217
|
+
sourceProps.filter,
|
|
218
|
+
{})),
|
|
219
|
+
backgroundImage(
|
|
220
|
+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
221
|
+
? sourceProps.backgroundImage
|
|
222
|
+
: convertRawProp(
|
|
223
|
+
context,
|
|
224
|
+
rawProps,
|
|
225
|
+
"experimental_backgroundImage",
|
|
226
|
+
sourceProps.backgroundImage,
|
|
227
|
+
{})),
|
|
228
|
+
mixBlendMode(
|
|
229
|
+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
230
|
+
? sourceProps.mixBlendMode
|
|
231
|
+
: convertRawProp(
|
|
232
|
+
context,
|
|
233
|
+
rawProps,
|
|
234
|
+
"mixBlendMode",
|
|
235
|
+
sourceProps.mixBlendMode,
|
|
236
|
+
{})),
|
|
237
|
+
isolation(
|
|
238
|
+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
239
|
+
? sourceProps.isolation
|
|
240
|
+
: convertRawProp(
|
|
241
|
+
context,
|
|
242
|
+
rawProps,
|
|
243
|
+
"isolation",
|
|
244
|
+
sourceProps.isolation,
|
|
245
|
+
{})),
|
|
246
|
+
transform(
|
|
247
|
+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
248
|
+
? sourceProps.transform
|
|
249
|
+
: convertRawProp(
|
|
250
|
+
context,
|
|
251
|
+
rawProps,
|
|
252
|
+
"transform",
|
|
253
|
+
sourceProps.transform,
|
|
254
|
+
{})),
|
|
255
|
+
transformOrigin(
|
|
256
|
+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
257
|
+
? sourceProps.transformOrigin
|
|
258
|
+
: convertRawProp(
|
|
259
|
+
context,
|
|
260
|
+
rawProps,
|
|
261
|
+
"transformOrigin",
|
|
262
|
+
sourceProps.transformOrigin,
|
|
263
|
+
{})),
|
|
264
|
+
backfaceVisibility(
|
|
265
|
+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
266
|
+
? sourceProps.backfaceVisibility
|
|
267
|
+
: convertRawProp(
|
|
268
|
+
context,
|
|
269
|
+
rawProps,
|
|
270
|
+
"backfaceVisibility",
|
|
271
|
+
sourceProps.backfaceVisibility,
|
|
272
|
+
{})),
|
|
273
|
+
shouldRasterize(
|
|
274
|
+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
275
|
+
? sourceProps.shouldRasterize
|
|
276
|
+
: convertRawProp(
|
|
277
|
+
context,
|
|
278
|
+
rawProps,
|
|
279
|
+
"shouldRasterizeIOS",
|
|
280
|
+
sourceProps.shouldRasterize,
|
|
281
|
+
{})),
|
|
282
|
+
zIndex(
|
|
283
|
+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
284
|
+
? sourceProps.zIndex
|
|
285
|
+
: convertRawProp(
|
|
286
|
+
context,
|
|
287
|
+
rawProps,
|
|
288
|
+
"zIndex",
|
|
289
|
+
sourceProps.zIndex,
|
|
290
|
+
{})),
|
|
291
|
+
pointerEvents(
|
|
292
|
+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
293
|
+
? sourceProps.pointerEvents
|
|
294
|
+
: convertRawProp(
|
|
295
|
+
context,
|
|
296
|
+
rawProps,
|
|
297
|
+
"pointerEvents",
|
|
298
|
+
sourceProps.pointerEvents,
|
|
299
|
+
{})),
|
|
300
|
+
hitSlop(
|
|
301
|
+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
302
|
+
? sourceProps.hitSlop
|
|
303
|
+
: convertRawProp(
|
|
304
|
+
context,
|
|
305
|
+
rawProps,
|
|
306
|
+
"hitSlop",
|
|
307
|
+
sourceProps.hitSlop,
|
|
308
|
+
{})),
|
|
309
|
+
onLayout(
|
|
310
|
+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
311
|
+
? sourceProps.onLayout
|
|
312
|
+
: convertRawProp(
|
|
313
|
+
context,
|
|
314
|
+
rawProps,
|
|
315
|
+
"onLayout",
|
|
316
|
+
sourceProps.onLayout,
|
|
317
|
+
{})),
|
|
318
|
+
events(
|
|
319
|
+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
320
|
+
? sourceProps.events
|
|
321
|
+
: convertRawProp(context, rawProps, sourceProps.events, {})),
|
|
322
|
+
collapsable(
|
|
323
|
+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
324
|
+
? sourceProps.collapsable
|
|
325
|
+
: convertRawProp(
|
|
326
|
+
context,
|
|
327
|
+
rawProps,
|
|
328
|
+
"collapsable",
|
|
329
|
+
sourceProps.collapsable,
|
|
330
|
+
true)),
|
|
331
|
+
collapsableChildren(
|
|
332
|
+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
333
|
+
? sourceProps.collapsableChildren
|
|
334
|
+
: convertRawProp(
|
|
335
|
+
context,
|
|
336
|
+
rawProps,
|
|
337
|
+
"collapsableChildren",
|
|
338
|
+
sourceProps.collapsableChildren,
|
|
339
|
+
true)),
|
|
340
|
+
removeClippedSubviews(
|
|
341
|
+
ReactNativeFeatureFlags::enableCppPropsIteratorSetter()
|
|
342
|
+
? sourceProps.removeClippedSubviews
|
|
343
|
+
: convertRawProp(
|
|
344
|
+
context,
|
|
345
|
+
rawProps,
|
|
346
|
+
"removeClippedSubviews",
|
|
347
|
+
sourceProps.removeClippedSubviews,
|
|
348
|
+
false)) {}
|
|
349
|
+
|
|
350
|
+
#define VIEW_EVENT_CASE(eventType) \
|
|
351
|
+
case CONSTEXPR_RAW_PROPS_KEY_HASH("on" #eventType): { \
|
|
352
|
+
const auto offset = ViewEvents::Offset::eventType; \
|
|
353
|
+
ViewEvents defaultViewEvents{}; \
|
|
354
|
+
bool res = defaultViewEvents[offset]; \
|
|
355
|
+
if (value.hasValue()) { \
|
|
356
|
+
fromRawValue(context, value, res); \
|
|
357
|
+
} \
|
|
358
|
+
events[offset] = res; \
|
|
359
|
+
return; \
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
void BaseViewProps::setProp(
|
|
363
|
+
const PropsParserContext& context,
|
|
364
|
+
RawPropsPropNameHash hash,
|
|
365
|
+
const char* propName,
|
|
366
|
+
const RawValue& value) {
|
|
367
|
+
// All Props structs setProp methods must always, unconditionally,
|
|
368
|
+
// call all super::setProp methods, since multiple structs may
|
|
369
|
+
// reuse the same values.
|
|
370
|
+
YogaStylableProps::setProp(context, hash, propName, value);
|
|
371
|
+
AccessibilityProps::setProp(context, hash, propName, value);
|
|
372
|
+
|
|
373
|
+
static auto defaults = BaseViewProps{};
|
|
374
|
+
|
|
375
|
+
switch (hash) {
|
|
376
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(opacity);
|
|
377
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(backgroundColor);
|
|
378
|
+
RAW_SET_PROP_SWITCH_CASE(backgroundImage, "experimental_backgroundImage");
|
|
379
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(shadowColor);
|
|
380
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(shadowOffset);
|
|
381
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(shadowOpacity);
|
|
382
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(shadowRadius);
|
|
383
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(transform);
|
|
384
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(backfaceVisibility);
|
|
385
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(shouldRasterize);
|
|
386
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(zIndex);
|
|
387
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(pointerEvents);
|
|
388
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(isolation);
|
|
389
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(hitSlop);
|
|
390
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(onLayout);
|
|
391
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(collapsable);
|
|
392
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(collapsableChildren);
|
|
393
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(removeClippedSubviews);
|
|
394
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(cursor);
|
|
395
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(outlineColor);
|
|
396
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(outlineOffset);
|
|
397
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(outlineStyle);
|
|
398
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(outlineWidth);
|
|
399
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(filter);
|
|
400
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(boxShadow);
|
|
401
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(mixBlendMode);
|
|
402
|
+
// events field
|
|
403
|
+
VIEW_EVENT_CASE(PointerEnter);
|
|
404
|
+
VIEW_EVENT_CASE(PointerEnterCapture);
|
|
405
|
+
VIEW_EVENT_CASE(PointerMove);
|
|
406
|
+
VIEW_EVENT_CASE(PointerMoveCapture);
|
|
407
|
+
VIEW_EVENT_CASE(PointerLeave);
|
|
408
|
+
VIEW_EVENT_CASE(PointerLeaveCapture);
|
|
409
|
+
VIEW_EVENT_CASE(PointerOver);
|
|
410
|
+
VIEW_EVENT_CASE(PointerOverCapture);
|
|
411
|
+
VIEW_EVENT_CASE(PointerOut);
|
|
412
|
+
VIEW_EVENT_CASE(PointerOutCapture);
|
|
413
|
+
// [Windows
|
|
414
|
+
VIEW_EVENT_CASE(Click);
|
|
415
|
+
VIEW_EVENT_CASE(ClickCapture);
|
|
416
|
+
VIEW_EVENT_CASE(PointerDown);
|
|
417
|
+
VIEW_EVENT_CASE(PointerDownCapture);
|
|
418
|
+
VIEW_EVENT_CASE(PointerUp);
|
|
419
|
+
VIEW_EVENT_CASE(PointerUpCapture);
|
|
420
|
+
VIEW_EVENT_CASE(GotPointerCapture);
|
|
421
|
+
VIEW_EVENT_CASE(LostPointerCapture);
|
|
422
|
+
// Windows]
|
|
423
|
+
VIEW_EVENT_CASE(MoveShouldSetResponder);
|
|
424
|
+
VIEW_EVENT_CASE(MoveShouldSetResponderCapture);
|
|
425
|
+
VIEW_EVENT_CASE(StartShouldSetResponder);
|
|
426
|
+
VIEW_EVENT_CASE(StartShouldSetResponderCapture);
|
|
427
|
+
VIEW_EVENT_CASE(ResponderGrant);
|
|
428
|
+
VIEW_EVENT_CASE(ResponderReject);
|
|
429
|
+
VIEW_EVENT_CASE(ResponderStart);
|
|
430
|
+
VIEW_EVENT_CASE(ResponderEnd);
|
|
431
|
+
VIEW_EVENT_CASE(ResponderRelease);
|
|
432
|
+
VIEW_EVENT_CASE(ResponderMove);
|
|
433
|
+
VIEW_EVENT_CASE(ResponderTerminate);
|
|
434
|
+
VIEW_EVENT_CASE(ResponderTerminationRequest);
|
|
435
|
+
VIEW_EVENT_CASE(ShouldBlockNativeResponder);
|
|
436
|
+
VIEW_EVENT_CASE(TouchStart);
|
|
437
|
+
VIEW_EVENT_CASE(TouchMove);
|
|
438
|
+
VIEW_EVENT_CASE(TouchEnd);
|
|
439
|
+
VIEW_EVENT_CASE(TouchCancel);
|
|
440
|
+
// BorderRadii
|
|
441
|
+
SET_CASCADED_RECTANGLE_CORNERS(borderRadii, "border", "Radius", value);
|
|
442
|
+
SET_CASCADED_RECTANGLE_EDGES(borderColors, "border", "Color", value);
|
|
443
|
+
SET_CASCADED_RECTANGLE_EDGES(borderStyles, "border", "Style", value);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
#pragma mark - Convenience Methods
|
|
448
|
+
|
|
449
|
+
static BorderRadii ensureNoOverlap(const BorderRadii& radii, const Size& size) {
|
|
450
|
+
// "Corner curves must not overlap: When the sum of any two adjacent border
|
|
451
|
+
// radii exceeds the size of the border box, UAs must proportionally reduce
|
|
452
|
+
// the used values of all border radii until none of them overlap."
|
|
453
|
+
// Source: https://www.w3.org/TR/css-backgrounds-3/#corner-overlap
|
|
454
|
+
|
|
455
|
+
float leftEdgeRadii = radii.topLeft.vertical + radii.bottomLeft.vertical;
|
|
456
|
+
float topEdgeRadii = radii.topLeft.horizontal + radii.topRight.horizontal;
|
|
457
|
+
float rightEdgeRadii = radii.topRight.vertical + radii.bottomRight.vertical;
|
|
458
|
+
float bottomEdgeRadii =
|
|
459
|
+
radii.bottomLeft.horizontal + radii.bottomRight.horizontal;
|
|
460
|
+
|
|
461
|
+
float leftEdgeRadiiScale =
|
|
462
|
+
(leftEdgeRadii > 0) ? std::min(size.height / leftEdgeRadii, (Float)1) : 0;
|
|
463
|
+
float topEdgeRadiiScale =
|
|
464
|
+
(topEdgeRadii > 0) ? std::min(size.width / topEdgeRadii, (Float)1) : 0;
|
|
465
|
+
float rightEdgeRadiiScale = (rightEdgeRadii > 0)
|
|
466
|
+
? std::min(size.height / rightEdgeRadii, (Float)1)
|
|
467
|
+
: 0;
|
|
468
|
+
float bottomEdgeRadiiScale = (bottomEdgeRadii > 0)
|
|
469
|
+
? std::min(size.width / bottomEdgeRadii, (Float)1)
|
|
470
|
+
: 0;
|
|
471
|
+
|
|
472
|
+
return BorderRadii{
|
|
473
|
+
.topLeft =
|
|
474
|
+
{static_cast<float>(
|
|
475
|
+
radii.topLeft.vertical *
|
|
476
|
+
std::min(topEdgeRadiiScale, leftEdgeRadiiScale)),
|
|
477
|
+
static_cast<float>(
|
|
478
|
+
radii.topLeft.horizontal *
|
|
479
|
+
std::min(topEdgeRadiiScale, leftEdgeRadiiScale))},
|
|
480
|
+
.topRight =
|
|
481
|
+
{static_cast<float>(
|
|
482
|
+
radii.topRight.vertical *
|
|
483
|
+
std::min(topEdgeRadiiScale, rightEdgeRadiiScale)),
|
|
484
|
+
static_cast<float>(
|
|
485
|
+
radii.topRight.horizontal *
|
|
486
|
+
std::min(topEdgeRadiiScale, rightEdgeRadiiScale))},
|
|
487
|
+
.bottomLeft =
|
|
488
|
+
{static_cast<float>(
|
|
489
|
+
radii.bottomLeft.vertical *
|
|
490
|
+
std::min(bottomEdgeRadiiScale, leftEdgeRadiiScale)),
|
|
491
|
+
static_cast<float>(
|
|
492
|
+
radii.bottomLeft.horizontal *
|
|
493
|
+
std::min(bottomEdgeRadiiScale, leftEdgeRadiiScale))},
|
|
494
|
+
.bottomRight =
|
|
495
|
+
{static_cast<float>(
|
|
496
|
+
radii.bottomRight.vertical *
|
|
497
|
+
std::min(bottomEdgeRadiiScale, rightEdgeRadiiScale)),
|
|
498
|
+
static_cast<float>(
|
|
499
|
+
radii.bottomRight.horizontal *
|
|
500
|
+
std::min(bottomEdgeRadiiScale, rightEdgeRadiiScale))},
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
static BorderRadii radiiPercentToPoint(
|
|
505
|
+
const RectangleCorners<ValueUnit>& radii,
|
|
506
|
+
const Size& size) {
|
|
507
|
+
return BorderRadii{
|
|
508
|
+
.topLeft =
|
|
509
|
+
{radii.topLeft.resolve(size.height),
|
|
510
|
+
radii.topLeft.resolve(size.width)},
|
|
511
|
+
.topRight =
|
|
512
|
+
{radii.topRight.resolve(size.height),
|
|
513
|
+
radii.topRight.resolve(size.width)},
|
|
514
|
+
.bottomLeft =
|
|
515
|
+
{radii.bottomLeft.resolve(size.height),
|
|
516
|
+
radii.bottomLeft.resolve(size.width)},
|
|
517
|
+
.bottomRight =
|
|
518
|
+
{radii.bottomRight.resolve(size.height),
|
|
519
|
+
radii.bottomRight.resolve(size.width)},
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
CascadedBorderWidths BaseViewProps::getBorderWidths() const {
|
|
524
|
+
return CascadedBorderWidths{
|
|
525
|
+
.left = optionalFloatFromYogaValue(yogaStyle.border(yoga::Edge::Left)),
|
|
526
|
+
.top = optionalFloatFromYogaValue(yogaStyle.border(yoga::Edge::Top)),
|
|
527
|
+
.right = optionalFloatFromYogaValue(yogaStyle.border(yoga::Edge::Right)),
|
|
528
|
+
.bottom =
|
|
529
|
+
optionalFloatFromYogaValue(yogaStyle.border(yoga::Edge::Bottom)),
|
|
530
|
+
.start = optionalFloatFromYogaValue(yogaStyle.border(yoga::Edge::Start)),
|
|
531
|
+
.end = optionalFloatFromYogaValue(yogaStyle.border(yoga::Edge::End)),
|
|
532
|
+
.horizontal =
|
|
533
|
+
optionalFloatFromYogaValue(yogaStyle.border(yoga::Edge::Horizontal)),
|
|
534
|
+
.vertical =
|
|
535
|
+
optionalFloatFromYogaValue(yogaStyle.border(yoga::Edge::Vertical)),
|
|
536
|
+
.all = optionalFloatFromYogaValue(yogaStyle.border(yoga::Edge::All)),
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
BorderMetrics BaseViewProps::resolveBorderMetrics(
|
|
541
|
+
const LayoutMetrics& layoutMetrics) const {
|
|
542
|
+
auto isRTL =
|
|
543
|
+
bool{layoutMetrics.layoutDirection == LayoutDirection::RightToLeft};
|
|
544
|
+
|
|
545
|
+
auto borderWidths = getBorderWidths();
|
|
546
|
+
|
|
547
|
+
BorderRadii radii = radiiPercentToPoint(
|
|
548
|
+
borderRadii.resolve(isRTL, ValueUnit{0.0f, UnitType::Point}),
|
|
549
|
+
layoutMetrics.frame.size);
|
|
550
|
+
|
|
551
|
+
return {
|
|
552
|
+
.borderColors = borderColors.resolve(isRTL, {}),
|
|
553
|
+
.borderWidths = borderWidths.resolve(isRTL, 0),
|
|
554
|
+
.borderRadii = ensureNoOverlap(radii, layoutMetrics.frame.size),
|
|
555
|
+
.borderCurves = borderCurves.resolve(isRTL, BorderCurve::Circular),
|
|
556
|
+
.borderStyles = borderStyles.resolve(isRTL, BorderStyle::Solid),
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
Transform BaseViewProps::resolveTransform(
|
|
561
|
+
const LayoutMetrics& layoutMetrics) const {
|
|
562
|
+
const auto& frameSize = layoutMetrics.frame.size;
|
|
563
|
+
return resolveTransform(frameSize, transform, transformOrigin);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
Transform BaseViewProps::resolveTransform(
|
|
567
|
+
const Size& frameSize,
|
|
568
|
+
const Transform& transform,
|
|
569
|
+
const TransformOrigin& transformOrigin) {
|
|
570
|
+
auto transformMatrix = Transform{};
|
|
571
|
+
|
|
572
|
+
// transform is matrix
|
|
573
|
+
if (transform.operations.size() == 1 &&
|
|
574
|
+
transform.operations[0].type == TransformOperationType::Arbitrary) {
|
|
575
|
+
transformMatrix = transform;
|
|
576
|
+
} else {
|
|
577
|
+
for (const auto& operation : transform.operations) {
|
|
578
|
+
transformMatrix = transformMatrix *
|
|
579
|
+
Transform::FromTransformOperation(operation, frameSize, transform);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
if (transformOrigin.isSet()) {
|
|
584
|
+
std::array<float, 3> translateOffsets = getTranslateForTransformOrigin(
|
|
585
|
+
frameSize.width, frameSize.height, transformOrigin);
|
|
586
|
+
transformMatrix =
|
|
587
|
+
Transform::Translate(
|
|
588
|
+
translateOffsets[0], translateOffsets[1], translateOffsets[2]) *
|
|
589
|
+
transformMatrix *
|
|
590
|
+
Transform::Translate(
|
|
591
|
+
-translateOffsets[0], -translateOffsets[1], -translateOffsets[2]);
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
return transformMatrix;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
bool BaseViewProps::getClipsContentToBounds() const {
|
|
598
|
+
return yogaStyle.overflow() != yoga::Overflow::Visible;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
#pragma mark - DebugStringConvertible
|
|
602
|
+
|
|
603
|
+
#if RN_DEBUG_STRING_CONVERTIBLE
|
|
604
|
+
SharedDebugStringConvertibleList BaseViewProps::getDebugProps() const {
|
|
605
|
+
const auto& defaultBaseViewProps = BaseViewProps();
|
|
606
|
+
|
|
607
|
+
return AccessibilityProps::getDebugProps() +
|
|
608
|
+
YogaStylableProps::getDebugProps() +
|
|
609
|
+
SharedDebugStringConvertibleList{
|
|
610
|
+
debugStringConvertibleItem(
|
|
611
|
+
"opacity", opacity, defaultBaseViewProps.opacity),
|
|
612
|
+
debugStringConvertibleItem(
|
|
613
|
+
"backgroundColor",
|
|
614
|
+
backgroundColor,
|
|
615
|
+
defaultBaseViewProps.backgroundColor),
|
|
616
|
+
debugStringConvertibleItem(
|
|
617
|
+
"zIndex", zIndex, defaultBaseViewProps.zIndex.value_or(0)),
|
|
618
|
+
debugStringConvertibleItem(
|
|
619
|
+
"pointerEvents",
|
|
620
|
+
pointerEvents,
|
|
621
|
+
defaultBaseViewProps.pointerEvents),
|
|
622
|
+
debugStringConvertibleItem(
|
|
623
|
+
"transform", transform, defaultBaseViewProps.transform),
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
#endif
|
|
627
|
+
|
|
628
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
#if _MSC_VER
|
|
9
|
+
#pragma warning(push)
|
|
10
|
+
#pragma warning(disable : 4996) // deprecated APIs
|
|
11
|
+
#endif
|
|
12
|
+
#include "EventDispatcher.h"
|
|
13
|
+
#include <cxxreact/JSExecutor.h>
|
|
14
|
+
#include <react/renderer/core/StateUpdate.h>
|
|
15
|
+
|
|
16
|
+
#include "EventQueue.h"
|
|
17
|
+
#include "RawEvent.h"
|
|
18
|
+
|
|
19
|
+
namespace facebook::react {
|
|
20
|
+
|
|
21
|
+
EventDispatcher::EventDispatcher(
|
|
22
|
+
const EventQueueProcessor& eventProcessor,
|
|
23
|
+
std::unique_ptr<EventBeat> eventBeat,
|
|
24
|
+
StatePipe statePipe,
|
|
25
|
+
std::weak_ptr<EventLogger> eventLogger)
|
|
26
|
+
: eventQueue_(EventQueue(eventProcessor, std::move(eventBeat))),
|
|
27
|
+
statePipe_(std::move(statePipe)),
|
|
28
|
+
eventLogger_(std::move(eventLogger)) {}
|
|
29
|
+
|
|
30
|
+
void EventDispatcher::dispatchEvent(RawEvent&& rawEvent) const {
|
|
31
|
+
// Allows the event listener to interrupt default event dispatch
|
|
32
|
+
if (eventListeners_.willDispatchEvent(rawEvent)) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
auto eventLogger = eventLogger_.lock();
|
|
37
|
+
if (eventLogger != nullptr) {
|
|
38
|
+
rawEvent.loggingTag = eventLogger->onEventStart(
|
|
39
|
+
rawEvent.type, rawEvent.eventTarget, rawEvent.eventStartTimeStamp);
|
|
40
|
+
}
|
|
41
|
+
eventQueue_.enqueueEvent(std::move(rawEvent));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
void EventDispatcher::experimental_flushSync() const {
|
|
45
|
+
eventQueue_.experimental_flushSync();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
void EventDispatcher::dispatchStateUpdate(
|
|
49
|
+
StateUpdate&& stateUpdate,
|
|
50
|
+
EventQueue::UpdateMode updateMode) const {
|
|
51
|
+
eventQueue_.enqueueStateUpdate(std::move(stateUpdate), updateMode);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
void EventDispatcher::dispatchUniqueEvent(RawEvent&& rawEvent) const {
|
|
55
|
+
// Allows the event listener to interrupt default event dispatch
|
|
56
|
+
if (eventListeners_.willDispatchEvent(rawEvent)) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
eventQueue_.enqueueUniqueEvent(std::move(rawEvent));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
void EventDispatcher::addListener(
|
|
64
|
+
std::shared_ptr<const EventListener> listener) const {
|
|
65
|
+
eventListeners_.addListener(std::move(listener));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/*
|
|
69
|
+
* Removes provided event listener to the event dispatcher.
|
|
70
|
+
*/
|
|
71
|
+
void EventDispatcher::removeListener(
|
|
72
|
+
const std::shared_ptr<const EventListener>& listener) const {
|
|
73
|
+
eventListeners_.removeListener(listener);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
} // namespace facebook::react
|
|
77
|
+
#if _MSC_VER
|
|
78
|
+
#pragma warning(pop)
|
|
79
|
+
#endif
|