react-native-windows 0.72.16 → 0.73.0-preview.2
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 +16 -5
- package/Chakra/ChakraHelpers.cpp +1 -1
- package/Chakra/ChakraUtils.cpp +1 -1
- package/Chakra/ChakraValue.h +1 -1
- package/Common/packages.lock.json +13 -0
- package/Directory.Build.props +6 -2
- package/Folly/TEMP_UntilFollyUpdate/dynamic-inl.h +1 -10
- package/Folly/TEMP_UntilFollyUpdate/hash/Hash.h +1016 -0
- package/Folly/TEMP_UntilFollyUpdate/lang/ToAscii.h +1 -1
- package/Folly/cgmanifest.json +1 -1
- package/Folly/packages.lock.json +23 -0
- package/Libraries/Animated/Animated.js +1 -1
- package/Libraries/Animated/AnimatedImplementation.js +1 -1
- package/Libraries/Animated/NativeAnimatedHelper.js +14 -10
- package/Libraries/Animated/NativeAnimatedModule.js +6 -2
- package/Libraries/Animated/NativeAnimatedTurboModule.js +7 -4
- package/Libraries/Animated/animations/Animation.js +57 -3
- package/Libraries/Animated/animations/DecayAnimation.js +9 -0
- package/Libraries/Animated/animations/SpringAnimation.js +8 -0
- package/Libraries/Animated/animations/TimingAnimation.js +8 -0
- package/Libraries/Animated/components/AnimatedFlatList.js +2 -1
- package/Libraries/Animated/components/AnimatedScrollView.js +2 -0
- package/Libraries/Animated/components/AnimatedSectionList.js +2 -1
- package/Libraries/Animated/createAnimatedComponent.js +1 -0
- package/Libraries/Animated/nodes/AnimatedColor.js +1 -1
- package/Libraries/Animated/nodes/AnimatedObject.js +146 -0
- package/Libraries/Animated/nodes/AnimatedProps.js +19 -7
- package/Libraries/Animated/nodes/AnimatedStyle.js +29 -55
- package/Libraries/Animated/nodes/AnimatedValueXY.js +3 -17
- package/Libraries/Animated/shouldUseTurboAnimatedModule.js +17 -0
- package/Libraries/Animated/useAnimatedProps.js +9 -10
- package/Libraries/AppState/AppState.d.ts +1 -1
- package/Libraries/AppState/NativeAppState.js +8 -4
- package/Libraries/AppTheme/AppTheme.js +5 -5
- package/Libraries/BatchedBridge/MessageQueue.js +45 -36
- package/Libraries/Blob/Blob.js +6 -2
- package/Libraries/Blob/BlobManager.js +9 -10
- package/Libraries/Blob/BlobRegistry.js +14 -9
- package/Libraries/Blob/File.js +1 -1
- package/Libraries/Blob/FileReader.js +1 -2
- package/Libraries/Components/Clipboard/Clipboard.d.ts +4 -4
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +3 -1
- package/Libraries/Components/Glyph/Glyph.js +1 -1
- package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +26 -6
- package/Libraries/Components/Keyboard/KeyboardExt.d.ts +4 -1
- package/Libraries/Components/Keyboard/KeyboardExt.js +3 -0
- package/Libraries/Components/Keyboard/KeyboardExt.js.map +1 -1
- package/Libraries/Components/Keyboard/KeyboardExtProps.d.ts +4 -29
- package/Libraries/Components/Keyboard/KeyboardExtProps.js +0 -17
- package/Libraries/Components/Keyboard/KeyboardExtProps.js.map +1 -1
- package/Libraries/Components/Pressable/Pressable.js +3 -2
- package/Libraries/Components/Pressable/Pressable.windows.js +4 -3
- package/Libraries/Components/Pressable/useAndroidRippleForView.js +1 -1
- package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js +20 -0
- package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.windows.js +7 -1
- package/Libraries/Components/SafeAreaView/SafeAreaView.js +7 -7
- package/Libraries/Components/SafeAreaView/SafeAreaView.windows.js +7 -10
- package/Libraries/Components/ScrollView/ScrollView.js +3 -1
- package/Libraries/Components/ScrollView/ScrollView.windows.js +3 -1
- package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +39 -46
- package/Libraries/Components/Switch/Switch.js +1 -0
- package/Libraries/Components/Switch/Switch.windows.js +259 -0
- package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +1 -0
- package/Libraries/Components/TextInput/TextInput.d.ts +49 -7
- package/Libraries/Components/TextInput/TextInput.flow.js +43 -10
- package/Libraries/Components/TextInput/TextInput.js +62 -10
- package/Libraries/Components/TextInput/TextInput.windows.js +100 -14
- package/Libraries/Components/ToastAndroid/{ToastAndroid.ios.js → ToastAndroid.js} +9 -1
- package/Libraries/Components/ToastAndroid/ToastAndroid.windows.js +9 -1
- package/Libraries/Components/Touchable/TouchableBounce.js +1 -1
- package/Libraries/Components/Touchable/TouchableHighlight.js +1 -1
- package/Libraries/Components/Touchable/TouchableHighlight.windows.js +1 -1
- package/Libraries/Components/Touchable/TouchableNativeFeedback.js +1 -1
- package/Libraries/Components/Touchable/TouchableOpacity.js +4 -1
- package/Libraries/Components/Touchable/TouchableOpacity.windows.js +4 -1
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +1 -0
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.windows.js +1 -0
- package/Libraries/Components/TraceUpdateOverlay/TraceUpdateOverlay.js +16 -6
- package/Libraries/Components/View/ReactNativeStyleAttributes.js +9 -0
- package/Libraries/Components/View/ReactNativeViewAttributes.js +1 -0
- package/Libraries/Components/View/ReactNativeViewAttributes.windows.js +1 -0
- package/Libraries/Components/View/View.js +46 -32
- package/Libraries/Components/View/View.windows.js +23 -7
- package/Libraries/Components/View/ViewAccessibility.d.ts +27 -1
- package/Libraries/Components/View/ViewAccessibility.windows.js +3 -0
- package/Libraries/Components/View/ViewNativeComponent.js +1 -0
- package/Libraries/Components/View/ViewPropTypes.d.ts +104 -1
- package/Libraries/Components/View/ViewPropTypes.js +18 -3
- package/Libraries/Components/View/ViewPropTypes.windows.js +33 -3
- package/Libraries/Core/Devtools/loadBundleFromServer.js +152 -0
- package/Libraries/Core/Devtools/symbolicateStackTrace.js +2 -1
- package/Libraries/Core/ExceptionsManager.js +16 -7
- package/Libraries/Core/ExtendedError.js +12 -0
- package/Libraries/Core/ReactNativeVersion.js +3 -3
- package/Libraries/Core/ReactNativeVersionCheck.js +0 -2
- package/Libraries/Core/__mocks__/NativeExceptionsManager.js +20 -0
- package/Libraries/Core/setUpDeveloperTools.js +5 -1
- package/Libraries/Core/setUpIntersectionObserver.js +16 -0
- package/Libraries/Core/setUpMutationObserver.js +16 -0
- package/Libraries/Core/setUpPerformance.js +6 -13
- package/Libraries/Core/setUpPerformanceObserver.js +16 -0
- package/Libraries/Core/setUpRegeneratorRuntime.js +4 -2
- package/Libraries/DOM/Nodes/ReactNativeElement.js +135 -18
- package/Libraries/DOM/Nodes/ReadOnlyCharacterData.js +72 -0
- package/Libraries/DOM/Nodes/ReadOnlyElement.js +209 -21
- package/Libraries/DOM/Nodes/ReadOnlyNode.js +206 -17
- package/Libraries/DOM/Nodes/ReadOnlyText.js +30 -0
- package/Libraries/DOM/Nodes/Utilities/Traversal.js +54 -0
- package/Libraries/EventEmitter/NativeEventEmitter.d.ts +0 -6
- package/Libraries/EventEmitter/RCTDeviceEventEmitter.js +15 -4
- package/Libraries/Image/Image.android.js +8 -2
- package/Libraries/Image/Image.d.ts +1 -1
- package/Libraries/Image/Image.ios.js +4 -1
- package/Libraries/Image/Image.windows.js +6 -3
- package/Libraries/Image/ImageBackground.js +3 -0
- package/Libraries/Inspector/DevtoolsOverlay.js +6 -3
- package/Libraries/Inspector/NetworkOverlay.js +2 -2
- package/Libraries/Interaction/JSEventLoopWatchdog.js +1 -5
- package/Libraries/Interaction/PanResponder.js +1 -4
- package/Libraries/IntersectionObserver/IntersectionObserver.js +252 -0
- package/Libraries/IntersectionObserver/IntersectionObserverEntry.js +140 -0
- package/Libraries/IntersectionObserver/IntersectionObserverManager.js +221 -0
- package/Libraries/IntersectionObserver/NativeIntersectionObserver.js +41 -0
- package/Libraries/IntersectionObserver/__mocks__/NativeIntersectionObserver.js +162 -0
- package/Libraries/LayoutAnimation/LayoutAnimation.js +1 -1
- package/Libraries/Lists/FlatList.d.ts +2 -1
- package/Libraries/Lists/FlatList.js +15 -5
- package/Libraries/Lists/SectionList.js +4 -0
- package/Libraries/LogBox/Data/LogBoxLog.js +4 -1
- package/Libraries/LogBox/Data/LogBoxSymbolication.js +5 -2
- package/Libraries/LogBox/Data/parseLogBoxLog.js +57 -20
- package/Libraries/LogBox/UI/AnsiHighlight.js +1 -1
- package/Libraries/LogBox/UI/LogBoxInspectorFooter.js +24 -31
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +1 -1
- package/Libraries/LogBox/UI/LogBoxMessage.js +4 -7
- package/Libraries/MutationObserver/MutationObserver.js +184 -0
- package/Libraries/MutationObserver/MutationObserverManager.js +218 -0
- package/Libraries/MutationObserver/MutationRecord.js +82 -0
- package/Libraries/MutationObserver/NativeMutationObserver.js +58 -0
- package/Libraries/MutationObserver/__mocks__/NativeMutationObserver.js +327 -0
- package/Libraries/NativeComponent/BaseViewConfig.android.js +18 -3
- package/Libraries/NativeComponent/BaseViewConfig.ios.js +33 -0
- package/Libraries/NativeComponent/BaseViewConfig.windows.js +34 -4
- package/Libraries/NativeComponent/NativeComponentRegistry.js +3 -5
- package/Libraries/NativeModules/specs/NativeSourceCode.js +6 -6
- package/Libraries/Network/RCTNetworking.android.js +2 -1
- package/Libraries/Network/XMLHttpRequest.js +1 -1
- package/Libraries/NewAppScreen/components/DebugInstructions.js +4 -4
- package/Libraries/NewAppScreen/components/DebugInstructions.windows.js +2 -2
- package/Libraries/NewAppScreen/components/LearnMoreLinks.js +9 -2
- package/Libraries/Performance/QuickPerformanceLogger.js +1 -1
- package/Libraries/PermissionsAndroid/NativePermissionsAndroid.js +1 -0
- package/Libraries/PermissionsAndroid/PermissionsAndroid.d.ts +1 -0
- package/Libraries/PermissionsAndroid/PermissionsAndroid.js +3 -1
- package/Libraries/Pressability/Pressability.js +28 -3
- package/Libraries/Pressability/Pressability.windows.js +30 -5
- package/Libraries/ReactNative/AppContainer.js +2 -3
- package/Libraries/ReactNative/AppRegistry.d.ts +0 -5
- package/Libraries/ReactNative/AppRegistry.js +66 -53
- package/Libraries/ReactNative/BridgelessUIManager.js +38 -9
- package/Libraries/ReactNative/FabricUIManager.js +143 -34
- package/Libraries/ReactNative/I18nManager.js +5 -11
- package/Libraries/ReactNative/NativeI18nManager.js +7 -5
- package/Libraries/ReactNative/PaperUIManager.windows.js +2 -2
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +151 -0
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +81 -0
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactNativeAttributePayload.js +492 -0
- package/Libraries/ReactNative/ReactFabricPublicInstance/warnForStyleProps.js +32 -0
- package/Libraries/ReactNative/ReactNativeFeatureFlags.js +19 -3
- package/Libraries/ReactNative/UIManager.js +8 -0
- package/Libraries/ReactNative/__mocks__/FabricUIManager.js +648 -0
- package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +38 -2
- package/Libraries/Renderer/implementations/ReactFabric-dev.js +27 -27
- package/Libraries/Renderer/implementations/ReactFabric-prod.js +3 -3
- package/Libraries/Renderer/implementations/ReactFabric-profiling.js +3 -3
- package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +27 -27
- package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +3 -3
- package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +3 -3
- package/Libraries/Renderer/shims/ReactFabric.js +5 -6
- package/Libraries/Renderer/shims/ReactFeatureFlags.js +2 -3
- package/Libraries/Renderer/shims/ReactNative.js +2 -3
- package/Libraries/Renderer/shims/ReactNativeTypes.js +35 -17
- package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +3 -3
- package/Libraries/Renderer/shims/createReactNativeComponentClass.js +2 -3
- package/Libraries/Settings/{Settings.android.js → Settings.js} +4 -4
- package/Libraries/Share/Share.d.ts +3 -9
- package/Libraries/StyleSheet/PlatformColorValueTypes.android.js +9 -4
- package/Libraries/StyleSheet/PlatformColorValueTypes.ios.js +28 -13
- package/Libraries/StyleSheet/PlatformColorValueTypes.windows.js +10 -6
- package/Libraries/StyleSheet/PlatformColorValueTypesIOS.ios.js +1 -1
- package/Libraries/StyleSheet/StyleSheet.d.ts +10 -1
- package/Libraries/StyleSheet/StyleSheet.js +3 -0
- package/Libraries/StyleSheet/StyleSheetTypes.d.ts +31 -17
- package/Libraries/StyleSheet/StyleSheetTypes.js +90 -6
- package/Libraries/StyleSheet/flattenStyle.js +4 -0
- package/Libraries/StyleSheet/private/_TransformStyle.js +16 -2
- package/Libraries/StyleSheet/processColor.js +1 -2
- package/Libraries/StyleSheet/processTransformOrigin.js +136 -0
- package/Libraries/StyleSheet/splitLayoutProps.js +1 -0
- package/Libraries/Text/Text.d.ts +5 -5
- package/Libraries/Text/Text.js +17 -10
- package/Libraries/Text/Text.windows.js +53 -20
- package/Libraries/Text/TextProps.windows.js +275 -0
- package/Libraries/TurboModule/TurboModuleRegistry.js +47 -7
- package/Libraries/TurboModule/samples/NativeSampleTurboModule.js +6 -0
- package/Libraries/Types/CoreEventTypes.d.ts +5 -2
- package/Libraries/Utilities/GlobalPerformanceLogger.js +2 -12
- package/Libraries/Utilities/NativeDeviceInfo.js +8 -9
- package/Libraries/Utilities/NativePlatformConstantsAndroid.js +23 -18
- package/Libraries/Utilities/NativePlatformConstantsIOS.js +16 -13
- package/Libraries/Utilities/NativePlatformConstantsWin.js +13 -10
- package/Libraries/Utilities/PerformanceLoggerContext.js +1 -1
- package/Libraries/Utilities/Platform.android.js +12 -8
- package/Libraries/Utilities/Platform.d.ts +1 -0
- package/Libraries/Utilities/Platform.flow.js +84 -0
- package/Libraries/Utilities/Platform.flow.windows.js +111 -0
- package/Libraries/Utilities/Platform.ios.js +12 -8
- package/Libraries/Utilities/Platform.windows.js +12 -8
- package/Libraries/Utilities/PolyfillFunctions.js +1 -1
- package/Libraries/Utilities/ReactNativeTestTools.js +1 -2
- package/Libraries/Utilities/SceneTracker.js +1 -1
- package/Libraries/Utilities/createPerformanceLogger.js +63 -32
- package/Libraries/Utilities/useColorScheme.js +7 -8
- package/Libraries/WebPerformance/MemoryInfo.js +1 -1
- package/Libraries/WebPerformance/NativePerformance.js +3 -8
- package/Libraries/WebPerformance/NativePerformanceObserver.js +4 -0
- package/Libraries/WebPerformance/Performance.js +42 -15
- package/Libraries/WebPerformance/PerformanceEntry.js +14 -6
- package/Libraries/WebPerformance/PerformanceEventTiming.js +18 -1
- package/Libraries/WebPerformance/ReactNativeStartupTiming.js +40 -14
- package/Libraries/WebPerformance/__mocks__/NativePerformance.js +4 -2
- package/Libraries/WebPerformance/__mocks__/NativePerformanceObserver.js +21 -3
- package/Libraries/__tests__/ViewWindows-test.js +3 -3
- package/Libraries/platform-types.d.ts +6 -2
- package/Libraries/promiseRejectionTrackingOptions.js +1 -3
- package/Libraries/vendor/emitter/EventEmitter.js +17 -17
- package/Microsoft.ReactNative/Composition.Input.idl +103 -0
- package/Microsoft.ReactNative/CompositionContext.idl +31 -8
- package/Microsoft.ReactNative/CompositionRootView.idl +8 -4
- package/Microsoft.ReactNative/CompositionSwitcher.idl +28 -17
- package/Microsoft.ReactNative/Fabric/AbiViewComponentDescriptor.cpp +15 -28
- package/Microsoft.ReactNative/Fabric/AbiViewComponentDescriptor.h +7 -10
- package/Microsoft.ReactNative/Fabric/ComponentView.h +42 -4
- package/Microsoft.ReactNative/Fabric/Composition/AbiCompositionViewComponentView.cpp +57 -4
- package/Microsoft.ReactNative/Fabric/Composition/AbiCompositionViewComponentView.h +22 -1
- package/Microsoft.ReactNative/Fabric/Composition/ActivityIndicatorComponentView.cpp +137 -0
- package/Microsoft.ReactNative/Fabric/Composition/ActivityIndicatorComponentView.h +59 -0
- package/Microsoft.ReactNative/Fabric/Composition/ComponentViewRegistry.cpp +8 -2
- package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.cpp +575 -0
- package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.h +170 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.cpp +890 -226
- package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.h +38 -6
- package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper_emptyimpl.cpp +79 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp +130 -27
- package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.h +6 -1
- package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +382 -228
- package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +35 -8
- package/Microsoft.ReactNative/Fabric/Composition/CompositionHelpers.h +46 -8
- package/Microsoft.ReactNative/Fabric/Composition/CompositionHwndHost.cpp +5 -21
- package/Microsoft.ReactNative/Fabric/Composition/CompositionHwndHost.h +1 -1
- package/Microsoft.ReactNative/Fabric/Composition/CompositionRootAutomationProvider.cpp +232 -4
- package/Microsoft.ReactNative/Fabric/Composition/CompositionRootAutomationProvider.h +36 -1
- package/Microsoft.ReactNative/Fabric/Composition/CompositionRootView.cpp +51 -14
- package/Microsoft.ReactNative/Fabric/Composition/CompositionRootView.h +15 -6
- package/Microsoft.ReactNative/Fabric/Composition/CompositionRootView_emptyimpl.cpp +123 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionUIService_emptyimpl.cpp +18 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +333 -137
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +52 -8
- package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.cpp +32 -26
- package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.h +5 -3
- package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp +183 -175
- package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.h +7 -4
- package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.cpp +101 -2
- package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.h +46 -2
- package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +36 -9
- package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.h +8 -2
- package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +247 -42
- package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.h +25 -8
- package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.cpp +78 -50
- package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.h +12 -4
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentDescriptor.h +26 -28
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +429 -89
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +24 -3
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputProps.cpp +1 -0
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputProps.h +3 -2
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.cpp +5 -7
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.h +4 -6
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputState.cpp +1 -7
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputState.h +1 -17
- package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp +74 -3
- package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.h +12 -0
- package/Microsoft.ReactNative/Fabric/Composition/UnimplementedNativeViewComponentView.cpp +53 -59
- package/Microsoft.ReactNative/Fabric/Composition/UnimplementedNativeViewComponentView.h +3 -2
- package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +5 -4
- package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.h +2 -1
- package/Microsoft.ReactNative/Fabric/ImageRequest.cpp +1 -1
- package/Microsoft.ReactNative/Fabric/ReactTaggedView.h +1 -1
- package/Microsoft.ReactNative/Fabric/WindowsComponentDescriptorRegistry.cpp +3 -4
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformTouch.h +10 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewEventEmitter.cpp +59 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewEventEmitter.h +31 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewProps.cpp +69 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewProps.h +25 -2
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewTraitsInitializer.h +23 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/KeyEvent.h +113 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/WindowsViewEvents.h +75 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/core/graphicsConversions.h +18 -21
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/Color.cpp +158 -7
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/Color.h +15 -17
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.cpp +1 -1
- package/Microsoft.ReactNative/GlyphViewManager.cpp +1 -1
- package/Microsoft.ReactNative/IJSValueReader.idl +2 -2
- package/Microsoft.ReactNative/IJSValueWriter.idl +2 -2
- package/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl +23 -1
- package/Microsoft.ReactNative/IReactContext.cpp +1 -1
- package/Microsoft.ReactNative/IReactNotificationService.cpp +4 -3
- package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +1 -4
- package/Microsoft.ReactNative/Modules/AlertModule.cpp +2 -2
- package/Microsoft.ReactNative/Modules/Animated/NativeAnimatedNodeManager.cpp +1 -2
- package/Microsoft.ReactNative/Modules/Animated/NativeAnimatedNodeManager.h +1 -1
- package/Microsoft.ReactNative/Modules/Animated/PropsAnimatedNode.cpp +3 -4
- package/Microsoft.ReactNative/Modules/AppStateModule.cpp +1 -1
- package/Microsoft.ReactNative/Modules/AppStateModule.h +2 -2
- package/Microsoft.ReactNative/Modules/AppearanceModule.h +1 -1
- package/Microsoft.ReactNative/Modules/DeviceInfoModule.cpp +4 -2
- package/Microsoft.ReactNative/Modules/DeviceInfoModule.h +1 -1
- package/Microsoft.ReactNative/Modules/I18nManagerModule.cpp +2 -2
- package/Microsoft.ReactNative/Modules/I18nManagerModule.h +1 -1
- package/Microsoft.ReactNative/Modules/NativeUIManager.cpp +21 -15
- package/Microsoft.ReactNative/Modules/PaperUIManagerModule.cpp +10 -6
- package/Microsoft.ReactNative/Modules/PaperUIManagerModule.h +4 -1
- package/Microsoft.ReactNative/QuirkSettings.idl +1 -1
- package/Microsoft.ReactNative/ReactApplication.cpp +13 -11
- package/Microsoft.ReactNative/ReactApplication.h +4 -4
- package/Microsoft.ReactNative/ReactCoreInjection.h +6 -5
- package/Microsoft.ReactNative/ReactHost/JSCallInvokerScheduler.cpp +2 -2
- package/Microsoft.ReactNative/ReactHost/MsoUtils.cpp +1 -1
- package/Microsoft.ReactNative/ReactHost/React.h +3 -6
- package/Microsoft.ReactNative/ReactHost/ReactHost.cpp +0 -16
- package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +5 -16
- package/Microsoft.ReactNative/ReactInstanceSettings.cpp +6 -5
- package/Microsoft.ReactNative/ReactInstanceSettings.h +7 -7
- package/Microsoft.ReactNative/ReactNativeHost.h +4 -4
- package/Microsoft.ReactNative/ReactRootView.cpp +5 -4
- package/Microsoft.ReactNative/ReactRootView.h +2 -2
- package/Microsoft.ReactNative/ReactSupport.h +1 -1
- package/Microsoft.ReactNative/RedBox.cpp +1 -1
- package/Microsoft.ReactNative/RedBoxHandler.idl +1 -1
- package/Microsoft.ReactNative/Utils/UwpPreparedScriptStore.h +1 -1
- package/Microsoft.ReactNative/Utils/ValueUtils.cpp +49 -21
- package/Microsoft.ReactNative/Utils/ValueUtils.h +2 -1
- package/Microsoft.ReactNative/Views/DynamicAutomationPeer.cpp +31 -59
- package/Microsoft.ReactNative/Views/DynamicAutomationPeer.h +3 -4
- package/Microsoft.ReactNative/Views/DynamicAutomationProperties.cpp +15 -46
- package/Microsoft.ReactNative/Views/DynamicAutomationProperties.h +5 -13
- package/Microsoft.ReactNative/Views/FlyoutViewManager.cpp +4 -4
- package/Microsoft.ReactNative/Views/FrameworkElementTransferProperties.cpp +2 -8
- package/Microsoft.ReactNative/Views/FrameworkElementViewManager.cpp +127 -86
- package/Microsoft.ReactNative/Views/ICompositionRootView.h +1 -1
- package/Microsoft.ReactNative/Views/Image/ImageViewManager.cpp +1 -1
- package/Microsoft.ReactNative/Views/Image/Microsoft.UI.Composition.Effects_Impl.h +2 -2
- package/Microsoft.ReactNative/Views/Image/ReactImage.cpp +1 -1
- package/Microsoft.ReactNative/Views/SIPEventHandler.cpp +5 -5
- package/Microsoft.ReactNative/Views/SIPEventHandler.h +1 -1
- package/Microsoft.ReactNative/Views/ShadowNodeBase.h +8 -5
- package/Microsoft.ReactNative/Views/SwitchViewManager.cpp +2 -2
- package/Microsoft.ReactNative/Views/Text/TextTransformVisitor.cpp +1 -1
- package/Microsoft.ReactNative/Views/TextInputViewManager.cpp +32 -14
- package/Microsoft.ReactNative/Views/TouchEventHandler.cpp +1 -1
- package/Microsoft.ReactNative/Views/ViewManagerBase.cpp +14 -2
- package/Microsoft.ReactNative/Views/ViewManagerBase.h +1 -1
- package/Microsoft.ReactNative/Views/ViewPanel.cpp +20 -219
- package/Microsoft.ReactNative/Views/ViewPanel.h +0 -30
- package/Microsoft.ReactNative/Views/ViewViewManager.cpp +17 -158
- package/Microsoft.ReactNative/Views/cppwinrt/DynamicAutomationPeer.idl +9 -12
- package/Microsoft.ReactNative/Views/cppwinrt/ViewPanel.idl +1 -9
- package/Microsoft.ReactNative/XamlHelper.cpp +1 -1
- package/Microsoft.ReactNative/XamlHelper.h +1 -1
- package/Microsoft.ReactNative/packages.lock.json +128 -0
- package/Microsoft.ReactNative.Cxx/JSI/JsiAbiApi.cpp +1 -1
- package/Microsoft.ReactNative.Cxx/JSI/JsiAbiApi.h +1 -1
- package/Microsoft.ReactNative.Cxx/JSI/JsiApiContext.cpp +2 -2
- package/Microsoft.ReactNative.Cxx/JSValue.h +2 -2
- package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems +0 -1
- package/Microsoft.ReactNative.Cxx/NativeModules.h +4 -4
- package/Microsoft.ReactNative.Cxx/ReactHandleHelper.h +1 -1
- package/Microsoft.ReactNative.Cxx/ReactNonAbiValue.h +2 -2
- package/Microsoft.ReactNative.Cxx/ReactNotificationService.h +10 -9
- package/Microsoft.ReactNative.Cxx/ReactPropertyBag.h +13 -12
- package/Microsoft.ReactNative.Managed/JSValueReaderGenerator.cs +5 -5
- package/Microsoft.ReactNative.Managed/JSValueWriterGenerator.cs +5 -5
- package/Microsoft.ReactNative.Managed/Microsoft.ReactNative.Managed.csproj +8 -2
- package/Microsoft.ReactNative.Managed/ReactPackageBuilderExtensions.cs +1 -1
- package/Microsoft.ReactNative.Managed/ReflectionReactPackageProvider.cs +1 -1
- package/Microsoft.ReactNative.Managed/packages.lock.json +9 -9
- package/Microsoft.ReactNative.Managed.CodeGen/CodeAnalyzer.cs +2 -0
- package/Microsoft.ReactNative.Managed.CodeGen/CodeGenerator.Module.cs +4 -2
- package/Microsoft.ReactNative.Managed.CodeGen/CodeGenerator.ViewManager.cs +1 -1
- package/Microsoft.ReactNative.Managed.CodeGen/DiagnosticDescriptors.cs +1 -1
- package/Microsoft.ReactNative.Managed.CodeGen/packages.lock.json +3197 -0
- package/Mso/compilerAdapters/compilerFeatures.h +1 -1
- package/Mso/compilerAdapters/functionDecorations.h +6 -6
- package/Mso/debugAssertApi/debugAssertDetails.h +1 -1
- package/Mso/dispatchQueue/dispatchQueue.h +3 -3
- package/Mso/motifCpp/motifCppTest.h +1 -1
- package/Mso/motifCpp/testCheck.h +1 -1
- package/Mso/oacr/oacr.h +1 -1
- package/Mso/smartPtr/smartPointerBase.h +1 -1
- package/Mso/src/dispatchQueue/looperScheduler.cpp +2 -2
- package/Mso/src/dispatchQueue/queueService.cpp +1 -1
- package/Mso/src/dispatchQueue/taskQueue.h +1 -1
- package/Mso/src/dispatchQueue/threadPoolScheduler_win.cpp +2 -2
- package/Mso/src/dispatchQueue/uiScheduler_winrt.cpp +122 -45
- package/Mso/src/eventWaitHandle/eventWaitHandleImpl_win.cpp +2 -2
- package/Mso/src/future/futureImpl.cpp +5 -5
- package/Mso/src/future/futureImpl.h +1 -1
- package/PropertySheets/External/Microsoft.ReactNative.Common.props +3 -0
- package/PropertySheets/External/{Microsoft.ReactNative.WinAppSDK.Common.props → Microsoft.ReactNative.Composition.Common.props} +2 -2
- package/PropertySheets/External/{Microsoft.ReactNative.WinAppSDK.CSharpApp.props → Microsoft.ReactNative.Composition.CppApp.props} +7 -10
- package/PropertySheets/External/Microsoft.ReactNative.Composition.CppApp.targets +19 -0
- package/PropertySheets/External/Microsoft.ReactNative.Composition.Package.props +14 -0
- package/PropertySheets/External/Microsoft.ReactNative.Composition.Package.targets +18 -0
- package/PropertySheets/External/Microsoft.ReactNative.WindowsSdk.Default.props +1 -1
- package/PropertySheets/Generated/PackageVersion.g.props +4 -4
- package/PropertySheets/HybridCRT.props +34 -0
- package/PropertySheets/JSEngine.props +1 -2
- package/PropertySheets/React.Cpp.props +0 -1
- package/PropertySheets/Warnings.props +1 -1
- package/PropertySheets/WinUI.props +1 -1
- package/ReactCommon/ReactCommon.vcxproj +15 -9
- package/ReactCommon/ReactCommon.vcxproj.filters +0 -3
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsi/jsi/test/testlib.cpp +32 -5
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/Bridging.h +20 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/YogaLayoutableShadowNode.cpp +1038 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/YogaStylableProps.cpp +228 -38
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/conversions.h +895 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/mounting/ShadowTree.cpp +543 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/uimanager/UIManagerBinding.cpp +1509 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/bits/NumericBitfield.h +67 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/config/Config.h +93 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/node/LayoutResults.h +88 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/node/Node.cpp +606 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/node/Node.h +344 -0
- package/ReactCommon/Yoga.cpp +497 -3895
- package/ReactCommon/packages.lock.json +30 -0
- package/Scripts/NuGetRestoreForceEvaluateAllSolutions.ps1 +22 -0
- package/Scripts/OfficeReact.Win32.nuspec +1 -0
- package/Scripts/rnw-dependencies.ps1 +79 -26
- package/Shared/BaseScriptStoreImpl.cpp +42 -13
- package/Shared/BaseScriptStoreImpl.h +1 -1
- package/Shared/Composition/AutoDraw.h +36 -0
- package/Shared/CxxMessageQueue.cpp +1 -1
- package/Shared/DevSupportManager.h +1 -1
- package/Shared/Hasher.cpp +64 -0
- package/Shared/Hasher.h +24 -0
- package/Shared/HermesRuntimeHolder.cpp +6 -6
- package/Shared/IDevSupportManager.h +1 -1
- package/Shared/JSI/ChakraApi.cpp +1 -1
- package/Shared/JSI/ChakraRuntime.cpp +10 -10
- package/Shared/JSI/ChakraRuntime.h +6 -6
- package/Shared/JSI/V8RuntimeHolder.cpp +1 -1
- package/Shared/Modules/IRequestBodyHandler.h +1 -1
- package/Shared/Modules/IUriHandler.h +1 -1
- package/Shared/Modules/PlatformConstantsModule.cpp +1 -1
- package/Shared/Modules/WebSocketModule.cpp +1 -1
- package/Shared/Networking/DefaultBlobResource.cpp +2 -2
- package/Shared/Networking/OriginPolicyHttpFilter.cpp +22 -16
- package/Shared/Networking/OriginPolicyHttpFilter.h +12 -11
- package/Shared/OInstance.cpp +3 -21
- package/Shared/OInstance.h +1 -1
- package/Shared/PackagerConnection.h +1 -1
- package/Shared/SafeLoadLibrary.cpp +8 -44
- package/Shared/SafeLoadLibrary.h +1 -5
- package/Shared/Shared.vcxitems +49 -19
- package/Shared/Shared.vcxitems.filters +24 -17
- package/Shared/Threading/BatchingQueueThread.cpp +5 -5
- package/Shared/Threading/BatchingQueueThread.h +4 -4
- package/Shared/TurboModuleManager.cpp +1 -1
- package/Shared/Utils.cpp +1 -1
- package/Shared/tracing/fbsystrace.h +1 -1
- package/codegen/NativeAnimatedModuleSpec.g.h +2 -0
- package/codegen/NativeAnimatedTurboModuleSpec.g.h +2 -0
- package/codegen/NativeAppStateSpec.g.h +11 -21
- package/codegen/NativeDeviceInfoSpec.g.h +4 -14
- package/codegen/NativeI18nManagerSpec.g.h +6 -16
- package/codegen/NativeIntersectionObserverSpec.g.h +96 -0
- package/codegen/NativeMutationObserverSpec.g.h +90 -0
- package/codegen/NativePerformanceObserverSpec.g.h +19 -13
- package/codegen/NativePerformanceSpec.g.h +6 -23
- package/codegen/NativePlatformConstantsAndroidSpec.g.h +22 -30
- package/codegen/NativePlatformConstantsIOSSpec.g.h +17 -25
- package/codegen/NativePlatformConstantsWinSpec.g.h +14 -22
- package/codegen/NativeSampleTurboModuleSpec.g.h +36 -0
- package/codegen/NativeSourceCodeSpec.g.h +3 -13
- package/codegen/react/components/rnwcore/EventEmitters.cpp +85 -58
- package/codegen/react/components/rnwcore/EventEmitters.h +17 -35
- package/codegen/react/components/rnwcore/Props.h +16 -17
- package/codegen/rnwcoreJSI-generated.cpp +1462 -319
- package/codegen/rnwcoreJSI.h +1609 -462
- package/fmt/packages.lock.json +13 -0
- package/index.windows.js +3 -3
- package/{Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.ios.js → jest/ReactNativeInternalFeatureFlagsMock.js} +2 -1
- package/jest/__tests__/setup-test.js +18 -0
- package/jest/mockModal.js +6 -4
- package/jest/setup.js +61 -30
- package/just-task.js +1 -0
- package/package.json +37 -42
- package/template/cs-app/proj/MyApp.csproj +0 -1
- package/template/cs-lib/proj/MyLib.csproj +0 -1
- package/templates/.clang-format +4 -0
- package/templates/cpp-app/metro.config.js +51 -0
- package/templates/cpp-app/template.config.js +119 -0
- package/templates/cpp-app/windows/ExperimentalFeatures.props +12 -0
- package/templates/cpp-app/windows/MyApp/MyApp.cpp +284 -0
- package/templates/cpp-app/windows/MyApp/MyApp.h +3 -0
- package/templates/cpp-app/windows/MyApp/MyApp.ico +0 -0
- package/templates/cpp-app/windows/MyApp/MyApp.rc +0 -0
- package/templates/cpp-app/windows/MyApp/MyApp.vcxproj +142 -0
- package/templates/cpp-app/windows/MyApp/MyApp.vcxproj.filters +55 -0
- package/templates/cpp-app/windows/MyApp/_gitignore +1 -0
- package/templates/cpp-app/windows/MyApp/pch.cpp +1 -0
- package/templates/cpp-app/windows/MyApp/pch.h +35 -0
- package/templates/cpp-app/windows/MyApp/resource.h +18 -0
- package/templates/cpp-app/windows/MyApp/small.ico +0 -0
- package/templates/cpp-app/windows/MyApp/targetver.h +8 -0
- package/templates/cpp-app/windows/MyApp.Package/Images/LockScreenLogo.scale-200.png +0 -0
- package/templates/cpp-app/windows/MyApp.Package/Images/SplashScreen.scale-200.png +0 -0
- package/templates/cpp-app/windows/MyApp.Package/Images/Square150x150Logo.scale-200.png +0 -0
- package/templates/cpp-app/windows/MyApp.Package/Images/Square44x44Logo.scale-200.png +0 -0
- package/templates/cpp-app/windows/MyApp.Package/Images/Square44x44Logo.targetsize-24_altform-unplated.png +0 -0
- package/templates/cpp-app/windows/MyApp.Package/Images/StoreLogo.png +0 -0
- package/templates/cpp-app/windows/MyApp.Package/Images/Wide310x150Logo.scale-200.png +0 -0
- package/templates/cpp-app/windows/MyApp.Package/MyApp.Package.wapproj +78 -0
- package/{template/cs-app-WinAppSDK/MyApp → templates/cpp-app/windows/MyApp.Package}/Package.appxmanifest +9 -8
- package/templates/cpp-app/windows/MyApp.sln +176 -0
- package/templates/cpp-app/windows/_gitignore +41 -0
- package/templates/old/generateWrapper.js +67 -0
- package/templates/old/uwp-cpp-app/template.config.js +15 -0
- package/templates/old/uwp-cpp-lib/template.config.js +15 -0
- package/templates/old/uwp-cs-app/template.config.js +15 -0
- package/templates/old/uwp-cs-lib/template.config.js +15 -0
- package/types/experimental.d.ts +44 -0
- package/types/index.d.ts +2 -1
- package/types/modules/Devtools.d.ts +1 -0
- package/types/modules/globals.d.ts +16 -1
- package/Libraries/Components/View/ViewWindows.d.ts +0 -19
- package/Libraries/Components/View/ViewWindows.js +0 -22
- package/Libraries/Components/View/ViewWindows.js.map +0 -1
- package/Libraries/Components/View/ViewWindowsProps.d.ts +0 -69
- package/Libraries/Components/View/ViewWindowsProps.js +0 -8
- package/Libraries/Components/View/ViewWindowsProps.js.map +0 -1
- package/Libraries/Utilities/AcessibilityMapping.js +0 -154
- package/Libraries/Utilities/NativeDevSplitBundleLoader.js +0 -19
- package/Libraries/Utilities/useColorScheme.windows.js +0 -26
- package/Microsoft.ReactNative/Fabric/platform/react/components/view/windows/WindowsViewProps.cpp +0 -61
- package/Microsoft.ReactNative/Fabric/platform/react/components/view/windows/WindowsViewProps.h +0 -34
- package/Microsoft.ReactNative/Fabric/platform/react/components/view/windows/primitives.h +0 -42
- package/PropertySheets/External/Microsoft.ReactNative.WinAppSDK.CSharp.PackageReferences.props +0 -11
- package/PropertySheets/External/Microsoft.ReactNative.WinAppSDK.CSharpApp.targets +0 -51
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/TouchEventEmitter.cpp +0 -237
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/TouchEventEmitter.h +0 -59
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/ViewEventEmitter.cpp +0 -159
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/ViewEventEmitter.h +0 -94
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/ViewProps.cpp +0 -465
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/ViewProps.h +0 -116
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/ViewShadowNode.cpp +0 -98
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/primitives.h +0 -326
- package/Scripts/Microsoft.ReactNative.WindowsAppSDK.nuspec +0 -30
- package/Shared/V8JSIRuntimeHolder.cpp +0 -71
- package/Shared/V8JSIRuntimeHolder.h +0 -56
- package/codegen/NativeDevSplitBundleLoaderSpec.g.h +0 -34
- package/template/cs-app-WinAppSDK/MyApp/App.xaml +0 -16
- package/template/cs-app-WinAppSDK/MyApp/App.xaml.cs +0 -70
- package/template/cs-app-WinAppSDK/MyApp/MainWindow.xaml +0 -14
- package/template/cs-app-WinAppSDK/MyApp/MainWindow.xaml.cs +0 -38
- package/template/cs-app-WinAppSDK/MyApp/Properties/PublishProfiles/win10-arm64.pubxml +0 -19
- package/template/cs-app-WinAppSDK/MyApp/Properties/PublishProfiles/win10-x64.pubxml +0 -19
- package/template/cs-app-WinAppSDK/MyApp/Properties/PublishProfiles/win10-x86.pubxml +0 -19
- package/template/cs-app-WinAppSDK/MyApp/Properties/launchSettings.json +0 -10
- package/template/cs-app-WinAppSDK/MyApp/app.manifest +0 -15
- package/template/cs-app-WinAppSDK/proj/ExperimentalFeatures.props +0 -24
- package/template/cs-app-WinAppSDK/proj/MyApp.csproj +0 -53
- package/template/cs-app-WinAppSDK/proj/MyApp.sln +0 -43
- package/template/cs-app-WinAppSDK/proj/NuGet_Config +0 -19
- /package/Libraries/Components/DrawerAndroid/{DrawerLayoutAndroid.ios.js → DrawerLayoutAndroid.js} +0 -0
- /package/Libraries/{Renderer/public → ReactNative/ReactFabricPublicInstance}/ReactFabricPublicInstanceUtils.js +0 -0
|
@@ -0,0 +1,1038 @@
|
|
|
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 "YogaLayoutableShadowNode.h"
|
|
9
|
+
#include <logger/react_native_log.h>
|
|
10
|
+
#include <react/debug/flags.h>
|
|
11
|
+
#include <react/debug/react_native_assert.h>
|
|
12
|
+
#include <react/renderer/components/view/ViewProps.h>
|
|
13
|
+
#include <react/renderer/components/view/ViewShadowNode.h>
|
|
14
|
+
#include <react/renderer/components/view/conversions.h>
|
|
15
|
+
#include <react/renderer/core/LayoutConstraints.h>
|
|
16
|
+
#include <react/renderer/core/LayoutContext.h>
|
|
17
|
+
#include <react/renderer/core/TraitCast.h>
|
|
18
|
+
#include <react/renderer/debug/DebugStringConvertibleItem.h>
|
|
19
|
+
#include <react/renderer/debug/SystraceSection.h>
|
|
20
|
+
#include <react/utils/CoreFeatures.h>
|
|
21
|
+
#include <yoga/Yoga.h>
|
|
22
|
+
#include <algorithm>
|
|
23
|
+
#include <limits>
|
|
24
|
+
#include <memory>
|
|
25
|
+
|
|
26
|
+
namespace facebook::react {
|
|
27
|
+
|
|
28
|
+
static int FabricDefaultYogaLog(
|
|
29
|
+
const YGConfigConstRef /*unused*/,
|
|
30
|
+
const YGNodeConstRef /*unused*/,
|
|
31
|
+
YGLogLevel level,
|
|
32
|
+
const char* format,
|
|
33
|
+
va_list args) {
|
|
34
|
+
va_list args_copy;
|
|
35
|
+
va_copy(args_copy, args);
|
|
36
|
+
|
|
37
|
+
// Adding 1 to add space for terminating null character.
|
|
38
|
+
int size_s = vsnprintf(nullptr, 0, format, args);
|
|
39
|
+
auto size = static_cast<size_t>(size_s);
|
|
40
|
+
std::vector<char> buffer(size);
|
|
41
|
+
|
|
42
|
+
vsnprintf(buffer.data(), size, format, args_copy);
|
|
43
|
+
switch (level) {
|
|
44
|
+
case YGLogLevelError:
|
|
45
|
+
react_native_log_error(buffer.data());
|
|
46
|
+
break;
|
|
47
|
+
case YGLogLevelFatal:
|
|
48
|
+
react_native_log_fatal(buffer.data());
|
|
49
|
+
break;
|
|
50
|
+
case YGLogLevelWarn:
|
|
51
|
+
react_native_log_warn(buffer.data());
|
|
52
|
+
break;
|
|
53
|
+
case YGLogLevelInfo:
|
|
54
|
+
case YGLogLevelDebug:
|
|
55
|
+
case YGLogLevelVerbose:
|
|
56
|
+
default:
|
|
57
|
+
react_native_log_info(buffer.data());
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return size_s;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
thread_local LayoutContext threadLocalLayoutContext;
|
|
64
|
+
|
|
65
|
+
ShadowNodeTraits YogaLayoutableShadowNode::BaseTraits() {
|
|
66
|
+
auto traits = LayoutableShadowNode::BaseTraits();
|
|
67
|
+
traits.set(IdentifierTrait());
|
|
68
|
+
return traits;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
ShadowNodeTraits::Trait YogaLayoutableShadowNode::IdentifierTrait() {
|
|
72
|
+
return ShadowNodeTraits::Trait::YogaLayoutableKind;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
YogaLayoutableShadowNode::YogaLayoutableShadowNode(
|
|
76
|
+
const ShadowNodeFragment& fragment,
|
|
77
|
+
const ShadowNodeFamily::Shared& family,
|
|
78
|
+
ShadowNodeTraits traits)
|
|
79
|
+
: LayoutableShadowNode(fragment, family, traits),
|
|
80
|
+
yogaConfig_(FabricDefaultYogaLog),
|
|
81
|
+
yogaNode_(&initializeYogaConfig(yogaConfig_)) {
|
|
82
|
+
yogaNode_.setContext(this);
|
|
83
|
+
|
|
84
|
+
// Newly created node must be `dirty` just because it is new.
|
|
85
|
+
// This is not a default for `yoga::Node`.
|
|
86
|
+
yogaNode_.setDirty(true);
|
|
87
|
+
|
|
88
|
+
if (getTraits().check(ShadowNodeTraits::Trait::MeasurableYogaNode)) {
|
|
89
|
+
react_native_assert(
|
|
90
|
+
getTraits().check(ShadowNodeTraits::Trait::LeafYogaNode));
|
|
91
|
+
|
|
92
|
+
yogaNode_.setMeasureFunc(
|
|
93
|
+
YogaLayoutableShadowNode::yogaNodeMeasureCallbackConnector);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
updateYogaProps();
|
|
97
|
+
updateYogaChildren();
|
|
98
|
+
|
|
99
|
+
ensureConsistency();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
YogaLayoutableShadowNode::YogaLayoutableShadowNode(
|
|
103
|
+
const ShadowNode& sourceShadowNode,
|
|
104
|
+
const ShadowNodeFragment& fragment)
|
|
105
|
+
: LayoutableShadowNode(sourceShadowNode, fragment),
|
|
106
|
+
yogaConfig_(FabricDefaultYogaLog),
|
|
107
|
+
yogaNode_(static_cast<const YogaLayoutableShadowNode&>(sourceShadowNode)
|
|
108
|
+
.yogaNode_) {
|
|
109
|
+
// Note, cloned `yoga::Node` instance (copied using copy-constructor) inherits
|
|
110
|
+
// dirty flag, measure function, and other properties being set originally in
|
|
111
|
+
// the `YogaLayoutableShadowNode` constructor above.
|
|
112
|
+
|
|
113
|
+
react_native_assert(
|
|
114
|
+
static_cast<const YogaLayoutableShadowNode&>(sourceShadowNode)
|
|
115
|
+
.yogaNode_.isDirty() == yogaNode_.isDirty() &&
|
|
116
|
+
"Yoga node must inherit dirty flag.");
|
|
117
|
+
|
|
118
|
+
if (!getTraits().check(ShadowNodeTraits::Trait::LeafYogaNode)) {
|
|
119
|
+
for (auto& child : getChildren()) {
|
|
120
|
+
if (auto layoutableChild = traitCast<YogaLayoutableShadowNode>(child)) {
|
|
121
|
+
yogaLayoutableChildren_.push_back(layoutableChild);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
YGConfigConstRef previousConfig =
|
|
127
|
+
&static_cast<const YogaLayoutableShadowNode&>(sourceShadowNode)
|
|
128
|
+
.yogaConfig_;
|
|
129
|
+
|
|
130
|
+
yogaNode_.setContext(this);
|
|
131
|
+
yogaNode_.setOwner(nullptr);
|
|
132
|
+
yogaNode_.setConfig(&initializeYogaConfig(yogaConfig_, previousConfig));
|
|
133
|
+
updateYogaChildrenOwnersIfNeeded();
|
|
134
|
+
|
|
135
|
+
// This is the only legit place where we can dirty cloned Yoga node.
|
|
136
|
+
// If we do it later, ancestor nodes will not be able to observe this and
|
|
137
|
+
// dirty (and clone) themselves as a result.
|
|
138
|
+
if (getTraits().check(ShadowNodeTraits::Trait::DirtyYogaNode) ||
|
|
139
|
+
getTraits().check(ShadowNodeTraits::Trait::MeasurableYogaNode)) {
|
|
140
|
+
yogaNode_.setDirty(true);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// We do not need to reconfigure this subtree before the next layout pass if
|
|
144
|
+
// the previous node with the same props and children has already been
|
|
145
|
+
// configured.
|
|
146
|
+
if (!fragment.props && !fragment.children) {
|
|
147
|
+
yogaTreeHasBeenConfigured_ =
|
|
148
|
+
static_cast<const YogaLayoutableShadowNode&>(sourceShadowNode)
|
|
149
|
+
.yogaTreeHasBeenConfigured_;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (fragment.props) {
|
|
153
|
+
updateYogaProps();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (fragment.children) {
|
|
157
|
+
updateYogaChildren();
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
ensureConsistency();
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
void YogaLayoutableShadowNode::cleanLayout() {
|
|
164
|
+
yogaNode_.setDirty(false);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
void YogaLayoutableShadowNode::dirtyLayout() {
|
|
168
|
+
yogaNode_.setDirty(true);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
bool YogaLayoutableShadowNode::getIsLayoutClean() const {
|
|
172
|
+
return !yogaNode_.isDirty();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
#pragma mark - Mutating Methods
|
|
176
|
+
|
|
177
|
+
void YogaLayoutableShadowNode::enableMeasurement() {
|
|
178
|
+
ensureUnsealed();
|
|
179
|
+
|
|
180
|
+
yogaNode_.setMeasureFunc(
|
|
181
|
+
YogaLayoutableShadowNode::yogaNodeMeasureCallbackConnector);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
void YogaLayoutableShadowNode::appendYogaChild(
|
|
185
|
+
const YogaLayoutableShadowNode::Shared& childNode) {
|
|
186
|
+
// The caller must check this before calling this method.
|
|
187
|
+
react_native_assert(
|
|
188
|
+
!getTraits().check(ShadowNodeTraits::Trait::LeafYogaNode));
|
|
189
|
+
|
|
190
|
+
ensureYogaChildrenLookFine();
|
|
191
|
+
|
|
192
|
+
yogaLayoutableChildren_.push_back(childNode);
|
|
193
|
+
yogaNode_.insertChild(&childNode->yogaNode_, yogaNode_.getChildren().size());
|
|
194
|
+
|
|
195
|
+
ensureYogaChildrenLookFine();
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
void YogaLayoutableShadowNode::adoptYogaChild(size_t index) {
|
|
199
|
+
ensureUnsealed();
|
|
200
|
+
ensureYogaChildrenLookFine();
|
|
201
|
+
|
|
202
|
+
// The caller must check this before calling this method.
|
|
203
|
+
react_native_assert(
|
|
204
|
+
!getTraits().check(ShadowNodeTraits::Trait::LeafYogaNode));
|
|
205
|
+
|
|
206
|
+
auto& childNode =
|
|
207
|
+
traitCast<const YogaLayoutableShadowNode&>(*getChildren().at(index));
|
|
208
|
+
|
|
209
|
+
if (childNode.yogaNode_.getOwner() == nullptr) {
|
|
210
|
+
// The child node is not owned.
|
|
211
|
+
childNode.yogaNode_.setOwner(&yogaNode_);
|
|
212
|
+
// At this point the child yoga node must be already inserted by the caller.
|
|
213
|
+
// react_native_assert(layoutableChildNode.yogaNode_.isDirty());
|
|
214
|
+
} else {
|
|
215
|
+
// The child is owned by some other node, we need to clone that.
|
|
216
|
+
// TODO: At this point, React has wrong reference to the node. (T138668036)
|
|
217
|
+
auto clonedChildNode = childNode.clone({});
|
|
218
|
+
|
|
219
|
+
// Replace the child node with a newly cloned one in the children list.
|
|
220
|
+
replaceChild(childNode, clonedChildNode, static_cast<int32_t>(index));
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
ensureYogaChildrenLookFine();
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
void YogaLayoutableShadowNode::appendChild(
|
|
227
|
+
const ShadowNode::Shared& childNode) {
|
|
228
|
+
ensureUnsealed();
|
|
229
|
+
ensureConsistency();
|
|
230
|
+
|
|
231
|
+
// Calling the base class (`ShadowNode`) method.
|
|
232
|
+
LayoutableShadowNode::appendChild(childNode);
|
|
233
|
+
|
|
234
|
+
if (getTraits().check(ShadowNodeTraits::Trait::LeafYogaNode)) {
|
|
235
|
+
// This node is a declared leaf.
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (auto yogaLayoutableChild =
|
|
240
|
+
traitCast<YogaLayoutableShadowNode>(childNode)) {
|
|
241
|
+
// Here we don't have information about the previous structure of the node
|
|
242
|
+
// (if it that existed before), so we don't have anything to compare the
|
|
243
|
+
// Yoga node with (like a previous version of this node). Therefore we must
|
|
244
|
+
// dirty the node.
|
|
245
|
+
yogaNode_.setDirty(true);
|
|
246
|
+
|
|
247
|
+
// Appending the Yoga node.
|
|
248
|
+
appendYogaChild(yogaLayoutableChild);
|
|
249
|
+
|
|
250
|
+
ensureYogaChildrenLookFine();
|
|
251
|
+
ensureYogaChildrenAlignment();
|
|
252
|
+
|
|
253
|
+
// Adopting the Yoga node.
|
|
254
|
+
adoptYogaChild(getChildren().size() - 1);
|
|
255
|
+
|
|
256
|
+
ensureConsistency();
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
void YogaLayoutableShadowNode::replaceChild(
|
|
261
|
+
const ShadowNode& oldChild,
|
|
262
|
+
const ShadowNode::Shared& newChild,
|
|
263
|
+
int32_t suggestedIndex) {
|
|
264
|
+
LayoutableShadowNode::replaceChild(oldChild, newChild, suggestedIndex);
|
|
265
|
+
|
|
266
|
+
ensureUnsealed();
|
|
267
|
+
ensureYogaChildrenLookFine();
|
|
268
|
+
|
|
269
|
+
auto layoutableOldChild =
|
|
270
|
+
traitCast<const YogaLayoutableShadowNode*>(&oldChild);
|
|
271
|
+
auto layoutableNewChild = traitCast<YogaLayoutableShadowNode>(newChild);
|
|
272
|
+
|
|
273
|
+
if (layoutableOldChild == nullptr && layoutableNewChild == nullptr) {
|
|
274
|
+
// No need to mutate yogaLayoutableChildren_
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
bool suggestedIndexAccurate = suggestedIndex >= 0 &&
|
|
279
|
+
suggestedIndex < static_cast<int32_t>(yogaLayoutableChildren_.size()) &&
|
|
280
|
+
yogaLayoutableChildren_[suggestedIndex].get() == layoutableOldChild;
|
|
281
|
+
|
|
282
|
+
auto oldChildIter = suggestedIndexAccurate
|
|
283
|
+
? yogaLayoutableChildren_.begin() + suggestedIndex
|
|
284
|
+
: std::find_if(
|
|
285
|
+
yogaLayoutableChildren_.begin(),
|
|
286
|
+
yogaLayoutableChildren_.end(),
|
|
287
|
+
[&](const YogaLayoutableShadowNode::Shared& layoutableChild) {
|
|
288
|
+
return layoutableChild.get() == layoutableOldChild;
|
|
289
|
+
});
|
|
290
|
+
auto oldChildIndex =
|
|
291
|
+
static_cast<int32_t>(oldChildIter - yogaLayoutableChildren_.begin());
|
|
292
|
+
|
|
293
|
+
if (oldChildIter == yogaLayoutableChildren_.end()) {
|
|
294
|
+
// oldChild does not exist as part of our node
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if (layoutableNewChild) {
|
|
299
|
+
// Both children are layoutable, replace the old one with the new one
|
|
300
|
+
react_native_assert(layoutableNewChild->yogaNode_.getOwner() == nullptr);
|
|
301
|
+
layoutableNewChild->yogaNode_.setOwner(&yogaNode_);
|
|
302
|
+
*oldChildIter = layoutableNewChild;
|
|
303
|
+
yogaNode_.replaceChild(&layoutableNewChild->yogaNode_, oldChildIndex);
|
|
304
|
+
} else {
|
|
305
|
+
// Layoutable child replaced with non layoutable child. Remove the previous
|
|
306
|
+
// child from the layoutable children list.
|
|
307
|
+
yogaLayoutableChildren_.erase(oldChildIter);
|
|
308
|
+
yogaNode_.removeChild(oldChildIndex);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
ensureYogaChildrenLookFine();
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
bool YogaLayoutableShadowNode::doesOwn(
|
|
315
|
+
const YogaLayoutableShadowNode& child) const {
|
|
316
|
+
return child.yogaNode_.getOwner() == &yogaNode_;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
void YogaLayoutableShadowNode::updateYogaChildrenOwnersIfNeeded() {
|
|
320
|
+
for (auto& childYogaNode : yogaNode_.getChildren()) {
|
|
321
|
+
if (childYogaNode->getOwner() == &yogaNode_) {
|
|
322
|
+
childYogaNode->setOwner(
|
|
323
|
+
reinterpret_cast<yoga::Node*>(0xBADC0FFEE0DDF00D));
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
void YogaLayoutableShadowNode::updateYogaChildren() {
|
|
329
|
+
if (getTraits().check(ShadowNodeTraits::Trait::LeafYogaNode)) {
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
ensureUnsealed();
|
|
334
|
+
|
|
335
|
+
bool isClean = !yogaNode_.isDirty() &&
|
|
336
|
+
getChildren().size() == yogaNode_.getChildren().size();
|
|
337
|
+
|
|
338
|
+
auto oldYogaChildren =
|
|
339
|
+
isClean ? yogaNode_.getChildren() : std::vector<yoga::Node*>{};
|
|
340
|
+
|
|
341
|
+
yogaNode_.setChildren({});
|
|
342
|
+
yogaLayoutableChildren_.clear();
|
|
343
|
+
|
|
344
|
+
for (size_t i = 0; i < getChildren().size(); i++) {
|
|
345
|
+
if (auto yogaLayoutableChild =
|
|
346
|
+
traitCast<YogaLayoutableShadowNode>(getChildren()[i])) {
|
|
347
|
+
appendYogaChild(yogaLayoutableChild);
|
|
348
|
+
adoptYogaChild(i);
|
|
349
|
+
|
|
350
|
+
if (isClean) {
|
|
351
|
+
auto yogaChildIndex = yogaLayoutableChildren_.size() - 1;
|
|
352
|
+
auto& oldYogaChildNode = *oldYogaChildren.at(yogaChildIndex);
|
|
353
|
+
auto& newYogaChildNode =
|
|
354
|
+
yogaLayoutableChildren_.at(yogaChildIndex)->yogaNode_;
|
|
355
|
+
|
|
356
|
+
isClean = isClean && !newYogaChildNode.isDirty() &&
|
|
357
|
+
(newYogaChildNode.getStyle() == oldYogaChildNode.getStyle());
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
react_native_assert(
|
|
363
|
+
yogaLayoutableChildren_.size() == yogaNode_.getChildren().size());
|
|
364
|
+
|
|
365
|
+
yogaNode_.setDirty(!isClean);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
void YogaLayoutableShadowNode::updateYogaProps() {
|
|
369
|
+
ensureUnsealed();
|
|
370
|
+
|
|
371
|
+
auto props = static_cast<const YogaStylableProps&>(*props_);
|
|
372
|
+
auto styleResult = applyAliasedProps(props.yogaStyle, props);
|
|
373
|
+
|
|
374
|
+
// Resetting `dirty` flag only if `yogaStyle` portion of `Props` was changed.
|
|
375
|
+
if (!yogaNode_.isDirty() && (styleResult != yogaNode_.getStyle())) {
|
|
376
|
+
yogaNode_.setDirty(true);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
yogaNode_.setStyle(styleResult);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/*static*/ yoga::Style YogaLayoutableShadowNode::applyAliasedProps(
|
|
383
|
+
const yoga::Style& baseStyle,
|
|
384
|
+
const YogaStylableProps& props) {
|
|
385
|
+
yoga::Style result{baseStyle};
|
|
386
|
+
|
|
387
|
+
// Aliases with precedence
|
|
388
|
+
if (!props.inset.isUndefined()) {
|
|
389
|
+
result.position()[YGEdgeAll] = props.inset;
|
|
390
|
+
}
|
|
391
|
+
if (!props.insetBlock.isUndefined()) {
|
|
392
|
+
result.position()[YGEdgeVertical] = props.insetBlock;
|
|
393
|
+
}
|
|
394
|
+
if (!props.insetInline.isUndefined()) {
|
|
395
|
+
result.position()[YGEdgeHorizontal] = props.insetInline;
|
|
396
|
+
}
|
|
397
|
+
if (!props.insetInlineEnd.isUndefined()) {
|
|
398
|
+
result.position()[YGEdgeEnd] = props.insetInlineEnd;
|
|
399
|
+
}
|
|
400
|
+
if (!props.insetInlineStart.isUndefined()) {
|
|
401
|
+
result.position()[YGEdgeStart] = props.insetInlineStart;
|
|
402
|
+
}
|
|
403
|
+
if (!props.marginInline.isUndefined()) {
|
|
404
|
+
result.margin()[YGEdgeHorizontal] = props.marginInline;
|
|
405
|
+
}
|
|
406
|
+
if (!props.marginInlineStart.isUndefined()) {
|
|
407
|
+
result.margin()[YGEdgeStart] = props.marginInlineStart;
|
|
408
|
+
}
|
|
409
|
+
if (!props.marginInlineEnd.isUndefined()) {
|
|
410
|
+
result.margin()[YGEdgeEnd] = props.marginInlineEnd;
|
|
411
|
+
}
|
|
412
|
+
if (!props.marginBlock.isUndefined()) {
|
|
413
|
+
result.margin()[YGEdgeVertical] = props.marginBlock;
|
|
414
|
+
}
|
|
415
|
+
if (!props.paddingInline.isUndefined()) {
|
|
416
|
+
result.padding()[YGEdgeHorizontal] = props.paddingInline;
|
|
417
|
+
}
|
|
418
|
+
if (!props.paddingInlineStart.isUndefined()) {
|
|
419
|
+
result.padding()[YGEdgeStart] = props.paddingInlineStart;
|
|
420
|
+
}
|
|
421
|
+
if (!props.paddingInlineEnd.isUndefined()) {
|
|
422
|
+
result.padding()[YGEdgeEnd] = props.paddingInlineEnd;
|
|
423
|
+
}
|
|
424
|
+
if (!props.paddingBlock.isUndefined()) {
|
|
425
|
+
result.padding()[YGEdgeVertical] = props.paddingBlock;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
// Aliases without precedence
|
|
429
|
+
if (CompactValue(result.position()[YGEdgeBottom]).isUndefined()) {
|
|
430
|
+
result.position()[YGEdgeBottom] = props.insetBlockEnd;
|
|
431
|
+
}
|
|
432
|
+
if (CompactValue(result.position()[YGEdgeTop]).isUndefined()) {
|
|
433
|
+
result.position()[YGEdgeTop] = props.insetBlockStart;
|
|
434
|
+
}
|
|
435
|
+
if (CompactValue(result.margin()[YGEdgeTop]).isUndefined()) {
|
|
436
|
+
result.margin()[YGEdgeTop] = props.marginBlockStart;
|
|
437
|
+
}
|
|
438
|
+
if (CompactValue(result.margin()[YGEdgeBottom]).isUndefined()) {
|
|
439
|
+
result.margin()[YGEdgeBottom] = props.marginBlockEnd;
|
|
440
|
+
}
|
|
441
|
+
if (CompactValue(result.padding()[YGEdgeTop]).isUndefined()) {
|
|
442
|
+
result.padding()[YGEdgeTop] = props.paddingBlockStart;
|
|
443
|
+
}
|
|
444
|
+
if (CompactValue(result.padding()[YGEdgeBottom]).isUndefined()) {
|
|
445
|
+
result.padding()[YGEdgeBottom] = props.paddingBlockEnd;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
return result;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
void YogaLayoutableShadowNode::configureYogaTree(
|
|
452
|
+
float pointScaleFactor,
|
|
453
|
+
YGErrata defaultErrata,
|
|
454
|
+
bool swapLeftAndRight) {
|
|
455
|
+
ensureUnsealed();
|
|
456
|
+
|
|
457
|
+
// Set state on our own Yoga node
|
|
458
|
+
YGErrata errata = resolveErrata(defaultErrata);
|
|
459
|
+
YGConfigSetErrata(&yogaConfig_, errata);
|
|
460
|
+
YGConfigSetPointScaleFactor(&yogaConfig_, pointScaleFactor);
|
|
461
|
+
|
|
462
|
+
// TODO: `swapLeftAndRight` modified backing props and cannot be undone
|
|
463
|
+
if (swapLeftAndRight) {
|
|
464
|
+
swapStyleLeftAndRight();
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
yogaTreeHasBeenConfigured_ = true;
|
|
468
|
+
|
|
469
|
+
// Recursively propagate the configuration to child nodes. If a child was
|
|
470
|
+
// already configured as part of a previous ShadowTree generation, we only
|
|
471
|
+
// need to reconfigure it if the context values passed to the Node have
|
|
472
|
+
// changed.
|
|
473
|
+
for (size_t i = 0; i < yogaLayoutableChildren_.size(); i++) {
|
|
474
|
+
const auto& child = *yogaLayoutableChildren_[i];
|
|
475
|
+
auto childLayoutMetrics = child.getLayoutMetrics();
|
|
476
|
+
auto childErrata =
|
|
477
|
+
YGConfigGetErrata(const_cast<yoga::Config*>(&child.yogaConfig_));
|
|
478
|
+
|
|
479
|
+
if (child.yogaTreeHasBeenConfigured_ &&
|
|
480
|
+
childLayoutMetrics.pointScaleFactor == pointScaleFactor &&
|
|
481
|
+
childLayoutMetrics.wasLeftAndRightSwapped == swapLeftAndRight &&
|
|
482
|
+
childErrata == child.resolveErrata(errata)) {
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
if (doesOwn(child)) {
|
|
487
|
+
auto& mutableChild = const_cast<YogaLayoutableShadowNode&>(child);
|
|
488
|
+
mutableChild.configureYogaTree(
|
|
489
|
+
pointScaleFactor, child.resolveErrata(errata), swapLeftAndRight);
|
|
490
|
+
} else {
|
|
491
|
+
cloneChildInPlace(i).configureYogaTree(
|
|
492
|
+
pointScaleFactor, errata, swapLeftAndRight);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
YGErrata YogaLayoutableShadowNode::resolveErrata(YGErrata defaultErrata) const {
|
|
498
|
+
if (auto viewShadowNode = traitCast<const ViewShadowNode*>(this)) {
|
|
499
|
+
const auto& props = viewShadowNode->getConcreteProps();
|
|
500
|
+
switch (props.experimental_layoutConformance) {
|
|
501
|
+
case LayoutConformance::Classic:
|
|
502
|
+
return YGErrataAll;
|
|
503
|
+
case LayoutConformance::Strict:
|
|
504
|
+
return YGErrataNone;
|
|
505
|
+
case LayoutConformance::Undefined:
|
|
506
|
+
return defaultErrata;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
return defaultErrata;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
YogaLayoutableShadowNode& YogaLayoutableShadowNode::cloneChildInPlace(
|
|
514
|
+
size_t layoutableChildIndex) {
|
|
515
|
+
ensureUnsealed();
|
|
516
|
+
|
|
517
|
+
const auto& childNode = *yogaLayoutableChildren_[layoutableChildIndex];
|
|
518
|
+
|
|
519
|
+
// TODO: Why does this not use `ShadowNodeFragment::statePlaceholder()` like
|
|
520
|
+
// `adoptYogaChild()`?
|
|
521
|
+
auto clonedChildNode = childNode.clone(
|
|
522
|
+
{ShadowNodeFragment::propsPlaceholder(),
|
|
523
|
+
ShadowNodeFragment::childrenPlaceholder(),
|
|
524
|
+
childNode.getState()});
|
|
525
|
+
|
|
526
|
+
replaceChild(
|
|
527
|
+
childNode, clonedChildNode, static_cast<int32_t>(layoutableChildIndex));
|
|
528
|
+
return static_cast<YogaLayoutableShadowNode&>(*clonedChildNode);
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
void YogaLayoutableShadowNode::setSize(Size size) const {
|
|
532
|
+
ensureUnsealed();
|
|
533
|
+
|
|
534
|
+
auto style = yogaNode_.getStyle();
|
|
535
|
+
style.setDimension(
|
|
536
|
+
YGDimensionWidth, yoga::CompactValue::ofMaybe<YGUnitPoint>(size.width));
|
|
537
|
+
style.setDimension(
|
|
538
|
+
YGDimensionHeight, yoga::CompactValue::ofMaybe<YGUnitPoint>(size.height));
|
|
539
|
+
yogaNode_.setStyle(style);
|
|
540
|
+
yogaNode_.setDirty(true);
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
void YogaLayoutableShadowNode::setPadding(RectangleEdges<Float> padding) const {
|
|
544
|
+
ensureUnsealed();
|
|
545
|
+
|
|
546
|
+
auto style = yogaNode_.getStyle();
|
|
547
|
+
|
|
548
|
+
auto leftPadding = yoga::CompactValue::ofMaybe<YGUnitPoint>(padding.left);
|
|
549
|
+
auto topPadding = yoga::CompactValue::ofMaybe<YGUnitPoint>(padding.top);
|
|
550
|
+
auto rightPadding = yoga::CompactValue::ofMaybe<YGUnitPoint>(padding.right);
|
|
551
|
+
auto bottomPadding = yoga::CompactValue::ofMaybe<YGUnitPoint>(padding.bottom);
|
|
552
|
+
|
|
553
|
+
if (leftPadding != style.padding()[YGEdgeLeft] ||
|
|
554
|
+
topPadding != style.padding()[YGEdgeTop] ||
|
|
555
|
+
rightPadding != style.padding()[YGEdgeRight] ||
|
|
556
|
+
bottomPadding != style.padding()[YGEdgeBottom]) {
|
|
557
|
+
style.padding()[YGEdgeTop] =
|
|
558
|
+
yoga::CompactValue::ofMaybe<YGUnitPoint>(padding.top);
|
|
559
|
+
style.padding()[YGEdgeLeft] =
|
|
560
|
+
yoga::CompactValue::ofMaybe<YGUnitPoint>(padding.left);
|
|
561
|
+
style.padding()[YGEdgeRight] =
|
|
562
|
+
yoga::CompactValue::ofMaybe<YGUnitPoint>(padding.right);
|
|
563
|
+
style.padding()[YGEdgeBottom] =
|
|
564
|
+
yoga::CompactValue::ofMaybe<YGUnitPoint>(padding.bottom);
|
|
565
|
+
yogaNode_.setStyle(style);
|
|
566
|
+
yogaNode_.setDirty(true);
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
void YogaLayoutableShadowNode::setPositionType(
|
|
571
|
+
YGPositionType positionType) const {
|
|
572
|
+
ensureUnsealed();
|
|
573
|
+
|
|
574
|
+
auto style = yogaNode_.getStyle();
|
|
575
|
+
style.positionType() = yoga::scopedEnum(positionType);
|
|
576
|
+
yogaNode_.setStyle(style);
|
|
577
|
+
yogaNode_.setDirty(true);
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
void YogaLayoutableShadowNode::layoutTree(
|
|
581
|
+
LayoutContext layoutContext,
|
|
582
|
+
LayoutConstraints layoutConstraints) {
|
|
583
|
+
ensureUnsealed();
|
|
584
|
+
|
|
585
|
+
SystraceSection s1("YogaLayoutableShadowNode::layoutTree");
|
|
586
|
+
|
|
587
|
+
bool swapLeftAndRight = layoutContext.swapLeftAndRightInRTL &&
|
|
588
|
+
(layoutConstraints.layoutDirection == LayoutDirection::RightToLeft ||
|
|
589
|
+
!CoreFeatures::doNotSwapLeftAndRightOnAndroidInLTR);
|
|
590
|
+
|
|
591
|
+
{
|
|
592
|
+
SystraceSection s2("YogaLayoutableShadowNode::configureYogaTree");
|
|
593
|
+
configureYogaTree(
|
|
594
|
+
layoutContext.pointScaleFactor,
|
|
595
|
+
YGErrataAll /*defaultErrata*/,
|
|
596
|
+
swapLeftAndRight);
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
auto minimumSize = layoutConstraints.minimumSize;
|
|
600
|
+
auto maximumSize = layoutConstraints.maximumSize;
|
|
601
|
+
|
|
602
|
+
// The caller must ensure that layout constraints make sense.
|
|
603
|
+
// Values cannot be NaN.
|
|
604
|
+
react_native_assert(!std::isnan(minimumSize.width));
|
|
605
|
+
react_native_assert(!std::isnan(minimumSize.height));
|
|
606
|
+
react_native_assert(!std::isnan(maximumSize.width));
|
|
607
|
+
react_native_assert(!std::isnan(maximumSize.height));
|
|
608
|
+
// Values cannot be negative.
|
|
609
|
+
react_native_assert(minimumSize.width >= 0);
|
|
610
|
+
react_native_assert(minimumSize.height >= 0);
|
|
611
|
+
react_native_assert(maximumSize.width >= 0);
|
|
612
|
+
react_native_assert(maximumSize.height >= 0);
|
|
613
|
+
// Minimum size cannot be infinity.
|
|
614
|
+
react_native_assert(!std::isinf(minimumSize.width));
|
|
615
|
+
react_native_assert(!std::isinf(minimumSize.height));
|
|
616
|
+
|
|
617
|
+
// Internally Yoga uses three different measurement modes controlling layout
|
|
618
|
+
// constraints: `Undefined`, `Exactly`, and `AtMost`. These modes are an
|
|
619
|
+
// implementation detail and are not defined in `CSS Flexible Box Layout
|
|
620
|
+
// Module`. Yoga C++ API (and `YGNodeCalculateLayout` function particularly)
|
|
621
|
+
// does not allow to specify the measure modes explicitly. Instead, it infers
|
|
622
|
+
// these from styles associated with the root node.
|
|
623
|
+
// To pass the actual layout constraints to Yoga we represent them as
|
|
624
|
+
// `(min/max)(Height/Width)` style properties. Also, we pass `ownerWidth` &
|
|
625
|
+
// `ownerHeight` to allow proper calculation of relative (e.g. specified in
|
|
626
|
+
// percents) style values.
|
|
627
|
+
|
|
628
|
+
auto& yogaStyle = yogaNode_.getStyle();
|
|
629
|
+
|
|
630
|
+
auto ownerWidth = yogaFloatFromFloat(maximumSize.width);
|
|
631
|
+
auto ownerHeight = yogaFloatFromFloat(maximumSize.height);
|
|
632
|
+
|
|
633
|
+
yogaStyle.setMaxDimension(
|
|
634
|
+
YGDimensionWidth,
|
|
635
|
+
yoga::CompactValue::ofMaybe<YGUnitPoint>(maximumSize.width));
|
|
636
|
+
|
|
637
|
+
yogaStyle.setMaxDimension(
|
|
638
|
+
YGDimensionHeight,
|
|
639
|
+
yoga::CompactValue::ofMaybe<YGUnitPoint>(maximumSize.height));
|
|
640
|
+
|
|
641
|
+
yogaStyle.setMinDimension(
|
|
642
|
+
YGDimensionWidth,
|
|
643
|
+
yoga::CompactValue::ofMaybe<YGUnitPoint>(minimumSize.width));
|
|
644
|
+
|
|
645
|
+
yogaStyle.setMinDimension(
|
|
646
|
+
YGDimensionHeight,
|
|
647
|
+
yoga::CompactValue::ofMaybe<YGUnitPoint>(minimumSize.height));
|
|
648
|
+
|
|
649
|
+
auto direction =
|
|
650
|
+
yogaDirectionFromLayoutDirection(layoutConstraints.layoutDirection);
|
|
651
|
+
|
|
652
|
+
threadLocalLayoutContext = layoutContext;
|
|
653
|
+
|
|
654
|
+
{
|
|
655
|
+
SystraceSection s3("YogaLayoutableShadowNode::YGNodeCalculateLayout");
|
|
656
|
+
YGNodeCalculateLayout(&yogaNode_, ownerWidth, ownerHeight, direction);
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
// Update layout metrics for root node. Updated for children in
|
|
660
|
+
// YogaLayoutableShadowNode::layout
|
|
661
|
+
if (yogaNode_.getHasNewLayout()) {
|
|
662
|
+
auto layoutMetrics = layoutMetricsFromYogaNode(yogaNode_);
|
|
663
|
+
layoutMetrics.pointScaleFactor = layoutContext.pointScaleFactor;
|
|
664
|
+
layoutMetrics.wasLeftAndRightSwapped = swapLeftAndRight;
|
|
665
|
+
setLayoutMetrics(layoutMetrics);
|
|
666
|
+
yogaNode_.setHasNewLayout(false);
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
layout(layoutContext);
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
static EdgeInsets calculateOverflowInset(
|
|
673
|
+
Rect contentFrame,
|
|
674
|
+
Rect contentBounds) {
|
|
675
|
+
auto size = contentFrame.size;
|
|
676
|
+
auto overflowInset = EdgeInsets{};
|
|
677
|
+
overflowInset.left = std::min(contentBounds.getMinX(), Float{0.0});
|
|
678
|
+
overflowInset.top = std::min(contentBounds.getMinY(), Float{0.0});
|
|
679
|
+
overflowInset.right =
|
|
680
|
+
-std::max(contentBounds.getMaxX() - size.width, Float{0.0});
|
|
681
|
+
overflowInset.bottom =
|
|
682
|
+
-std::max(contentBounds.getMaxY() - size.height, Float{0.0});
|
|
683
|
+
return overflowInset;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
void YogaLayoutableShadowNode::layout(LayoutContext layoutContext) {
|
|
687
|
+
// Reading data from a dirtied node does not make sense.
|
|
688
|
+
react_native_assert(!yogaNode_.isDirty());
|
|
689
|
+
|
|
690
|
+
for (auto childYogaNode : yogaNode_.getChildren()) {
|
|
691
|
+
auto& childNode = shadowNodeFromContext(childYogaNode);
|
|
692
|
+
|
|
693
|
+
// Verifying that the Yoga node belongs to the ShadowNode.
|
|
694
|
+
react_native_assert(&childNode.yogaNode_ == childYogaNode);
|
|
695
|
+
|
|
696
|
+
if (childYogaNode->getHasNewLayout()) {
|
|
697
|
+
childYogaNode->setHasNewLayout(false);
|
|
698
|
+
|
|
699
|
+
// Reading data from a dirtied node does not make sense.
|
|
700
|
+
react_native_assert(!childYogaNode->isDirty());
|
|
701
|
+
|
|
702
|
+
// We must copy layout metrics from Yoga node only once (when the parent
|
|
703
|
+
// node exclusively ownes the child node).
|
|
704
|
+
react_native_assert(childYogaNode->getOwner() == &yogaNode_);
|
|
705
|
+
|
|
706
|
+
// We are about to mutate layout metrics of the node.
|
|
707
|
+
childNode.ensureUnsealed();
|
|
708
|
+
|
|
709
|
+
auto newLayoutMetrics = layoutMetricsFromYogaNode(*childYogaNode);
|
|
710
|
+
newLayoutMetrics.pointScaleFactor = layoutContext.pointScaleFactor;
|
|
711
|
+
newLayoutMetrics.wasLeftAndRightSwapped =
|
|
712
|
+
layoutContext.swapLeftAndRightInRTL &&
|
|
713
|
+
(newLayoutMetrics.layoutDirection == LayoutDirection::RightToLeft ||
|
|
714
|
+
!CoreFeatures::doNotSwapLeftAndRightOnAndroidInLTR);
|
|
715
|
+
|
|
716
|
+
// Child node's layout has changed. When a node is added to
|
|
717
|
+
// `affectedNodes`, onLayout event is called on the component. Comparing
|
|
718
|
+
// `newLayoutMetrics.frame` with `childNode.getLayoutMetrics().frame` to
|
|
719
|
+
// detect if layout has not changed is not advised, please refer to
|
|
720
|
+
// D22999891 for details.
|
|
721
|
+
if (layoutContext.affectedNodes != nullptr) {
|
|
722
|
+
layoutContext.affectedNodes->push_back(&childNode);
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
childNode.setLayoutMetrics(newLayoutMetrics);
|
|
726
|
+
|
|
727
|
+
if (newLayoutMetrics.displayType != DisplayType::None) {
|
|
728
|
+
childNode.layout(layoutContext);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
if (yogaNode_.getStyle().overflow() == yoga::Overflow::Visible) {
|
|
734
|
+
// Note that the parent node's overflow layout is NOT affected by its
|
|
735
|
+
// transform matrix. That transform matrix is applied on the parent node as
|
|
736
|
+
// well as all of its child nodes, which won't cause changes on the
|
|
737
|
+
// overflowInset values. A special note on the scale transform -- the scaled
|
|
738
|
+
// layout may look like it's causing overflowInset changes, but it's purely
|
|
739
|
+
// cosmetic and will be handled by pixel density conversion logic later when
|
|
740
|
+
// render the view. The actual overflowInset value is not changed as if the
|
|
741
|
+
// transform is not happening here.
|
|
742
|
+
auto contentBounds = getContentBounds();
|
|
743
|
+
layoutMetrics_.overflowInset =
|
|
744
|
+
calculateOverflowInset(layoutMetrics_.frame, contentBounds);
|
|
745
|
+
} else {
|
|
746
|
+
layoutMetrics_.overflowInset = {};
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
Rect YogaLayoutableShadowNode::getContentBounds() const {
|
|
751
|
+
auto contentBounds = Rect{};
|
|
752
|
+
|
|
753
|
+
for (auto childYogaNode : yogaNode_.getChildren()) {
|
|
754
|
+
auto& childNode = shadowNodeFromContext(childYogaNode);
|
|
755
|
+
|
|
756
|
+
// Verifying that the Yoga node belongs to the ShadowNode.
|
|
757
|
+
react_native_assert(&childNode.yogaNode_ == childYogaNode);
|
|
758
|
+
|
|
759
|
+
auto layoutMetricsWithOverflowInset = childNode.getLayoutMetrics();
|
|
760
|
+
if (layoutMetricsWithOverflowInset.displayType != DisplayType::None) {
|
|
761
|
+
auto viewChildNode = traitCast<const ViewShadowNode*>(&childNode);
|
|
762
|
+
auto hitSlop = viewChildNode != nullptr
|
|
763
|
+
? viewChildNode->getConcreteProps().hitSlop
|
|
764
|
+
: EdgeInsets{};
|
|
765
|
+
|
|
766
|
+
// The contentBounds should always union with existing child node layout +
|
|
767
|
+
// overflowInset. The transform may in a deferred animation and not
|
|
768
|
+
// applied yet.
|
|
769
|
+
contentBounds.unionInPlace(insetBy(
|
|
770
|
+
layoutMetricsWithOverflowInset.frame,
|
|
771
|
+
layoutMetricsWithOverflowInset.overflowInset));
|
|
772
|
+
contentBounds.unionInPlace(
|
|
773
|
+
outsetBy(layoutMetricsWithOverflowInset.frame, hitSlop));
|
|
774
|
+
|
|
775
|
+
auto childTransform = childNode.getTransform();
|
|
776
|
+
if (childTransform != Transform::Identity()) {
|
|
777
|
+
// The child node's transform matrix will affect the parent node's
|
|
778
|
+
// contentBounds. We need to union with child node's after transform
|
|
779
|
+
// layout here.
|
|
780
|
+
contentBounds.unionInPlace(insetBy(
|
|
781
|
+
layoutMetricsWithOverflowInset.frame * childTransform,
|
|
782
|
+
layoutMetricsWithOverflowInset.overflowInset * childTransform));
|
|
783
|
+
contentBounds.unionInPlace(outsetBy(
|
|
784
|
+
layoutMetricsWithOverflowInset.frame * childTransform, hitSlop));
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
return contentBounds;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
#pragma mark - Yoga Connectors
|
|
793
|
+
|
|
794
|
+
YGNodeRef YogaLayoutableShadowNode::yogaNodeCloneCallbackConnector(
|
|
795
|
+
YGNodeConstRef /*oldYogaNode*/,
|
|
796
|
+
YGNodeConstRef parentYogaNode,
|
|
797
|
+
size_t childIndex) {
|
|
798
|
+
SystraceSection s("YogaLayoutableShadowNode::yogaNodeCloneCallbackConnector");
|
|
799
|
+
|
|
800
|
+
auto& parentNode = shadowNodeFromContext(parentYogaNode);
|
|
801
|
+
return &parentNode.cloneChildInPlace(childIndex).yogaNode_;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
YGSize YogaLayoutableShadowNode::yogaNodeMeasureCallbackConnector(
|
|
805
|
+
YGNodeConstRef yogaNode,
|
|
806
|
+
float width,
|
|
807
|
+
YGMeasureMode widthMode,
|
|
808
|
+
float height,
|
|
809
|
+
YGMeasureMode heightMode) {
|
|
810
|
+
SystraceSection s(
|
|
811
|
+
"YogaLayoutableShadowNode::yogaNodeMeasureCallbackConnector");
|
|
812
|
+
|
|
813
|
+
auto& shadowNode = shadowNodeFromContext(yogaNode);
|
|
814
|
+
|
|
815
|
+
auto minimumSize = Size{0, 0};
|
|
816
|
+
auto maximumSize = Size{
|
|
817
|
+
std::numeric_limits<Float>::infinity(),
|
|
818
|
+
std::numeric_limits<Float>::infinity()};
|
|
819
|
+
|
|
820
|
+
switch (widthMode) {
|
|
821
|
+
case YGMeasureModeUndefined:
|
|
822
|
+
break;
|
|
823
|
+
case YGMeasureModeExactly:
|
|
824
|
+
minimumSize.width = floatFromYogaFloat(width);
|
|
825
|
+
maximumSize.width = floatFromYogaFloat(width);
|
|
826
|
+
break;
|
|
827
|
+
case YGMeasureModeAtMost:
|
|
828
|
+
maximumSize.width = floatFromYogaFloat(width);
|
|
829
|
+
break;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
switch (heightMode) {
|
|
833
|
+
case YGMeasureModeUndefined:
|
|
834
|
+
break;
|
|
835
|
+
case YGMeasureModeExactly:
|
|
836
|
+
minimumSize.height = floatFromYogaFloat(height);
|
|
837
|
+
maximumSize.height = floatFromYogaFloat(height);
|
|
838
|
+
break;
|
|
839
|
+
case YGMeasureModeAtMost:
|
|
840
|
+
maximumSize.height = floatFromYogaFloat(height);
|
|
841
|
+
break;
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
auto size = shadowNode.measureContent(
|
|
845
|
+
threadLocalLayoutContext, {minimumSize, maximumSize});
|
|
846
|
+
|
|
847
|
+
return YGSize{
|
|
848
|
+
yogaFloatFromFloat(size.width), yogaFloatFromFloat(size.height)};
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
YogaLayoutableShadowNode& YogaLayoutableShadowNode::shadowNodeFromContext(
|
|
852
|
+
YGNodeConstRef yogaNode) {
|
|
853
|
+
return traitCast<YogaLayoutableShadowNode&>(
|
|
854
|
+
*static_cast<ShadowNode*>(YGNodeGetContext(yogaNode)));
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
yoga::Config& YogaLayoutableShadowNode::initializeYogaConfig(
|
|
858
|
+
yoga::Config& config,
|
|
859
|
+
YGConfigConstRef previousConfig) {
|
|
860
|
+
YGConfigSetCloneNodeFunc(
|
|
861
|
+
&config, YogaLayoutableShadowNode::yogaNodeCloneCallbackConnector);
|
|
862
|
+
if (previousConfig != nullptr) {
|
|
863
|
+
YGConfigSetPointScaleFactor(
|
|
864
|
+
&config, YGConfigGetPointScaleFactor(previousConfig));
|
|
865
|
+
YGConfigSetErrata(&config, YGConfigGetErrata(previousConfig));
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
#ifdef RN_DEBUG_YOGA_LOGGER
|
|
869
|
+
YGConfigSetPrintTreeFlag(&config, true);
|
|
870
|
+
#endif
|
|
871
|
+
return config;
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
#pragma mark - RTL left and right swapping
|
|
875
|
+
|
|
876
|
+
void YogaLayoutableShadowNode::swapStyleLeftAndRight() {
|
|
877
|
+
ensureUnsealed();
|
|
878
|
+
|
|
879
|
+
swapLeftAndRightInYogaStyleProps(*this);
|
|
880
|
+
swapLeftAndRightInViewProps(*this);
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
void YogaLayoutableShadowNode::swapLeftAndRightInYogaStyleProps(
|
|
884
|
+
const YogaLayoutableShadowNode& shadowNode) {
|
|
885
|
+
auto yogaStyle = shadowNode.yogaNode_.getStyle();
|
|
886
|
+
|
|
887
|
+
const yoga::Style::Edges& position = yogaStyle.position();
|
|
888
|
+
const yoga::Style::Edges& padding = yogaStyle.padding();
|
|
889
|
+
const yoga::Style::Edges& margin = yogaStyle.margin();
|
|
890
|
+
|
|
891
|
+
// Swap Yoga node values, position, padding and margin.
|
|
892
|
+
|
|
893
|
+
if (yogaStyle.position()[YGEdgeLeft] != YGValueUndefined) {
|
|
894
|
+
yogaStyle.position()[YGEdgeStart] = position[YGEdgeLeft];
|
|
895
|
+
yogaStyle.position()[YGEdgeLeft] = YGValueUndefined;
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
if (yogaStyle.position()[YGEdgeRight] != YGValueUndefined) {
|
|
899
|
+
yogaStyle.position()[YGEdgeEnd] = position[YGEdgeRight];
|
|
900
|
+
yogaStyle.position()[YGEdgeRight] = YGValueUndefined;
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
if (yogaStyle.padding()[YGEdgeLeft] != YGValueUndefined) {
|
|
904
|
+
yogaStyle.padding()[YGEdgeStart] = padding[YGEdgeLeft];
|
|
905
|
+
yogaStyle.padding()[YGEdgeLeft] = YGValueUndefined;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
if (yogaStyle.padding()[YGEdgeRight] != YGValueUndefined) {
|
|
909
|
+
yogaStyle.padding()[YGEdgeEnd] = padding[YGEdgeRight];
|
|
910
|
+
yogaStyle.padding()[YGEdgeRight] = YGValueUndefined;
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
if (yogaStyle.margin()[YGEdgeLeft] != YGValueUndefined) {
|
|
914
|
+
yogaStyle.margin()[YGEdgeStart] = margin[YGEdgeLeft];
|
|
915
|
+
yogaStyle.margin()[YGEdgeLeft] = YGValueUndefined;
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
if (yogaStyle.margin()[YGEdgeRight] != YGValueUndefined) {
|
|
919
|
+
yogaStyle.margin()[YGEdgeEnd] = margin[YGEdgeRight];
|
|
920
|
+
yogaStyle.margin()[YGEdgeRight] = YGValueUndefined;
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
shadowNode.yogaNode_.setStyle(yogaStyle);
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
void YogaLayoutableShadowNode::swapLeftAndRightInViewProps(
|
|
927
|
+
const YogaLayoutableShadowNode& shadowNode) {
|
|
928
|
+
auto& typedCasting = static_cast<const ViewProps&>(*shadowNode.props_);
|
|
929
|
+
auto& props = const_cast<ViewProps&>(typedCasting);
|
|
930
|
+
|
|
931
|
+
// Swap border node values, borderRadii, borderColors and borderStyles.
|
|
932
|
+
|
|
933
|
+
if (props.borderRadii.topLeft.has_value()) {
|
|
934
|
+
props.borderRadii.topStart = props.borderRadii.topLeft;
|
|
935
|
+
props.borderRadii.topLeft.reset();
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
if (props.borderRadii.bottomLeft.has_value()) {
|
|
939
|
+
props.borderRadii.bottomStart = props.borderRadii.bottomLeft;
|
|
940
|
+
props.borderRadii.bottomLeft.reset();
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
if (props.borderRadii.topRight.has_value()) {
|
|
944
|
+
props.borderRadii.topEnd = props.borderRadii.topRight;
|
|
945
|
+
props.borderRadii.topRight.reset();
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
if (props.borderRadii.bottomRight.has_value()) {
|
|
949
|
+
props.borderRadii.bottomEnd = props.borderRadii.bottomRight;
|
|
950
|
+
props.borderRadii.bottomRight.reset();
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
if (props.borderColors.left.has_value()) {
|
|
954
|
+
props.borderColors.start = props.borderColors.left;
|
|
955
|
+
props.borderColors.left.reset();
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
if (props.borderColors.right.has_value()) {
|
|
959
|
+
props.borderColors.end = props.borderColors.right;
|
|
960
|
+
props.borderColors.right.reset();
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
if (props.borderStyles.left.has_value()) {
|
|
964
|
+
props.borderStyles.start = props.borderStyles.left;
|
|
965
|
+
props.borderStyles.left.reset();
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
if (props.borderStyles.right.has_value()) {
|
|
969
|
+
props.borderStyles.end = props.borderStyles.right;
|
|
970
|
+
props.borderStyles.right.reset();
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
const yoga::Style::Edges& border = props.yogaStyle.border();
|
|
974
|
+
|
|
975
|
+
if (props.yogaStyle.border()[YGEdgeLeft] != YGValueUndefined) {
|
|
976
|
+
props.yogaStyle.border()[YGEdgeStart] = border[YGEdgeLeft];
|
|
977
|
+
props.yogaStyle.border()[YGEdgeLeft] = YGValueUndefined;
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
if (props.yogaStyle.border()[YGEdgeRight] != YGValueUndefined) {
|
|
981
|
+
props.yogaStyle.border()[YGEdgeEnd] = border[YGEdgeRight];
|
|
982
|
+
props.yogaStyle.border()[YGEdgeRight] = YGValueUndefined;
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
#pragma mark - Consistency Ensuring Helpers
|
|
987
|
+
|
|
988
|
+
void YogaLayoutableShadowNode::ensureConsistency() const {
|
|
989
|
+
ensureYogaChildrenLookFine();
|
|
990
|
+
ensureYogaChildrenAlignment();
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
void YogaLayoutableShadowNode::ensureYogaChildrenLookFine() const {
|
|
994
|
+
#ifdef REACT_NATIVE_DEBUG
|
|
995
|
+
// Checking that the shapes of Yoga node children object look fine.
|
|
996
|
+
// This is the only heuristic that might produce false-positive results
|
|
997
|
+
// (really broken dangled nodes might look fine). This is useful as an early
|
|
998
|
+
// signal that something went wrong.
|
|
999
|
+
auto& yogaChildren = yogaNode_.getChildren();
|
|
1000
|
+
|
|
1001
|
+
for (const auto& yogaChild : yogaChildren) {
|
|
1002
|
+
react_native_assert(yogaChild->getContext());
|
|
1003
|
+
react_native_assert(yogaChild->getChildren().size() < 16384);
|
|
1004
|
+
if (!yogaChild->getChildren().empty()) {
|
|
1005
|
+
react_native_assert(!yogaChild->hasMeasureFunc());
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
#endif
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
void YogaLayoutableShadowNode::ensureYogaChildrenAlignment() const {
|
|
1012
|
+
#ifdef REACT_NATIVE_DEBUG
|
|
1013
|
+
// If the node is not a leaf node, checking that:
|
|
1014
|
+
// - All children are `YogaLayoutableShadowNode` subclasses.
|
|
1015
|
+
// - All Yoga children are owned/connected to corresponding children of
|
|
1016
|
+
// this node.
|
|
1017
|
+
|
|
1018
|
+
auto& yogaChildren = yogaNode_.getChildren();
|
|
1019
|
+
auto& children = yogaLayoutableChildren_;
|
|
1020
|
+
|
|
1021
|
+
if (getTraits().check(ShadowNodeTraits::Trait::LeafYogaNode)) {
|
|
1022
|
+
react_native_assert(yogaChildren.empty());
|
|
1023
|
+
return;
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
react_native_assert(yogaChildren.size() == children.size());
|
|
1027
|
+
|
|
1028
|
+
for (size_t i = 0; i < children.size(); i++) {
|
|
1029
|
+
auto& yogaChild = yogaChildren.at(i);
|
|
1030
|
+
auto& child = children.at(i);
|
|
1031
|
+
react_native_assert(
|
|
1032
|
+
yogaChild->getContext() ==
|
|
1033
|
+
traitCast<const YogaLayoutableShadowNode*>(child.get()));
|
|
1034
|
+
}
|
|
1035
|
+
#endif
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
} // namespace facebook::react
|