react-native-windows 0.69.4 → 0.70.0-preview.1
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/.flowconfig +5 -1
- package/Chakra/ChakraHelpers.cpp +1 -1
- package/Chakra/ChakraPlatform.cpp +1 -1
- package/Chakra/ChakraValue.cpp +6 -3
- package/Chakra/ChakraValue.h +1 -1
- package/Directory.Build.props +7 -7
- package/Folly/Folly.vcxproj +20 -13
- package/Folly/cgmanifest.json +14 -0
- package/Libraries/Alert/Alert.js +18 -4
- package/Libraries/Alert/Alert.windows.js +4 -0
- package/Libraries/Alert/NativeAlertManager.js +1 -0
- package/Libraries/Animated/Animated.js +2 -2
- package/Libraries/Animated/AnimatedEvent.js +7 -4
- package/Libraries/Animated/AnimatedImplementation.js +17 -3
- package/Libraries/Animated/AnimatedMock.js +7 -2
- package/Libraries/Animated/NativeAnimatedHelper.js +220 -95
- package/Libraries/Animated/NativeAnimatedModule.js +3 -0
- package/Libraries/Animated/NativeAnimatedTurboModule.js +3 -0
- package/Libraries/Animated/animations/SpringAnimation.js +3 -3
- package/Libraries/Animated/animations/TimingAnimation.js +3 -3
- package/Libraries/Animated/createAnimatedComponent.js +8 -1
- package/Libraries/Animated/nodes/AnimatedAddition.js +3 -1
- package/Libraries/Animated/nodes/AnimatedColor.js +50 -29
- package/Libraries/Animated/nodes/AnimatedDiffClamp.js +3 -1
- package/Libraries/Animated/nodes/AnimatedDivision.js +3 -1
- package/Libraries/Animated/nodes/AnimatedInterpolation.js +22 -21
- package/Libraries/Animated/nodes/AnimatedModulo.js +3 -1
- package/Libraries/Animated/nodes/AnimatedMultiplication.js +3 -2
- package/Libraries/Animated/nodes/AnimatedProps.js +20 -12
- package/Libraries/Animated/nodes/AnimatedStyle.js +19 -16
- package/Libraries/Animated/nodes/AnimatedSubtraction.js +3 -1
- package/Libraries/Animated/nodes/AnimatedTransform.js +5 -5
- package/Libraries/Animated/nodes/AnimatedValue.js +14 -5
- package/Libraries/Animated/nodes/AnimatedValueXY.js +28 -1
- package/Libraries/Animated/useAnimatedProps.js +1 -0
- package/Libraries/AppState/AppState.js +0 -32
- package/Libraries/AppTheme/AppTheme.js +14 -8
- package/Libraries/AppTheme/AppThemeTypes.d.ts +0 -3
- package/Libraries/BatchedBridge/MessageQueue.js +21 -15
- package/Libraries/BatchedBridge/NativeModules.js +3 -4
- package/Libraries/Blob/FileReader.js +0 -6
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +0 -20
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.windows.js +0 -20
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +4 -0
- package/Libraries/Components/Keyboard/Keyboard.js +0 -11
- package/Libraries/Components/Pressable/Pressable.js +2 -0
- package/Libraries/Components/Pressable/Pressable.windows.js +2 -0
- package/Libraries/Components/SafeAreaView/RCTSafeAreaViewNativeComponent.js +1 -3
- package/Libraries/Components/SafeAreaView/SafeAreaView.js +3 -30
- package/Libraries/Components/SafeAreaView/SafeAreaView.windows.js +4 -30
- package/Libraries/Components/ScrollView/ScrollView.js +13 -11
- package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +5 -3
- package/Libraries/Components/StatusBar/StatusBar.js +10 -7
- package/Libraries/Components/TextInput/InputAccessoryView.js +14 -13
- package/Libraries/Components/TextInput/TextInput.js +12 -2
- package/Libraries/Components/TextInput/TextInput.windows.js +12 -2
- package/Libraries/Components/Touchable/PooledClass.js +16 -4
- package/Libraries/Components/Touchable/Touchable.js +50 -1
- package/Libraries/Components/Touchable/Touchable.windows.js +972 -0
- package/Libraries/Components/Touchable/TouchableNativeFeedback.js +6 -2
- package/Libraries/Components/View/ReactNativeStyleAttributes.js +0 -7
- package/Libraries/Components/View/ViewPropTypes.js +3 -8
- package/Libraries/Components/View/ViewPropTypes.windows.js +3 -8
- package/Libraries/Core/ExceptionsManager.js +2 -0
- package/Libraries/Core/ReactNativeVersion.js +2 -2
- package/Libraries/Core/Timers/JSTimers.js +2 -2
- package/Libraries/Core/polyfillPromise.js +0 -32
- package/Libraries/Core/setUpBatchedBridge.js +5 -1
- package/Libraries/Core/setUpPerformance.js +1 -1
- package/Libraries/EventEmitter/NativeEventEmitter.js +0 -13
- package/Libraries/Image/AssetSourceResolver.js +2 -2
- package/Libraries/Image/Image.android.js +5 -3
- package/Libraries/Image/Image.ios.js +6 -3
- package/Libraries/Image/Image.windows.js +6 -3
- package/Libraries/Image/ImageSource.js +7 -5
- package/Libraries/Inspector/ElementBox.js +2 -2
- package/Libraries/Inspector/NetworkOverlay.js +13 -8
- package/Libraries/Interaction/PanResponder.js +16 -14
- package/Libraries/Linking/Linking.js +0 -11
- package/Libraries/Lists/FlatList.js +3 -2
- package/Libraries/Lists/SectionList.js +2 -0
- package/Libraries/Lists/ViewabilityHelper.js +7 -3
- package/Libraries/Lists/VirtualizeUtils.js +33 -20
- package/Libraries/Lists/VirtualizedList.js +93 -47
- package/Libraries/Lists/VirtualizedListContext.js +1 -0
- package/Libraries/Lists/VirtualizedSectionList.js +14 -9
- package/Libraries/Lists/__tests__/VirtualizeUtils-test.js +19 -18
- package/Libraries/Lists/__tests__/VirtualizedList-test.js +10 -6
- package/Libraries/LogBox/Data/LogBoxData.js +1 -1
- package/Libraries/LogBox/Data/parseLogBoxLog.js +1 -1
- package/Libraries/LogBox/LogBox.js +3 -1
- package/Libraries/LogBox/UI/AnsiHighlight.js +2 -0
- package/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.js +3 -0
- package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.js +0 -3
- package/Libraries/LogBox/UI/LogBoxInspectorStackFrames.js +8 -3
- package/Libraries/NativeComponent/BaseViewConfig.android.js +9 -18
- package/Libraries/NativeComponent/BaseViewConfig.ios.js +26 -12
- package/Libraries/NativeComponent/BaseViewConfig.windows.js +26 -12
- package/Libraries/Network/XMLHttpRequest.js +9 -11
- package/Libraries/Performance/PureComponentDebug.js +1 -0
- package/Libraries/PermissionsAndroid/NativePermissionsAndroid.js +9 -1
- package/Libraries/PermissionsAndroid/PermissionsAndroid.js +16 -0
- package/Libraries/Pressability/Pressability.js +26 -16
- package/Libraries/Pressability/Pressability.windows.js +30 -17
- package/Libraries/Promise.js +0 -1
- package/Libraries/ReactNative/AppRegistry.js +16 -13
- package/Libraries/ReactNative/BridgelessUIManager.js +2 -0
- package/Libraries/ReactNative/PaperUIManager.js +9 -9
- package/Libraries/ReactNative/PaperUIManager.windows.js +7 -8
- package/Libraries/ReactNative/ReactNativeFeatureFlags.js +12 -0
- package/Libraries/ReactNative/ReactNativeRuntimeDiagnostics.js +68 -0
- package/Libraries/ReactNative/getNativeComponentAttributes.js +6 -7
- package/Libraries/ReactNative/renderApplication.js +1 -1
- package/Libraries/Renderer/implementations/ReactFabric-dev.js +4443 -3615
- package/Libraries/Renderer/implementations/ReactFabric-prod.js +1496 -1170
- package/Libraries/Renderer/implementations/ReactFabric-profiling.js +1694 -1356
- package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +4439 -3588
- package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +1583 -1249
- package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +1719 -1372
- package/Libraries/Storage/AsyncStorage.js +7 -1
- package/Libraries/StyleSheet/PlatformColorValueTypes.ios.js +8 -0
- package/Libraries/StyleSheet/flattenStyle.js +1 -1
- package/Libraries/StyleSheet/processTransform.js +2 -0
- package/Libraries/StyleSheet/processTransform.windows.js +2 -0
- package/Libraries/StyleSheet/splitLayoutProps.js +2 -0
- package/Libraries/Text/Text.js +15 -7
- package/Libraries/Text/Text.windows.js +14 -7
- package/Libraries/Types/CoreEventTypes.js +137 -11
- package/Libraries/Types/CoreEventTypes.windows.js +147 -22
- package/Libraries/Utilities/Dimensions.js +0 -13
- package/Libraries/Utilities/HMRClient.js +3 -3
- package/Libraries/Utilities/Platform.ios.js +0 -7
- package/Libraries/Utilities/ReactNativeTestTools.js +3 -1
- package/Libraries/Utilities/codegenNativeCommands.js +11 -2
- package/Libraries/Utilities/deepFreezeAndThrowOnMutationInDev.js +2 -0
- package/Libraries/Utilities/stringifySafe.js +3 -1
- package/Libraries/Utilities/truncate.js +1 -1
- package/Libraries/Utilities/verifyComponentAttributeEquivalence.js +2 -2
- package/Libraries/Vibration/Vibration.js +1 -1
- package/Libraries/WebSocket/WebSocket.js +1 -0
- package/Libraries/vendor/emitter/EventEmitter.js +105 -12
- package/Libraries/vendor/emitter/__flowtests__/EventEmitter-flowtest.js +73 -117
- package/Microsoft.ReactNative/Base/CoreNativeModules.cpp +24 -12
- package/Microsoft.ReactNative/CoreApp.cpp +303 -0
- package/Microsoft.ReactNative/CoreAppPage.cpp +21 -0
- package/Microsoft.ReactNative/CoreAppPage.h +15 -0
- package/Microsoft.ReactNative/CoreAppPage.idl +12 -0
- package/Microsoft.ReactNative/CoreAppPage.xaml +14 -0
- package/Microsoft.ReactNative/Fabric/ActivityIndicatorComponentView.cpp +1 -2
- package/Microsoft.ReactNative/Fabric/ActivityIndicatorComponentView.h +1 -1
- package/Microsoft.ReactNative/Fabric/ComponentView.h +1 -1
- package/Microsoft.ReactNative/Fabric/ImageComponentView.cpp +1 -1
- package/Microsoft.ReactNative/Fabric/ImageComponentView.h +1 -1
- package/Microsoft.ReactNative/Fabric/ParagraphComponentView.cpp +1 -1
- package/Microsoft.ReactNative/Fabric/ParagraphComponentView.h +1 -1
- package/Microsoft.ReactNative/Fabric/ScrollViewComponentView.cpp +1 -1
- package/Microsoft.ReactNative/Fabric/ScrollViewComponentView.h +1 -1
- package/Microsoft.ReactNative/Fabric/SliderComponentView.cpp +1 -1
- package/Microsoft.ReactNative/Fabric/SliderComponentView.h +1 -1
- package/Microsoft.ReactNative/Fabric/SwitchComponentView.cpp +1 -1
- package/Microsoft.ReactNative/Fabric/SwitchComponentView.h +1 -1
- package/Microsoft.ReactNative/Fabric/TextComponentView.cpp +1 -1
- package/Microsoft.ReactNative/Fabric/TextComponentView.h +1 -1
- package/Microsoft.ReactNative/Fabric/TextInput/WindowsTextInputComponentView.cpp +1 -1
- package/Microsoft.ReactNative/Fabric/TextInput/WindowsTextInputComponentView.h +1 -1
- package/Microsoft.ReactNative/Fabric/ViewComponentView.cpp +1 -1
- package/Microsoft.ReactNative/Fabric/ViewComponentView.h +1 -1
- package/Microsoft.ReactNative/GlyphViewManager.cpp +1 -0
- package/Microsoft.ReactNative/IReactDispatcher.cpp +18 -0
- package/Microsoft.ReactNative/IReactDispatcher.h +18 -3
- package/Microsoft.ReactNative/IReactDispatcher.idl +15 -0
- package/Microsoft.ReactNative/IReactNotificationService.cpp +197 -70
- package/Microsoft.ReactNative/IReactNotificationService.h +11 -30
- package/Microsoft.ReactNative/IReactPropertyBag.cpp +9 -0
- package/Microsoft.ReactNative/IReactPropertyBag.h +3 -0
- package/Microsoft.ReactNative/IReactPropertyBag.idl +3 -0
- package/Microsoft.ReactNative/JsiApi.cpp +41 -1
- package/Microsoft.ReactNative/JsiApi.h +3 -0
- package/Microsoft.ReactNative/JsiApi.idl +19 -1
- package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +18 -2
- package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj.filters +7 -7
- package/Microsoft.ReactNative/Modules/AccessibilityInfoModule.h +1 -1
- package/Microsoft.ReactNative/Modules/AlertModule.cpp +15 -12
- package/Microsoft.ReactNative/Modules/AlertModule.h +1 -1
- package/Microsoft.ReactNative/Modules/AppStateModule.cpp +45 -9
- package/Microsoft.ReactNative/Modules/AppStateModule.h +9 -3
- package/Microsoft.ReactNative/Modules/AppThemeModuleUwp.h +1 -1
- package/Microsoft.ReactNative/Modules/ClipboardModule.h +1 -1
- package/Microsoft.ReactNative/Modules/DevSettingsModule.h +1 -1
- package/Microsoft.ReactNative/Modules/DeviceInfoModule.h +1 -1
- package/Microsoft.ReactNative/Modules/I18nManagerModule.h +1 -1
- package/Microsoft.ReactNative/Modules/ImageViewManagerModule.cpp +1 -1
- package/Microsoft.ReactNative/Modules/ImageViewManagerModule.h +1 -1
- package/Microsoft.ReactNative/Modules/LinkingManagerModule.h +1 -1
- package/Microsoft.ReactNative/Modules/LogBoxModule.h +1 -1
- package/Microsoft.ReactNative/Modules/NativeUIManager.cpp +66 -39
- package/Microsoft.ReactNative/Modules/PaperUIManagerModule.cpp +41 -11
- package/Microsoft.ReactNative/Modules/PaperUIManagerModule.h +1 -1
- package/Microsoft.ReactNative/QuirkSettings.cpp +22 -0
- package/Microsoft.ReactNative/QuirkSettings.h +10 -0
- package/Microsoft.ReactNative/QuirkSettings.idl +7 -0
- package/Microsoft.ReactNative/ReactApplication.cpp +44 -0
- package/Microsoft.ReactNative/ReactApplication.h +40 -5
- package/Microsoft.ReactNative/ReactHost/JSCallInvokerScheduler.cpp +5 -2
- package/Microsoft.ReactNative/ReactHost/JSCallInvokerScheduler.h +1 -0
- package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +23 -4
- package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.h +1 -1
- package/Microsoft.ReactNative/ReactPointerEventArgs.cpp +12 -2
- package/Microsoft.ReactNative/Utils/BatchingEventEmitter.cpp +1 -0
- package/Microsoft.ReactNative/Utils/Helpers.cpp +1 -1
- package/Microsoft.ReactNative/Utils/Helpers.h +1 -1
- package/Microsoft.ReactNative/Utils/PropertyUtils.h +1 -1
- package/Microsoft.ReactNative/Utils/TransformableText.h +1 -1
- package/Microsoft.ReactNative/Utils/ValueUtils.cpp +12 -8
- package/Microsoft.ReactNative/Views/DynamicAutomationPeer.cpp +9 -7
- package/Microsoft.ReactNative/Views/DynamicAutomationProperties.cpp +3 -3
- package/Microsoft.ReactNative/Views/FlyoutViewManager.cpp +13 -1
- package/Microsoft.ReactNative/Views/FrameworkElementTransferProperties.cpp +1 -1
- package/Microsoft.ReactNative/Views/FrameworkElementViewManager.cpp +63 -13
- package/Microsoft.ReactNative/Views/Image/ImageViewManager.cpp +2 -2
- package/Microsoft.ReactNative/Views/Image/ReactImage.cpp +5 -6
- package/Microsoft.ReactNative/Views/Image/ReactImage.h +4 -4
- package/Microsoft.ReactNative/Views/Text/TextTransformParentVisitor.h +1 -1
- package/Microsoft.ReactNative/Views/TextInputViewManager.cpp +21 -2
- package/Microsoft.ReactNative/Views/TextViewManager.cpp +6 -3
- package/Microsoft.ReactNative/Views/TouchEventHandler.cpp +1 -1
- package/Microsoft.ReactNative/Views/ViewManagerBase.cpp +7 -1
- package/Microsoft.ReactNative/Views/ViewPanel.cpp +4 -0
- package/Microsoft.ReactNative/Views/ViewViewManager.cpp +8 -3
- package/Microsoft.ReactNative/Views/cppwinrt/DynamicAutomationPeer.idl +2 -0
- package/Microsoft.ReactNative/microsoft.reactnative.def +4 -1
- package/Microsoft.ReactNative.Cxx/AppModelHelpers.h +17 -0
- package/Microsoft.ReactNative.Cxx/CoreApp.h +60 -0
- package/Microsoft.ReactNative.Cxx/JSI/JsiAbiApi.cpp +65 -0
- package/Microsoft.ReactNative.Cxx/JSI/JsiAbiApi.h +13 -0
- package/Microsoft.ReactNative.Cxx/JSI/JsiValueHelpers.cpp +53 -0
- package/Microsoft.ReactNative.Cxx/JSI/JsiValueHelpers.h +32 -0
- package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiRuntime.cpp +14 -2
- package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems +3 -0
- package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems.filters +7 -0
- package/Microsoft.ReactNative.Managed/packages.lock.json +1 -24
- package/Mso/dispatchQueue/dispatchQueue.h +12 -4
- package/Mso/src/dispatchQueue/looperScheduler.cpp +36 -9
- package/Mso/src/dispatchQueue/queueService.cpp +2 -2
- package/Mso/src/dispatchQueue/queueService.h +2 -2
- package/Mso/src/memoryApi/memoryApi.cpp +3 -0
- package/PropertySheets/Generated/PackageVersion.g.props +3 -3
- package/PropertySheets/JSEngine.props +1 -1
- package/PropertySheets/Release.props +6 -0
- package/ReactCommon/ReactCommon.vcxproj +11 -21
- package/ReactCommon/ReactCommon.vcxproj.filters +64 -46
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSExecutor.h +145 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/NativeToJsBridge.cpp +344 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/text/BaseTextProps.cpp +313 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/ViewProps.cpp +455 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/ConcreteComponentDescriptor.h +216 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/PropsMacros.h +91 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/graphics/RectangleEdges.h +100 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/CompactValue.h +3 -1
- package/Scripts/Microsoft.ReactNative.nuspec +6 -0
- package/Scripts/Microsoft.ReactNative.targets +7 -0
- package/Shared/DevSettings.h +4 -0
- package/Shared/JSI/ChakraRuntime.cpp +11 -2
- package/Shared/JSI/ChakraRuntime.h +2 -0
- package/Shared/Modules/BlobModule.cpp +4 -4
- package/Shared/Modules/BlobModule.h +1 -1
- package/Shared/Modules/FileReaderModule.cpp +3 -2
- package/Shared/Modules/IBlobPersistor.h +1 -1
- package/Shared/Networking/IHttpResource.h +1 -0
- package/Shared/Networking/OriginPolicyHttpFilter.cpp +16 -10
- package/Shared/Networking/WinRTHttpResource.cpp +34 -2
- package/Shared/OInstance.cpp +14 -6
- package/Shared/Threading/BatchingQueueThread.cpp +23 -12
- package/Shared/Utils.cpp +2 -5
- package/codegen/NativeAlertManagerSpec.g.h +2 -0
- package/codegen/NativeAnimatedModuleSpec.g.h +6 -0
- package/codegen/NativeAnimatedTurboModuleSpec.g.h +6 -0
- package/codegen/react/components/rnwcore/Props.cpp +2 -2
- package/codegen/react/components/rnwcore/Props.h +1 -1
- package/fmt/cgmanifest.json +14 -0
- package/fmt/fmt.vcxproj +25 -11
- package/jest/assetFileTransformer.js +3 -2
- package/jest/setup.js +4 -0
- package/package.json +27 -28
- package/rntypes/index.d.ts +0 -1
- package/template/cs-app-WinAppSDK/proj/{NuGet.Config → NuGet_Config} +0 -0
- package/template/metro.devMode.config.js +49 -2
- package/template/shared-app/proj/{NuGet.Config → NuGet_Config} +0 -0
- package/template/shared-lib/proj/{NuGet.Config → NuGet_Config} +0 -0
- package/Libraries/vendor/emitter/EventSubscription.js +0 -19
- package/Libraries/vendor/emitter/_EmitterSubscription.js +0 -62
- package/Libraries/vendor/emitter/_EventEmitter.js +0 -184
- package/Libraries/vendor/emitter/_EventSubscription.js +0 -45
- package/Libraries/vendor/emitter/_EventSubscriptionVendor.js +0 -108
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModule.h +0 -87
- package/Scripts/copyRNLibraries.js +0 -99
- package/jest/preprocessor.js +0 -40
- package/jest/preprocessor_DO_NOT_USE.js +0 -122
|
@@ -0,0 +1,455 @@
|
|
|
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 "ViewProps.h"
|
|
9
|
+
|
|
10
|
+
#include <algorithm>
|
|
11
|
+
|
|
12
|
+
#include <react/renderer/components/view/conversions.h>
|
|
13
|
+
#include <react/renderer/components/view/propsConversions.h>
|
|
14
|
+
#include <react/renderer/core/propsConversions.h>
|
|
15
|
+
#include <react/renderer/debug/debugStringConvertibleUtils.h>
|
|
16
|
+
#include <react/renderer/graphics/conversions.h>
|
|
17
|
+
|
|
18
|
+
namespace facebook {
|
|
19
|
+
namespace react {
|
|
20
|
+
|
|
21
|
+
ViewProps::ViewProps(
|
|
22
|
+
const PropsParserContext &context,
|
|
23
|
+
ViewProps const &sourceProps,
|
|
24
|
+
RawProps const &rawProps,
|
|
25
|
+
bool shouldSetRawProps)
|
|
26
|
+
: YogaStylableProps(context, sourceProps, rawProps, shouldSetRawProps),
|
|
27
|
+
AccessibilityProps(context, sourceProps, rawProps),
|
|
28
|
+
opacity(
|
|
29
|
+
Props::enablePropIteratorSetter ? sourceProps.opacity
|
|
30
|
+
: convertRawProp(
|
|
31
|
+
context,
|
|
32
|
+
rawProps,
|
|
33
|
+
"opacity",
|
|
34
|
+
sourceProps.opacity,
|
|
35
|
+
(Float)1.0)),
|
|
36
|
+
foregroundColor(
|
|
37
|
+
Props::enablePropIteratorSetter ? sourceProps.foregroundColor
|
|
38
|
+
: convertRawProp(
|
|
39
|
+
context,
|
|
40
|
+
rawProps,
|
|
41
|
+
"foregroundColor",
|
|
42
|
+
sourceProps.foregroundColor,
|
|
43
|
+
{})),
|
|
44
|
+
backgroundColor(
|
|
45
|
+
Props::enablePropIteratorSetter ? sourceProps.backgroundColor
|
|
46
|
+
: convertRawProp(
|
|
47
|
+
context,
|
|
48
|
+
rawProps,
|
|
49
|
+
"backgroundColor",
|
|
50
|
+
sourceProps.backgroundColor,
|
|
51
|
+
{})),
|
|
52
|
+
borderRadii(
|
|
53
|
+
Props::enablePropIteratorSetter ? sourceProps.borderRadii
|
|
54
|
+
: convertRawProp(
|
|
55
|
+
context,
|
|
56
|
+
rawProps,
|
|
57
|
+
"border",
|
|
58
|
+
"Radius",
|
|
59
|
+
sourceProps.borderRadii,
|
|
60
|
+
{})),
|
|
61
|
+
borderColors(
|
|
62
|
+
Props::enablePropIteratorSetter ? sourceProps.borderColors
|
|
63
|
+
: convertRawProp(
|
|
64
|
+
context,
|
|
65
|
+
rawProps,
|
|
66
|
+
"border",
|
|
67
|
+
"Color",
|
|
68
|
+
sourceProps.borderColors,
|
|
69
|
+
{})),
|
|
70
|
+
borderStyles(
|
|
71
|
+
Props::enablePropIteratorSetter ? sourceProps.borderStyles
|
|
72
|
+
: convertRawProp(
|
|
73
|
+
context,
|
|
74
|
+
rawProps,
|
|
75
|
+
"border",
|
|
76
|
+
"Style",
|
|
77
|
+
sourceProps.borderStyles,
|
|
78
|
+
{})),
|
|
79
|
+
shadowColor(
|
|
80
|
+
Props::enablePropIteratorSetter ? sourceProps.shadowColor
|
|
81
|
+
: convertRawProp(
|
|
82
|
+
context,
|
|
83
|
+
rawProps,
|
|
84
|
+
"shadowColor",
|
|
85
|
+
sourceProps.shadowColor,
|
|
86
|
+
{})),
|
|
87
|
+
shadowOffset(
|
|
88
|
+
Props::enablePropIteratorSetter ? sourceProps.shadowOffset
|
|
89
|
+
: convertRawProp(
|
|
90
|
+
context,
|
|
91
|
+
rawProps,
|
|
92
|
+
"shadowOffset",
|
|
93
|
+
sourceProps.shadowOffset,
|
|
94
|
+
{})),
|
|
95
|
+
shadowOpacity(
|
|
96
|
+
Props::enablePropIteratorSetter ? sourceProps.shadowOpacity
|
|
97
|
+
: convertRawProp(
|
|
98
|
+
context,
|
|
99
|
+
rawProps,
|
|
100
|
+
"shadowOpacity",
|
|
101
|
+
sourceProps.shadowOpacity,
|
|
102
|
+
{})),
|
|
103
|
+
shadowRadius(
|
|
104
|
+
Props::enablePropIteratorSetter ? sourceProps.shadowRadius
|
|
105
|
+
: convertRawProp(
|
|
106
|
+
context,
|
|
107
|
+
rawProps,
|
|
108
|
+
"shadowRadius",
|
|
109
|
+
sourceProps.shadowRadius,
|
|
110
|
+
{})),
|
|
111
|
+
transform(
|
|
112
|
+
Props::enablePropIteratorSetter ? sourceProps.transform
|
|
113
|
+
: convertRawProp(
|
|
114
|
+
context,
|
|
115
|
+
rawProps,
|
|
116
|
+
"transform",
|
|
117
|
+
sourceProps.transform,
|
|
118
|
+
{})),
|
|
119
|
+
backfaceVisibility(
|
|
120
|
+
Props::enablePropIteratorSetter ? sourceProps.backfaceVisibility
|
|
121
|
+
: convertRawProp(
|
|
122
|
+
context,
|
|
123
|
+
rawProps,
|
|
124
|
+
"backfaceVisibility",
|
|
125
|
+
sourceProps.backfaceVisibility,
|
|
126
|
+
{})),
|
|
127
|
+
shouldRasterize(
|
|
128
|
+
Props::enablePropIteratorSetter ? sourceProps.shouldRasterize
|
|
129
|
+
: convertRawProp(
|
|
130
|
+
context,
|
|
131
|
+
rawProps,
|
|
132
|
+
"shouldRasterize",
|
|
133
|
+
sourceProps.shouldRasterize,
|
|
134
|
+
{})),
|
|
135
|
+
zIndex(
|
|
136
|
+
Props::enablePropIteratorSetter ? sourceProps.zIndex
|
|
137
|
+
: convertRawProp(
|
|
138
|
+
context,
|
|
139
|
+
rawProps,
|
|
140
|
+
"zIndex",
|
|
141
|
+
sourceProps.zIndex,
|
|
142
|
+
{})),
|
|
143
|
+
pointerEvents(
|
|
144
|
+
Props::enablePropIteratorSetter ? sourceProps.pointerEvents
|
|
145
|
+
: convertRawProp(
|
|
146
|
+
context,
|
|
147
|
+
rawProps,
|
|
148
|
+
"pointerEvents",
|
|
149
|
+
sourceProps.pointerEvents,
|
|
150
|
+
{})),
|
|
151
|
+
hitSlop(
|
|
152
|
+
Props::enablePropIteratorSetter ? sourceProps.hitSlop
|
|
153
|
+
: convertRawProp(
|
|
154
|
+
context,
|
|
155
|
+
rawProps,
|
|
156
|
+
"hitSlop",
|
|
157
|
+
sourceProps.hitSlop,
|
|
158
|
+
{})),
|
|
159
|
+
onLayout(
|
|
160
|
+
Props::enablePropIteratorSetter ? sourceProps.onLayout
|
|
161
|
+
: convertRawProp(
|
|
162
|
+
context,
|
|
163
|
+
rawProps,
|
|
164
|
+
"onLayout",
|
|
165
|
+
sourceProps.onLayout,
|
|
166
|
+
{})),
|
|
167
|
+
events(
|
|
168
|
+
Props::enablePropIteratorSetter
|
|
169
|
+
? sourceProps.events
|
|
170
|
+
: convertRawProp(context, rawProps, sourceProps.events, {})),
|
|
171
|
+
collapsable(
|
|
172
|
+
Props::enablePropIteratorSetter ? sourceProps.collapsable
|
|
173
|
+
: convertRawProp(
|
|
174
|
+
context,
|
|
175
|
+
rawProps,
|
|
176
|
+
"collapsable",
|
|
177
|
+
sourceProps.collapsable,
|
|
178
|
+
true)),
|
|
179
|
+
removeClippedSubviews(
|
|
180
|
+
Props::enablePropIteratorSetter
|
|
181
|
+
? sourceProps.removeClippedSubviews
|
|
182
|
+
: convertRawProp(
|
|
183
|
+
context,
|
|
184
|
+
rawProps,
|
|
185
|
+
"removeClippedSubviews",
|
|
186
|
+
sourceProps.removeClippedSubviews,
|
|
187
|
+
false))
|
|
188
|
+
#ifdef ANDROID
|
|
189
|
+
,
|
|
190
|
+
elevation(
|
|
191
|
+
Props::enablePropIteratorSetter ? sourceProps.elevation
|
|
192
|
+
: convertRawProp(
|
|
193
|
+
context,
|
|
194
|
+
rawProps,
|
|
195
|
+
"elevation",
|
|
196
|
+
sourceProps.elevation,
|
|
197
|
+
{})),
|
|
198
|
+
nativeBackground(
|
|
199
|
+
Props::enablePropIteratorSetter ? sourceProps.nativeBackground
|
|
200
|
+
: convertRawProp(
|
|
201
|
+
context,
|
|
202
|
+
rawProps,
|
|
203
|
+
"nativeBackgroundAndroid",
|
|
204
|
+
sourceProps.nativeBackground,
|
|
205
|
+
{})),
|
|
206
|
+
nativeForeground(
|
|
207
|
+
Props::enablePropIteratorSetter ? sourceProps.nativeForeground
|
|
208
|
+
: convertRawProp(
|
|
209
|
+
context,
|
|
210
|
+
rawProps,
|
|
211
|
+
"nativeForegroundAndroid",
|
|
212
|
+
sourceProps.nativeForeground,
|
|
213
|
+
{})),
|
|
214
|
+
focusable(
|
|
215
|
+
Props::enablePropIteratorSetter ? sourceProps.focusable
|
|
216
|
+
: convertRawProp(
|
|
217
|
+
context,
|
|
218
|
+
rawProps,
|
|
219
|
+
"focusable",
|
|
220
|
+
sourceProps.focusable,
|
|
221
|
+
{})),
|
|
222
|
+
hasTVPreferredFocus(
|
|
223
|
+
Props::enablePropIteratorSetter ? sourceProps.hasTVPreferredFocus
|
|
224
|
+
: convertRawProp(
|
|
225
|
+
context,
|
|
226
|
+
rawProps,
|
|
227
|
+
"hasTVPreferredFocus",
|
|
228
|
+
sourceProps.hasTVPreferredFocus,
|
|
229
|
+
{})),
|
|
230
|
+
needsOffscreenAlphaCompositing(
|
|
231
|
+
Props::enablePropIteratorSetter
|
|
232
|
+
? sourceProps.needsOffscreenAlphaCompositing
|
|
233
|
+
: convertRawProp(
|
|
234
|
+
context,
|
|
235
|
+
rawProps,
|
|
236
|
+
"needsOffscreenAlphaCompositing",
|
|
237
|
+
sourceProps.needsOffscreenAlphaCompositing,
|
|
238
|
+
{})),
|
|
239
|
+
renderToHardwareTextureAndroid(
|
|
240
|
+
Props::enablePropIteratorSetter
|
|
241
|
+
? sourceProps.renderToHardwareTextureAndroid
|
|
242
|
+
: convertRawProp(
|
|
243
|
+
context,
|
|
244
|
+
rawProps,
|
|
245
|
+
"renderToHardwareTextureAndroid",
|
|
246
|
+
sourceProps.renderToHardwareTextureAndroid,
|
|
247
|
+
{}))
|
|
248
|
+
|
|
249
|
+
#endif
|
|
250
|
+
{};
|
|
251
|
+
|
|
252
|
+
#define VIEW_EVENT_CASE(eventType, eventString) \
|
|
253
|
+
case CONSTEXPR_RAW_PROPS_KEY_HASH(eventString): { \
|
|
254
|
+
ViewEvents defaultViewEvents{}; \
|
|
255
|
+
events[eventType] = [defaultViewEvents, &value, &context]{ \
|
|
256
|
+
bool res = defaultViewEvents[eventType]; \
|
|
257
|
+
if (value.hasValue()) { \
|
|
258
|
+
fromRawValue(context, value, res); \
|
|
259
|
+
} \
|
|
260
|
+
return res; \
|
|
261
|
+
}(); \
|
|
262
|
+
return; \
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
void ViewProps::setProp(
|
|
266
|
+
const PropsParserContext &context,
|
|
267
|
+
RawPropsPropNameHash hash,
|
|
268
|
+
const char *propName,
|
|
269
|
+
RawValue const &value) {
|
|
270
|
+
// All Props structs setProp methods must always, unconditionally,
|
|
271
|
+
// call all super::setProp methods, since multiple structs may
|
|
272
|
+
// reuse the same values.
|
|
273
|
+
YogaStylableProps::setProp(context, hash, propName, value);
|
|
274
|
+
AccessibilityProps::setProp(context, hash, propName, value);
|
|
275
|
+
|
|
276
|
+
switch (hash) {
|
|
277
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(opacity, (Float)1.0);
|
|
278
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(foregroundColor, {});
|
|
279
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(backgroundColor, {});
|
|
280
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(shadowColor, {});
|
|
281
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(shadowOffset, {});
|
|
282
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(shadowOpacity, {});
|
|
283
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(shadowRadius, {});
|
|
284
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(transform, {});
|
|
285
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(backfaceVisibility, {});
|
|
286
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(shouldRasterize, {});
|
|
287
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(zIndex, {});
|
|
288
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(pointerEvents, {});
|
|
289
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(hitSlop, {});
|
|
290
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(onLayout, {});
|
|
291
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(collapsable, true);
|
|
292
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(removeClippedSubviews, false);
|
|
293
|
+
// events field
|
|
294
|
+
VIEW_EVENT_CASE(ViewEvents::Offset::PointerEnter, "onPointerEnter");
|
|
295
|
+
VIEW_EVENT_CASE(
|
|
296
|
+
ViewEvents::Offset::PointerEnterCapture, "onPointerEnterCapture");
|
|
297
|
+
VIEW_EVENT_CASE(ViewEvents::Offset::PointerMove, "onPointerMove");
|
|
298
|
+
VIEW_EVENT_CASE(
|
|
299
|
+
ViewEvents::Offset::PointerMoveCapture, "onPointerMoveCapture");
|
|
300
|
+
VIEW_EVENT_CASE(ViewEvents::Offset::PointerLeave, "onPointerLeave");
|
|
301
|
+
VIEW_EVENT_CASE(
|
|
302
|
+
ViewEvents::Offset::PointerLeaveCapture, "onPointerLeaveCapture");
|
|
303
|
+
VIEW_EVENT_CASE(ViewEvents::Offset::PointerOver, "onPointerOver");
|
|
304
|
+
VIEW_EVENT_CASE(ViewEvents::Offset::PointerOut, "onPointerOut");
|
|
305
|
+
VIEW_EVENT_CASE(
|
|
306
|
+
ViewEvents::Offset::MoveShouldSetResponder, "onMoveShouldSetResponder");
|
|
307
|
+
VIEW_EVENT_CASE(
|
|
308
|
+
ViewEvents::Offset::MoveShouldSetResponderCapture,
|
|
309
|
+
"onMoveShouldSetResponderCapture");
|
|
310
|
+
VIEW_EVENT_CASE(
|
|
311
|
+
ViewEvents::Offset::StartShouldSetResponder,
|
|
312
|
+
"onStartShouldSetResponder");
|
|
313
|
+
VIEW_EVENT_CASE(
|
|
314
|
+
ViewEvents::Offset::StartShouldSetResponderCapture,
|
|
315
|
+
"onStartShouldSetResponderCapture");
|
|
316
|
+
VIEW_EVENT_CASE(ViewEvents::Offset::ResponderGrant, "onResponderGrant");
|
|
317
|
+
VIEW_EVENT_CASE(ViewEvents::Offset::ResponderReject, "onResponderReject");
|
|
318
|
+
VIEW_EVENT_CASE(ViewEvents::Offset::ResponderStart, "onResponderStart");
|
|
319
|
+
VIEW_EVENT_CASE(ViewEvents::Offset::ResponderEnd, "onResponderEnd");
|
|
320
|
+
VIEW_EVENT_CASE(ViewEvents::Offset::ResponderRelease, "onResponderRelease");
|
|
321
|
+
VIEW_EVENT_CASE(ViewEvents::Offset::ResponderMove, "ResponderMove");
|
|
322
|
+
VIEW_EVENT_CASE(
|
|
323
|
+
ViewEvents::Offset::ResponderTerminate, "onResponderTerminate");
|
|
324
|
+
VIEW_EVENT_CASE(
|
|
325
|
+
ViewEvents::Offset::ResponderTerminationRequest,
|
|
326
|
+
"onResponderTerminationRequest");
|
|
327
|
+
VIEW_EVENT_CASE(
|
|
328
|
+
ViewEvents::Offset::ShouldBlockNativeResponder,
|
|
329
|
+
"onShouldBlockNativeResponder");
|
|
330
|
+
VIEW_EVENT_CASE(ViewEvents::Offset::TouchStart, "onTouchStart");
|
|
331
|
+
VIEW_EVENT_CASE(ViewEvents::Offset::TouchMove, "onTouchMove");
|
|
332
|
+
VIEW_EVENT_CASE(ViewEvents::Offset::TouchEnd, "onTouchEnd");
|
|
333
|
+
VIEW_EVENT_CASE(ViewEvents::Offset::TouchCancel, "onTouchCancel");
|
|
334
|
+
#ifdef ANDROID
|
|
335
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(elevation, {});
|
|
336
|
+
RAW_SET_PROP_SWITCH_CASE(nativeBackground, "nativeBackgroundAndroid", {});
|
|
337
|
+
RAW_SET_PROP_SWITCH_CASE(nativeForeground, "nativeForegroundAndroid", {});
|
|
338
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(focusable, false);
|
|
339
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(hasTVPreferredFocus, false);
|
|
340
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(needsOffscreenAlphaCompositing, false);
|
|
341
|
+
RAW_SET_PROP_SWITCH_CASE_BASIC(renderToHardwareTextureAndroid, false);
|
|
342
|
+
#endif
|
|
343
|
+
// BorderRadii
|
|
344
|
+
SET_CASCADED_RECTANGLE_CORNERS(borderRadii, "border", "Radius", value);
|
|
345
|
+
SET_CASCADED_RECTANGLE_EDGES(borderColors, "border", "Color", value);
|
|
346
|
+
SET_CASCADED_RECTANGLE_EDGES(borderStyles, "border", "Style", value);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
#pragma mark - Convenience Methods
|
|
351
|
+
|
|
352
|
+
static BorderRadii ensureNoOverlap(BorderRadii const &radii, Size const &size) {
|
|
353
|
+
// "Corner curves must not overlap: When the sum of any two adjacent border
|
|
354
|
+
// radii exceeds the size of the border box, UAs must proportionally reduce
|
|
355
|
+
// the used values of all border radii until none of them overlap."
|
|
356
|
+
// Source: https://www.w3.org/TR/css-backgrounds-3/#corner-overlap
|
|
357
|
+
|
|
358
|
+
auto insets = EdgeInsets{
|
|
359
|
+
/* .left = */ radii.topLeft + radii.bottomLeft,
|
|
360
|
+
/* .top = */ radii.topLeft + radii.topRight,
|
|
361
|
+
/* .right = */ radii.topRight + radii.bottomRight,
|
|
362
|
+
/* .bottom = */ radii.bottomLeft + radii.bottomRight,
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
auto insetsScale = EdgeInsets{
|
|
366
|
+
/* .left = */
|
|
367
|
+
insets.left > 0 ? std::min((Float)1.0, size.height / insets.left) : 0,
|
|
368
|
+
/* .top = */
|
|
369
|
+
insets.top > 0 ? std::min((Float)1.0, size.width / insets.top) : 0,
|
|
370
|
+
/* .right = */
|
|
371
|
+
insets.right > 0 ? std::min((Float)1.0, size.height / insets.right) : 0,
|
|
372
|
+
/* .bottom = */
|
|
373
|
+
insets.bottom > 0 ? std::min((Float)1.0, size.width / insets.bottom) : 0,
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
return BorderRadii{
|
|
377
|
+
/* topLeft = */
|
|
378
|
+
radii.topLeft * std::min(insetsScale.top, insetsScale.left),
|
|
379
|
+
/* topRight = */
|
|
380
|
+
radii.topRight * std::min(insetsScale.top, insetsScale.right),
|
|
381
|
+
/* bottomLeft = */
|
|
382
|
+
radii.bottomLeft * std::min(insetsScale.bottom, insetsScale.left),
|
|
383
|
+
/* bottomRight = */
|
|
384
|
+
radii.bottomRight * std::min(insetsScale.bottom, insetsScale.right),
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
BorderMetrics ViewProps::resolveBorderMetrics(
|
|
389
|
+
LayoutMetrics const &layoutMetrics) const {
|
|
390
|
+
auto isRTL =
|
|
391
|
+
bool{layoutMetrics.layoutDirection == LayoutDirection::RightToLeft};
|
|
392
|
+
|
|
393
|
+
auto borderWidths = CascadedBorderWidths{
|
|
394
|
+
/* .left = */ optionalFloatFromYogaValue(yogaStyle.border()[YGEdgeLeft]),
|
|
395
|
+
/* .top = */ optionalFloatFromYogaValue(yogaStyle.border()[YGEdgeTop]),
|
|
396
|
+
/* .right = */
|
|
397
|
+
optionalFloatFromYogaValue(yogaStyle.border()[YGEdgeRight]),
|
|
398
|
+
/* .bottom = */
|
|
399
|
+
optionalFloatFromYogaValue(yogaStyle.border()[YGEdgeBottom]),
|
|
400
|
+
/* .start = */
|
|
401
|
+
optionalFloatFromYogaValue(yogaStyle.border()[YGEdgeStart]),
|
|
402
|
+
/* .end = */ optionalFloatFromYogaValue(yogaStyle.border()[YGEdgeEnd]),
|
|
403
|
+
/* .horizontal = */
|
|
404
|
+
optionalFloatFromYogaValue(yogaStyle.border()[YGEdgeHorizontal]),
|
|
405
|
+
/* .vertical = */
|
|
406
|
+
optionalFloatFromYogaValue(yogaStyle.border()[YGEdgeVertical]),
|
|
407
|
+
/* .all = */ optionalFloatFromYogaValue(yogaStyle.border()[YGEdgeAll]),
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
return {
|
|
411
|
+
/* .borderColors = */ borderColors.resolve(isRTL, {}),
|
|
412
|
+
/* .borderWidths = */ borderWidths.resolve(isRTL, 0),
|
|
413
|
+
/* .borderRadii = */
|
|
414
|
+
ensureNoOverlap(borderRadii.resolve(isRTL, 0), layoutMetrics.frame.size),
|
|
415
|
+
/* .borderStyles = */ borderStyles.resolve(isRTL, BorderStyle::Solid),
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
bool ViewProps::getClipsContentToBounds() const {
|
|
420
|
+
return yogaStyle.overflow() != YGOverflowVisible;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
#ifdef ANDROID
|
|
424
|
+
bool ViewProps::getProbablyMoreHorizontalThanVertical_DEPRECATED() const {
|
|
425
|
+
return yogaStyle.flexDirection() == YGFlexDirectionRow;
|
|
426
|
+
}
|
|
427
|
+
#endif
|
|
428
|
+
|
|
429
|
+
#pragma mark - DebugStringConvertible
|
|
430
|
+
|
|
431
|
+
#if RN_DEBUG_STRING_CONVERTIBLE
|
|
432
|
+
SharedDebugStringConvertibleList ViewProps::getDebugProps() const {
|
|
433
|
+
const auto &defaultViewProps = ViewProps();
|
|
434
|
+
|
|
435
|
+
return AccessibilityProps::getDebugProps() +
|
|
436
|
+
YogaStylableProps::getDebugProps() +
|
|
437
|
+
SharedDebugStringConvertibleList{
|
|
438
|
+
debugStringConvertibleItem(
|
|
439
|
+
"opacity", opacity, defaultViewProps.opacity),
|
|
440
|
+
debugStringConvertibleItem(
|
|
441
|
+
"foregroundColor",
|
|
442
|
+
foregroundColor,
|
|
443
|
+
defaultViewProps.foregroundColor),
|
|
444
|
+
debugStringConvertibleItem(
|
|
445
|
+
"backgroundColor",
|
|
446
|
+
backgroundColor,
|
|
447
|
+
defaultViewProps.backgroundColor),
|
|
448
|
+
debugStringConvertibleItem(
|
|
449
|
+
"zIndex", zIndex, defaultViewProps.zIndex.value_or(0)),
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
#endif
|
|
453
|
+
|
|
454
|
+
} // namespace react
|
|
455
|
+
} // namespace facebook
|
package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/ConcreteComponentDescriptor.h
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
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 <functional>
|
|
11
|
+
#include <memory>
|
|
12
|
+
|
|
13
|
+
#include <react/debug/react_native_assert.h>
|
|
14
|
+
#include <react/renderer/components/view/ViewPropsInterpolation.h>
|
|
15
|
+
#include <react/renderer/core/ComponentDescriptor.h>
|
|
16
|
+
#include <react/renderer/core/EventDispatcher.h>
|
|
17
|
+
#include <react/renderer/core/Props.h>
|
|
18
|
+
#include <react/renderer/core/PropsParserContext.h>
|
|
19
|
+
#include <react/renderer/core/ShadowNode.h>
|
|
20
|
+
#include <react/renderer/core/ShadowNodeFragment.h>
|
|
21
|
+
#include <react/renderer/core/State.h>
|
|
22
|
+
#include <react/renderer/graphics/Float.h>
|
|
23
|
+
|
|
24
|
+
namespace facebook {
|
|
25
|
+
namespace react {
|
|
26
|
+
|
|
27
|
+
/*
|
|
28
|
+
* Default template-based implementation of ComponentDescriptor.
|
|
29
|
+
* Use your `ShadowNode` type as a template argument and override any methods
|
|
30
|
+
* if necessary.
|
|
31
|
+
*/
|
|
32
|
+
template <typename ShadowNodeT>
|
|
33
|
+
class ConcreteComponentDescriptor : public ComponentDescriptor {
|
|
34
|
+
static_assert(
|
|
35
|
+
std::is_base_of<ShadowNode, ShadowNodeT>::value,
|
|
36
|
+
"ShadowNodeT must be a descendant of ShadowNode");
|
|
37
|
+
|
|
38
|
+
using SharedShadowNodeT = std::shared_ptr<const ShadowNodeT>;
|
|
39
|
+
|
|
40
|
+
public:
|
|
41
|
+
using ConcreteShadowNode = ShadowNodeT;
|
|
42
|
+
using ConcreteProps = typename ShadowNodeT::ConcreteProps;
|
|
43
|
+
using SharedConcreteProps = typename ShadowNodeT::SharedConcreteProps;
|
|
44
|
+
using ConcreteEventEmitter = typename ShadowNodeT::ConcreteEventEmitter;
|
|
45
|
+
using SharedConcreteEventEmitter =
|
|
46
|
+
typename ShadowNodeT::SharedConcreteEventEmitter;
|
|
47
|
+
using ConcreteState = typename ShadowNodeT::ConcreteState;
|
|
48
|
+
using ConcreteStateData = typename ShadowNodeT::ConcreteState::Data;
|
|
49
|
+
|
|
50
|
+
ConcreteComponentDescriptor(ComponentDescriptorParameters const ¶meters)
|
|
51
|
+
: ComponentDescriptor(parameters) {
|
|
52
|
+
rawPropsParser_.prepare<ConcreteProps>();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
ComponentHandle getComponentHandle() const override {
|
|
56
|
+
return ShadowNodeT::Handle();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
ComponentName getComponentName() const override {
|
|
60
|
+
return ShadowNodeT::Name();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
ShadowNodeTraits getTraits() const override {
|
|
64
|
+
return ShadowNodeT::BaseTraits();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
ShadowNode::Shared createShadowNode(
|
|
68
|
+
const ShadowNodeFragment &fragment,
|
|
69
|
+
ShadowNodeFamily::Shared const &family) const override {
|
|
70
|
+
auto shadowNode =
|
|
71
|
+
std::make_shared<ShadowNodeT>(fragment, family, getTraits());
|
|
72
|
+
|
|
73
|
+
adopt(shadowNode);
|
|
74
|
+
|
|
75
|
+
return shadowNode;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
ShadowNode::Unshared cloneShadowNode(
|
|
79
|
+
const ShadowNode &sourceShadowNode,
|
|
80
|
+
const ShadowNodeFragment &fragment) const override {
|
|
81
|
+
auto shadowNode = std::make_shared<ShadowNodeT>(sourceShadowNode, fragment);
|
|
82
|
+
|
|
83
|
+
adopt(shadowNode);
|
|
84
|
+
return shadowNode;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
void appendChild(
|
|
88
|
+
const ShadowNode::Shared &parentShadowNode,
|
|
89
|
+
const ShadowNode::Shared &childShadowNode) const override {
|
|
90
|
+
auto concreteParentShadowNode =
|
|
91
|
+
std::static_pointer_cast<const ShadowNodeT>(parentShadowNode);
|
|
92
|
+
auto concreteNonConstParentShadowNode =
|
|
93
|
+
std::const_pointer_cast<ShadowNodeT>(concreteParentShadowNode);
|
|
94
|
+
concreteNonConstParentShadowNode->appendChild(childShadowNode);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
virtual Props::Shared cloneProps(
|
|
98
|
+
const PropsParserContext &context,
|
|
99
|
+
const Props::Shared &props,
|
|
100
|
+
const RawProps &rawProps) const override {
|
|
101
|
+
// Optimization:
|
|
102
|
+
// Quite often nodes are constructed with default/empty props: the base
|
|
103
|
+
// `props` object is `null` (there no base because it's not cloning) and the
|
|
104
|
+
// `rawProps` is empty. In this case, we can return the default props object
|
|
105
|
+
// of a concrete type entirely bypassing parsing.
|
|
106
|
+
if (!props && rawProps.isEmpty()) {
|
|
107
|
+
return ShadowNodeT::defaultSharedProps();
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
rawProps.parse(rawPropsParser_, context);
|
|
111
|
+
|
|
112
|
+
// Call old-style constructor
|
|
113
|
+
auto shadowNodeProps = ShadowNodeT::Props(context, rawProps, props);
|
|
114
|
+
|
|
115
|
+
// Use the new-style iterator
|
|
116
|
+
// Note that we just check if `Props` has this flag set, no matter
|
|
117
|
+
// the type of ShadowNode; it acts as the single global flag.
|
|
118
|
+
if (Props::enablePropIteratorSetter) {
|
|
119
|
+
rawProps.iterateOverValues([&](RawPropsPropNameHash hash,
|
|
120
|
+
const char *propName,
|
|
121
|
+
RawValue const &fn) {
|
|
122
|
+
shadowNodeProps.get()->Props::setProp(context, hash, propName, fn);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return shadowNodeProps;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
Props::Shared interpolateProps(
|
|
130
|
+
const PropsParserContext &context,
|
|
131
|
+
Float animationProgress,
|
|
132
|
+
const Props::Shared &props,
|
|
133
|
+
const Props::Shared &newProps) const override {
|
|
134
|
+
#ifdef ANDROID
|
|
135
|
+
// On Android only, the merged props should have the same RawProps as the
|
|
136
|
+
// final props struct
|
|
137
|
+
Props::Shared interpolatedPropsShared =
|
|
138
|
+
(newProps != nullptr ? cloneProps(context, newProps, newProps->rawProps)
|
|
139
|
+
: cloneProps(context, newProps, {}));
|
|
140
|
+
#else
|
|
141
|
+
Props::Shared interpolatedPropsShared = cloneProps(context, newProps, {});
|
|
142
|
+
#endif
|
|
143
|
+
|
|
144
|
+
if (ConcreteShadowNode::BaseTraits().check(
|
|
145
|
+
ShadowNodeTraits::Trait::ViewKind)) {
|
|
146
|
+
interpolateViewProps(
|
|
147
|
+
animationProgress, props, newProps, interpolatedPropsShared);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return interpolatedPropsShared;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
virtual State::Shared createInitialState(
|
|
154
|
+
ShadowNodeFragment const &fragment,
|
|
155
|
+
ShadowNodeFamily::Shared const &family) const override {
|
|
156
|
+
if (std::is_same<ConcreteStateData, StateData>::value) {
|
|
157
|
+
// Default case: Returning `null` for nodes that don't use `State`.
|
|
158
|
+
return nullptr;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return std::make_shared<ConcreteState>(
|
|
162
|
+
std::make_shared<ConcreteStateData const>(
|
|
163
|
+
ConcreteShadowNode::initialStateData(
|
|
164
|
+
fragment, ShadowNodeFamilyFragment::build(*family), *this)),
|
|
165
|
+
family);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
virtual State::Shared createState(
|
|
169
|
+
ShadowNodeFamily const &family,
|
|
170
|
+
StateData::Shared const &data) const override {
|
|
171
|
+
if (std::is_same<ConcreteStateData, StateData>::value) {
|
|
172
|
+
// Default case: Returning `null` for nodes that don't use `State`.
|
|
173
|
+
return nullptr;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
react_native_assert(data && "Provided `data` is nullptr.");
|
|
177
|
+
|
|
178
|
+
return std::make_shared<ConcreteState const>(
|
|
179
|
+
std::static_pointer_cast<ConcreteStateData const>(data),
|
|
180
|
+
*family.getMostRecentState());
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
ShadowNodeFamily::Shared createFamily(
|
|
184
|
+
ShadowNodeFamilyFragment const &fragment,
|
|
185
|
+
SharedEventTarget eventTarget) const override {
|
|
186
|
+
auto eventEmitter = std::make_shared<ConcreteEventEmitter const>(
|
|
187
|
+
std::move(eventTarget), fragment.tag, eventDispatcher_);
|
|
188
|
+
return std::make_shared<ShadowNodeFamily>(
|
|
189
|
+
ShadowNodeFamilyFragment{
|
|
190
|
+
fragment.tag, fragment.surfaceId, eventEmitter},
|
|
191
|
+
eventDispatcher_,
|
|
192
|
+
*this);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
protected:
|
|
196
|
+
/*
|
|
197
|
+
* Called immediatelly after `ShadowNode` is created or cloned.
|
|
198
|
+
*
|
|
199
|
+
* Override this method to pass information from custom `ComponentDescriptor`
|
|
200
|
+
* to new instance of `ShadowNode`.
|
|
201
|
+
*
|
|
202
|
+
* Example usages:
|
|
203
|
+
* - Inject image manager to `ImageShadowNode` in
|
|
204
|
+
* `ImageComponentDescriptor`.
|
|
205
|
+
* - Set `ShadowNode`'s size from state in
|
|
206
|
+
* `ModalHostViewComponentDescriptor`.
|
|
207
|
+
*/
|
|
208
|
+
virtual void adopt(ShadowNode::Unshared const &shadowNode) const {
|
|
209
|
+
// Default implementation does nothing.
|
|
210
|
+
react_native_assert(
|
|
211
|
+
shadowNode->getComponentHandle() == getComponentHandle());
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
} // namespace react
|
|
216
|
+
} // namespace facebook
|