react-native-windows 0.81.1 → 0.82.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.
Files changed (724) hide show
  1. package/.flowconfig +11 -10
  2. package/Directory.Build.props +3 -3
  3. package/Folly/Folly.vcxproj +1 -3
  4. package/Libraries/ActionSheetIOS/ActionSheetIOS.js +7 -3
  5. package/Libraries/Alert/RCTAlertManager.android.js +4 -2
  6. package/Libraries/Animated/Animated.d.ts +2 -0
  7. package/Libraries/Animated/AnimatedEvent.js +1 -1
  8. package/Libraries/Animated/AnimatedExports.js.flow +1 -0
  9. package/Libraries/Animated/AnimatedImplementation.js +4 -2
  10. package/Libraries/Animated/AnimatedMock.js +1 -1
  11. package/Libraries/Animated/Easing.js +2 -0
  12. package/Libraries/Animated/NativeAnimatedAllowlist.js +1 -0
  13. package/Libraries/Animated/animations/Animation.js +19 -20
  14. package/Libraries/Animated/animations/TimingAnimation.js +2 -0
  15. package/Libraries/Animated/components/AnimatedScrollView.js +3 -2
  16. package/Libraries/Animated/components/AnimatedSectionList.js +1 -1
  17. package/Libraries/Animated/nodes/AnimatedColor.js +9 -9
  18. package/Libraries/Animated/nodes/AnimatedInterpolation.js +4 -4
  19. package/Libraries/Animated/nodes/AnimatedNode.js +14 -7
  20. package/Libraries/Animated/nodes/AnimatedObject.js +7 -7
  21. package/Libraries/Animated/nodes/AnimatedProps.js +32 -32
  22. package/Libraries/Animated/nodes/AnimatedStyle.js +23 -21
  23. package/Libraries/Animated/nodes/AnimatedTransform.js +6 -6
  24. package/Libraries/Animated/nodes/AnimatedValue.js +18 -18
  25. package/Libraries/AppState/AppState.js +8 -4
  26. package/Libraries/BatchedBridge/MessageQueue.js +4 -0
  27. package/Libraries/BatchedBridge/NativeModules.js +1 -1
  28. package/Libraries/Blob/BlobManager.js +1 -1
  29. package/Libraries/Blob/URLSearchParams.js +2 -0
  30. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +2 -2
  31. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.windows.js +2 -2
  32. package/Libraries/Components/Button.js +1 -1
  33. package/Libraries/Components/Button.windows.js +1 -1
  34. package/Libraries/Components/Flyout/FlyoutNativeComponent.js +2 -2
  35. package/Libraries/Components/Glyph/GlyphNativeComponent.js +1 -1
  36. package/Libraries/Components/Popup/PopupNativeComponent.js +1 -0
  37. package/Libraries/Components/Pressable/Pressable.d.ts +8 -0
  38. package/Libraries/Components/Pressable/Pressable.js +10 -1
  39. package/Libraries/Components/Pressable/Pressable.windows.js +30 -2
  40. package/Libraries/Components/Pressable/useAndroidRippleForView.js +2 -2
  41. package/Libraries/Components/ScrollView/ScrollView.js +13 -4
  42. package/Libraries/Components/ScrollView/ScrollView.windows.js +14 -5
  43. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +1 -1
  44. package/Libraries/Components/StatusBar/StatusBar.js +2 -2
  45. package/Libraries/Components/Switch/Switch.js +2 -2
  46. package/Libraries/Components/Switch/Switch.windows.js +2 -2
  47. package/Libraries/Components/TextInput/TextInput.flow.js +12 -5
  48. package/Libraries/Components/TextInput/TextInput.flow.windows.js +12 -5
  49. package/Libraries/Components/TextInput/TextInput.js +14 -5
  50. package/Libraries/Components/TextInput/TextInput.windows.js +23 -11
  51. package/Libraries/Components/TextInput/TextInputState.js +1 -1
  52. package/Libraries/Components/TextInput/TextInputState.windows.js +1 -1
  53. package/Libraries/Components/Touchable/TouchableBounce.js +1 -1
  54. package/Libraries/Components/Touchable/TouchableHighlight.js +1 -1
  55. package/Libraries/Components/Touchable/TouchableNativeFeedback.js +1 -1
  56. package/Libraries/Components/Touchable/TouchableOpacity.js +1 -1
  57. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +3 -3
  58. package/Libraries/Components/Touchable/TouchableWithoutFeedback.windows.js +1 -1
  59. package/Libraries/Components/View/View.js +81 -167
  60. package/Libraries/Components/View/View.windows.js +202 -302
  61. package/Libraries/Core/Devtools/loadBundleFromServer.js +1 -1
  62. package/Libraries/Core/Devtools/loadBundleFromServer.windows.js +1 -1
  63. package/Libraries/Core/ExceptionsManager.js +4 -2
  64. package/Libraries/Core/ReactFiberErrorDialog.js +3 -3
  65. package/Libraries/Core/ReactNativeVersion.js +37 -10
  66. package/Libraries/Core/Timers/JSTimers.js +3 -1
  67. package/Libraries/Core/Timers/immediateShim.js +1 -1
  68. package/Libraries/Core/Timers/queueMicrotask.js +1 -0
  69. package/Libraries/Core/setUpPerformance.js +2 -1
  70. package/Libraries/Debugging/DebuggingOverlayRegistry.js +5 -3
  71. package/Libraries/Image/AssetSourceResolver.windows.js +2 -2
  72. package/Libraries/Image/Image.android.js +327 -111
  73. package/Libraries/Image/Image.ios.js +6 -1
  74. package/Libraries/Image/Image.windows.js +28 -61
  75. package/Libraries/Image/ImageSourceUtils.js +8 -2
  76. package/Libraries/Image/resolveAssetSource.js +1 -1
  77. package/Libraries/Image/resolveAssetSource.windows.js +1 -1
  78. package/Libraries/Interaction/InteractionManager.js +118 -167
  79. package/Libraries/Interaction/PanResponder.js +1 -1
  80. package/Libraries/LayoutAnimation/LayoutAnimation.js +2 -0
  81. package/Libraries/Lists/FlatList.js +5 -6
  82. package/Libraries/LogBox/Data/LogBoxData.js +5 -2
  83. package/Libraries/LogBox/Data/parseLogBoxLog.js +1 -1
  84. package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.js +1 -1
  85. package/Libraries/Modal/Modal.js +3 -3
  86. package/Libraries/Modal/Modal.windows.js +2 -2
  87. package/Libraries/NativeComponent/NativeComponentRegistry.js +1 -1
  88. package/Libraries/NativeComponent/ViewConfig.js +2 -2
  89. package/Libraries/Network/RCTNetworking.android.js +1 -1
  90. package/Libraries/Network/RCTNetworking.ios.js +1 -1
  91. package/Libraries/Network/RCTNetworking.windows.js +1 -1
  92. package/Libraries/Network/XMLHttpRequest.js +20 -5
  93. package/Libraries/Network/convertRequestBody.js +1 -1
  94. package/Libraries/PermissionsAndroid/PermissionsAndroid.js +10 -9
  95. package/Libraries/Pressability/HoverState.js +2 -0
  96. package/Libraries/Pressability/Pressability.js +1 -1
  97. package/Libraries/Pressability/Pressability.windows.js +5 -5
  98. package/Libraries/PushNotificationIOS/PushNotificationIOS.js +2 -2
  99. package/Libraries/ReactNative/AppRegistryImpl.js +4 -2
  100. package/Libraries/ReactNative/PaperUIManager.windows.js +4 -4
  101. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +2 -0
  102. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +3 -3
  103. package/Libraries/ReactNative/RendererImplementation.js +116 -116
  104. package/Libraries/ReactNative/UIManager.js +3 -3
  105. package/Libraries/ReactNative/renderApplication.js +1 -0
  106. package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +1 -1
  107. package/Libraries/Renderer/implementations/ReactFabric-dev.js +38 -35
  108. package/Libraries/Renderer/implementations/ReactFabric-prod.js +51 -22
  109. package/Libraries/Renderer/implementations/ReactFabric-profiling.js +54 -24
  110. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +36 -33
  111. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +5 -5
  112. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +5 -5
  113. package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +3 -1
  114. package/Libraries/Share/Share.js +4 -0
  115. package/Libraries/StyleSheet/PlatformColorValueTypes.android.js +2 -2
  116. package/Libraries/StyleSheet/PlatformColorValueTypes.ios.js +2 -2
  117. package/Libraries/StyleSheet/PlatformColorValueTypes.windows.js +2 -0
  118. package/Libraries/StyleSheet/StyleSheet.d.ts +7 -22
  119. package/Libraries/StyleSheet/StyleSheetExports.js +2 -8
  120. package/Libraries/StyleSheet/StyleSheetExports.js.flow +11 -18
  121. package/Libraries/StyleSheet/flattenStyle.js +2 -2
  122. package/Libraries/StyleSheet/processAspectRatio.js +2 -0
  123. package/Libraries/StyleSheet/processFilter.js +5 -5
  124. package/Libraries/StyleSheet/splitLayoutProps.js +2 -2
  125. package/Libraries/Text/Text.js +534 -234
  126. package/Libraries/Text/Text.windows.js +622 -265
  127. package/Libraries/Text/TextNativeComponent.js +2 -2
  128. package/Libraries/Utilities/Appearance.d.ts +3 -5
  129. package/Libraries/Utilities/Appearance.js +5 -17
  130. package/Libraries/Utilities/HMRClient.js +2 -1
  131. package/Libraries/Utilities/Platform.android.js +3 -3
  132. package/Libraries/Utilities/Platform.d.ts +1 -0
  133. package/Libraries/Utilities/Platform.ios.js +1 -1
  134. package/Libraries/Utilities/Platform.windows.js +3 -3
  135. package/Libraries/Utilities/PlatformTypes.js +1 -1
  136. package/Libraries/Utilities/ReactNativeTestTools.js +12 -0
  137. package/Libraries/Utilities/SceneTracker.js +1 -1
  138. package/Libraries/Utilities/codegenNativeCommands.js +1 -1
  139. package/Libraries/Utilities/codegenNativeComponent.js +1 -1
  140. package/Libraries/Utilities/createPerformanceLogger.js +32 -0
  141. package/Libraries/Utilities/deepFreezeAndThrowOnMutationInDev.js +2 -0
  142. package/Libraries/Utilities/differ/pointsDiffer.js +1 -1
  143. package/Libraries/Utilities/useMergeRefs.js +1 -1
  144. package/Libraries/WebSocket/WebSocketInterceptor.js +2 -0
  145. package/Libraries/promiseRejectionTrackingOptions.js +17 -31
  146. package/Libraries/vendor/emitter/EventEmitter.js +1 -1
  147. package/Microsoft.ReactNative/App.xaml +5 -0
  148. package/Microsoft.ReactNative/Base/CxxReactIncludes.h +0 -3
  149. package/Microsoft.ReactNative/CompositionContext.idl +0 -2
  150. package/Microsoft.ReactNative/Fabric/AbiViewProps.cpp +2 -2
  151. package/Microsoft.ReactNative/Fabric/AbiViewProps.h +0 -2
  152. package/Microsoft.ReactNative/Fabric/ComponentView.cpp +26 -0
  153. package/Microsoft.ReactNative/Fabric/ComponentView.h +2 -0
  154. package/Microsoft.ReactNative/Fabric/Composition/ActivityIndicatorComponentView.cpp +0 -1
  155. package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.cpp +0 -69
  156. package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.h +1 -15
  157. package/Microsoft.ReactNative/Fabric/Composition/CompositionAnnotationProvider.cpp +2 -5
  158. package/Microsoft.ReactNative/Fabric/Composition/CompositionAnnotationProvider.h +1 -4
  159. package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.cpp +0 -31
  160. package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.h +0 -10
  161. package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper_emptyimpl.cpp +0 -4
  162. package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp +65 -32
  163. package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.h +9 -0
  164. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +8 -6
  165. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +0 -2
  166. package/Microsoft.ReactNative/Fabric/Composition/CompositionHelpers.h +0 -2
  167. package/Microsoft.ReactNative/Fabric/Composition/CompositionHwndHost.cpp +0 -9
  168. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootAutomationProvider.cpp +2 -11
  169. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootAutomationProvider.h +0 -4
  170. package/Microsoft.ReactNative/Fabric/Composition/CompositionTextProvider.cpp +4 -7
  171. package/Microsoft.ReactNative/Fabric/Composition/CompositionTextProvider.h +1 -5
  172. package/Microsoft.ReactNative/Fabric/Composition/CompositionTextRangeProvider.cpp +68 -53
  173. package/Microsoft.ReactNative/Fabric/Composition/CompositionTextRangeProvider.h +1 -5
  174. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +20 -18
  175. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +10 -3
  176. package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp +30 -9
  177. package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.h +4 -1
  178. package/Microsoft.ReactNative/Fabric/Composition/DebuggingOverlayComponentView.cpp +3 -2
  179. package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.cpp +0 -2
  180. package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.h +0 -1
  181. package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp +550 -4
  182. package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.h +52 -0
  183. package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.cpp +16 -0
  184. package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.h +6 -0
  185. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +0 -6
  186. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +0 -2
  187. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +53 -2
  188. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.h +8 -1
  189. package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +0 -2
  190. package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.cpp +0 -1
  191. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +5 -2
  192. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.cpp +4 -1
  193. package/Microsoft.ReactNative/Fabric/Composition/Theme.cpp +6 -30
  194. package/Microsoft.ReactNative/Fabric/Composition/Theme.h +1 -3
  195. package/Microsoft.ReactNative/Fabric/Composition/TooltipService.cpp +1 -1
  196. package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp +36 -14
  197. package/Microsoft.ReactNative/Fabric/Composition/UnimplementedNativeViewComponentView.cpp +0 -1
  198. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +0 -1
  199. package/Microsoft.ReactNative/Fabric/ImageManager.cpp +0 -4
  200. package/Microsoft.ReactNative/Fabric/ReactTaggedView.h +1 -1
  201. package/Microsoft.ReactNative/Fabric/WindowsComponentDescriptorRegistry.cpp +8 -0
  202. package/Microsoft.ReactNative/Fabric/WindowsComponentDescriptorRegistry.h +3 -0
  203. package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorUtils.cpp +0 -11
  204. package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/WindowsTextLayoutManager.h +2 -1
  205. package/Microsoft.ReactNative/IReactContext.cpp +2 -25
  206. package/Microsoft.ReactNative/IReactContext.h +0 -7
  207. package/Microsoft.ReactNative/IReactContext.idl +4 -29
  208. package/Microsoft.ReactNative/IReactModuleBuilder.cpp +24 -140
  209. package/Microsoft.ReactNative/IReactModuleBuilder.h +0 -11
  210. package/Microsoft.ReactNative/IReactPackageBuilder.idl +1 -16
  211. package/Microsoft.ReactNative/IReactPackageProvider.idl +0 -1
  212. package/Microsoft.ReactNative/IReactViewComponentBuilder.idl +10 -0
  213. package/Microsoft.ReactNative/JsiApi.cpp +4 -3
  214. package/Microsoft.ReactNative/JsiApi.h +2 -3
  215. package/Microsoft.ReactNative/JsiApi.idl +3 -2
  216. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +6 -214
  217. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj.filters +0 -252
  218. package/Microsoft.ReactNative/Modules/AccessibilityInfoModule.cpp +0 -37
  219. package/Microsoft.ReactNative/Modules/AlertModule.cpp +2 -140
  220. package/Microsoft.ReactNative/Modules/AlertModule.h +0 -2
  221. package/Microsoft.ReactNative/Modules/Animated/NativeAnimatedNodeManager.cpp +5 -10
  222. package/Microsoft.ReactNative/Modules/Animated/NativeAnimatedNodeManager.h +0 -1
  223. package/Microsoft.ReactNative/Modules/Animated/PropsAnimatedNode.cpp +1 -96
  224. package/Microsoft.ReactNative/Modules/Animated/PropsAnimatedNode.h +0 -14
  225. package/Microsoft.ReactNative/Modules/AppStateModule.cpp +0 -53
  226. package/Microsoft.ReactNative/Modules/AppStateModule.h +0 -5
  227. package/Microsoft.ReactNative/Modules/AppThemeModuleUwp.cpp +5 -14
  228. package/Microsoft.ReactNative/Modules/AppThemeModuleUwp.h +0 -2
  229. package/Microsoft.ReactNative/Modules/AppearanceModule.cpp +1 -9
  230. package/Microsoft.ReactNative/Modules/DevSettingsModule.cpp +0 -4
  231. package/Microsoft.ReactNative/Modules/DevSettingsModule.h +0 -2
  232. package/Microsoft.ReactNative/Modules/DeviceInfoModule.cpp +16 -90
  233. package/Microsoft.ReactNative/Modules/I18nManagerModule.cpp +3 -8
  234. package/Microsoft.ReactNative/Modules/ImageViewManagerModule.cpp +11 -48
  235. package/Microsoft.ReactNative/Modules/LinkingManagerModule.cpp +0 -3
  236. package/Microsoft.ReactNative/Modules/LogBoxModule.cpp +30 -102
  237. package/Microsoft.ReactNative/Modules/LogBoxModule.h +0 -7
  238. package/Microsoft.ReactNative/Modules/Timing.cpp +7 -9
  239. package/Microsoft.ReactNative/Pch/pch.h +0 -28
  240. package/Microsoft.ReactNative/ReactCoreInjection.h +0 -1
  241. package/Microsoft.ReactNative/ReactHost/IReactInstance.h +0 -8
  242. package/Microsoft.ReactNative/ReactHost/MsoReactContext.cpp +0 -15
  243. package/Microsoft.ReactNative/ReactHost/MsoReactContext.h +0 -2
  244. package/Microsoft.ReactNative/ReactHost/React.h +0 -44
  245. package/Microsoft.ReactNative/ReactHost/ReactHost.cpp +10 -47
  246. package/Microsoft.ReactNative/ReactHost/ReactHost.h +1 -1
  247. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +30 -586
  248. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.h +2 -37
  249. package/Microsoft.ReactNative/ReactHost/ReactNativeHeaders.h +0 -13
  250. package/Microsoft.ReactNative/ReactHost/React_Win.h +0 -1
  251. package/Microsoft.ReactNative/ReactInstanceSettings.cpp +0 -8
  252. package/Microsoft.ReactNative/ReactInstanceSettings.h +0 -13
  253. package/Microsoft.ReactNative/ReactInstanceSettings.idl +7 -23
  254. package/Microsoft.ReactNative/ReactNativeHost.cpp +10 -35
  255. package/Microsoft.ReactNative/ReactNativeHost.h +0 -1
  256. package/Microsoft.ReactNative/ReactNativeIsland.idl +0 -4
  257. package/Microsoft.ReactNative/ReactPackageBuilder.cpp +9 -36
  258. package/Microsoft.ReactNative/ReactPackageBuilder.h +4 -38
  259. package/Microsoft.ReactNative/RedBox.cpp +9 -362
  260. package/Microsoft.ReactNative/Theme.idl +0 -2
  261. package/Microsoft.ReactNative/Timer.cpp +3 -2
  262. package/Microsoft.ReactNative/Utils/Helpers.cpp +0 -47
  263. package/Microsoft.ReactNative/Utils/Helpers.h +0 -5
  264. package/Microsoft.ReactNative/Utils/IcuUtils.cpp +84 -0
  265. package/Microsoft.ReactNative/Utils/IcuUtils.h +42 -0
  266. package/Microsoft.ReactNative/Utils/KeyboardUtils.cpp +0 -11
  267. package/Microsoft.ReactNative/Utils/ThemeUtils.cpp +0 -4
  268. package/Microsoft.ReactNative/Utils/ThemeUtils.h +1 -5
  269. package/Microsoft.ReactNative/Utils/UwpPreparedScriptStore.h +0 -2
  270. package/Microsoft.ReactNative/Utils/ValueUtils.cpp +0 -245
  271. package/Microsoft.ReactNative/Utils/ValueUtils.h +0 -23
  272. package/Microsoft.ReactNative/ViewProps.idl +0 -2
  273. package/Microsoft.ReactNative/Views/DevMenu.cpp +2 -278
  274. package/Microsoft.ReactNative/Views/DevMenu.h +0 -5
  275. package/Microsoft.ReactNative/XamlApplication.cpp +71 -0
  276. package/Microsoft.ReactNative/XamlApplication.h +47 -0
  277. package/Microsoft.ReactNative/XamlApplication.idl +19 -0
  278. package/Microsoft.ReactNative/XamlUIService.cpp +0 -54
  279. package/Microsoft.ReactNative/XamlUIService.h +0 -12
  280. package/Microsoft.ReactNative/XamlUIService.idl +0 -12
  281. package/Microsoft.ReactNative.Cxx/CppWinRTIncludes.h +0 -19
  282. package/Microsoft.ReactNative.Cxx/DesktopWindowBridge.h +1 -1
  283. package/Microsoft.ReactNative.Cxx/JSI/decorator.h +191 -114
  284. package/Microsoft.ReactNative.Cxx/JSI/instrumentation.h +5 -0
  285. package/Microsoft.ReactNative.Cxx/JSI/jsi-inl.h +37 -0
  286. package/Microsoft.ReactNative.Cxx/JSI/jsi.cpp +68 -0
  287. package/Microsoft.ReactNative.Cxx/JSI/jsi.h +77 -11
  288. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems +2 -2
  289. package/Microsoft.ReactNative.Cxx/NamespaceRedirect.h +0 -5
  290. package/Microsoft.ReactNative.Cxx/NodeApiJsiRuntime.cpp +93 -1
  291. package/Microsoft.ReactNative.Cxx/ReactCommon/TurboModule.cpp +4 -3
  292. package/Microsoft.ReactNative.Cxx/ReactCommon/TurboModule.h +2 -2
  293. package/Microsoft.ReactNative.Cxx/ReactCommon/TurboModuleUtils.cpp +2 -55
  294. package/Microsoft.ReactNative.Cxx/ReactCommon/TurboModuleUtils.h +4 -8
  295. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Class.h +5 -0
  296. package/Microsoft.ReactNative.Cxx/ReactCommon/react/timing/primitives.h +32 -4
  297. package/Microsoft.ReactNative.Cxx/ReactContext.h +0 -13
  298. package/Microsoft.ReactNative.Cxx/StructInfo.h +8 -1
  299. package/Microsoft.ReactNative.Cxx/UI.Composition.Effects.h +0 -4
  300. package/Microsoft.ReactNative.Cxx/UI.Composition.h +0 -4
  301. package/Microsoft.ReactNative.Cxx/UI.Input.h +0 -4
  302. package/Microsoft.ReactNative.Cxx/UI.Popups.h +0 -4
  303. package/Microsoft.ReactNative.Cxx/UI.Text.h +0 -4
  304. package/Microsoft.ReactNative.Cxx/XamlUtils.h +0 -33
  305. package/Microsoft.ReactNative.Managed/JSValueReader.cs +0 -4
  306. package/Microsoft.ReactNative.Managed/Microsoft.ReactNative.Managed.csproj +0 -3
  307. package/Microsoft.ReactNative.Managed/ReactContext.cs +0 -5
  308. package/Microsoft.ReactNative.Managed/ReactContextGenerator.cs +0 -4
  309. package/Microsoft.ReactNative.Managed/ReactPackageBuilderExtensions.cs +0 -25
  310. package/Microsoft.ReactNative.Managed/ReactSettingsSnapshot.cs +0 -4
  311. package/Microsoft.ReactNative.Managed/ReflectionReactPackageProvider.cs +1 -2
  312. package/Microsoft.ReactNative.Managed.CodeGen/CodeAnalyzer.cs +0 -10
  313. package/Microsoft.ReactNative.Managed.CodeGen/CodeGenerator.ViewManager.cs +0 -36
  314. package/Microsoft.ReactNative.Managed.CodeGen/CodeGenerator.cs +0 -6
  315. package/Microsoft.ReactNative.Managed.CodeGen/Model/ReactAssembly.cs +0 -2
  316. package/Microsoft.ReactNative.Managed.CodeGen/Model/ReactTypes.cs +0 -2
  317. package/Microsoft.ReactNative.Managed.CodeGen/ReactNativeNames.cs +0 -2
  318. package/Mso/src/dispatchQueue/queueService.cpp +3 -1
  319. package/Mso/src/dispatchQueue/uiScheduler_winrt.cpp +2 -10
  320. package/PropertySheets/Bundle.Common.targets +1 -1
  321. package/PropertySheets/Bundle.props +3 -4
  322. package/PropertySheets/External/Microsoft.ReactNative.Common.props +0 -1
  323. package/PropertySheets/External/Microsoft.ReactNative.Uwp.CSharpApp.targets +1 -1
  324. package/PropertySheets/External/Microsoft.ReactNative.Uwp.CppApp.targets +1 -1
  325. package/PropertySheets/Generated/PackageVersion.g.props +4 -4
  326. package/PropertySheets/JSEngine.props +1 -1
  327. package/PropertySheets/NuGet.LockFile.props +0 -8
  328. package/PropertySheets/OutputMSBuildProperties.targets +0 -1
  329. package/PropertySheets/React.Cpp.props +3 -5
  330. package/PropertySheets/WinUI.props +3 -3
  331. package/README.md +1 -5
  332. package/ReactCommon/ReactCommon.vcxproj +12 -31
  333. package/ReactCommon/ReactCommon.vcxproj.filters +0 -3
  334. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/CxxNativeModule.cpp +3 -2
  335. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/NativeToJsBridge.cpp +5 -2
  336. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/TraceSection.h +20 -4
  337. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsi/jsi/test/testlib.cpp +113 -1
  338. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.cpp +14 -6
  339. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/Utf8.h +1 -0
  340. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/tracing/RuntimeSamplingProfileTraceEventSerializer.cpp +351 -0
  341. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModule.h +2 -2
  342. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/dom/NativeDOM.cpp +42 -36
  343. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/dom/NativeDOM.h +15 -3
  344. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp +1 -1
  345. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/image/conversions.h +174 -0
  346. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/text/ParagraphShadowNode.cpp +1 -0
  347. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/AccessibilityPrimitives.h +26 -3
  348. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/conversions.h +1 -1
  349. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/ShadowNode.cpp +1 -1
  350. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/imagemanager/primitives.h +189 -0
  351. package/ReactCommon/TEMP_UntilReactCommonUpdate/reactperflogger/reactperflogger/ReactPerfettoLogger.cpp +27 -8
  352. package/ReactCommon/cgmanifest.json +1 -1
  353. package/Scripts/Microsoft.ReactNative.nuspec +15 -33
  354. package/Scripts/NuGetRestoreForceEvaluateAllSolutions.ps1 +23 -23
  355. package/Scripts/OfficeReact.Win32.nuspec +0 -3
  356. package/Scripts/creaternwapp.cmd +1 -1
  357. package/Shared/DevServerHelper.h +17 -21
  358. package/Shared/DevSettings.h +1 -25
  359. package/Shared/DevSupportManager.cpp +0 -50
  360. package/Shared/DevSupportManager.h +0 -4
  361. package/Shared/Hermes/HermesRuntimeTargetDelegate.cpp +5 -1
  362. package/Shared/HermesRuntimeHolder.cpp +0 -31
  363. package/Shared/HermesRuntimeHolder.h +0 -14
  364. package/Shared/IDevSupportManager.h +0 -6
  365. package/Shared/InstanceManager.cpp +0 -97
  366. package/Shared/InstanceManager.h +0 -53
  367. package/Shared/JSI/ScriptStore.h +1 -1
  368. package/Shared/Logging.cpp +1 -12
  369. package/Shared/Modules/CxxModuleUtilities.cpp +0 -9
  370. package/Shared/Modules/CxxModuleUtilities.h +0 -8
  371. package/Shared/Networking/OriginPolicyHttpFilter.cpp +9 -1
  372. package/Shared/OInstance.cpp +144 -424
  373. package/Shared/OInstance.h +0 -81
  374. package/Shared/Shared.vcxitems +83 -203
  375. package/Shared/Shared.vcxitems.filters +8 -67
  376. package/Shared/Threading/MessageQueueThreadFactory.cpp +0 -6
  377. package/Shared/Threading/MessageQueueThreadFactory.h +0 -4
  378. package/Shared/TurboModuleManager.cpp +0 -4
  379. package/Shared/Utils.cpp +26 -0
  380. package/Shared/Utils.h +3 -0
  381. package/codegen/NativeDOMSpec.g.h +41 -35
  382. package/codegen/NativeIntersectionObserverSpec.g.h +9 -21
  383. package/codegen/NativePerformanceSpec.g.h +47 -35
  384. package/codegen/NativeReactNativeFeatureFlagsSpec.g.h +177 -129
  385. package/codegen/react/components/rnwcore/ActivityIndicatorView.g.h +14 -0
  386. package/codegen/react/components/rnwcore/AndroidDrawerLayout.g.h +14 -0
  387. package/codegen/react/components/rnwcore/AndroidHorizontalScrollContentView.g.h +14 -0
  388. package/codegen/react/components/rnwcore/AndroidProgressBar.g.h +14 -0
  389. package/codegen/react/components/rnwcore/AndroidSwipeRefreshLayout.g.h +14 -0
  390. package/codegen/react/components/rnwcore/AndroidSwitch.g.h +14 -0
  391. package/codegen/react/components/rnwcore/DebuggingOverlay.g.h +14 -0
  392. package/codegen/react/components/rnwcore/EventEmitters.cpp +25 -0
  393. package/codegen/react/components/rnwcore/EventEmitters.h +25 -0
  394. package/codegen/react/components/rnwcore/InputAccessory.g.h +14 -0
  395. package/codegen/react/components/rnwcore/ModalHostView.g.h +14 -0
  396. package/codegen/react/components/rnwcore/Props.cpp +41 -2
  397. package/codegen/react/components/rnwcore/Props.h +51 -2
  398. package/codegen/react/components/rnwcore/PullToRefreshView.g.h +14 -0
  399. package/codegen/react/components/rnwcore/SafeAreaView.g.h +14 -0
  400. package/codegen/react/components/rnwcore/Switch.g.h +14 -0
  401. package/codegen/react/components/rnwcore/UnimplementedNativeView.g.h +14 -0
  402. package/codegen/react/components/rnwcore/VirtualView.g.h +18 -0
  403. package/codegen/react/components/rnwcore/VirtualViewExperimental.g.h +240 -0
  404. package/codegen/rnwcoreJSI-generated.cpp +106 -51
  405. package/codegen/rnwcoreJSI.h +148 -67
  406. package/fmt/cgmanifest.json +1 -1
  407. package/fmt/fmt.vcxproj +0 -8
  408. package/index.js +8 -2
  409. package/index.windows.js +8 -2
  410. package/jest/local-setup.js +2 -2
  411. package/jest/mock.js +1 -1
  412. package/jest/mockComponent.js +9 -9
  413. package/jest/mockNativeComponent.js +3 -2
  414. package/jest/mocks/Modal.js +1 -1
  415. package/jest/mocks/ScrollView.js +1 -1
  416. package/jest/mocks/ViewNativeComponent.js +1 -1
  417. package/jest/setup.js +23 -12
  418. package/just-task.js +14 -0
  419. package/package.json +31 -32
  420. package/src/private/animated/NativeAnimatedHelper.js +16 -5
  421. package/src/private/animated/createAnimatedPropsHook.js +11 -60
  422. package/src/private/animated/createAnimatedPropsMemoHook.js +8 -54
  423. package/src/private/components/virtualview/VirtualView.js +43 -12
  424. package/src/private/components/virtualview/VirtualViewExperimentalNativeComponent.js +93 -0
  425. package/src/private/components/virtualview/VirtualViewNativeComponent.js +6 -0
  426. package/src/private/devsupport/devmenu/elementinspector/Inspector.js +2 -2
  427. package/src/private/devsupport/devmenu/elementinspector/ReactDevToolsOverlay.js +2 -2
  428. package/src/private/featureflags/ReactNativeFeatureFlags.js +80 -52
  429. package/src/private/featureflags/ReactNativeFeatureFlagsBase.js +23 -4
  430. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +14 -6
  431. package/src/private/renderer/errorhandling/ErrorHandlers.js +3 -3
  432. package/src/private/specs_DEPRECATED/components/SwitchNativeComponent.js +0 -1
  433. package/src/private/types/HostInstance.js +4 -1
  434. package/src/private/webapis/dom/nodes/ReactNativeDocument.js +22 -2
  435. package/src/private/webapis/dom/nodes/ReactNativeElement.js +1 -1
  436. package/src/private/webapis/dom/nodes/ReadOnlyElement.js +5 -3
  437. package/src/private/webapis/dom/nodes/ReadOnlyNode.js +16 -13
  438. package/src/private/webapis/dom/nodes/internals/NodeInternals.js +45 -22
  439. package/src/private/webapis/dom/nodes/internals/ReactNativeDocumentInstanceHandle.js +1 -1
  440. package/src/private/webapis/dom/nodes/specs/NativeDOM.js +26 -192
  441. package/src/private/webapis/dom/oldstylecollections/HTMLCollection.js +15 -12
  442. package/src/private/webapis/dom/oldstylecollections/NodeList.js +14 -11
  443. package/src/private/webapis/geometry/DOMRectList.js +2 -2
  444. package/src/private/webapis/intersectionobserver/internals/IntersectionObserverManager.js +19 -74
  445. package/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js +0 -4
  446. package/src/private/webapis/mutationobserver/internals/MutationObserverManager.js +1 -1
  447. package/src/private/webapis/performance/EventTiming.js +6 -10
  448. package/src/private/webapis/performance/Performance.js +309 -164
  449. package/src/private/webapis/performance/PerformanceEntry.js +20 -16
  450. package/src/private/webapis/performance/PerformanceObserver.js +8 -29
  451. package/src/private/webapis/performance/UserTiming.js +71 -18
  452. package/src/private/webapis/performance/UserTimingExtensibility.js.flow +38 -0
  453. package/src/private/webapis/performance/internals/Utilities.js +9 -0
  454. package/src/private/webapis/performance/specs/NativePerformance.js +21 -23
  455. package/src/private/webapis/structuredClone/structuredClone.js +10 -10
  456. package/stubs/double-conversion/README.md +1 -1
  457. package/template/cpp-lib/proj/MyLib.sln +0 -5
  458. package/template/cpp-lib/src/pch.h +0 -5
  459. package/template/cs-lib/proj/MyLib.sln +0 -5
  460. package/template/metro.config.js +1 -0
  461. package/templates/cpp-app/metro.config.js +2 -1
  462. package/templates/cpp-app/windows/MyApp.sln +0 -5
  463. package/templates/cpp-lib/example/metro.config.js +3 -4
  464. package/templates/cpp-lib/windows/MyLib.sln +0 -5
  465. package/Chakra/Chakra.vcxitems +0 -32
  466. package/Chakra/Chakra.vcxitems.filters +0 -54
  467. package/Chakra/ChakraHelpers.cpp +0 -468
  468. package/Chakra/ChakraHelpers.h +0 -146
  469. package/Chakra/ChakraInstanceArgs.h +0 -52
  470. package/Chakra/ChakraPlatform.cpp +0 -42
  471. package/Chakra/ChakraPlatform.h +0 -51
  472. package/Chakra/ChakraTracing.cpp +0 -275
  473. package/Chakra/ChakraTracing.h +0 -11
  474. package/Chakra/ChakraUtils.cpp +0 -190
  475. package/Chakra/ChakraUtils.h +0 -72
  476. package/Chakra/ChakraValue.cpp +0 -257
  477. package/Chakra/ChakraValue.h +0 -308
  478. package/Chakra/Utf8DebugExtensions.cpp +0 -62
  479. package/Chakra/Utf8DebugExtensions.h +0 -29
  480. package/Libraries/Interaction/InteractionManagerStub.js +0 -184
  481. package/Libraries/Interaction/TaskQueue.js +0 -183
  482. package/Libraries/ReactNative/ReactNativeFeatureFlags.js +0 -31
  483. package/Microsoft.ReactNative/ABICxxModule.cpp +0 -51
  484. package/Microsoft.ReactNative/ABICxxModule.h +0 -38
  485. package/Microsoft.ReactNative/ABIViewManager.cpp +0 -263
  486. package/Microsoft.ReactNative/ABIViewManager.h +0 -100
  487. package/Microsoft.ReactNative/Base/CoreUIManagers.cpp +0 -55
  488. package/Microsoft.ReactNative/DevMenuControl.cpp +0 -14
  489. package/Microsoft.ReactNative/DevMenuControl.h +0 -20
  490. package/Microsoft.ReactNative/DevMenuControl.idl +0 -28
  491. package/Microsoft.ReactNative/DevMenuControl.xaml +0 -139
  492. package/Microsoft.ReactNative/GlyphViewManager.cpp +0 -167
  493. package/Microsoft.ReactNative/GlyphViewManager.h +0 -24
  494. package/Microsoft.ReactNative/INativeUIManager.h +0 -75
  495. package/Microsoft.ReactNative/IViewManager.idl +0 -120
  496. package/Microsoft.ReactNative/IViewManagerCore.idl +0 -45
  497. package/Microsoft.ReactNative/LayoutService.cpp +0 -51
  498. package/Microsoft.ReactNative/LayoutService.h +0 -32
  499. package/Microsoft.ReactNative/LayoutService.idl +0 -41
  500. package/Microsoft.ReactNative/Modules/NativeUIManager.cpp +0 -1187
  501. package/Microsoft.ReactNative/Modules/NativeUIManager.h +0 -128
  502. package/Microsoft.ReactNative/Modules/PaperUIManagerModule.cpp +0 -891
  503. package/Microsoft.ReactNative/Modules/PaperUIManagerModule.h +0 -185
  504. package/Microsoft.ReactNative/NativeModulesProvider.cpp +0 -49
  505. package/Microsoft.ReactNative/NativeModulesProvider.h +0 -25
  506. package/Microsoft.ReactNative/ReactApplication.cpp +0 -276
  507. package/Microsoft.ReactNative/ReactApplication.h +0 -156
  508. package/Microsoft.ReactNative/ReactApplication.idl +0 -48
  509. package/Microsoft.ReactNative/ReactHost/ViewManagerProvider.h +0 -19
  510. package/Microsoft.ReactNative/ReactPointerEventArgs.cpp +0 -55
  511. package/Microsoft.ReactNative/ReactPointerEventArgs.h +0 -32
  512. package/Microsoft.ReactNative/ReactPointerEventArgs.idl +0 -79
  513. package/Microsoft.ReactNative/ReactRootView.cpp +0 -592
  514. package/Microsoft.ReactNative/ReactRootView.h +0 -127
  515. package/Microsoft.ReactNative/ReactRootView.idl +0 -40
  516. package/Microsoft.ReactNative/TestHook.cpp +0 -99
  517. package/Microsoft.ReactNative/TestHook.h +0 -15
  518. package/Microsoft.ReactNative/Utils/AccessibilityUtils.cpp +0 -36
  519. package/Microsoft.ReactNative/Utils/AccessibilityUtils.h +0 -15
  520. package/Microsoft.ReactNative/Utils/BatchingEventEmitter.cpp +0 -171
  521. package/Microsoft.ReactNative/Utils/BatchingEventEmitter.h +0 -72
  522. package/Microsoft.ReactNative/Utils/PropertyHandlerUtils.h +0 -87
  523. package/Microsoft.ReactNative/Utils/PropertyUtils.h +0 -568
  524. package/Microsoft.ReactNative/Utils/ResourceBrushUtils.cpp +0 -182
  525. package/Microsoft.ReactNative/Utils/ResourceBrushUtils.h +0 -58
  526. package/Microsoft.ReactNative/Utils/ShadowNodeTypeUtils.h +0 -26
  527. package/Microsoft.ReactNative/Utils/XamlIslandUtils.cpp +0 -93
  528. package/Microsoft.ReactNative/Utils/XamlIslandUtils.h +0 -48
  529. package/Microsoft.ReactNative/ViewManagersProvider.cpp +0 -39
  530. package/Microsoft.ReactNative/ViewManagersProvider.h +0 -27
  531. package/Microsoft.ReactNative/Views/ActivityIndicatorViewManager.cpp +0 -62
  532. package/Microsoft.ReactNative/Views/ActivityIndicatorViewManager.h +0 -29
  533. package/Microsoft.ReactNative/Views/ConfigureBundlerDlg.cpp +0 -186
  534. package/Microsoft.ReactNative/Views/ConfigureBundlerDlg.h +0 -11
  535. package/Microsoft.ReactNative/Views/ControlViewManager.cpp +0 -143
  536. package/Microsoft.ReactNative/Views/ControlViewManager.h +0 -38
  537. package/Microsoft.ReactNative/Views/DebuggingOverlayViewManager.cpp +0 -53
  538. package/Microsoft.ReactNative/Views/DebuggingOverlayViewManager.h +0 -30
  539. package/Microsoft.ReactNative/Views/DynamicAutomationPeer.cpp +0 -586
  540. package/Microsoft.ReactNative/Views/DynamicAutomationPeer.h +0 -104
  541. package/Microsoft.ReactNative/Views/DynamicAutomationProperties.cpp +0 -330
  542. package/Microsoft.ReactNative/Views/DynamicAutomationProperties.h +0 -111
  543. package/Microsoft.ReactNative/Views/DynamicValueProvider.cpp +0 -59
  544. package/Microsoft.ReactNative/Views/DynamicValueProvider.h +0 -32
  545. package/Microsoft.ReactNative/Views/ExpressionAnimationStore.cpp +0 -61
  546. package/Microsoft.ReactNative/Views/ExpressionAnimationStore.h +0 -26
  547. package/Microsoft.ReactNative/Views/FlyoutViewManager.cpp +0 -559
  548. package/Microsoft.ReactNative/Views/FlyoutViewManager.h +0 -34
  549. package/Microsoft.ReactNative/Views/FrameworkElementTransferProperties.cpp +0 -126
  550. package/Microsoft.ReactNative/Views/FrameworkElementTransferProperties.h +0 -23
  551. package/Microsoft.ReactNative/Views/FrameworkElementViewManager.cpp +0 -957
  552. package/Microsoft.ReactNative/Views/FrameworkElementViewManager.h +0 -41
  553. package/Microsoft.ReactNative/Views/IXamlRootView.h +0 -17
  554. package/Microsoft.ReactNative/Views/Image/ImageViewManager.cpp +0 -245
  555. package/Microsoft.ReactNative/Views/Image/ImageViewManager.h +0 -45
  556. package/Microsoft.ReactNative/Views/Image/ReactImage.cpp +0 -469
  557. package/Microsoft.ReactNative/Views/Image/ReactImage.h +0 -80
  558. package/Microsoft.ReactNative/Views/Image/ReactImageBrush.cpp +0 -247
  559. package/Microsoft.ReactNative/Views/Image/ReactImageBrush.h +0 -67
  560. package/Microsoft.ReactNative/Views/KeyboardEventHandler.cpp +0 -261
  561. package/Microsoft.ReactNative/Views/KeyboardEventHandler.h +0 -132
  562. package/Microsoft.ReactNative/Views/PaperShadowNode.cpp +0 -18
  563. package/Microsoft.ReactNative/Views/PaperShadowNode.h +0 -38
  564. package/Microsoft.ReactNative/Views/PopupViewManager.cpp +0 -349
  565. package/Microsoft.ReactNative/Views/PopupViewManager.h +0 -36
  566. package/Microsoft.ReactNative/Views/RawTextViewManager.cpp +0 -69
  567. package/Microsoft.ReactNative/Views/RawTextViewManager.h +0 -46
  568. package/Microsoft.ReactNative/Views/ReactViewInstance.cpp +0 -43
  569. package/Microsoft.ReactNative/Views/ReactViewInstance.h +0 -53
  570. package/Microsoft.ReactNative/Views/RefreshControlManager.cpp +0 -116
  571. package/Microsoft.ReactNative/Views/RefreshControlManager.h +0 -28
  572. package/Microsoft.ReactNative/Views/RootViewManager.cpp +0 -65
  573. package/Microsoft.ReactNative/Views/RootViewManager.h +0 -36
  574. package/Microsoft.ReactNative/Views/SIPEventHandler.cpp +0 -117
  575. package/Microsoft.ReactNative/Views/SIPEventHandler.h +0 -45
  576. package/Microsoft.ReactNative/Views/ScrollContentViewManager.cpp +0 -16
  577. package/Microsoft.ReactNative/Views/ScrollContentViewManager.h +0 -19
  578. package/Microsoft.ReactNative/Views/ScrollViewManager.cpp +0 -540
  579. package/Microsoft.ReactNative/Views/ScrollViewManager.h +0 -42
  580. package/Microsoft.ReactNative/Views/ShadowNodeBase.cpp +0 -228
  581. package/Microsoft.ReactNative/Views/ShadowNodeBase.h +0 -169
  582. package/Microsoft.ReactNative/Views/ShadowNodeRegistry.cpp +0 -68
  583. package/Microsoft.ReactNative/Views/ShadowNodeRegistry.h +0 -40
  584. package/Microsoft.ReactNative/Views/SliderViewManager.cpp +0 -97
  585. package/Microsoft.ReactNative/Views/SliderViewManager.h +0 -32
  586. package/Microsoft.ReactNative/Views/SwitchViewManager.cpp +0 -227
  587. package/Microsoft.ReactNative/Views/SwitchViewManager.h +0 -31
  588. package/Microsoft.ReactNative/Views/Text/TextHighlighterVisitor.cpp +0 -52
  589. package/Microsoft.ReactNative/Views/Text/TextHighlighterVisitor.h +0 -37
  590. package/Microsoft.ReactNative/Views/Text/TextHitTestUtils.cpp +0 -348
  591. package/Microsoft.ReactNative/Views/Text/TextHitTestUtils.h +0 -13
  592. package/Microsoft.ReactNative/Views/Text/TextHitTestVisitor.cpp +0 -76
  593. package/Microsoft.ReactNative/Views/Text/TextHitTestVisitor.h +0 -32
  594. package/Microsoft.ReactNative/Views/Text/TextParentVisitor.cpp +0 -12
  595. package/Microsoft.ReactNative/Views/Text/TextParentVisitor.h +0 -19
  596. package/Microsoft.ReactNative/Views/Text/TextPropertyChangedParentVisitor.cpp +0 -75
  597. package/Microsoft.ReactNative/Views/Text/TextPropertyChangedParentVisitor.h +0 -43
  598. package/Microsoft.ReactNative/Views/Text/TextTransformParentVisitor.cpp +0 -21
  599. package/Microsoft.ReactNative/Views/Text/TextTransformParentVisitor.h +0 -23
  600. package/Microsoft.ReactNative/Views/Text/TextTransformVisitor.cpp +0 -70
  601. package/Microsoft.ReactNative/Views/Text/TextTransformVisitor.h +0 -34
  602. package/Microsoft.ReactNative/Views/Text/TextVisitor.cpp +0 -56
  603. package/Microsoft.ReactNative/Views/Text/TextVisitor.h +0 -34
  604. package/Microsoft.ReactNative/Views/Text/TextVisitorScope.h +0 -35
  605. package/Microsoft.ReactNative/Views/Text/TextVisitors.h +0 -47
  606. package/Microsoft.ReactNative/Views/TextInputViewManager.cpp +0 -1003
  607. package/Microsoft.ReactNative/Views/TextInputViewManager.h +0 -33
  608. package/Microsoft.ReactNative/Views/TextViewManager.cpp +0 -414
  609. package/Microsoft.ReactNative/Views/TextViewManager.h +0 -47
  610. package/Microsoft.ReactNative/Views/TouchEventHandler.cpp +0 -608
  611. package/Microsoft.ReactNative/Views/TouchEventHandler.h +0 -116
  612. package/Microsoft.ReactNative/Views/UnimplementedViewManager.cpp +0 -79
  613. package/Microsoft.ReactNative/Views/UnimplementedViewManager.h +0 -27
  614. package/Microsoft.ReactNative/Views/ViewControl.cpp +0 -43
  615. package/Microsoft.ReactNative/Views/ViewControl.h +0 -32
  616. package/Microsoft.ReactNative/Views/ViewManager.h +0 -33
  617. package/Microsoft.ReactNative/Views/ViewManagerBase.cpp +0 -487
  618. package/Microsoft.ReactNative/Views/ViewManagerBase.h +0 -121
  619. package/Microsoft.ReactNative/Views/ViewPanel.cpp +0 -164
  620. package/Microsoft.ReactNative/Views/ViewPanel.h +0 -82
  621. package/Microsoft.ReactNative/Views/ViewViewManager.cpp +0 -507
  622. package/Microsoft.ReactNative/Views/ViewViewManager.h +0 -52
  623. package/Microsoft.ReactNative/Views/VirtualTextViewManager.cpp +0 -143
  624. package/Microsoft.ReactNative/Views/VirtualTextViewManager.h +0 -57
  625. package/Microsoft.ReactNative/Views/XamlFeatures.cpp +0 -11
  626. package/Microsoft.ReactNative/Views/XamlFeatures.h +0 -11
  627. package/Microsoft.ReactNative/Views/cppwinrt/AccessibilityAction.idl +0 -12
  628. package/Microsoft.ReactNative/Views/cppwinrt/DynamicAutomationPeer.idl +0 -231
  629. package/Microsoft.ReactNative/Views/cppwinrt/ViewPanel.idl +0 -48
  630. package/Microsoft.ReactNative/XamlHelper.cpp +0 -78
  631. package/Microsoft.ReactNative/XamlHelper.h +0 -54
  632. package/Microsoft.ReactNative/XamlHelper.idl +0 -30
  633. package/Microsoft.ReactNative/XamlLoadState.cpp +0 -217
  634. package/Microsoft.ReactNative/XamlLoadState.h +0 -44
  635. package/Microsoft.ReactNative/XamlView.cpp +0 -59
  636. package/Microsoft.ReactNative/XamlView.h +0 -58
  637. package/Microsoft.ReactNative/getLayoutProps.ps1 +0 -5
  638. package/Microsoft.ReactNative.Cxx/UI.Xaml.Automation.Peers.h +0 -10
  639. package/Microsoft.ReactNative.Cxx/UI.Xaml.Automation.h +0 -10
  640. package/Microsoft.ReactNative.Cxx/UI.Xaml.Controls.Primitives.h +0 -10
  641. package/Microsoft.ReactNative.Cxx/UI.Xaml.Controls.h +0 -13
  642. package/Microsoft.ReactNative.Cxx/UI.Xaml.Documents.h +0 -10
  643. package/Microsoft.ReactNative.Cxx/UI.Xaml.Hosting.DesktopWindowXamlSource.h +0 -11
  644. package/Microsoft.ReactNative.Cxx/UI.Xaml.Hosting.h +0 -10
  645. package/Microsoft.ReactNative.Cxx/UI.Xaml.Input.h +0 -10
  646. package/Microsoft.ReactNative.Cxx/UI.Xaml.Markup.h +0 -10
  647. package/Microsoft.ReactNative.Cxx/UI.Xaml.Media.Imaging.h +0 -10
  648. package/Microsoft.ReactNative.Cxx/UI.Xaml.Media.Media3D.h +0 -10
  649. package/Microsoft.ReactNative.Cxx/UI.Xaml.Media.h +0 -10
  650. package/Microsoft.ReactNative.Cxx/UI.Xaml.Navigation.h +0 -10
  651. package/Microsoft.ReactNative.Cxx/UI.Xaml.Shapes.h +0 -10
  652. package/Microsoft.ReactNative.Managed/AttributedViewManager.cs +0 -527
  653. package/Microsoft.ReactNative.Managed/ViewManagerAttributes.cs +0 -91
  654. package/Microsoft.ReactNative.Managed/ViewManagerEvent.cs +0 -13
  655. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/AccessibilityProps.cpp +0 -344
  656. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/DynamicEventPayload.cpp +0 -42
  657. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/YGEnums.h +0 -146
  658. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/algorithm/CalculateLayout.cpp +0 -2435
  659. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/enums/ExperimentalFeature.h +0 -40
  660. package/Shared/BatchingMessageQueueThread.h +0 -20
  661. package/Shared/ChakraRuntimeHolder.cpp +0 -62
  662. package/Shared/ChakraRuntimeHolder.h +0 -46
  663. package/Shared/CreateInstance.h +0 -25
  664. package/Shared/Executors/WebSocketJSExecutor.cpp +0 -294
  665. package/Shared/Executors/WebSocketJSExecutor.h +0 -123
  666. package/Shared/Executors/WebSocketJSExecutorFactory.cpp +0 -25
  667. package/Shared/Hermes/HermesSamplingProfiler.cpp +0 -114
  668. package/Shared/Hermes/HermesSamplingProfiler.h +0 -26
  669. package/Shared/JSI/ChakraApi.cpp +0 -436
  670. package/Shared/JSI/ChakraApi.h +0 -474
  671. package/Shared/JSI/ChakraJsiRuntime_edgemode.cpp +0 -100
  672. package/Shared/JSI/ChakraRuntime.cpp +0 -1132
  673. package/Shared/JSI/ChakraRuntime.h +0 -512
  674. package/Shared/JSI/ChakraRuntimeArgs.h +0 -45
  675. package/Shared/JSI/ChakraRuntimeFactory.h +0 -15
  676. package/Shared/JSI/JSExecutorFactoryDelegate.h +0 -12
  677. package/Shared/JSI/JSExecutorFactorySettings.cpp +0 -30
  678. package/Shared/JSI/JSExecutorFactorySettings.h +0 -21
  679. package/Shared/NativeModuleProvider.h +0 -40
  680. package/Shared/SystemChakraRuntime.h +0 -38
  681. package/Shared/Threading/BatchingQueueThread.cpp +0 -128
  682. package/Shared/Threading/BatchingQueueThread.h +0 -59
  683. package/Shared/WebSocketJSExecutorFactory.h +0 -27
  684. package/fmt/TEMP_UntilFmtUpdate/core.h +0 -2925
  685. package/template/cpp-app/proj/MyApp.sln +0 -166
  686. package/template/cpp-app/proj/MyApp.vcxproj +0 -176
  687. package/template/cpp-app/proj/MyApp.vcxproj.filters +0 -62
  688. package/template/cpp-app/src/App.cpp +0 -93
  689. package/template/cpp-app/src/App.h +0 -21
  690. package/template/cpp-app/src/App.idl +0 -3
  691. package/template/cpp-app/src/AutolinkedNativeModules.g.cpp +0 -13
  692. package/template/cpp-app/src/AutolinkedNativeModules.g.h +0 -10
  693. package/template/cpp-app/src/MainPage.cpp +0 -20
  694. package/template/cpp-app/src/MainPage.h +0 -19
  695. package/template/cpp-app/src/MainPage.idl +0 -10
  696. package/template/cpp-app/src/PropertySheet.props +0 -16
  697. package/template/cpp-app/src/ReactPackageProvider.cpp +0 -15
  698. package/template/cpp-app/src/ReactPackageProvider.h +0 -13
  699. package/template/cpp-app/src/pch.cpp +0 -1
  700. package/template/cpp-app/src/pch.h +0 -24
  701. package/template/cs-app/proj/MyApp.csproj +0 -162
  702. package/template/cs-app/proj/MyApp.sln +0 -191
  703. package/template/cs-app/src/App.xaml.cs +0 -62
  704. package/template/cs-app/src/AutolinkedNativeModules.g.cs +0 -13
  705. package/template/cs-app/src/MainPage.xaml.cs +0 -34
  706. package/template/cs-app/src/Properties/AssemblyInfo.cs +0 -29
  707. package/template/cs-app/src/Properties/Default.rd.xml +0 -32
  708. package/template/cs-app/src/ReactPackageProvider.cs +0 -17
  709. package/template/shared-app/assets/LockScreenLogo.scale-200.png +0 -0
  710. package/template/shared-app/assets/SplashScreen.scale-200.png +0 -0
  711. package/template/shared-app/assets/Square150x150Logo.scale-200.png +0 -0
  712. package/template/shared-app/assets/Square44x44Logo.scale-200.png +0 -0
  713. package/template/shared-app/assets/Square44x44Logo.targetsize-24_altform-unplated.png +0 -0
  714. package/template/shared-app/assets/StoreLogo.png +0 -0
  715. package/template/shared-app/assets/Wide310x150Logo.scale-200.png +0 -0
  716. package/template/shared-app/proj/ExperimentalFeatures.props +0 -32
  717. package/template/shared-app/proj/NuGet_Config +0 -19
  718. package/template/shared-app/src/App.xaml +0 -10
  719. package/template/shared-app/src/AutolinkedNativeModules.g.props +0 -6
  720. package/template/shared-app/src/AutolinkedNativeModules.g.targets +0 -6
  721. package/template/shared-app/src/MainPage.xaml +0 -21
  722. package/template/shared-app/src/Package.appxmanifest +0 -50
  723. package/templates/old/uwp-cpp-app/template.config.js +0 -15
  724. package/templates/old/uwp-cs-app/template.config.js +0 -15
@@ -1,2435 +0,0 @@
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 <algorithm>
9
- #include <atomic>
10
- #include <cfloat>
11
- #include <cmath>
12
- #include <cstring>
13
-
14
- #include <yoga/Yoga.h>
15
-
16
- #include <yoga/algorithm/AbsoluteLayout.h>
17
- #include <yoga/algorithm/Align.h>
18
- #include <yoga/algorithm/Baseline.h>
19
- #include <yoga/algorithm/BoundAxis.h>
20
- #include <yoga/algorithm/Cache.h>
21
- #include <yoga/algorithm/CalculateLayout.h>
22
- #include <yoga/algorithm/FlexDirection.h>
23
- #include <yoga/algorithm/FlexLine.h>
24
- #include <yoga/algorithm/PixelGrid.h>
25
- #include <yoga/algorithm/SizingMode.h>
26
- #include <yoga/algorithm/TrailingPosition.h>
27
- #include <yoga/debug/AssertFatal.h>
28
- #include <yoga/debug/Log.h>
29
- #include <yoga/event/event.h>
30
- #include <yoga/node/Node.h>
31
- #include <yoga/numeric/Comparison.h>
32
- #include <yoga/numeric/FloatOptional.h>
33
-
34
- namespace facebook::yoga {
35
-
36
- std::atomic<uint32_t> gCurrentGenerationCount(0);
37
-
38
- static void constrainMaxSizeForMode(
39
- const yoga::Node* node,
40
- Direction direction,
41
- FlexDirection axis,
42
- float ownerAxisSize,
43
- float ownerWidth,
44
- /*in_out*/ SizingMode* mode,
45
- /*in_out*/ float* size) {
46
- const FloatOptional maxSize =
47
- node->style().resolvedMaxDimension(
48
- direction, dimension(axis), ownerAxisSize, ownerWidth) +
49
- FloatOptional(node->style().computeMarginForAxis(axis, ownerWidth));
50
- switch (*mode) {
51
- case SizingMode::StretchFit:
52
- case SizingMode::FitContent:
53
- *size = (maxSize.isUndefined() || *size < maxSize.unwrap())
54
- ? *size
55
- : maxSize.unwrap();
56
- break;
57
- case SizingMode::MaxContent:
58
- if (maxSize.isDefined()) {
59
- *mode = SizingMode::FitContent;
60
- *size = maxSize.unwrap();
61
- }
62
- break;
63
- }
64
- }
65
-
66
- static void computeFlexBasisForChild(
67
- const yoga::Node* const node,
68
- yoga::Node* const child,
69
- const float width,
70
- const SizingMode widthMode,
71
- const float height,
72
- const float ownerWidth,
73
- const float ownerHeight,
74
- const SizingMode heightMode,
75
- const Direction direction,
76
- LayoutData& layoutMarkerData,
77
- const uint32_t depth,
78
- const uint32_t generationCount) {
79
- const FlexDirection mainAxis =
80
- resolveDirection(node->style().flexDirection(), direction);
81
- const bool isMainAxisRow = isRow(mainAxis);
82
- const float mainAxisSize = isMainAxisRow ? width : height;
83
- const float mainAxisOwnerSize = isMainAxisRow ? ownerWidth : ownerHeight;
84
-
85
- float childWidth = YGUndefined;
86
- float childHeight = YGUndefined;
87
- SizingMode childWidthSizingMode;
88
- SizingMode childHeightSizingMode;
89
-
90
- const FloatOptional resolvedFlexBasis = child->resolveFlexBasis(
91
- direction, mainAxis, mainAxisOwnerSize, ownerWidth);
92
- const bool isRowStyleDimDefined =
93
- child->hasDefiniteLength(Dimension::Width, ownerWidth);
94
- const bool isColumnStyleDimDefined =
95
- child->hasDefiniteLength(Dimension::Height, ownerHeight);
96
-
97
- if (resolvedFlexBasis.isDefined() && yoga::isDefined(mainAxisSize)) {
98
- if (child->getLayout().computedFlexBasis.isUndefined() ||
99
- (child->getConfig()->isExperimentalFeatureEnabled(
100
- ExperimentalFeature::WebFlexBasis) &&
101
- child->getLayout().computedFlexBasisGeneration != generationCount)) {
102
- const FloatOptional paddingAndBorder = FloatOptional(
103
- paddingAndBorderForAxis(child, mainAxis, direction, ownerWidth));
104
- child->setLayoutComputedFlexBasis(
105
- yoga::maxOrDefined(resolvedFlexBasis, paddingAndBorder));
106
- }
107
- } else if (isMainAxisRow && isRowStyleDimDefined) {
108
- // The width is definite, so use that as the flex basis.
109
- const FloatOptional paddingAndBorder =
110
- FloatOptional(paddingAndBorderForAxis(
111
- child, FlexDirection::Row, direction, ownerWidth));
112
-
113
- child->setLayoutComputedFlexBasis(yoga::maxOrDefined(
114
- child->getResolvedDimension(
115
- direction, Dimension::Width, ownerWidth, ownerWidth),
116
- paddingAndBorder));
117
- } else if (!isMainAxisRow && isColumnStyleDimDefined) {
118
- // The height is definite, so use that as the flex basis.
119
- const FloatOptional paddingAndBorder =
120
- FloatOptional(paddingAndBorderForAxis(
121
- child, FlexDirection::Column, direction, ownerWidth));
122
- child->setLayoutComputedFlexBasis(yoga::maxOrDefined(
123
- child->getResolvedDimension(
124
- direction, Dimension::Height, ownerHeight, ownerWidth),
125
- paddingAndBorder));
126
- } else {
127
- // Compute the flex basis and hypothetical main size (i.e. the clamped flex
128
- // basis).
129
- childWidthSizingMode = SizingMode::MaxContent;
130
- childHeightSizingMode = SizingMode::MaxContent;
131
-
132
- auto marginRow =
133
- child->style().computeMarginForAxis(FlexDirection::Row, ownerWidth);
134
- auto marginColumn =
135
- child->style().computeMarginForAxis(FlexDirection::Column, ownerWidth);
136
-
137
- if (isRowStyleDimDefined) {
138
- childWidth = child
139
- ->getResolvedDimension(
140
- direction, Dimension::Width, ownerWidth, ownerWidth)
141
- .unwrap() +
142
- marginRow;
143
- childWidthSizingMode = SizingMode::StretchFit;
144
- }
145
- if (isColumnStyleDimDefined) {
146
- childHeight =
147
- child
148
- ->getResolvedDimension(
149
- direction, Dimension::Height, ownerHeight, ownerWidth)
150
- .unwrap() +
151
- marginColumn;
152
- childHeightSizingMode = SizingMode::StretchFit;
153
- }
154
-
155
- // The W3C spec doesn't say anything about the 'overflow' property, but all
156
- // major browsers appear to implement the following logic.
157
- if ((!isMainAxisRow && node->style().overflow() == Overflow::Scroll) ||
158
- node->style().overflow() != Overflow::Scroll) {
159
- if (yoga::isUndefined(childWidth) && yoga::isDefined(width)) {
160
- childWidth = width;
161
- childWidthSizingMode = SizingMode::FitContent;
162
- }
163
- }
164
-
165
- if ((isMainAxisRow && node->style().overflow() == Overflow::Scroll) ||
166
- node->style().overflow() != Overflow::Scroll) {
167
- if (yoga::isUndefined(childHeight) && yoga::isDefined(height)) {
168
- childHeight = height;
169
- childHeightSizingMode = SizingMode::FitContent;
170
- }
171
- }
172
-
173
- const auto& childStyle = child->style();
174
- if (childStyle.aspectRatio().isDefined()) {
175
- if (!isMainAxisRow && childWidthSizingMode == SizingMode::StretchFit) {
176
- childHeight = marginColumn +
177
- (childWidth - marginRow) / childStyle.aspectRatio().unwrap();
178
- childHeightSizingMode = SizingMode::StretchFit;
179
- } else if (
180
- isMainAxisRow && childHeightSizingMode == SizingMode::StretchFit) {
181
- childWidth = marginRow +
182
- (childHeight - marginColumn) * childStyle.aspectRatio().unwrap();
183
- childWidthSizingMode = SizingMode::StretchFit;
184
- }
185
- }
186
-
187
- // If child has no defined size in the cross axis and is set to stretch, set
188
- // the cross axis to be measured exactly with the available inner width
189
-
190
- const bool hasExactWidth =
191
- yoga::isDefined(width) && widthMode == SizingMode::StretchFit;
192
- const bool childWidthStretch =
193
- resolveChildAlignment(node, child) == Align::Stretch &&
194
- childWidthSizingMode != SizingMode::StretchFit;
195
- if (!isMainAxisRow && !isRowStyleDimDefined && hasExactWidth &&
196
- childWidthStretch) {
197
- childWidth = width;
198
- childWidthSizingMode = SizingMode::StretchFit;
199
- if (childStyle.aspectRatio().isDefined()) {
200
- childHeight =
201
- (childWidth - marginRow) / childStyle.aspectRatio().unwrap();
202
- childHeightSizingMode = SizingMode::StretchFit;
203
- }
204
- }
205
-
206
- const bool hasExactHeight =
207
- yoga::isDefined(height) && heightMode == SizingMode::StretchFit;
208
- const bool childHeightStretch =
209
- resolveChildAlignment(node, child) == Align::Stretch &&
210
- childHeightSizingMode != SizingMode::StretchFit;
211
- if (isMainAxisRow && !isColumnStyleDimDefined && hasExactHeight &&
212
- childHeightStretch) {
213
- childHeight = height;
214
- childHeightSizingMode = SizingMode::StretchFit;
215
-
216
- if (childStyle.aspectRatio().isDefined()) {
217
- childWidth =
218
- (childHeight - marginColumn) * childStyle.aspectRatio().unwrap();
219
- childWidthSizingMode = SizingMode::StretchFit;
220
- }
221
- }
222
-
223
- constrainMaxSizeForMode(
224
- child,
225
- direction,
226
- FlexDirection::Row,
227
- ownerWidth,
228
- ownerWidth,
229
- &childWidthSizingMode,
230
- &childWidth);
231
- constrainMaxSizeForMode(
232
- child,
233
- direction,
234
- FlexDirection::Column,
235
- ownerHeight,
236
- ownerWidth,
237
- &childHeightSizingMode,
238
- &childHeight);
239
-
240
- // Measure the child
241
- calculateLayoutInternal(
242
- child,
243
- childWidth,
244
- childHeight,
245
- direction,
246
- childWidthSizingMode,
247
- childHeightSizingMode,
248
- ownerWidth,
249
- ownerHeight,
250
- false,
251
- LayoutPassReason::kMeasureChild,
252
- layoutMarkerData,
253
- depth,
254
- generationCount);
255
-
256
- child->setLayoutComputedFlexBasis(FloatOptional(yoga::maxOrDefined(
257
- child->getLayout().measuredDimension(dimension(mainAxis)),
258
- paddingAndBorderForAxis(child, mainAxis, direction, ownerWidth))));
259
- }
260
- child->setLayoutComputedFlexBasisGeneration(generationCount);
261
- }
262
-
263
- static void measureNodeWithMeasureFunc(
264
- yoga::Node* const node,
265
- const Direction direction,
266
- float availableWidth,
267
- float availableHeight,
268
- const SizingMode widthSizingMode,
269
- const SizingMode heightSizingMode,
270
- const float ownerWidth,
271
- const float ownerHeight,
272
- LayoutData& layoutMarkerData,
273
- const LayoutPassReason reason) {
274
- yoga::assertFatalWithNode(
275
- node,
276
- node->hasMeasureFunc(),
277
- "Expected node to have custom measure function");
278
-
279
- if (widthSizingMode == SizingMode::MaxContent) {
280
- availableWidth = YGUndefined;
281
- }
282
- if (heightSizingMode == SizingMode::MaxContent) {
283
- availableHeight = YGUndefined;
284
- }
285
-
286
- const auto& layout = node->getLayout();
287
- const float paddingAndBorderAxisRow = layout.padding(PhysicalEdge::Left) +
288
- layout.padding(PhysicalEdge::Right) + layout.border(PhysicalEdge::Left) +
289
- layout.border(PhysicalEdge::Right);
290
- const float paddingAndBorderAxisColumn = layout.padding(PhysicalEdge::Top) +
291
- layout.padding(PhysicalEdge::Bottom) + layout.border(PhysicalEdge::Top) +
292
- layout.border(PhysicalEdge::Bottom);
293
-
294
- // We want to make sure we don't call measure with negative size
295
- const float innerWidth = yoga::isUndefined(availableWidth)
296
- ? availableWidth
297
- : yoga::maxOrDefined(0.0f, availableWidth - paddingAndBorderAxisRow);
298
- const float innerHeight = yoga::isUndefined(availableHeight)
299
- ? availableHeight
300
- : yoga::maxOrDefined(0.0f, availableHeight - paddingAndBorderAxisColumn);
301
-
302
- if (widthSizingMode == SizingMode::StretchFit &&
303
- heightSizingMode == SizingMode::StretchFit &&
304
- !YGConfigIsExperimentalFeatureEnabled( // [Win] YGExperimentalFeatureCallMeasureCallbackOnAllNodes check added for NetUI
305
- node->getConfig(), YGExperimentalFeatureCallMeasureCallbackOnAllNodes)) {
306
- // Don't bother sizing the text if both dimensions are already defined.
307
- node->setLayoutMeasuredDimension(
308
- boundAxis(
309
- node,
310
- FlexDirection::Row,
311
- direction,
312
- availableWidth,
313
- ownerWidth,
314
- ownerWidth),
315
- Dimension::Width);
316
- node->setLayoutMeasuredDimension(
317
- boundAxis(
318
- node,
319
- FlexDirection::Column,
320
- direction,
321
- availableHeight,
322
- ownerHeight,
323
- ownerWidth),
324
- Dimension::Height);
325
- } else {
326
- Event::publish<Event::MeasureCallbackStart>(node);
327
-
328
- // Measure the text under the current constraints.
329
- const YGSize measuredSize = node->measure(
330
- innerWidth,
331
- measureMode(widthSizingMode),
332
- innerHeight,
333
- measureMode(heightSizingMode));
334
-
335
- layoutMarkerData.measureCallbacks += 1;
336
- layoutMarkerData.measureCallbackReasonsCount[static_cast<size_t>(reason)] +=
337
- 1;
338
-
339
- Event::publish<Event::MeasureCallbackEnd>(
340
- node,
341
- {innerWidth,
342
- unscopedEnum(measureMode(widthSizingMode)),
343
- innerHeight,
344
- unscopedEnum(measureMode(heightSizingMode)),
345
- measuredSize.width,
346
- measuredSize.height,
347
- reason});
348
-
349
- node->setLayoutMeasuredDimension(
350
- boundAxis(
351
- node,
352
- FlexDirection::Row,
353
- direction,
354
- (widthSizingMode == SizingMode::MaxContent ||
355
- widthSizingMode == SizingMode::FitContent)
356
- ? measuredSize.width + paddingAndBorderAxisRow
357
- : availableWidth,
358
- ownerWidth,
359
- ownerWidth),
360
- Dimension::Width);
361
-
362
- node->setLayoutMeasuredDimension(
363
- boundAxis(
364
- node,
365
- FlexDirection::Column,
366
- direction,
367
- (heightSizingMode == SizingMode::MaxContent ||
368
- heightSizingMode == SizingMode::FitContent)
369
- ? measuredSize.height + paddingAndBorderAxisColumn
370
- : availableHeight,
371
- ownerHeight,
372
- ownerWidth),
373
- Dimension::Height);
374
- }
375
- }
376
-
377
- // For nodes with no children, use the available values if they were provided,
378
- // or the minimum size as indicated by the padding and border sizes.
379
- static void measureNodeWithoutChildren(
380
- yoga::Node* const node,
381
- const Direction direction,
382
- const float availableWidth,
383
- const float availableHeight,
384
- const SizingMode widthSizingMode,
385
- const SizingMode heightSizingMode,
386
- const float ownerWidth,
387
- const float ownerHeight) {
388
- const auto& layout = node->getLayout();
389
-
390
- float width = availableWidth;
391
- if (widthSizingMode == SizingMode::MaxContent ||
392
- widthSizingMode == SizingMode::FitContent) {
393
- width = layout.padding(PhysicalEdge::Left) +
394
- layout.padding(PhysicalEdge::Right) +
395
- layout.border(PhysicalEdge::Left) + layout.border(PhysicalEdge::Right);
396
- }
397
- node->setLayoutMeasuredDimension(
398
- boundAxis(
399
- node, FlexDirection::Row, direction, width, ownerWidth, ownerWidth),
400
- Dimension::Width);
401
-
402
- float height = availableHeight;
403
- if (heightSizingMode == SizingMode::MaxContent ||
404
- heightSizingMode == SizingMode::FitContent) {
405
- height = layout.padding(PhysicalEdge::Top) +
406
- layout.padding(PhysicalEdge::Bottom) +
407
- layout.border(PhysicalEdge::Top) + layout.border(PhysicalEdge::Bottom);
408
- }
409
- node->setLayoutMeasuredDimension(
410
- boundAxis(
411
- node,
412
- FlexDirection::Column,
413
- direction,
414
- height,
415
- ownerHeight,
416
- ownerWidth),
417
- Dimension::Height);
418
- }
419
-
420
- inline bool isFixedSize(float dim, SizingMode sizingMode) {
421
- return sizingMode == SizingMode::StretchFit ||
422
- (yoga::isDefined(dim) && sizingMode == SizingMode::FitContent &&
423
- dim <= 0.0);
424
- }
425
-
426
- static bool measureNodeWithFixedSize(
427
- yoga::Node* const node,
428
- const Direction direction,
429
- const float availableWidth,
430
- const float availableHeight,
431
- const SizingMode widthSizingMode,
432
- const SizingMode heightSizingMode,
433
- const float ownerWidth,
434
- const float ownerHeight) {
435
- if (isFixedSize(availableWidth, widthSizingMode) &&
436
- isFixedSize(availableHeight, heightSizingMode)) {
437
- node->setLayoutMeasuredDimension(
438
- boundAxis(
439
- node,
440
- FlexDirection::Row,
441
- direction,
442
- yoga::isUndefined(availableWidth) ||
443
- (widthSizingMode == SizingMode::FitContent &&
444
- availableWidth < 0.0f)
445
- ? 0.0f
446
- : availableWidth,
447
- ownerWidth,
448
- ownerWidth),
449
- Dimension::Width);
450
-
451
- node->setLayoutMeasuredDimension(
452
- boundAxis(
453
- node,
454
- FlexDirection::Column,
455
- direction,
456
- yoga::isUndefined(availableHeight) ||
457
- (heightSizingMode == SizingMode::FitContent &&
458
- availableHeight < 0.0f)
459
- ? 0.0f
460
- : availableHeight,
461
- ownerHeight,
462
- ownerWidth),
463
- Dimension::Height);
464
- return true;
465
- }
466
-
467
- return false;
468
- }
469
-
470
- static void zeroOutLayoutRecursively(yoga::Node* const node) {
471
- node->getLayout() = {};
472
- node->setLayoutDimension(0, Dimension::Width);
473
- node->setLayoutDimension(0, Dimension::Height);
474
- node->setHasNewLayout(true);
475
-
476
- node->cloneChildrenIfNeeded();
477
- for (const auto child : node->getChildren()) {
478
- zeroOutLayoutRecursively(child);
479
- }
480
- }
481
-
482
- static void cleanupContentsNodesRecursively(yoga::Node* const node) {
483
- if (node->hasContentsChildren()) [[unlikely]] {
484
- node->cloneContentsChildrenIfNeeded();
485
- for (auto child : node->getChildren()) {
486
- if (child->style().display() == Display::Contents) {
487
- child->getLayout() = {};
488
- child->setLayoutDimension(0, Dimension::Width);
489
- child->setLayoutDimension(0, Dimension::Height);
490
- child->setHasNewLayout(true);
491
- child->setDirty(false);
492
- child->cloneChildrenIfNeeded();
493
-
494
- cleanupContentsNodesRecursively(child);
495
- }
496
- }
497
- }
498
- }
499
-
500
- static float calculateAvailableInnerDimension(
501
- const yoga::Node* const node,
502
- const Direction direction,
503
- const Dimension dimension,
504
- const float availableDim,
505
- const float paddingAndBorder,
506
- const float ownerDim,
507
- const float ownerWidth) {
508
- float availableInnerDim = availableDim - paddingAndBorder;
509
- // Max dimension overrides predefined dimension value; Min dimension in turn
510
- // overrides both of the above
511
- if (yoga::isDefined(availableInnerDim)) {
512
- // We want to make sure our available height does not violate min and max
513
- // constraints
514
- const FloatOptional minDimensionOptional =
515
- node->style().resolvedMinDimension(
516
- direction, dimension, ownerDim, ownerWidth);
517
- const float minInnerDim = minDimensionOptional.isUndefined()
518
- ? 0.0f
519
- : minDimensionOptional.unwrap() - paddingAndBorder;
520
-
521
- const FloatOptional maxDimensionOptional =
522
- node->style().resolvedMaxDimension(
523
- direction, dimension, ownerDim, ownerWidth);
524
-
525
- const float maxInnerDim = maxDimensionOptional.isUndefined()
526
- ? FLT_MAX
527
- : maxDimensionOptional.unwrap() - paddingAndBorder;
528
- availableInnerDim = yoga::maxOrDefined(
529
- yoga::minOrDefined(availableInnerDim, maxInnerDim), minInnerDim);
530
- }
531
-
532
- return availableInnerDim;
533
- }
534
-
535
- static float computeFlexBasisForChildren(
536
- yoga::Node* const node,
537
- const float availableInnerWidth,
538
- const float availableInnerHeight,
539
- SizingMode widthSizingMode,
540
- SizingMode heightSizingMode,
541
- Direction direction,
542
- FlexDirection mainAxis,
543
- bool performLayout,
544
- LayoutData& layoutMarkerData,
545
- const uint32_t depth,
546
- const uint32_t generationCount) {
547
- float totalOuterFlexBasis = 0.0f;
548
- YGNodeRef singleFlexChild = nullptr;
549
- auto children = node->getLayoutChildren();
550
- SizingMode sizingModeMainDim =
551
- isRow(mainAxis) ? widthSizingMode : heightSizingMode;
552
- // If there is only one child with flexGrow + flexShrink it means we can set
553
- // the computedFlexBasis to 0 instead of measuring and shrinking / flexing the
554
- // child to exactly match the remaining space
555
- if (sizingModeMainDim == SizingMode::StretchFit) {
556
- for (auto child : children) {
557
- if (child->isNodeFlexible()) {
558
- if (singleFlexChild != nullptr ||
559
- yoga::inexactEquals(child->resolveFlexGrow(), 0.0f) ||
560
- yoga::inexactEquals(child->resolveFlexShrink(), 0.0f)) {
561
- // There is already a flexible child, or this flexible child doesn't
562
- // have flexGrow and flexShrink, abort
563
- singleFlexChild = nullptr;
564
- break;
565
- } else {
566
- singleFlexChild = child;
567
- }
568
- }
569
- }
570
- }
571
-
572
- for (auto child : children) {
573
- child->processDimensions();
574
- if (child->style().display() == Display::None) {
575
- zeroOutLayoutRecursively(child);
576
- child->setHasNewLayout(true);
577
- child->setDirty(false);
578
- continue;
579
- }
580
- if (performLayout) {
581
- // Set the initial position (relative to the owner).
582
- const Direction childDirection = child->resolveDirection(direction);
583
- child->setPosition(
584
- childDirection, availableInnerWidth, availableInnerHeight);
585
- }
586
-
587
- if (child->style().positionType() == PositionType::Absolute) {
588
- continue;
589
- }
590
- if (child == singleFlexChild) {
591
- child->setLayoutComputedFlexBasisGeneration(generationCount);
592
- child->setLayoutComputedFlexBasis(FloatOptional(0));
593
- } else {
594
- computeFlexBasisForChild(
595
- node,
596
- child,
597
- availableInnerWidth,
598
- widthSizingMode,
599
- availableInnerHeight,
600
- availableInnerWidth,
601
- availableInnerHeight,
602
- heightSizingMode,
603
- direction,
604
- layoutMarkerData,
605
- depth,
606
- generationCount);
607
- }
608
-
609
- totalOuterFlexBasis +=
610
- (child->getLayout().computedFlexBasis.unwrap() +
611
- child->style().computeMarginForAxis(mainAxis, availableInnerWidth));
612
- }
613
-
614
- return totalOuterFlexBasis;
615
- }
616
-
617
- // It distributes the free space to the flexible items and ensures that the size
618
- // of the flex items abide the min and max constraints. At the end of this
619
- // function the child nodes would have proper size. Prior using this function
620
- // please ensure that distributeFreeSpaceFirstPass is called.
621
- static float distributeFreeSpaceSecondPass(
622
- FlexLine& flexLine,
623
- yoga::Node* const node,
624
- const FlexDirection mainAxis,
625
- const FlexDirection crossAxis,
626
- const Direction direction,
627
- const float ownerWidth,
628
- const float mainAxisOwnerSize,
629
- const float availableInnerMainDim,
630
- const float availableInnerCrossDim,
631
- const float availableInnerWidth,
632
- const float availableInnerHeight,
633
- const bool mainAxisOverflows,
634
- const SizingMode sizingModeCrossDim,
635
- const bool performLayout,
636
- LayoutData& layoutMarkerData,
637
- const uint32_t depth,
638
- const uint32_t generationCount) {
639
- float childFlexBasis = 0;
640
- float flexShrinkScaledFactor = 0;
641
- float flexGrowFactor = 0;
642
- float deltaFreeSpace = 0;
643
- const bool isMainAxisRow = isRow(mainAxis);
644
- const bool isNodeFlexWrap = node->style().flexWrap() != Wrap::NoWrap;
645
-
646
- for (auto currentLineChild : flexLine.itemsInFlow) {
647
- childFlexBasis = boundAxisWithinMinAndMax(
648
- currentLineChild,
649
- direction,
650
- mainAxis,
651
- currentLineChild->getLayout().computedFlexBasis,
652
- mainAxisOwnerSize,
653
- ownerWidth)
654
- .unwrap();
655
- float updatedMainSize = childFlexBasis;
656
-
657
- if (yoga::isDefined(flexLine.layout.remainingFreeSpace) &&
658
- flexLine.layout.remainingFreeSpace < 0) {
659
- flexShrinkScaledFactor =
660
- -currentLineChild->resolveFlexShrink() * childFlexBasis;
661
- // Is this child able to shrink?
662
- if (flexShrinkScaledFactor != 0) {
663
- float childSize = YGUndefined;
664
-
665
- if (yoga::isDefined(flexLine.layout.totalFlexShrinkScaledFactors) &&
666
- flexLine.layout.totalFlexShrinkScaledFactors == 0) {
667
- childSize = childFlexBasis + flexShrinkScaledFactor;
668
- } else {
669
- childSize = childFlexBasis +
670
- (flexLine.layout.remainingFreeSpace /
671
- flexLine.layout.totalFlexShrinkScaledFactors) *
672
- flexShrinkScaledFactor;
673
- }
674
-
675
- updatedMainSize = boundAxis(
676
- currentLineChild,
677
- mainAxis,
678
- direction,
679
- childSize,
680
- availableInnerMainDim,
681
- availableInnerWidth);
682
- }
683
- } else if (
684
- yoga::isDefined(flexLine.layout.remainingFreeSpace) &&
685
- flexLine.layout.remainingFreeSpace > 0) {
686
- flexGrowFactor = currentLineChild->resolveFlexGrow();
687
-
688
- // Is this child able to grow?
689
- if (!std::isnan(flexGrowFactor) && flexGrowFactor != 0) {
690
- updatedMainSize = boundAxis(
691
- currentLineChild,
692
- mainAxis,
693
- direction,
694
- childFlexBasis +
695
- flexLine.layout.remainingFreeSpace /
696
- flexLine.layout.totalFlexGrowFactors * flexGrowFactor,
697
- availableInnerMainDim,
698
- availableInnerWidth);
699
- }
700
- }
701
-
702
- deltaFreeSpace += updatedMainSize - childFlexBasis;
703
-
704
- const float marginMain = currentLineChild->style().computeMarginForAxis(
705
- mainAxis, availableInnerWidth);
706
- const float marginCross = currentLineChild->style().computeMarginForAxis(
707
- crossAxis, availableInnerWidth);
708
-
709
- float childCrossSize = YGUndefined;
710
- float childMainSize = updatedMainSize + marginMain;
711
- SizingMode childCrossSizingMode;
712
- SizingMode childMainSizingMode = SizingMode::StretchFit;
713
-
714
- const auto& childStyle = currentLineChild->style();
715
- if (childStyle.aspectRatio().isDefined()) {
716
- childCrossSize = isMainAxisRow
717
- ? (childMainSize - marginMain) / childStyle.aspectRatio().unwrap()
718
- : (childMainSize - marginMain) * childStyle.aspectRatio().unwrap();
719
- childCrossSizingMode = SizingMode::StretchFit;
720
-
721
- childCrossSize += marginCross;
722
- } else if (
723
- !std::isnan(availableInnerCrossDim) &&
724
- !currentLineChild->hasDefiniteLength(
725
- dimension(crossAxis), availableInnerCrossDim) &&
726
- sizingModeCrossDim == SizingMode::StretchFit &&
727
- !(isNodeFlexWrap && mainAxisOverflows) &&
728
- resolveChildAlignment(node, currentLineChild) == Align::Stretch &&
729
- !currentLineChild->style().flexStartMarginIsAuto(
730
- crossAxis, direction) &&
731
- !currentLineChild->style().flexEndMarginIsAuto(crossAxis, direction)) {
732
- childCrossSize = availableInnerCrossDim;
733
- childCrossSizingMode = SizingMode::StretchFit;
734
- } else if (!currentLineChild->hasDefiniteLength(
735
- dimension(crossAxis), availableInnerCrossDim)) {
736
- childCrossSize = availableInnerCrossDim;
737
- childCrossSizingMode = yoga::isUndefined(childCrossSize)
738
- ? SizingMode::MaxContent
739
- : SizingMode::FitContent;
740
- } else {
741
- childCrossSize = currentLineChild
742
- ->getResolvedDimension(
743
- direction,
744
- dimension(crossAxis),
745
- availableInnerCrossDim,
746
- availableInnerWidth)
747
- .unwrap() +
748
- marginCross;
749
- const bool isLoosePercentageMeasurement =
750
- currentLineChild->getProcessedDimension(dimension(crossAxis))
751
- .isPercent() &&
752
- sizingModeCrossDim != SizingMode::StretchFit;
753
- childCrossSizingMode =
754
- yoga::isUndefined(childCrossSize) || isLoosePercentageMeasurement
755
- ? SizingMode::MaxContent
756
- : SizingMode::StretchFit;
757
- }
758
-
759
- constrainMaxSizeForMode(
760
- currentLineChild,
761
- direction,
762
- mainAxis,
763
- availableInnerMainDim,
764
- availableInnerWidth,
765
- &childMainSizingMode,
766
- &childMainSize);
767
- constrainMaxSizeForMode(
768
- currentLineChild,
769
- direction,
770
- crossAxis,
771
- availableInnerCrossDim,
772
- availableInnerWidth,
773
- &childCrossSizingMode,
774
- &childCrossSize);
775
-
776
- const bool requiresStretchLayout =
777
- !currentLineChild->hasDefiniteLength(
778
- dimension(crossAxis), availableInnerCrossDim) &&
779
- resolveChildAlignment(node, currentLineChild) == Align::Stretch &&
780
- !currentLineChild->style().flexStartMarginIsAuto(
781
- crossAxis, direction) &&
782
- !currentLineChild->style().flexEndMarginIsAuto(crossAxis, direction);
783
-
784
- const float childWidth = isMainAxisRow ? childMainSize : childCrossSize;
785
- const float childHeight = !isMainAxisRow ? childMainSize : childCrossSize;
786
-
787
- const SizingMode childWidthSizingMode =
788
- isMainAxisRow ? childMainSizingMode : childCrossSizingMode;
789
- const SizingMode childHeightSizingMode =
790
- !isMainAxisRow ? childMainSizingMode : childCrossSizingMode;
791
-
792
- const bool isLayoutPass = performLayout && !requiresStretchLayout;
793
- // Recursively call the layout algorithm for this child with the updated
794
- // main size.
795
- calculateLayoutInternal(
796
- currentLineChild,
797
- childWidth,
798
- childHeight,
799
- node->getLayout().direction(),
800
- childWidthSizingMode,
801
- childHeightSizingMode,
802
- availableInnerWidth,
803
- availableInnerHeight,
804
- isLayoutPass,
805
- isLayoutPass ? LayoutPassReason::kFlexLayout
806
- : LayoutPassReason::kFlexMeasure,
807
- layoutMarkerData,
808
- depth,
809
- generationCount);
810
- node->setLayoutHadOverflow(
811
- node->getLayout().hadOverflow() ||
812
- currentLineChild->getLayout().hadOverflow());
813
- }
814
- return deltaFreeSpace;
815
- }
816
-
817
- // It distributes the free space to the flexible items.For those flexible items
818
- // whose min and max constraints are triggered, those flex item's clamped size
819
- // is removed from the remaingfreespace.
820
- static void distributeFreeSpaceFirstPass(
821
- FlexLine& flexLine,
822
- const Direction direction,
823
- const FlexDirection mainAxis,
824
- const float ownerWidth,
825
- const float mainAxisOwnerSize,
826
- const float availableInnerMainDim,
827
- const float availableInnerWidth) {
828
- float flexShrinkScaledFactor = 0;
829
- float flexGrowFactor = 0;
830
- float baseMainSize = 0;
831
- float boundMainSize = 0;
832
- float deltaFreeSpace = 0;
833
-
834
- for (auto currentLineChild : flexLine.itemsInFlow) {
835
- float childFlexBasis = boundAxisWithinMinAndMax(
836
- currentLineChild,
837
- direction,
838
- mainAxis,
839
- currentLineChild->getLayout().computedFlexBasis,
840
- mainAxisOwnerSize,
841
- ownerWidth)
842
- .unwrap();
843
-
844
- if (flexLine.layout.remainingFreeSpace < 0) {
845
- flexShrinkScaledFactor =
846
- -currentLineChild->resolveFlexShrink() * childFlexBasis;
847
-
848
- // Is this child able to shrink?
849
- if (yoga::isDefined(flexShrinkScaledFactor) &&
850
- flexShrinkScaledFactor != 0) {
851
- baseMainSize = childFlexBasis +
852
- flexLine.layout.remainingFreeSpace /
853
- flexLine.layout.totalFlexShrinkScaledFactors *
854
- flexShrinkScaledFactor;
855
- boundMainSize = boundAxis(
856
- currentLineChild,
857
- mainAxis,
858
- direction,
859
- baseMainSize,
860
- availableInnerMainDim,
861
- availableInnerWidth);
862
- if (yoga::isDefined(baseMainSize) && yoga::isDefined(boundMainSize) &&
863
- baseMainSize != boundMainSize) {
864
- // By excluding this item's size and flex factor from remaining, this
865
- // item's min/max constraints should also trigger in the second pass
866
- // resulting in the item's size calculation being identical in the
867
- // first and second passes.
868
- deltaFreeSpace += boundMainSize - childFlexBasis;
869
- flexLine.layout.totalFlexShrinkScaledFactors -=
870
- (-currentLineChild->resolveFlexShrink() *
871
- currentLineChild->getLayout().computedFlexBasis.unwrap());
872
- }
873
- }
874
- } else if (
875
- yoga::isDefined(flexLine.layout.remainingFreeSpace) &&
876
- flexLine.layout.remainingFreeSpace > 0) {
877
- flexGrowFactor = currentLineChild->resolveFlexGrow();
878
-
879
- // Is this child able to grow?
880
- if (yoga::isDefined(flexGrowFactor) && flexGrowFactor != 0) {
881
- baseMainSize = childFlexBasis +
882
- flexLine.layout.remainingFreeSpace /
883
- flexLine.layout.totalFlexGrowFactors * flexGrowFactor;
884
- boundMainSize = boundAxis(
885
- currentLineChild,
886
- mainAxis,
887
- direction,
888
- baseMainSize,
889
- availableInnerMainDim,
890
- availableInnerWidth);
891
-
892
- if (yoga::isDefined(baseMainSize) && yoga::isDefined(boundMainSize) &&
893
- baseMainSize != boundMainSize) {
894
- // By excluding this item's size and flex factor from remaining, this
895
- // item's min/max constraints should also trigger in the second pass
896
- // resulting in the item's size calculation being identical in the
897
- // first and second passes.
898
- deltaFreeSpace += boundMainSize - childFlexBasis;
899
- flexLine.layout.totalFlexGrowFactors -= flexGrowFactor;
900
- }
901
- }
902
- }
903
- }
904
- flexLine.layout.remainingFreeSpace -= deltaFreeSpace;
905
- }
906
-
907
- // Do two passes over the flex items to figure out how to distribute the
908
- // remaining space.
909
- //
910
- // The first pass finds the items whose min/max constraints trigger, freezes
911
- // them at those sizes, and excludes those sizes from the remaining space.
912
- //
913
- // The second pass sets the size of each flexible item. It distributes the
914
- // remaining space amongst the items whose min/max constraints didn't trigger in
915
- // the first pass. For the other items, it sets their sizes by forcing their
916
- // min/max constraints to trigger again.
917
- //
918
- // This two pass approach for resolving min/max constraints deviates from the
919
- // spec. The spec
920
- // (https://www.w3.org/TR/CSS-flexbox-1/#resolve-flexible-lengths) describes a
921
- // process that needs to be repeated a variable number of times. The algorithm
922
- // implemented here won't handle all cases but it was simpler to implement and
923
- // it mitigates performance concerns because we know exactly how many passes
924
- // it'll do.
925
- //
926
- // At the end of this function the child nodes would have the proper size
927
- // assigned to them.
928
- //
929
- static void resolveFlexibleLength(
930
- yoga::Node* const node,
931
- FlexLine& flexLine,
932
- const FlexDirection mainAxis,
933
- const FlexDirection crossAxis,
934
- const Direction direction,
935
- const float ownerWidth,
936
- const float mainAxisOwnerSize,
937
- const float availableInnerMainDim,
938
- const float availableInnerCrossDim,
939
- const float availableInnerWidth,
940
- const float availableInnerHeight,
941
- const bool mainAxisOverflows,
942
- const SizingMode sizingModeCrossDim,
943
- const bool performLayout,
944
- LayoutData& layoutMarkerData,
945
- const uint32_t depth,
946
- const uint32_t generationCount) {
947
- const float originalFreeSpace = flexLine.layout.remainingFreeSpace;
948
- // First pass: detect the flex items whose min/max constraints trigger
949
- distributeFreeSpaceFirstPass(
950
- flexLine,
951
- direction,
952
- mainAxis,
953
- ownerWidth,
954
- mainAxisOwnerSize,
955
- availableInnerMainDim,
956
- availableInnerWidth);
957
-
958
- // Second pass: resolve the sizes of the flexible items
959
- const float distributedFreeSpace = distributeFreeSpaceSecondPass(
960
- flexLine,
961
- node,
962
- mainAxis,
963
- crossAxis,
964
- direction,
965
- ownerWidth,
966
- mainAxisOwnerSize,
967
- availableInnerMainDim,
968
- availableInnerCrossDim,
969
- availableInnerWidth,
970
- availableInnerHeight,
971
- mainAxisOverflows,
972
- sizingModeCrossDim,
973
- performLayout,
974
- layoutMarkerData,
975
- depth,
976
- generationCount);
977
-
978
- flexLine.layout.remainingFreeSpace = originalFreeSpace - distributedFreeSpace;
979
- }
980
-
981
- static void justifyMainAxis(
982
- yoga::Node* const node,
983
- FlexLine& flexLine,
984
- const FlexDirection mainAxis,
985
- const FlexDirection crossAxis,
986
- const Direction direction,
987
- const SizingMode sizingModeMainDim,
988
- const SizingMode sizingModeCrossDim,
989
- const float mainAxisOwnerSize,
990
- const float ownerWidth,
991
- const float availableInnerMainDim,
992
- const float availableInnerCrossDim,
993
- const float availableInnerWidth,
994
- const bool performLayout) {
995
- const auto& style = node->style();
996
-
997
- const float leadingPaddingAndBorderMain =
998
- node->style().computeFlexStartPaddingAndBorder(
999
- mainAxis, direction, ownerWidth);
1000
- const float trailingPaddingAndBorderMain =
1001
- node->style().computeFlexEndPaddingAndBorder(
1002
- mainAxis, direction, ownerWidth);
1003
-
1004
- const float gap =
1005
- node->style().computeGapForAxis(mainAxis, availableInnerMainDim);
1006
- // If we are using "at most" rules in the main axis, make sure that
1007
- // remainingFreeSpace is 0 when min main dimension is not given
1008
- if (sizingModeMainDim == SizingMode::FitContent &&
1009
- flexLine.layout.remainingFreeSpace > 0) {
1010
- if (style.minDimension(dimension(mainAxis)).isDefined() &&
1011
- style
1012
- .resolvedMinDimension(
1013
- direction, dimension(mainAxis), mainAxisOwnerSize, ownerWidth)
1014
- .isDefined()) {
1015
- // This condition makes sure that if the size of main dimension(after
1016
- // considering child nodes main dim, leading and trailing padding etc)
1017
- // falls below min dimension, then the remainingFreeSpace is reassigned
1018
- // considering the min dimension
1019
-
1020
- // `minAvailableMainDim` denotes minimum available space in which child
1021
- // can be laid out, it will exclude space consumed by padding and border.
1022
- const float minAvailableMainDim =
1023
- style
1024
- .resolvedMinDimension(
1025
- direction, dimension(mainAxis), mainAxisOwnerSize, ownerWidth)
1026
- .unwrap() -
1027
- leadingPaddingAndBorderMain - trailingPaddingAndBorderMain;
1028
- const float occupiedSpaceByChildNodes =
1029
- availableInnerMainDim - flexLine.layout.remainingFreeSpace;
1030
- flexLine.layout.remainingFreeSpace = yoga::maxOrDefined(
1031
- 0.0f, minAvailableMainDim - occupiedSpaceByChildNodes);
1032
- } else {
1033
- flexLine.layout.remainingFreeSpace = 0;
1034
- }
1035
- }
1036
-
1037
- // In order to position the elements in the main axis, we have two controls.
1038
- // The space between the beginning and the first element and the space between
1039
- // each two elements.
1040
- float leadingMainDim = 0;
1041
- float betweenMainDim = gap;
1042
- const Justify justifyContent = flexLine.layout.remainingFreeSpace >= 0
1043
- ? node->style().justifyContent()
1044
- : fallbackAlignment(node->style().justifyContent());
1045
-
1046
- if (flexLine.numberOfAutoMargins == 0) {
1047
- switch (justifyContent) {
1048
- case Justify::Center:
1049
- leadingMainDim = flexLine.layout.remainingFreeSpace / 2;
1050
- break;
1051
- case Justify::FlexEnd:
1052
- leadingMainDim = flexLine.layout.remainingFreeSpace;
1053
- break;
1054
- case Justify::SpaceBetween:
1055
- if (flexLine.itemsInFlow.size() > 1) {
1056
- betweenMainDim += flexLine.layout.remainingFreeSpace /
1057
- static_cast<float>(flexLine.itemsInFlow.size() - 1);
1058
- }
1059
- break;
1060
- case Justify::SpaceEvenly:
1061
- // Space is distributed evenly across all elements
1062
- leadingMainDim = flexLine.layout.remainingFreeSpace /
1063
- static_cast<float>(flexLine.itemsInFlow.size() + 1);
1064
- betweenMainDim += leadingMainDim;
1065
- break;
1066
- case Justify::SpaceAround:
1067
- // Space on the edges is half of the space between elements
1068
- leadingMainDim = 0.5f * flexLine.layout.remainingFreeSpace /
1069
- static_cast<float>(flexLine.itemsInFlow.size());
1070
- betweenMainDim += leadingMainDim * 2;
1071
- break;
1072
- case Justify::FlexStart:
1073
- break;
1074
- }
1075
- }
1076
-
1077
- flexLine.layout.mainDim = leadingPaddingAndBorderMain + leadingMainDim;
1078
- flexLine.layout.crossDim = 0;
1079
-
1080
- float maxAscentForCurrentLine = 0;
1081
- float maxDescentForCurrentLine = 0;
1082
- bool isNodeBaselineLayout = isBaselineLayout(node);
1083
- for (auto child : flexLine.itemsInFlow) {
1084
- const LayoutResults& childLayout = child->getLayout();
1085
- if (child->style().flexStartMarginIsAuto(mainAxis, direction) &&
1086
- flexLine.layout.remainingFreeSpace > 0.0f) {
1087
- flexLine.layout.mainDim += flexLine.layout.remainingFreeSpace /
1088
- static_cast<float>(flexLine.numberOfAutoMargins);
1089
- }
1090
-
1091
- if (performLayout) {
1092
- child->setLayoutPosition(
1093
- childLayout.position(flexStartEdge(mainAxis)) +
1094
- flexLine.layout.mainDim,
1095
- flexStartEdge(mainAxis));
1096
- }
1097
-
1098
- if (child != flexLine.itemsInFlow.back()) {
1099
- flexLine.layout.mainDim += betweenMainDim;
1100
- }
1101
-
1102
- if (child->style().flexEndMarginIsAuto(mainAxis, direction) &&
1103
- flexLine.layout.remainingFreeSpace > 0.0f) {
1104
- flexLine.layout.mainDim += flexLine.layout.remainingFreeSpace /
1105
- static_cast<float>(flexLine.numberOfAutoMargins);
1106
- }
1107
- bool canSkipFlex =
1108
- !performLayout && sizingModeCrossDim == SizingMode::StretchFit;
1109
- if (canSkipFlex) {
1110
- // If we skipped the flex step, then we can't rely on the measuredDims
1111
- // because they weren't computed. This means we can't call
1112
- // dimensionWithMargin.
1113
- flexLine.layout.mainDim +=
1114
- child->style().computeMarginForAxis(mainAxis, availableInnerWidth) +
1115
- childLayout.computedFlexBasis.unwrap();
1116
- flexLine.layout.crossDim = availableInnerCrossDim;
1117
- } else {
1118
- // The main dimension is the sum of all the elements dimension plus
1119
- // the spacing.
1120
- flexLine.layout.mainDim +=
1121
- child->dimensionWithMargin(mainAxis, availableInnerWidth);
1122
-
1123
- if (isNodeBaselineLayout) {
1124
- // If the child is baseline aligned then the cross dimension is
1125
- // calculated by adding maxAscent and maxDescent from the baseline.
1126
- const float ascent = calculateBaseline(child) +
1127
- child->style().computeFlexStartMargin(
1128
- FlexDirection::Column, direction, availableInnerWidth);
1129
- const float descent =
1130
- child->getLayout().measuredDimension(Dimension::Height) +
1131
- child->style().computeMarginForAxis(
1132
- FlexDirection::Column, availableInnerWidth) -
1133
- ascent;
1134
-
1135
- maxAscentForCurrentLine =
1136
- yoga::maxOrDefined(maxAscentForCurrentLine, ascent);
1137
- maxDescentForCurrentLine =
1138
- yoga::maxOrDefined(maxDescentForCurrentLine, descent);
1139
- } else {
1140
- // The cross dimension is the max of the elements dimension since
1141
- // there can only be one element in that cross dimension in the case
1142
- // when the items are not baseline aligned
1143
- flexLine.layout.crossDim = yoga::maxOrDefined(
1144
- flexLine.layout.crossDim,
1145
- child->dimensionWithMargin(crossAxis, availableInnerWidth));
1146
- }
1147
- }
1148
- }
1149
- flexLine.layout.mainDim += trailingPaddingAndBorderMain;
1150
-
1151
- if (isNodeBaselineLayout) {
1152
- flexLine.layout.crossDim =
1153
- maxAscentForCurrentLine + maxDescentForCurrentLine;
1154
- }
1155
- }
1156
-
1157
- //
1158
- // This is the main routine that implements a subset of the flexbox layout
1159
- // algorithm described in the W3C CSS documentation:
1160
- // https://www.w3.org/TR/CSS3-flexbox/.
1161
- //
1162
- // Limitations of this algorithm, compared to the full standard:
1163
- // * Display property is always assumed to be 'flex' except for Text nodes,
1164
- // which are assumed to be 'inline-flex'.
1165
- // * The 'zIndex' property (or any form of z ordering) is not supported. Nodes
1166
- // are stacked in document order.
1167
- // * The 'order' property is not supported. The order of flex items is always
1168
- // defined by document order.
1169
- // * The 'visibility' property is always assumed to be 'visible'. Values of
1170
- // 'collapse' and 'hidden' are not supported.
1171
- // * There is no support for forced breaks.
1172
- // * It does not support vertical inline directions (top-to-bottom or
1173
- // bottom-to-top text).
1174
- //
1175
- // Deviations from standard:
1176
- // * Section 4.5 of the spec indicates that all flex items have a default
1177
- // minimum main size. For text blocks, for example, this is the width of the
1178
- // widest word. Calculating the minimum width is expensive, so we forego it
1179
- // and assume a default minimum main size of 0.
1180
- // * Min/Max sizes in the main axis are not honored when resolving flexible
1181
- // lengths.
1182
- // * The spec indicates that the default value for 'flexDirection' is 'row',
1183
- // but the algorithm below assumes a default of 'column'.
1184
- //
1185
- // Input parameters:
1186
- // - node: current node to be sized and laid out
1187
- // - availableWidth & availableHeight: available size to be used for sizing
1188
- // the node or YGUndefined if the size is not available; interpretation
1189
- // depends on layout flags
1190
- // - ownerDirection: the inline (text) direction within the owner
1191
- // (left-to-right or right-to-left)
1192
- // - widthSizingMode: indicates the sizing rules for the width (see below
1193
- // for explanation)
1194
- // - heightSizingMode: indicates the sizing rules for the height (see below
1195
- // for explanation)
1196
- // - performLayout: specifies whether the caller is interested in just the
1197
- // dimensions of the node or it requires the entire node and its subtree to
1198
- // be laid out (with final positions)
1199
- //
1200
- // Details:
1201
- // This routine is called recursively to lay out subtrees of flexbox
1202
- // elements. It uses the information in node.style, which is treated as a
1203
- // read-only input. It is responsible for setting the layout.direction and
1204
- // layout.measuredDimensions fields for the input node as well as the
1205
- // layout.position and layout.lineIndex fields for its child nodes. The
1206
- // layout.measuredDimensions field includes any border or padding for the
1207
- // node but does not include margins.
1208
- //
1209
- // When calling calculateLayoutImpl and calculateLayoutInternal, if the
1210
- // caller passes an available size of undefined then it must also pass a
1211
- // measure mode of SizingMode::MaxContent in that dimension.
1212
- //
1213
- static void calculateLayoutImpl(
1214
- yoga::Node* const node,
1215
- const float availableWidth,
1216
- const float availableHeight,
1217
- const Direction ownerDirection,
1218
- const SizingMode widthSizingMode,
1219
- const SizingMode heightSizingMode,
1220
- const float ownerWidth,
1221
- const float ownerHeight,
1222
- const bool performLayout,
1223
- const LayoutPassReason reason,
1224
- LayoutData& layoutMarkerData,
1225
- const uint32_t depth,
1226
- const uint32_t generationCount) {
1227
- yoga::assertFatalWithNode(
1228
- node,
1229
- yoga::isUndefined(availableWidth)
1230
- ? widthSizingMode == SizingMode::MaxContent
1231
- : true,
1232
- "availableWidth is indefinite so widthSizingMode must be "
1233
- "SizingMode::MaxContent");
1234
- yoga::assertFatalWithNode(
1235
- node,
1236
- yoga::isUndefined(availableHeight)
1237
- ? heightSizingMode == SizingMode::MaxContent
1238
- : true,
1239
- "availableHeight is indefinite so heightSizingMode must be "
1240
- "SizingMode::MaxContent");
1241
-
1242
- (performLayout ? layoutMarkerData.layouts : layoutMarkerData.measures) += 1;
1243
-
1244
- // Set the resolved resolution in the node's layout.
1245
- const Direction direction = node->resolveDirection(ownerDirection);
1246
- node->setLayoutDirection(direction);
1247
-
1248
- const FlexDirection flexRowDirection =
1249
- resolveDirection(FlexDirection::Row, direction);
1250
- const FlexDirection flexColumnDirection =
1251
- resolveDirection(FlexDirection::Column, direction);
1252
-
1253
- const auto startEdge =
1254
- direction == Direction::LTR ? PhysicalEdge::Left : PhysicalEdge::Right;
1255
- const auto endEdge =
1256
- direction == Direction::LTR ? PhysicalEdge::Right : PhysicalEdge::Left;
1257
-
1258
- const float marginRowLeading = node->style().computeInlineStartMargin(
1259
- flexRowDirection, direction, ownerWidth);
1260
- node->setLayoutMargin(marginRowLeading, startEdge);
1261
- const float marginRowTrailing = node->style().computeInlineEndMargin(
1262
- flexRowDirection, direction, ownerWidth);
1263
- node->setLayoutMargin(marginRowTrailing, endEdge);
1264
- const float marginColumnLeading = node->style().computeInlineStartMargin(
1265
- flexColumnDirection, direction, ownerWidth);
1266
- node->setLayoutMargin(marginColumnLeading, PhysicalEdge::Top);
1267
- const float marginColumnTrailing = node->style().computeInlineEndMargin(
1268
- flexColumnDirection, direction, ownerWidth);
1269
- node->setLayoutMargin(marginColumnTrailing, PhysicalEdge::Bottom);
1270
-
1271
- const float marginAxisRow = marginRowLeading + marginRowTrailing;
1272
- const float marginAxisColumn = marginColumnLeading + marginColumnTrailing;
1273
-
1274
- node->setLayoutBorder(
1275
- node->style().computeInlineStartBorder(flexRowDirection, direction),
1276
- startEdge);
1277
- node->setLayoutBorder(
1278
- node->style().computeInlineEndBorder(flexRowDirection, direction),
1279
- endEdge);
1280
- node->setLayoutBorder(
1281
- node->style().computeInlineStartBorder(flexColumnDirection, direction),
1282
- PhysicalEdge::Top);
1283
- node->setLayoutBorder(
1284
- node->style().computeInlineEndBorder(flexColumnDirection, direction),
1285
- PhysicalEdge::Bottom);
1286
-
1287
- node->setLayoutPadding(
1288
- node->style().computeInlineStartPadding(
1289
- flexRowDirection, direction, ownerWidth),
1290
- startEdge);
1291
- node->setLayoutPadding(
1292
- node->style().computeInlineEndPadding(
1293
- flexRowDirection, direction, ownerWidth),
1294
- endEdge);
1295
- node->setLayoutPadding(
1296
- node->style().computeInlineStartPadding(
1297
- flexColumnDirection, direction, ownerWidth),
1298
- PhysicalEdge::Top);
1299
- node->setLayoutPadding(
1300
- node->style().computeInlineEndPadding(
1301
- flexColumnDirection, direction, ownerWidth),
1302
- PhysicalEdge::Bottom);
1303
-
1304
- if (node->hasMeasureFunc()) {
1305
- measureNodeWithMeasureFunc(
1306
- node,
1307
- direction,
1308
- availableWidth - marginAxisRow,
1309
- availableHeight - marginAxisColumn,
1310
- widthSizingMode,
1311
- heightSizingMode,
1312
- ownerWidth,
1313
- ownerHeight,
1314
- layoutMarkerData,
1315
- reason);
1316
-
1317
- // Clean and update all display: contents nodes with a direct path to the
1318
- // current node as they will not be traversed
1319
- cleanupContentsNodesRecursively(node);
1320
- return;
1321
- }
1322
-
1323
- const auto childCount = node->getLayoutChildCount();
1324
- if (childCount == 0) {
1325
- measureNodeWithoutChildren(
1326
- node,
1327
- direction,
1328
- availableWidth - marginAxisRow,
1329
- availableHeight - marginAxisColumn,
1330
- widthSizingMode,
1331
- heightSizingMode,
1332
- ownerWidth,
1333
- ownerHeight);
1334
-
1335
- // Clean and update all display: contents nodes with a direct path to the
1336
- // current node as they will not be traversed
1337
- cleanupContentsNodesRecursively(node);
1338
- return;
1339
- }
1340
-
1341
- // If we're not being asked to perform a full layout we can skip the algorithm
1342
- // if we already know the size
1343
- if (!performLayout &&
1344
- measureNodeWithFixedSize(
1345
- node,
1346
- direction,
1347
- availableWidth - marginAxisRow,
1348
- availableHeight - marginAxisColumn,
1349
- widthSizingMode,
1350
- heightSizingMode,
1351
- ownerWidth,
1352
- ownerHeight)) {
1353
- // Clean and update all display: contents nodes with a direct path to the
1354
- // current node as they will not be traversed
1355
- cleanupContentsNodesRecursively(node);
1356
- return;
1357
- }
1358
-
1359
- // At this point we know we're going to perform work. Ensure that each child
1360
- // has a mutable copy.
1361
- node->cloneChildrenIfNeeded();
1362
- // Reset layout flags, as they could have changed.
1363
- node->setLayoutHadOverflow(false);
1364
-
1365
- // Clean and update all display: contents nodes with a direct path to the
1366
- // current node as they will not be traversed
1367
- cleanupContentsNodesRecursively(node);
1368
-
1369
- // STEP 1: CALCULATE VALUES FOR REMAINDER OF ALGORITHM
1370
- const FlexDirection mainAxis =
1371
- resolveDirection(node->style().flexDirection(), direction);
1372
- const FlexDirection crossAxis = resolveCrossDirection(mainAxis, direction);
1373
- const bool isMainAxisRow = isRow(mainAxis);
1374
- const bool isNodeFlexWrap = node->style().flexWrap() != Wrap::NoWrap;
1375
-
1376
- const float mainAxisOwnerSize = isMainAxisRow ? ownerWidth : ownerHeight;
1377
- const float crossAxisOwnerSize = isMainAxisRow ? ownerHeight : ownerWidth;
1378
-
1379
- const float paddingAndBorderAxisMain =
1380
- paddingAndBorderForAxis(node, mainAxis, direction, ownerWidth);
1381
- const float paddingAndBorderAxisCross =
1382
- paddingAndBorderForAxis(node, crossAxis, direction, ownerWidth);
1383
- const float leadingPaddingAndBorderCross =
1384
- node->style().computeFlexStartPaddingAndBorder(
1385
- crossAxis, direction, ownerWidth);
1386
-
1387
- SizingMode sizingModeMainDim =
1388
- isMainAxisRow ? widthSizingMode : heightSizingMode;
1389
- SizingMode sizingModeCrossDim =
1390
- isMainAxisRow ? heightSizingMode : widthSizingMode;
1391
-
1392
- const float paddingAndBorderAxisRow =
1393
- isMainAxisRow ? paddingAndBorderAxisMain : paddingAndBorderAxisCross;
1394
- const float paddingAndBorderAxisColumn =
1395
- isMainAxisRow ? paddingAndBorderAxisCross : paddingAndBorderAxisMain;
1396
-
1397
- // STEP 2: DETERMINE AVAILABLE SIZE IN MAIN AND CROSS DIRECTIONS
1398
-
1399
- float availableInnerWidth = calculateAvailableInnerDimension(
1400
- node,
1401
- direction,
1402
- Dimension::Width,
1403
- availableWidth - marginAxisRow,
1404
- paddingAndBorderAxisRow,
1405
- ownerWidth,
1406
- ownerWidth);
1407
- float availableInnerHeight = calculateAvailableInnerDimension(
1408
- node,
1409
- direction,
1410
- Dimension::Height,
1411
- availableHeight - marginAxisColumn,
1412
- paddingAndBorderAxisColumn,
1413
- ownerHeight,
1414
- ownerWidth);
1415
-
1416
- float availableInnerMainDim =
1417
- isMainAxisRow ? availableInnerWidth : availableInnerHeight;
1418
- const float availableInnerCrossDim =
1419
- isMainAxisRow ? availableInnerHeight : availableInnerWidth;
1420
-
1421
- // STEP 3: DETERMINE FLEX BASIS FOR EACH ITEM
1422
-
1423
- // Computed basis + margins + gap
1424
- float totalMainDim = 0;
1425
- totalMainDim += computeFlexBasisForChildren(
1426
- node,
1427
- availableInnerWidth,
1428
- availableInnerHeight,
1429
- widthSizingMode,
1430
- heightSizingMode,
1431
- direction,
1432
- mainAxis,
1433
- performLayout,
1434
- layoutMarkerData,
1435
- depth,
1436
- generationCount);
1437
-
1438
- if (childCount > 1) {
1439
- totalMainDim +=
1440
- node->style().computeGapForAxis(mainAxis, availableInnerMainDim) *
1441
- static_cast<float>(childCount - 1);
1442
- }
1443
-
1444
- const bool mainAxisOverflows =
1445
- (sizingModeMainDim != SizingMode::MaxContent) &&
1446
- totalMainDim > availableInnerMainDim;
1447
-
1448
- if (isNodeFlexWrap && mainAxisOverflows &&
1449
- sizingModeMainDim == SizingMode::FitContent) {
1450
- sizingModeMainDim = SizingMode::StretchFit;
1451
- }
1452
- // STEP 4: COLLECT FLEX ITEMS INTO FLEX LINES
1453
-
1454
- // Iterator representing the beginning of the current line
1455
- Node::LayoutableChildren::Iterator startOfLineIterator =
1456
- node->getLayoutChildren().begin();
1457
-
1458
- // Number of lines.
1459
- size_t lineCount = 0;
1460
-
1461
- // Accumulated cross dimensions of all lines so far.
1462
- float totalLineCrossDim = 0;
1463
-
1464
- const float crossAxisGap =
1465
- node->style().computeGapForAxis(crossAxis, availableInnerCrossDim);
1466
-
1467
- // Max main dimension of all the lines.
1468
- float maxLineMainDim = 0;
1469
- for (; startOfLineIterator != node->getLayoutChildren().end(); lineCount++) {
1470
- auto flexLine = calculateFlexLine(
1471
- node,
1472
- ownerDirection,
1473
- ownerWidth,
1474
- mainAxisOwnerSize,
1475
- availableInnerWidth,
1476
- availableInnerMainDim,
1477
- startOfLineIterator,
1478
- lineCount);
1479
-
1480
- // If we don't need to measure the cross axis, we can skip the entire flex
1481
- // step.
1482
- const bool canSkipFlex =
1483
- !performLayout && sizingModeCrossDim == SizingMode::StretchFit;
1484
-
1485
- // STEP 5: RESOLVING FLEXIBLE LENGTHS ON MAIN AXIS
1486
- // Calculate the remaining available space that needs to be allocated. If
1487
- // the main dimension size isn't known, it is computed based on the line
1488
- // length, so there's no more space left to distribute.
1489
-
1490
- bool sizeBasedOnContent = false;
1491
- // If we don't measure with exact main dimension we want to ensure we don't
1492
- // violate min and max
1493
- if (sizingModeMainDim != SizingMode::StretchFit) {
1494
- const auto& style = node->style();
1495
- const float minInnerWidth =
1496
- style
1497
- .resolvedMinDimension(
1498
- direction, Dimension::Width, ownerWidth, ownerWidth)
1499
- .unwrap() -
1500
- paddingAndBorderAxisRow;
1501
- const float maxInnerWidth =
1502
- style
1503
- .resolvedMaxDimension(
1504
- direction, Dimension::Width, ownerWidth, ownerWidth)
1505
- .unwrap() -
1506
- paddingAndBorderAxisRow;
1507
- const float minInnerHeight =
1508
- style
1509
- .resolvedMinDimension(
1510
- direction, Dimension::Height, ownerHeight, ownerWidth)
1511
- .unwrap() -
1512
- paddingAndBorderAxisColumn;
1513
- const float maxInnerHeight =
1514
- style
1515
- .resolvedMaxDimension(
1516
- direction, Dimension::Height, ownerHeight, ownerWidth)
1517
- .unwrap() -
1518
- paddingAndBorderAxisColumn;
1519
-
1520
- const float minInnerMainDim =
1521
- isMainAxisRow ? minInnerWidth : minInnerHeight;
1522
- const float maxInnerMainDim =
1523
- isMainAxisRow ? maxInnerWidth : maxInnerHeight;
1524
-
1525
- if (yoga::isDefined(minInnerMainDim) &&
1526
- flexLine.sizeConsumed < minInnerMainDim) {
1527
- availableInnerMainDim = minInnerMainDim;
1528
- } else if (
1529
- yoga::isDefined(maxInnerMainDim) &&
1530
- flexLine.sizeConsumed > maxInnerMainDim) {
1531
- availableInnerMainDim = maxInnerMainDim;
1532
- } else {
1533
- bool useLegacyStretchBehaviour =
1534
- node->hasErrata(Errata::StretchFlexBasis);
1535
-
1536
- if (!useLegacyStretchBehaviour &&
1537
- ((yoga::isDefined(flexLine.layout.totalFlexGrowFactors) &&
1538
- flexLine.layout.totalFlexGrowFactors == 0) ||
1539
- (yoga::isDefined(node->resolveFlexGrow()) &&
1540
- node->resolveFlexGrow() == 0))) {
1541
- // If we don't have any children to flex or we can't flex the node
1542
- // itself, space we've used is all space we need. Root node also
1543
- // should be shrunk to minimum
1544
- availableInnerMainDim = flexLine.sizeConsumed;
1545
- }
1546
-
1547
- sizeBasedOnContent = !useLegacyStretchBehaviour;
1548
- }
1549
- }
1550
-
1551
- if (!sizeBasedOnContent && yoga::isDefined(availableInnerMainDim)) {
1552
- flexLine.layout.remainingFreeSpace =
1553
- availableInnerMainDim - flexLine.sizeConsumed;
1554
- } else if (flexLine.sizeConsumed < 0) {
1555
- // availableInnerMainDim is indefinite which means the node is being sized
1556
- // based on its content. sizeConsumed is negative which means
1557
- // the node will allocate 0 points for its content. Consequently,
1558
- // remainingFreeSpace is 0 - sizeConsumed.
1559
- flexLine.layout.remainingFreeSpace = -flexLine.sizeConsumed;
1560
- }
1561
-
1562
- if (!canSkipFlex) {
1563
- resolveFlexibleLength(
1564
- node,
1565
- flexLine,
1566
- mainAxis,
1567
- crossAxis,
1568
- direction,
1569
- ownerWidth,
1570
- mainAxisOwnerSize,
1571
- availableInnerMainDim,
1572
- availableInnerCrossDim,
1573
- availableInnerWidth,
1574
- availableInnerHeight,
1575
- mainAxisOverflows,
1576
- sizingModeCrossDim,
1577
- performLayout,
1578
- layoutMarkerData,
1579
- depth,
1580
- generationCount);
1581
- }
1582
-
1583
- node->setLayoutHadOverflow(
1584
- node->getLayout().hadOverflow() ||
1585
- (flexLine.layout.remainingFreeSpace < 0));
1586
-
1587
- // STEP 6: MAIN-AXIS JUSTIFICATION & CROSS-AXIS SIZE DETERMINATION
1588
-
1589
- // At this point, all the children have their dimensions set in the main
1590
- // axis. Their dimensions are also set in the cross axis with the exception
1591
- // of items that are aligned "stretch". We need to compute these stretch
1592
- // values and set the final positions.
1593
-
1594
- justifyMainAxis(
1595
- node,
1596
- flexLine,
1597
- mainAxis,
1598
- crossAxis,
1599
- direction,
1600
- sizingModeMainDim,
1601
- sizingModeCrossDim,
1602
- mainAxisOwnerSize,
1603
- ownerWidth,
1604
- availableInnerMainDim,
1605
- availableInnerCrossDim,
1606
- availableInnerWidth,
1607
- performLayout);
1608
-
1609
- float containerCrossAxis = availableInnerCrossDim;
1610
- if (sizingModeCrossDim == SizingMode::MaxContent ||
1611
- sizingModeCrossDim == SizingMode::FitContent) {
1612
- // Compute the cross axis from the max cross dimension of the children.
1613
- containerCrossAxis =
1614
- boundAxis(
1615
- node,
1616
- crossAxis,
1617
- direction,
1618
- flexLine.layout.crossDim + paddingAndBorderAxisCross,
1619
- crossAxisOwnerSize,
1620
- ownerWidth) -
1621
- paddingAndBorderAxisCross;
1622
- }
1623
-
1624
- // If there's no flex wrap, the cross dimension is defined by the container.
1625
- if (!isNodeFlexWrap && sizingModeCrossDim == SizingMode::StretchFit) {
1626
- flexLine.layout.crossDim = availableInnerCrossDim;
1627
- }
1628
-
1629
- // As-per https://www.w3.org/TR/css-flexbox-1/#cross-sizing, the
1630
- // cross-size of the line within a single-line container should be bound to
1631
- // min/max constraints before alignment within the line. In a multi-line
1632
- // container, affecting alignment between the lines.
1633
- if (!isNodeFlexWrap) {
1634
- flexLine.layout.crossDim =
1635
- boundAxis(
1636
- node,
1637
- crossAxis,
1638
- direction,
1639
- flexLine.layout.crossDim + paddingAndBorderAxisCross,
1640
- crossAxisOwnerSize,
1641
- ownerWidth) -
1642
- paddingAndBorderAxisCross;
1643
- }
1644
-
1645
- // STEP 7: CROSS-AXIS ALIGNMENT
1646
- // We can skip child alignment if we're just measuring the container.
1647
- if (performLayout) {
1648
- for (auto child : flexLine.itemsInFlow) {
1649
- float leadingCrossDim = leadingPaddingAndBorderCross;
1650
-
1651
- // For a relative children, we're either using alignItems (owner) or
1652
- // alignSelf (child) in order to determine the position in the cross
1653
- // axis
1654
- const Align alignItem = resolveChildAlignment(node, child);
1655
-
1656
- // If the child uses align stretch, we need to lay it out one more
1657
- // time, this time forcing the cross-axis size to be the computed
1658
- // cross size for the current line.
1659
- if (alignItem == Align::Stretch &&
1660
- !child->style().flexStartMarginIsAuto(crossAxis, direction) &&
1661
- !child->style().flexEndMarginIsAuto(crossAxis, direction)) {
1662
- // If the child defines a definite size for its cross axis, there's
1663
- // no need to stretch.
1664
- if (!child->hasDefiniteLength(
1665
- dimension(crossAxis), availableInnerCrossDim)) {
1666
- float childMainSize =
1667
- child->getLayout().measuredDimension(dimension(mainAxis));
1668
- const auto& childStyle = child->style();
1669
- float childCrossSize = childStyle.aspectRatio().isDefined()
1670
- ? child->style().computeMarginForAxis(
1671
- crossAxis, availableInnerWidth) +
1672
- (isMainAxisRow
1673
- ? childMainSize / childStyle.aspectRatio().unwrap()
1674
- : childMainSize * childStyle.aspectRatio().unwrap())
1675
- : flexLine.layout.crossDim;
1676
-
1677
- childMainSize += child->style().computeMarginForAxis(
1678
- mainAxis, availableInnerWidth);
1679
-
1680
- SizingMode childMainSizingMode = SizingMode::StretchFit;
1681
- SizingMode childCrossSizingMode = SizingMode::StretchFit;
1682
- constrainMaxSizeForMode(
1683
- child,
1684
- direction,
1685
- mainAxis,
1686
- availableInnerMainDim,
1687
- availableInnerWidth,
1688
- &childMainSizingMode,
1689
- &childMainSize);
1690
- constrainMaxSizeForMode(
1691
- child,
1692
- direction,
1693
- crossAxis,
1694
- availableInnerCrossDim,
1695
- availableInnerWidth,
1696
- &childCrossSizingMode,
1697
- &childCrossSize);
1698
-
1699
- const float childWidth =
1700
- isMainAxisRow ? childMainSize : childCrossSize;
1701
- const float childHeight =
1702
- !isMainAxisRow ? childMainSize : childCrossSize;
1703
-
1704
- auto alignContent = node->style().alignContent();
1705
- auto crossAxisDoesNotGrow =
1706
- alignContent != Align::Stretch && isNodeFlexWrap;
1707
- const SizingMode childWidthSizingMode =
1708
- yoga::isUndefined(childWidth) ||
1709
- (!isMainAxisRow && crossAxisDoesNotGrow)
1710
- ? SizingMode::MaxContent
1711
- : SizingMode::StretchFit;
1712
- const SizingMode childHeightSizingMode =
1713
- yoga::isUndefined(childHeight) ||
1714
- (isMainAxisRow && crossAxisDoesNotGrow)
1715
- ? SizingMode::MaxContent
1716
- : SizingMode::StretchFit;
1717
-
1718
- calculateLayoutInternal(
1719
- child,
1720
- childWidth,
1721
- childHeight,
1722
- direction,
1723
- childWidthSizingMode,
1724
- childHeightSizingMode,
1725
- availableInnerWidth,
1726
- availableInnerHeight,
1727
- true,
1728
- LayoutPassReason::kStretch,
1729
- layoutMarkerData,
1730
- depth,
1731
- generationCount);
1732
- }
1733
- } else {
1734
- const float remainingCrossDim = containerCrossAxis -
1735
- child->dimensionWithMargin(crossAxis, availableInnerWidth);
1736
-
1737
- if (child->style().flexStartMarginIsAuto(crossAxis, direction) &&
1738
- child->style().flexEndMarginIsAuto(crossAxis, direction)) {
1739
- leadingCrossDim += yoga::maxOrDefined(0.0f, remainingCrossDim / 2);
1740
- } else if (child->style().flexEndMarginIsAuto(crossAxis, direction)) {
1741
- // No-Op
1742
- } else if (child->style().flexStartMarginIsAuto(
1743
- crossAxis, direction)) {
1744
- leadingCrossDim += yoga::maxOrDefined(0.0f, remainingCrossDim);
1745
- } else if (alignItem == Align::FlexStart) {
1746
- // No-Op
1747
- } else if (alignItem == Align::Center) {
1748
- leadingCrossDim += remainingCrossDim / 2;
1749
- } else {
1750
- leadingCrossDim += remainingCrossDim;
1751
- }
1752
- }
1753
- // And we apply the position
1754
- child->setLayoutPosition(
1755
- child->getLayout().position(flexStartEdge(crossAxis)) +
1756
- totalLineCrossDim + leadingCrossDim,
1757
- flexStartEdge(crossAxis));
1758
- }
1759
- }
1760
-
1761
- const float appliedCrossGap = lineCount != 0 ? crossAxisGap : 0.0f;
1762
- totalLineCrossDim += flexLine.layout.crossDim + appliedCrossGap;
1763
- maxLineMainDim =
1764
- yoga::maxOrDefined(maxLineMainDim, flexLine.layout.mainDim);
1765
- }
1766
-
1767
- // STEP 8: MULTI-LINE CONTENT ALIGNMENT
1768
- // currentLead stores the size of the cross dim
1769
- if (performLayout && (isNodeFlexWrap || isBaselineLayout(node))) {
1770
- float leadPerLine = 0;
1771
- float currentLead = leadingPaddingAndBorderCross;
1772
- float extraSpacePerLine = 0;
1773
-
1774
- const float unclampedCrossDim = sizingModeCrossDim == SizingMode::StretchFit
1775
- ? availableInnerCrossDim + paddingAndBorderAxisCross
1776
- : node->hasDefiniteLength(dimension(crossAxis), crossAxisOwnerSize)
1777
- ? node->getResolvedDimension(
1778
- direction,
1779
- dimension(crossAxis),
1780
- crossAxisOwnerSize,
1781
- ownerWidth)
1782
- .unwrap()
1783
- : totalLineCrossDim + paddingAndBorderAxisCross;
1784
-
1785
- const float innerCrossDim = boundAxis(
1786
- node,
1787
- crossAxis,
1788
- direction,
1789
- unclampedCrossDim,
1790
- crossAxisOwnerSize,
1791
- ownerWidth) -
1792
- paddingAndBorderAxisCross;
1793
-
1794
- const float remainingAlignContentDim = innerCrossDim - totalLineCrossDim;
1795
-
1796
- const auto alignContent = remainingAlignContentDim >= 0
1797
- ? node->style().alignContent()
1798
- : fallbackAlignment(node->style().alignContent());
1799
-
1800
- switch (alignContent) {
1801
- case Align::FlexEnd:
1802
- currentLead += remainingAlignContentDim;
1803
- break;
1804
- case Align::Center:
1805
- currentLead += remainingAlignContentDim / 2;
1806
- break;
1807
- case Align::Stretch:
1808
- extraSpacePerLine =
1809
- remainingAlignContentDim / static_cast<float>(lineCount);
1810
- break;
1811
- case Align::SpaceAround:
1812
- currentLead +=
1813
- remainingAlignContentDim / (2 * static_cast<float>(lineCount));
1814
- leadPerLine = remainingAlignContentDim / static_cast<float>(lineCount);
1815
- break;
1816
- case Align::SpaceEvenly:
1817
- currentLead +=
1818
- remainingAlignContentDim / static_cast<float>(lineCount + 1);
1819
- leadPerLine =
1820
- remainingAlignContentDim / static_cast<float>(lineCount + 1);
1821
- break;
1822
- case Align::SpaceBetween:
1823
- if (lineCount > 1) {
1824
- leadPerLine =
1825
- remainingAlignContentDim / static_cast<float>(lineCount - 1);
1826
- }
1827
- break;
1828
- case Align::Auto:
1829
- case Align::FlexStart:
1830
- case Align::Baseline:
1831
- break;
1832
- }
1833
- Node::LayoutableChildren::Iterator endIterator =
1834
- node->getLayoutChildren().begin();
1835
- for (size_t i = 0; i < lineCount; i++) {
1836
- const Node::LayoutableChildren::Iterator startIterator = endIterator;
1837
- auto iterator = startIterator;
1838
-
1839
- // compute the line's height and find the endIndex
1840
- float lineHeight = 0;
1841
- float maxAscentForCurrentLine = 0;
1842
- float maxDescentForCurrentLine = 0;
1843
- for (; iterator != node->getLayoutChildren().end(); iterator++) {
1844
- const auto child = *iterator;
1845
- if (child->style().display() == Display::None) {
1846
- continue;
1847
- }
1848
- if (child->style().positionType() != PositionType::Absolute) {
1849
- if (child->getLineIndex() != i) {
1850
- break;
1851
- }
1852
- if (child->isLayoutDimensionDefined(crossAxis)) {
1853
- lineHeight = yoga::maxOrDefined(
1854
- lineHeight,
1855
- child->getLayout().measuredDimension(dimension(crossAxis)) +
1856
- child->style().computeMarginForAxis(
1857
- crossAxis, availableInnerWidth));
1858
- }
1859
- if (resolveChildAlignment(node, child) == Align::Baseline) {
1860
- const float ascent = calculateBaseline(child) +
1861
- child->style().computeFlexStartMargin(
1862
- FlexDirection::Column, direction, availableInnerWidth);
1863
- const float descent =
1864
- child->getLayout().measuredDimension(Dimension::Height) +
1865
- child->style().computeMarginForAxis(
1866
- FlexDirection::Column, availableInnerWidth) -
1867
- ascent;
1868
- maxAscentForCurrentLine =
1869
- yoga::maxOrDefined(maxAscentForCurrentLine, ascent);
1870
- maxDescentForCurrentLine =
1871
- yoga::maxOrDefined(maxDescentForCurrentLine, descent);
1872
- lineHeight = yoga::maxOrDefined(
1873
- lineHeight, maxAscentForCurrentLine + maxDescentForCurrentLine);
1874
- }
1875
- }
1876
- }
1877
- endIterator = iterator;
1878
- currentLead += i != 0 ? crossAxisGap : 0;
1879
- lineHeight += extraSpacePerLine;
1880
-
1881
- for (iterator = startIterator; iterator != endIterator; iterator++) {
1882
- const auto child = *iterator;
1883
- if (child->style().display() == Display::None) {
1884
- continue;
1885
- }
1886
- if (child->style().positionType() != PositionType::Absolute) {
1887
- switch (resolveChildAlignment(node, child)) {
1888
- case Align::FlexStart: {
1889
- child->setLayoutPosition(
1890
- currentLead +
1891
- child->style().computeFlexStartPosition(
1892
- crossAxis, direction, availableInnerWidth),
1893
- flexStartEdge(crossAxis));
1894
- break;
1895
- }
1896
- case Align::FlexEnd: {
1897
- child->setLayoutPosition(
1898
- currentLead + lineHeight -
1899
- child->style().computeFlexEndMargin(
1900
- crossAxis, direction, availableInnerWidth) -
1901
- child->getLayout().measuredDimension(
1902
- dimension(crossAxis)),
1903
- flexStartEdge(crossAxis));
1904
- break;
1905
- }
1906
- case Align::Center: {
1907
- float childHeight =
1908
- child->getLayout().measuredDimension(dimension(crossAxis));
1909
-
1910
- child->setLayoutPosition(
1911
- currentLead + (lineHeight - childHeight) / 2,
1912
- flexStartEdge(crossAxis));
1913
- break;
1914
- }
1915
- case Align::Stretch: {
1916
- child->setLayoutPosition(
1917
- currentLead +
1918
- child->style().computeFlexStartMargin(
1919
- crossAxis, direction, availableInnerWidth),
1920
- flexStartEdge(crossAxis));
1921
-
1922
- // Remeasure child with the line height as it as been only
1923
- // measured with the owners height yet.
1924
- if (!child->hasDefiniteLength(
1925
- dimension(crossAxis), availableInnerCrossDim)) {
1926
- const float childWidth = isMainAxisRow
1927
- ? (child->getLayout().measuredDimension(Dimension::Width) +
1928
- child->style().computeMarginForAxis(
1929
- mainAxis, availableInnerWidth))
1930
- : leadPerLine + lineHeight;
1931
-
1932
- const float childHeight = !isMainAxisRow
1933
- ? (child->getLayout().measuredDimension(Dimension::Height) +
1934
- child->style().computeMarginForAxis(
1935
- crossAxis, availableInnerWidth))
1936
- : leadPerLine + lineHeight;
1937
-
1938
- if (!(yoga::inexactEquals(
1939
- childWidth,
1940
- child->getLayout().measuredDimension(
1941
- Dimension::Width)) &&
1942
- yoga::inexactEquals(
1943
- childHeight,
1944
- child->getLayout().measuredDimension(
1945
- Dimension::Height)))) {
1946
- calculateLayoutInternal(
1947
- child,
1948
- childWidth,
1949
- childHeight,
1950
- direction,
1951
- SizingMode::StretchFit,
1952
- SizingMode::StretchFit,
1953
- availableInnerWidth,
1954
- availableInnerHeight,
1955
- true,
1956
- LayoutPassReason::kMultilineStretch,
1957
- layoutMarkerData,
1958
- depth,
1959
- generationCount);
1960
- }
1961
- }
1962
- break;
1963
- }
1964
- case Align::Baseline: {
1965
- child->setLayoutPosition(
1966
- currentLead + maxAscentForCurrentLine -
1967
- calculateBaseline(child) +
1968
- child->style().computeFlexStartPosition(
1969
- FlexDirection::Column,
1970
- direction,
1971
- availableInnerCrossDim),
1972
- PhysicalEdge::Top);
1973
-
1974
- break;
1975
- }
1976
- case Align::Auto:
1977
- case Align::SpaceBetween:
1978
- case Align::SpaceAround:
1979
- case Align::SpaceEvenly:
1980
- break;
1981
- }
1982
- }
1983
- }
1984
-
1985
- currentLead = currentLead + leadPerLine + lineHeight;
1986
- }
1987
- }
1988
-
1989
- // STEP 9: COMPUTING FINAL DIMENSIONS
1990
-
1991
- node->setLayoutMeasuredDimension(
1992
- boundAxis(
1993
- node,
1994
- FlexDirection::Row,
1995
- direction,
1996
- availableWidth - marginAxisRow,
1997
- ownerWidth,
1998
- ownerWidth),
1999
- Dimension::Width);
2000
-
2001
- node->setLayoutMeasuredDimension(
2002
- boundAxis(
2003
- node,
2004
- FlexDirection::Column,
2005
- direction,
2006
- availableHeight - marginAxisColumn,
2007
- ownerHeight,
2008
- ownerWidth),
2009
- Dimension::Height);
2010
-
2011
- // If the user didn't specify a width or height for the node, set the
2012
- // dimensions based on the children.
2013
- if (sizingModeMainDim == SizingMode::MaxContent ||
2014
- (node->style().overflow() != Overflow::Scroll &&
2015
- sizingModeMainDim == SizingMode::FitContent)) {
2016
- // Clamp the size to the min/max size, if specified, and make sure it
2017
- // doesn't go below the padding and border amount.
2018
- node->setLayoutMeasuredDimension(
2019
- boundAxis(
2020
- node,
2021
- mainAxis,
2022
- direction,
2023
- maxLineMainDim,
2024
- mainAxisOwnerSize,
2025
- ownerWidth),
2026
- dimension(mainAxis));
2027
-
2028
- } else if (
2029
- sizingModeMainDim == SizingMode::FitContent &&
2030
- node->style().overflow() == Overflow::Scroll) {
2031
- node->setLayoutMeasuredDimension(
2032
- yoga::maxOrDefined(
2033
- yoga::minOrDefined(
2034
- availableInnerMainDim + paddingAndBorderAxisMain,
2035
- boundAxisWithinMinAndMax(
2036
- node,
2037
- direction,
2038
- mainAxis,
2039
- FloatOptional{maxLineMainDim},
2040
- mainAxisOwnerSize,
2041
- ownerWidth)
2042
- .unwrap()),
2043
- paddingAndBorderAxisMain),
2044
- dimension(mainAxis));
2045
- }
2046
-
2047
- if (sizingModeCrossDim == SizingMode::MaxContent ||
2048
- (node->style().overflow() != Overflow::Scroll &&
2049
- sizingModeCrossDim == SizingMode::FitContent)) {
2050
- // Clamp the size to the min/max size, if specified, and make sure it
2051
- // doesn't go below the padding and border amount.
2052
- node->setLayoutMeasuredDimension(
2053
- boundAxis(
2054
- node,
2055
- crossAxis,
2056
- direction,
2057
- totalLineCrossDim + paddingAndBorderAxisCross,
2058
- crossAxisOwnerSize,
2059
- ownerWidth),
2060
- dimension(crossAxis));
2061
-
2062
- } else if (
2063
- sizingModeCrossDim == SizingMode::FitContent &&
2064
- node->style().overflow() == Overflow::Scroll) {
2065
- node->setLayoutMeasuredDimension(
2066
- yoga::maxOrDefined(
2067
- yoga::minOrDefined(
2068
- availableInnerCrossDim + paddingAndBorderAxisCross,
2069
- boundAxisWithinMinAndMax(
2070
- node,
2071
- direction,
2072
- crossAxis,
2073
- FloatOptional{
2074
- totalLineCrossDim + paddingAndBorderAxisCross},
2075
- crossAxisOwnerSize,
2076
- ownerWidth)
2077
- .unwrap()),
2078
- paddingAndBorderAxisCross),
2079
- dimension(crossAxis));
2080
- }
2081
-
2082
- // As we only wrapped in normal direction yet, we need to reverse the
2083
- // positions on wrap-reverse.
2084
- if (performLayout && node->style().flexWrap() == Wrap::WrapReverse) {
2085
- for (auto child : node->getLayoutChildren()) {
2086
- if (child->style().positionType() != PositionType::Absolute) {
2087
- child->setLayoutPosition(
2088
- node->getLayout().measuredDimension(dimension(crossAxis)) -
2089
- child->getLayout().position(flexStartEdge(crossAxis)) -
2090
- child->getLayout().measuredDimension(dimension(crossAxis)),
2091
- flexStartEdge(crossAxis));
2092
- }
2093
- }
2094
- }
2095
-
2096
- if (performLayout) {
2097
- // STEP 10: SETTING TRAILING POSITIONS FOR CHILDREN
2098
- const bool needsMainTrailingPos = needsTrailingPosition(mainAxis);
2099
- const bool needsCrossTrailingPos = needsTrailingPosition(crossAxis);
2100
-
2101
- if (needsMainTrailingPos || needsCrossTrailingPos) {
2102
- for (auto child : node->getLayoutChildren()) {
2103
- // Absolute children will be handled by their containing block since we
2104
- // cannot guarantee that their positions are set when their parents are
2105
- // done with layout.
2106
- if (child->style().display() == Display::None ||
2107
- child->style().positionType() == PositionType::Absolute) {
2108
- continue;
2109
- }
2110
- if (needsMainTrailingPos) {
2111
- setChildTrailingPosition(node, child, mainAxis);
2112
- }
2113
-
2114
- if (needsCrossTrailingPos) {
2115
- setChildTrailingPosition(node, child, crossAxis);
2116
- }
2117
- }
2118
- }
2119
-
2120
- // STEP 11: SIZING AND POSITIONING ABSOLUTE CHILDREN
2121
- // Let the containing block layout its absolute descendants.
2122
- if (node->style().positionType() != PositionType::Static ||
2123
- node->alwaysFormsContainingBlock() || depth == 1) {
2124
- layoutAbsoluteDescendants(
2125
- node,
2126
- node,
2127
- isMainAxisRow ? sizingModeMainDim : sizingModeCrossDim,
2128
- direction,
2129
- layoutMarkerData,
2130
- depth,
2131
- generationCount,
2132
- 0.0f,
2133
- 0.0f,
2134
- availableInnerWidth,
2135
- availableInnerHeight);
2136
- }
2137
- }
2138
- }
2139
-
2140
- //
2141
- // This is a wrapper around the calculateLayoutImpl function. It determines
2142
- // whether the layout request is redundant and can be skipped.
2143
- //
2144
- // Parameters:
2145
- // Input parameters are the same as calculateLayoutImpl (see above)
2146
- // Return parameter is true if layout was performed, false if skipped
2147
- //
2148
- bool calculateLayoutInternal(
2149
- yoga::Node* const node,
2150
- const float availableWidth,
2151
- const float availableHeight,
2152
- const Direction ownerDirection,
2153
- const SizingMode widthSizingMode,
2154
- const SizingMode heightSizingMode,
2155
- const float ownerWidth,
2156
- const float ownerHeight,
2157
- const bool performLayout,
2158
- const LayoutPassReason reason,
2159
- LayoutData& layoutMarkerData,
2160
- uint32_t depth,
2161
- const uint32_t generationCount) {
2162
- LayoutResults* layout = &node->getLayout();
2163
-
2164
- depth++;
2165
-
2166
- const bool needToVisitNode =
2167
- (node->isDirty() && layout->generationCount != generationCount) ||
2168
- layout->configVersion != node->getConfig()->getVersion() ||
2169
- layout->lastOwnerDirection != ownerDirection;
2170
-
2171
- if (needToVisitNode) {
2172
- // Invalidate the cached results.
2173
- layout->nextCachedMeasurementsIndex = 0;
2174
- layout->cachedLayout.availableWidth = -1;
2175
- layout->cachedLayout.availableHeight = -1;
2176
- layout->cachedLayout.widthSizingMode = SizingMode::MaxContent;
2177
- layout->cachedLayout.heightSizingMode = SizingMode::MaxContent;
2178
- layout->cachedLayout.computedWidth = -1;
2179
- layout->cachedLayout.computedHeight = -1;
2180
- }
2181
-
2182
- CachedMeasurement* cachedResults = nullptr;
2183
-
2184
- // Determine whether the results are already cached. We maintain a separate
2185
- // cache for layouts and measurements. A layout operation modifies the
2186
- // positions and dimensions for nodes in the subtree. The algorithm assumes
2187
- // that each node gets laid out a maximum of one time per tree layout, but
2188
- // multiple measurements may be required to resolve all of the flex
2189
- // dimensions. We handle nodes with measure functions specially here because
2190
- // they are the most expensive to measure, so it's worth avoiding redundant
2191
- // measurements if at all possible.
2192
- if (node->hasMeasureFunc()) {
2193
- const float marginAxisRow =
2194
- node->style().computeMarginForAxis(FlexDirection::Row, ownerWidth);
2195
- const float marginAxisColumn =
2196
- node->style().computeMarginForAxis(FlexDirection::Column, ownerWidth);
2197
-
2198
- // First, try to use the layout cache.
2199
- if (canUseCachedMeasurement(
2200
- widthSizingMode,
2201
- availableWidth,
2202
- heightSizingMode,
2203
- availableHeight,
2204
- layout->cachedLayout.widthSizingMode,
2205
- layout->cachedLayout.availableWidth,
2206
- layout->cachedLayout.heightSizingMode,
2207
- layout->cachedLayout.availableHeight,
2208
- layout->cachedLayout.computedWidth,
2209
- layout->cachedLayout.computedHeight,
2210
- marginAxisRow,
2211
- marginAxisColumn,
2212
- node->getConfig())) {
2213
- cachedResults = &layout->cachedLayout;
2214
- } else {
2215
- // Try to use the measurement cache.
2216
- for (size_t i = 0; i < layout->nextCachedMeasurementsIndex; i++) {
2217
- if (canUseCachedMeasurement(
2218
- widthSizingMode,
2219
- availableWidth,
2220
- heightSizingMode,
2221
- availableHeight,
2222
- layout->cachedMeasurements[i].widthSizingMode,
2223
- layout->cachedMeasurements[i].availableWidth,
2224
- layout->cachedMeasurements[i].heightSizingMode,
2225
- layout->cachedMeasurements[i].availableHeight,
2226
- layout->cachedMeasurements[i].computedWidth,
2227
- layout->cachedMeasurements[i].computedHeight,
2228
- marginAxisRow,
2229
- marginAxisColumn,
2230
- node->getConfig())) {
2231
- cachedResults = &layout->cachedMeasurements[i];
2232
- break;
2233
- }
2234
- }
2235
- }
2236
- } else if (performLayout) {
2237
- if (yoga::inexactEquals(
2238
- layout->cachedLayout.availableWidth, availableWidth) &&
2239
- yoga::inexactEquals(
2240
- layout->cachedLayout.availableHeight, availableHeight) &&
2241
- layout->cachedLayout.widthSizingMode == widthSizingMode &&
2242
- layout->cachedLayout.heightSizingMode == heightSizingMode) {
2243
- cachedResults = &layout->cachedLayout;
2244
- }
2245
- } else {
2246
- for (uint32_t i = 0; i < layout->nextCachedMeasurementsIndex; i++) {
2247
- if (yoga::inexactEquals(
2248
- layout->cachedMeasurements[i].availableWidth, availableWidth) &&
2249
- yoga::inexactEquals(
2250
- layout->cachedMeasurements[i].availableHeight, availableHeight) &&
2251
- layout->cachedMeasurements[i].widthSizingMode == widthSizingMode &&
2252
- layout->cachedMeasurements[i].heightSizingMode == heightSizingMode) {
2253
- cachedResults = &layout->cachedMeasurements[i];
2254
- break;
2255
- }
2256
- }
2257
- }
2258
-
2259
- if (!needToVisitNode && cachedResults != nullptr) {
2260
- layout->setMeasuredDimension(
2261
- Dimension::Width, cachedResults->computedWidth);
2262
- layout->setMeasuredDimension(
2263
- Dimension::Height, cachedResults->computedHeight);
2264
-
2265
- (performLayout ? layoutMarkerData.cachedLayouts
2266
- : layoutMarkerData.cachedMeasures) += 1;
2267
- } else {
2268
- calculateLayoutImpl(
2269
- node,
2270
- availableWidth,
2271
- availableHeight,
2272
- ownerDirection,
2273
- widthSizingMode,
2274
- heightSizingMode,
2275
- ownerWidth,
2276
- ownerHeight,
2277
- performLayout,
2278
- reason,
2279
- layoutMarkerData,
2280
- depth,
2281
- generationCount);
2282
-
2283
- layout->lastOwnerDirection = ownerDirection;
2284
- layout->configVersion = node->getConfig()->getVersion();
2285
-
2286
- if (cachedResults == nullptr) {
2287
- layoutMarkerData.maxMeasureCache = std::max(
2288
- layoutMarkerData.maxMeasureCache,
2289
- layout->nextCachedMeasurementsIndex + 1u);
2290
-
2291
- if (layout->nextCachedMeasurementsIndex ==
2292
- LayoutResults::MaxCachedMeasurements) {
2293
- layout->nextCachedMeasurementsIndex = 0;
2294
- }
2295
-
2296
- CachedMeasurement* newCacheEntry = nullptr;
2297
- if (performLayout) {
2298
- // Use the single layout cache entry.
2299
- newCacheEntry = &layout->cachedLayout;
2300
- } else {
2301
- // Allocate a new measurement cache entry.
2302
- newCacheEntry =
2303
- &layout->cachedMeasurements[layout->nextCachedMeasurementsIndex];
2304
- layout->nextCachedMeasurementsIndex++;
2305
- }
2306
-
2307
- newCacheEntry->availableWidth = availableWidth;
2308
- newCacheEntry->availableHeight = availableHeight;
2309
- newCacheEntry->widthSizingMode = widthSizingMode;
2310
- newCacheEntry->heightSizingMode = heightSizingMode;
2311
- newCacheEntry->computedWidth =
2312
- layout->measuredDimension(Dimension::Width);
2313
- newCacheEntry->computedHeight =
2314
- layout->measuredDimension(Dimension::Height);
2315
- }
2316
- }
2317
-
2318
- if (performLayout) {
2319
- node->setLayoutDimension(
2320
- node->getLayout().measuredDimension(Dimension::Width),
2321
- Dimension::Width);
2322
- node->setLayoutDimension(
2323
- node->getLayout().measuredDimension(Dimension::Height),
2324
- Dimension::Height);
2325
-
2326
- node->setHasNewLayout(true);
2327
- node->setDirty(false);
2328
- }
2329
-
2330
- layout->generationCount = generationCount;
2331
-
2332
- LayoutType layoutType;
2333
- if (performLayout) {
2334
- layoutType = !needToVisitNode && cachedResults == &layout->cachedLayout
2335
- ? LayoutType::kCachedLayout
2336
- : LayoutType::kLayout;
2337
- } else {
2338
- layoutType = cachedResults != nullptr ? LayoutType::kCachedMeasure
2339
- : LayoutType::kMeasure;
2340
- }
2341
- Event::publish<Event::NodeLayout>(node, {layoutType});
2342
-
2343
- return (needToVisitNode || cachedResults == nullptr);
2344
- }
2345
-
2346
- void calculateLayout(
2347
- yoga::Node* const node,
2348
- const float ownerWidth,
2349
- const float ownerHeight,
2350
- const Direction ownerDirection) {
2351
- Event::publish<Event::LayoutPassStart>(node);
2352
- LayoutData markerData = {};
2353
-
2354
- // Increment the generation count. This will force the recursive routine to
2355
- // visit all dirty nodes at least once. Subsequent visits will be skipped if
2356
- // the input parameters don't change.
2357
- gCurrentGenerationCount.fetch_add(1, std::memory_order_relaxed);
2358
- node->processDimensions();
2359
- const Direction direction = node->resolveDirection(ownerDirection);
2360
- float width = YGUndefined;
2361
- SizingMode widthSizingMode = SizingMode::MaxContent;
2362
- const auto& style = node->style();
2363
- if (node->hasDefiniteLength(Dimension::Width, ownerWidth)) {
2364
- width =
2365
- (node->getResolvedDimension(
2366
- direction,
2367
- dimension(FlexDirection::Row),
2368
- ownerWidth,
2369
- ownerWidth)
2370
- .unwrap() +
2371
- node->style().computeMarginForAxis(FlexDirection::Row, ownerWidth));
2372
- widthSizingMode = SizingMode::StretchFit;
2373
- } else if (style
2374
- .resolvedMaxDimension(
2375
- direction, Dimension::Width, ownerWidth, ownerWidth)
2376
- .isDefined()) {
2377
- width = style
2378
- .resolvedMaxDimension(
2379
- direction, Dimension::Width, ownerWidth, ownerWidth)
2380
- .unwrap();
2381
- widthSizingMode = SizingMode::FitContent;
2382
- } else {
2383
- width = ownerWidth;
2384
- widthSizingMode = yoga::isUndefined(width) ? SizingMode::MaxContent
2385
- : SizingMode::StretchFit;
2386
- }
2387
-
2388
- float height = YGUndefined;
2389
- SizingMode heightSizingMode = SizingMode::MaxContent;
2390
- if (node->hasDefiniteLength(Dimension::Height, ownerHeight)) {
2391
- height =
2392
- (node->getResolvedDimension(
2393
- direction,
2394
- dimension(FlexDirection::Column),
2395
- ownerHeight,
2396
- ownerWidth)
2397
- .unwrap() +
2398
- node->style().computeMarginForAxis(FlexDirection::Column, ownerWidth));
2399
- heightSizingMode = SizingMode::StretchFit;
2400
- } else if (style
2401
- .resolvedMaxDimension(
2402
- direction, Dimension::Height, ownerHeight, ownerWidth)
2403
- .isDefined()) {
2404
- height = style
2405
- .resolvedMaxDimension(
2406
- direction, Dimension::Height, ownerHeight, ownerWidth)
2407
- .unwrap();
2408
- heightSizingMode = SizingMode::FitContent;
2409
- } else {
2410
- height = ownerHeight;
2411
- heightSizingMode = yoga::isUndefined(height) ? SizingMode::MaxContent
2412
- : SizingMode::StretchFit;
2413
- }
2414
- if (calculateLayoutInternal(
2415
- node,
2416
- width,
2417
- height,
2418
- ownerDirection,
2419
- widthSizingMode,
2420
- heightSizingMode,
2421
- ownerWidth,
2422
- ownerHeight,
2423
- true,
2424
- LayoutPassReason::kInitial,
2425
- markerData,
2426
- 0, // tree root
2427
- gCurrentGenerationCount.load(std::memory_order_relaxed))) {
2428
- node->setPosition(node->getLayout().direction(), ownerWidth, ownerHeight);
2429
- roundLayoutResultsToPixelGrid(node, 0.0f, 0.0f);
2430
- }
2431
-
2432
- Event::publish<Event::LayoutPassEnd>(node, {&markerData});
2433
- }
2434
-
2435
- } // namespace facebook::yoga