react-nitro-yoga 0.0.0-stage → 0.0.1-alpha.7

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 (529) hide show
  1. package/Generated/.gitattributes +1 -0
  2. package/Generated/api.d.ts +100 -0
  3. package/Generated/ffigen_yoga_adapters.h +52 -0
  4. package/Generated/native.d.ts +84 -0
  5. package/Generated/native.ts +283 -0
  6. package/Generated/yoga.c +1087 -0
  7. package/LICENSE +21 -0
  8. package/Package.swift +57 -0
  9. package/README.md +61 -2
  10. package/Sources/ReactNitroYoga/InstallHermesBindings.cpp +11 -0
  11. package/Sources/ReactNitroYoga/SHUnit.h +16 -0
  12. package/include/ReactNitroYoga/InstallHermesBindings.hpp +12 -0
  13. package/package.json +26 -4
  14. package/yoga/.clang-format +109 -0
  15. package/yoga/.clang-tidy +217 -0
  16. package/yoga/.editorconfig +11 -0
  17. package/yoga/.eslintrc.cjs +84 -0
  18. package/yoga/.github/ISSUE_TEMPLATE.md +21 -0
  19. package/yoga/.github/actions/black/action.yml +25 -0
  20. package/yoga/.github/actions/cache-emsdk/action.yml +10 -0
  21. package/yoga/.github/actions/install-ninja/action.yml +14 -0
  22. package/yoga/.github/actions/setup-android/action.yml +12 -0
  23. package/yoga/.github/actions/setup-apple/action.yml +8 -0
  24. package/yoga/.github/actions/setup-cpp/action.yml +34 -0
  25. package/yoga/.github/actions/setup-js/action.yml +18 -0
  26. package/yoga/.github/workflows/publish-android-release.yml +38 -0
  27. package/yoga/.github/workflows/publish-android-snashot.yml +36 -0
  28. package/yoga/.github/workflows/publish-npm-release.yml +25 -0
  29. package/yoga/.github/workflows/validate-android.yml +30 -0
  30. package/yoga/.github/workflows/validate-cpp.yml +101 -0
  31. package/yoga/.github/workflows/validate-format.yml +36 -0
  32. package/yoga/.github/workflows/validate-js.yml +119 -0
  33. package/yoga/.github/workflows/validate-swiftpm.yml +29 -0
  34. package/yoga/.github/workflows/validate-tests.yml +35 -0
  35. package/yoga/.github/workflows/validate-website.yml +45 -0
  36. package/yoga/.prettierignore +3 -0
  37. package/yoga/.prettierrc.js +16 -0
  38. package/yoga/.vscode/extensions.json +7 -0
  39. package/yoga/.vscode/launch.json +25 -0
  40. package/yoga/.vscode/settings.json +20 -0
  41. package/yoga/.vscode/tasks.json +23 -0
  42. package/yoga/CMakeLists.txt +58 -0
  43. package/yoga/CODE_OF_CONDUCT.md +76 -0
  44. package/yoga/CONTRIBUTING.md +44 -0
  45. package/yoga/LICENSE +21 -0
  46. package/yoga/LICENSE-examples +9 -0
  47. package/yoga/Package.swift +32 -0
  48. package/yoga/README.md +36 -0
  49. package/yoga/benchmark/Benchmark.cpp +400 -0
  50. package/yoga/benchmark/Benchmark.h +39 -0
  51. package/yoga/benchmark/CMakeLists.txt +27 -0
  52. package/yoga/benchmark/TreeDeserialization.cpp +248 -0
  53. package/yoga/benchmark/TreeDeserialization.h +52 -0
  54. package/yoga/benchmark/YGBenchmark.c +183 -0
  55. package/yoga/benchmark/benchmark +15 -0
  56. package/yoga/benchmark/captures/chat-mac.json +24426 -0
  57. package/yoga/benchmark/captures/feed-android.json +10335 -0
  58. package/yoga/benchmark/captures/profile-ios.json +1955 -0
  59. package/yoga/benchmark/captures/rendering-sample-mac.json +1927 -0
  60. package/yoga/build.gradle +46 -0
  61. package/yoga/build_fuzz_tests +28 -0
  62. package/yoga/capture/CMakeLists.txt +23 -0
  63. package/yoga/capture/CaptureTree.cpp +100 -0
  64. package/yoga/capture/CaptureTree.h +47 -0
  65. package/yoga/capture/NodeToString.cpp +359 -0
  66. package/yoga/capture/NodeToString.h +40 -0
  67. package/yoga/cmake/project-defaults.cmake +50 -0
  68. package/yoga/cmake/yoga-config.cmake.in +10 -0
  69. package/yoga/enums.py +394 -0
  70. package/yoga/fuzz/CMakeLists.txt +21 -0
  71. package/yoga/fuzz/FuzzLayout.cpp +57 -0
  72. package/yoga/gentest/babel.config.cjs +12 -0
  73. package/yoga/gentest/fixtures/YGAbsolutePositionTest.html +168 -0
  74. package/yoga/gentest/fixtures/YGAlignContentTest.html +479 -0
  75. package/yoga/gentest/fixtures/YGAlignItemsTest.html +227 -0
  76. package/yoga/gentest/fixtures/YGAlignSelfTest.html +23 -0
  77. package/yoga/gentest/fixtures/YGAndroidNewsFeed.html +28 -0
  78. package/yoga/gentest/fixtures/YGAspectRatioTest.html +3 -0
  79. package/yoga/gentest/fixtures/YGAutoTest.html +25 -0
  80. package/yoga/gentest/fixtures/YGBorderTest.html +18 -0
  81. package/yoga/gentest/fixtures/YGBoxSizingTest.html +240 -0
  82. package/yoga/gentest/fixtures/YGDimensionTest.html +9 -0
  83. package/yoga/gentest/fixtures/YGDisplayTest.html +89 -0
  84. package/yoga/gentest/fixtures/YGFlexBasisFitContentTest.html +55 -0
  85. package/yoga/gentest/fixtures/YGFlexDirectionTest.html +391 -0
  86. package/yoga/gentest/fixtures/YGFlexTest.html +53 -0
  87. package/yoga/gentest/fixtures/YGFlexWrapTest.html +160 -0
  88. package/yoga/gentest/fixtures/YGGapTest.html +233 -0
  89. package/yoga/gentest/fixtures/YGIntrinsicSizeTest.html +295 -0
  90. package/yoga/gentest/fixtures/YGJustifyContentTest.html +164 -0
  91. package/yoga/gentest/fixtures/YGMarginTest.html +157 -0
  92. package/yoga/gentest/fixtures/YGMinMaxDimensionTest.html +116 -0
  93. package/yoga/gentest/fixtures/YGPaddingTest.html +29 -0
  94. package/yoga/gentest/fixtures/YGPercentageTest.html +125 -0
  95. package/yoga/gentest/fixtures/YGRoundingTest.html +95 -0
  96. package/yoga/gentest/fixtures/YGSizeOverflowTest.html +17 -0
  97. package/yoga/gentest/fixtures/YGStaticPositionTest.html +712 -0
  98. package/yoga/gentest/fonts/Ahem.ttf +0 -0
  99. package/yoga/gentest/gentest-driver.ts +141 -0
  100. package/yoga/gentest/gentest-validate.ts +43 -0
  101. package/yoga/gentest/package.json +24 -0
  102. package/yoga/gentest/scripts/gentest-validate.ts +43 -0
  103. package/yoga/gentest/signedsource.d.ts +10 -0
  104. package/yoga/gentest/src/ChromePool.ts +78 -0
  105. package/yoga/gentest/src/CssToYoga.ts +958 -0
  106. package/yoga/gentest/src/buildLayoutTree.ts +98 -0
  107. package/yoga/gentest/src/cli.ts +163 -0
  108. package/yoga/gentest/src/emitters/CppEmitter.ts +452 -0
  109. package/yoga/gentest/src/emitters/Emitter.ts +204 -0
  110. package/yoga/gentest/src/emitters/JavaEmitter.ts +469 -0
  111. package/yoga/gentest/src/emitters/JavascriptEmitter.ts +353 -0
  112. package/yoga/gentest/src/types.ts +41 -0
  113. package/yoga/gentest/test-template.html +42 -0
  114. package/yoga/gentest/tsconfig.json +13 -0
  115. package/yoga/gradle/wrapper/gradle-wrapper.jar +0 -0
  116. package/yoga/gradle/wrapper/gradle-wrapper.properties +7 -0
  117. package/yoga/gradle.properties +14 -0
  118. package/yoga/gradlew +251 -0
  119. package/yoga/gradlew.bat +94 -0
  120. package/yoga/java/AndroidManifest.xml +14 -0
  121. package/yoga/java/CMakeLists.txt +22 -0
  122. package/yoga/java/build.gradle.kts +127 -0
  123. package/yoga/java/com/facebook/yoga/LayoutPassReason.kt +35 -0
  124. package/yoga/java/com/facebook/yoga/YogaAlign.kt +45 -0
  125. package/yoga/java/com/facebook/yoga/YogaBaselineFunction.kt +16 -0
  126. package/yoga/java/com/facebook/yoga/YogaBoxSizing.kt +27 -0
  127. package/yoga/java/com/facebook/yoga/YogaConfig.kt +48 -0
  128. package/yoga/java/com/facebook/yoga/YogaConfigFactory.kt +12 -0
  129. package/yoga/java/com/facebook/yoga/YogaConfigJNIBase.kt +70 -0
  130. package/yoga/java/com/facebook/yoga/YogaConfigJNIFinalizer.kt +30 -0
  131. package/yoga/java/com/facebook/yoga/YogaConstants.kt +18 -0
  132. package/yoga/java/com/facebook/yoga/YogaDimension.kt +27 -0
  133. package/yoga/java/com/facebook/yoga/YogaDirection.kt +29 -0
  134. package/yoga/java/com/facebook/yoga/YogaDisplay.kt +31 -0
  135. package/yoga/java/com/facebook/yoga/YogaEdge.kt +41 -0
  136. package/yoga/java/com/facebook/yoga/YogaErrata.kt +39 -0
  137. package/yoga/java/com/facebook/yoga/YogaExperimentalFeature.kt +27 -0
  138. package/yoga/java/com/facebook/yoga/YogaFlexDirection.kt +31 -0
  139. package/yoga/java/com/facebook/yoga/YogaGridTrackType.kt +33 -0
  140. package/yoga/java/com/facebook/yoga/YogaGutter.kt +29 -0
  141. package/yoga/java/com/facebook/yoga/YogaJustify.kt +43 -0
  142. package/yoga/java/com/facebook/yoga/YogaLayoutType.kt +27 -0
  143. package/yoga/java/com/facebook/yoga/YogaLogLevel.kt +39 -0
  144. package/yoga/java/com/facebook/yoga/YogaLogger.kt +19 -0
  145. package/yoga/java/com/facebook/yoga/YogaMeasureFunction.kt +19 -0
  146. package/yoga/java/com/facebook/yoga/YogaMeasureMode.kt +29 -0
  147. package/yoga/java/com/facebook/yoga/YogaMeasureOutput.kt +29 -0
  148. package/yoga/java/com/facebook/yoga/YogaNative.kt +347 -0
  149. package/yoga/java/com/facebook/yoga/YogaNode.kt +254 -0
  150. package/yoga/java/com/facebook/yoga/YogaNodeFactory.kt +14 -0
  151. package/yoga/java/com/facebook/yoga/YogaNodeJNIBase.kt +762 -0
  152. package/yoga/java/com/facebook/yoga/YogaNodeJNIFinalizer.kt +33 -0
  153. package/yoga/java/com/facebook/yoga/YogaNodeType.kt +27 -0
  154. package/yoga/java/com/facebook/yoga/YogaOverflow.kt +29 -0
  155. package/yoga/java/com/facebook/yoga/YogaPositionType.kt +29 -0
  156. package/yoga/java/com/facebook/yoga/YogaProps.kt +205 -0
  157. package/yoga/java/com/facebook/yoga/YogaStyleInputs.kt +51 -0
  158. package/yoga/java/com/facebook/yoga/YogaUnit.kt +37 -0
  159. package/yoga/java/com/facebook/yoga/YogaValue.kt +66 -0
  160. package/yoga/java/com/facebook/yoga/YogaWrap.kt +29 -0
  161. package/yoga/java/com/facebook/yoga/annotations/DoNotStrip.kt +19 -0
  162. package/yoga/java/gen/com/facebook/yoga/BuildConfig.java +15 -0
  163. package/yoga/java/jni/LayoutContext.cpp +34 -0
  164. package/yoga/java/jni/LayoutContext.h +29 -0
  165. package/yoga/java/jni/ScopedGlobalRef.h +140 -0
  166. package/yoga/java/jni/ScopedLocalRef.h +141 -0
  167. package/yoga/java/jni/YGJNI.h +77 -0
  168. package/yoga/java/jni/YGJNIVanilla.cpp +1178 -0
  169. package/yoga/java/jni/YGJNIVanilla.h +12 -0
  170. package/yoga/java/jni/YGJTypesVanilla.h +52 -0
  171. package/yoga/java/jni/YogaJniException.cpp +49 -0
  172. package/yoga/java/jni/YogaJniException.h +35 -0
  173. package/yoga/java/jni/common.cpp +109 -0
  174. package/yoga/java/jni/common.h +73 -0
  175. package/yoga/java/jni/corefunctions.cpp +91 -0
  176. package/yoga/java/jni/corefunctions.h +50 -0
  177. package/yoga/java/jni/macros.h +23 -0
  178. package/yoga/java/jni/tests/corefunctionsTest.cpp +247 -0
  179. package/yoga/java/jni/yogajni.cpp +18 -0
  180. package/yoga/java/proguard-rules.pro +10 -0
  181. package/yoga/java/res/values/strings.xml +12 -0
  182. package/yoga/java/tests/com/facebook/yoga/TestParametrization.kt +29 -0
  183. package/yoga/java/tests/com/facebook/yoga/YGAlignBaselineTest.kt +117 -0
  184. package/yoga/java/tests/com/facebook/yoga/YogaExceptionTest.kt +140 -0
  185. package/yoga/java/tests/com/facebook/yoga/YogaLoggerTest.kt +77 -0
  186. package/yoga/java/tests/com/facebook/yoga/YogaNodeStylePropertiesTest.kt +1020 -0
  187. package/yoga/java/tests/com/facebook/yoga/YogaNodeTest.kt +319 -0
  188. package/yoga/java/tests/com/facebook/yoga/YogaValueTest.kt +23 -0
  189. package/yoga/java/tests/com/facebook/yoga/utils/TestUtils.kt +99 -0
  190. package/yoga/java/tests/generated/com/facebook/yoga/YGAbsolutePositionTest.java +1670 -0
  191. package/yoga/java/tests/generated/com/facebook/yoga/YGAlignContentTest.java +5440 -0
  192. package/yoga/java/tests/generated/com/facebook/yoga/YGAlignItemsTest.java +2132 -0
  193. package/yoga/java/tests/generated/com/facebook/yoga/YGAlignSelfTest.java +271 -0
  194. package/yoga/java/tests/generated/com/facebook/yoga/YGAndroidNewsFeed.java +313 -0
  195. package/yoga/java/tests/generated/com/facebook/yoga/YGAspectRatioTest.java +73 -0
  196. package/yoga/java/tests/generated/com/facebook/yoga/YGAutoTest.java +326 -0
  197. package/yoga/java/tests/generated/com/facebook/yoga/YGBorderTest.java +222 -0
  198. package/yoga/java/tests/generated/com/facebook/yoga/YGBoxSizingTest.java +2165 -0
  199. package/yoga/java/tests/generated/com/facebook/yoga/YGDimensionTest.java +122 -0
  200. package/yoga/java/tests/generated/com/facebook/yoga/YGDisplayContentsTest.java +107 -0
  201. package/yoga/java/tests/generated/com/facebook/yoga/YGDisplayTest.java +1021 -0
  202. package/yoga/java/tests/generated/com/facebook/yoga/YGFlexBasisFitContentTest.java +391 -0
  203. package/yoga/java/tests/generated/com/facebook/yoga/YGFlexDirectionTest.java +4118 -0
  204. package/yoga/java/tests/generated/com/facebook/yoga/YGFlexTest.java +630 -0
  205. package/yoga/java/tests/generated/com/facebook/yoga/YGFlexWrapTest.java +1863 -0
  206. package/yoga/java/tests/generated/com/facebook/yoga/YGGapTest.java +2988 -0
  207. package/yoga/java/tests/generated/com/facebook/yoga/YGIntrinsicSizeTest.java +926 -0
  208. package/yoga/java/tests/generated/com/facebook/yoga/YGJustifyContentTest.java +1865 -0
  209. package/yoga/java/tests/generated/com/facebook/yoga/YGMarginTest.java +1796 -0
  210. package/yoga/java/tests/generated/com/facebook/yoga/YGMinMaxDimensionTest.java +1210 -0
  211. package/yoga/java/tests/generated/com/facebook/yoga/YGPaddingTest.java +307 -0
  212. package/yoga/java/tests/generated/com/facebook/yoga/YGPercentageTest.java +1345 -0
  213. package/yoga/java/tests/generated/com/facebook/yoga/YGRoundingTest.java +1099 -0
  214. package/yoga/java/tests/generated/com/facebook/yoga/YGSizeOverflowTest.java +195 -0
  215. package/yoga/java/tests/generated/com/facebook/yoga/YGStaticPositionTest.java +5992 -0
  216. package/yoga/java/yogajni.version +13 -0
  217. package/yoga/javascript/CMakeLists.txt +59 -0
  218. package/yoga/javascript/README.md +27 -0
  219. package/yoga/javascript/babel.config.cjs +30 -0
  220. package/yoga/javascript/jest.config.js +14 -0
  221. package/yoga/javascript/jest.setup.js +12 -0
  222. package/yoga/javascript/just.config.cjs +258 -0
  223. package/yoga/javascript/package.json +52 -0
  224. package/yoga/javascript/src/generated/YGEnums.ts +249 -0
  225. package/yoga/javascript/src/index.ts +23 -0
  226. package/yoga/javascript/src/load.ts +25 -0
  227. package/yoga/javascript/src/wasm_bridge.c +155 -0
  228. package/yoga/javascript/src/wrapAssembly.ts +1025 -0
  229. package/yoga/javascript/tests/Benchmarks/YGBenchmark.test.ts +110 -0
  230. package/yoga/javascript/tests/YGAlignBaselineTest.test.ts +104 -0
  231. package/yoga/javascript/tests/YGComputedBorderTest.test.ts +25 -0
  232. package/yoga/javascript/tests/YGComputedMarginTest.test.ts +25 -0
  233. package/yoga/javascript/tests/YGComputedPaddingTest.test.ts +25 -0
  234. package/yoga/javascript/tests/YGDirtiedTest.test.ts +149 -0
  235. package/yoga/javascript/tests/YGErrataTest.test.ts +34 -0
  236. package/yoga/javascript/tests/YGFlexBasisAuto.test.ts +21 -0
  237. package/yoga/javascript/tests/YGHadOverflowTest.test.ts +110 -0
  238. package/yoga/javascript/tests/YGHasNewLayout.test.ts +81 -0
  239. package/yoga/javascript/tests/YGMeasureCacheTest.test.ts +29 -0
  240. package/yoga/javascript/tests/YGMeasureTest.test.ts +66 -0
  241. package/yoga/javascript/tests/bin/run-bench.ts +60 -0
  242. package/yoga/javascript/tests/generated/YGAbsolutePositionTest.test.ts +1531 -0
  243. package/yoga/javascript/tests/generated/YGAlignContentTest.test.ts +5181 -0
  244. package/yoga/javascript/tests/generated/YGAlignItemsTest.test.ts +2013 -0
  245. package/yoga/javascript/tests/generated/YGAlignSelfTest.test.ts +248 -0
  246. package/yoga/javascript/tests/generated/YGAndroidNewsFeed.test.ts +306 -0
  247. package/yoga/javascript/tests/generated/YGAspectRatioTest.test.ts +66 -0
  248. package/yoga/javascript/tests/generated/YGAutoTest.test.ts +303 -0
  249. package/yoga/javascript/tests/generated/YGBorderTest.test.ts +199 -0
  250. package/yoga/javascript/tests/generated/YGBoxSizingTest.test.ts +1978 -0
  251. package/yoga/javascript/tests/generated/YGDimensionTest.test.ts +111 -0
  252. package/yoga/javascript/tests/generated/YGDisplayContentsTest.test.ts +99 -0
  253. package/yoga/javascript/tests/generated/YGDisplayTest.test.ts +962 -0
  254. package/yoga/javascript/tests/generated/YGFlexBasisFitContentTest.test.ts +364 -0
  255. package/yoga/javascript/tests/generated/YGFlexDirectionTest.test.ts +3903 -0
  256. package/yoga/javascript/tests/generated/YGFlexTest.test.ts +587 -0
  257. package/yoga/javascript/tests/generated/YGFlexWrapTest.test.ts +1768 -0
  258. package/yoga/javascript/tests/generated/YGGapTest.test.ts +2857 -0
  259. package/yoga/javascript/tests/generated/YGIntrinsicSizeTest.test.ts +843 -0
  260. package/yoga/javascript/tests/generated/YGJustifyContentTest.test.ts +1750 -0
  261. package/yoga/javascript/tests/generated/YGMarginTest.test.ts +1657 -0
  262. package/yoga/javascript/tests/generated/YGMinMaxDimensionTest.test.ts +1111 -0
  263. package/yoga/javascript/tests/generated/YGPaddingTest.test.ts +276 -0
  264. package/yoga/javascript/tests/generated/YGPercentageTest.test.ts +1246 -0
  265. package/yoga/javascript/tests/generated/YGRoundingTest.test.ts +1044 -0
  266. package/yoga/javascript/tests/generated/YGSizeOverflowTest.test.ts +180 -0
  267. package/yoga/javascript/tests/generated/YGStaticPositionTest.test.ts +5741 -0
  268. package/yoga/javascript/tests/tools/MeasureCounter.ts +66 -0
  269. package/yoga/javascript/tests/tools/globals.ts +19 -0
  270. package/yoga/javascript/tests/tools/utils.ts +90 -0
  271. package/yoga/javascript/tsconfig.json +23 -0
  272. package/yoga/lib/jni/jni.h +13 -0
  273. package/yoga/lib/jni/real/jni.h +1141 -0
  274. package/yoga/lib/jsr-305/jsr305.jar +0 -0
  275. package/yoga/lib/nlohmann/json.hpp +24766 -0
  276. package/yoga/lib/soloader/soloader-0.5.1.aar +0 -0
  277. package/yoga/package.json +44 -0
  278. package/yoga/scripts/clang-format +52 -0
  279. package/yoga/scripts/clang-format.js +93 -0
  280. package/yoga/scripts/format-kotlin.js +88 -0
  281. package/yoga/scripts/format-python.js +150 -0
  282. package/yoga/scripts/format-utils.js +82 -0
  283. package/yoga/set-version.py +37 -0
  284. package/yoga/settings.gradle.kts +29 -0
  285. package/yoga/test/AssertFatalTest.cpp +70 -0
  286. package/yoga/tests/.clang-tidy +7 -0
  287. package/yoga/tests/CMakeLists.txt +35 -0
  288. package/yoga/tests/CacheTest.cpp +229 -0
  289. package/yoga/tests/EventPublisherTest.cpp +162 -0
  290. package/yoga/tests/EventsTest.cpp +362 -0
  291. package/yoga/tests/FlexGapTest.cpp +93 -0
  292. package/yoga/tests/FloatOptionalTest.cpp +214 -0
  293. package/yoga/tests/GridStyleTest.cpp +103 -0
  294. package/yoga/tests/OrdinalsTest.cpp +35 -0
  295. package/yoga/tests/SmallValueBufferTest.cpp +161 -0
  296. package/yoga/tests/StyleTest.cpp +48 -0
  297. package/yoga/tests/StyleValuePoolTest.cpp +146 -0
  298. package/yoga/tests/YGAlignBaselineTest.cpp +837 -0
  299. package/yoga/tests/YGAspectRatioTest.cpp +898 -0
  300. package/yoga/tests/YGAutoMinSizeTest.cpp +581 -0
  301. package/yoga/tests/YGBaselineFuncTest.cpp +62 -0
  302. package/yoga/tests/YGCloneNodeTest.cpp +131 -0
  303. package/yoga/tests/YGComputedMarginTest.cpp +117 -0
  304. package/yoga/tests/YGComputedPaddingTest.cpp +119 -0
  305. package/yoga/tests/YGConfigTest.cpp +239 -0
  306. package/yoga/tests/YGContentsNodeHasNewLayoutTest.cpp +190 -0
  307. package/yoga/tests/YGDefaultValuesTest.cpp +175 -0
  308. package/yoga/tests/YGDirtiedTest.cpp +110 -0
  309. package/yoga/tests/YGDirtyMarkingTest.cpp +341 -0
  310. package/yoga/tests/YGEdgeTest.cpp +161 -0
  311. package/yoga/tests/YGFirstChildMinWidthTest.cpp +133 -0
  312. package/yoga/tests/YGFlexBasisFitContentTest.cpp +241 -0
  313. package/yoga/tests/YGFlexShrinkBorderBugTest.cpp +48 -0
  314. package/yoga/tests/YGHadOverflowTest.cpp +135 -0
  315. package/yoga/tests/YGLayoutableChildrenTest.cpp +191 -0
  316. package/yoga/tests/YGMeasureCacheTest.cpp +178 -0
  317. package/yoga/tests/YGMeasureModeTest.cpp +332 -0
  318. package/yoga/tests/YGMeasureTest.cpp +1010 -0
  319. package/yoga/tests/YGNodeCallbackTest.cpp +80 -0
  320. package/yoga/tests/YGNodeChildTest.cpp +68 -0
  321. package/yoga/tests/YGPersistenceTest.cpp +291 -0
  322. package/yoga/tests/YGPersistentNodeCloningTest.cpp +214 -0
  323. package/yoga/tests/YGRelayoutTest.cpp +255 -0
  324. package/yoga/tests/YGRoundingFunctionTest.cpp +186 -0
  325. package/yoga/tests/YGRoundingMeasureFuncTest.cpp +139 -0
  326. package/yoga/tests/YGScaleChangeTest.cpp +176 -0
  327. package/yoga/tests/YGStyleTest.cpp +75 -0
  328. package/yoga/tests/YGTreeMutationTest.cpp +115 -0
  329. package/yoga/tests/YGValueTest.cpp +23 -0
  330. package/yoga/tests/YGZeroOutLayoutRecursivelyTest.cpp +37 -0
  331. package/yoga/tests/generated/YGAbsolutePositionTest.cpp +1685 -0
  332. package/yoga/tests/generated/YGAlignContentTest.cpp +5485 -0
  333. package/yoga/tests/generated/YGAlignItemsTest.cpp +2142 -0
  334. package/yoga/tests/generated/YGAlignSelfTest.cpp +257 -0
  335. package/yoga/tests/generated/YGAndroidNewsFeed.cpp +295 -0
  336. package/yoga/tests/generated/YGAspectRatioTest.cpp +55 -0
  337. package/yoga/tests/generated/YGAutoTest.cpp +312 -0
  338. package/yoga/tests/generated/YGBorderTest.cpp +208 -0
  339. package/yoga/tests/generated/YGBoxSizingTest.cpp +2192 -0
  340. package/yoga/tests/generated/YGDimensionTest.cpp +105 -0
  341. package/yoga/tests/generated/YGDisplayContentsTest.cpp +89 -0
  342. package/yoga/tests/generated/YGDisplayTest.cpp +1016 -0
  343. package/yoga/tests/generated/YGFlexBasisFitContentTest.cpp +378 -0
  344. package/yoga/tests/generated/YGFlexDirectionTest.cpp +4152 -0
  345. package/yoga/tests/generated/YGFlexTest.cpp +621 -0
  346. package/yoga/tests/generated/YGFlexWrapTest.cpp +1867 -0
  347. package/yoga/tests/generated/YGGapTest.cpp +3001 -0
  348. package/yoga/tests/generated/YGIntrinsicSizeTest.cpp +924 -0
  349. package/yoga/tests/generated/YGJustifyContentTest.cpp +1874 -0
  350. package/yoga/tests/generated/YGMarginTest.cpp +1811 -0
  351. package/yoga/tests/generated/YGMinMaxDimensionTest.cpp +1215 -0
  352. package/yoga/tests/generated/YGPaddingTest.cpp +295 -0
  353. package/yoga/tests/generated/YGPercentageTest.cpp +1350 -0
  354. package/yoga/tests/generated/YGRoundingTest.cpp +1093 -0
  355. package/yoga/tests/generated/YGSizeOverflowTest.cpp +179 -0
  356. package/yoga/tests/generated/YGStaticPositionTest.cpp +6035 -0
  357. package/yoga/tests/util/TestUtil.cpp +164 -0
  358. package/yoga/tests/util/TestUtil.h +43 -0
  359. package/yoga/unit_tests +25 -0
  360. package/yoga/unit_tests.bat +28 -0
  361. package/yoga/website/.eslintrc.cjs +26 -0
  362. package/yoga/website/README.md +41 -0
  363. package/yoga/website/babel.config.cjs +10 -0
  364. package/yoga/website/blog/2023-06-30-announcing-yoga-2.0.md +183 -0
  365. package/yoga/website/blog/2024-06-24-announcing-yoga-3.1.md +67 -0
  366. package/yoga/website/blog/2024-12-02-announcing-yoga-3.2.md +84 -0
  367. package/yoga/website/blog/authors.yml +10 -0
  368. package/yoga/website/blog/yoga-3-release/2024-03-14-announcing-yoga-3.0.md +586 -0
  369. package/yoga/website/blog/yoga-3-release/img/image1.png +0 -0
  370. package/yoga/website/blog/yoga-3-release/img/image10.png +0 -0
  371. package/yoga/website/blog/yoga-3-release/img/image11.png +0 -0
  372. package/yoga/website/blog/yoga-3-release/img/image12.png +0 -0
  373. package/yoga/website/blog/yoga-3-release/img/image13.png +0 -0
  374. package/yoga/website/blog/yoga-3-release/img/image14.png +0 -0
  375. package/yoga/website/blog/yoga-3-release/img/image15.png +0 -0
  376. package/yoga/website/blog/yoga-3-release/img/image16.png +0 -0
  377. package/yoga/website/blog/yoga-3-release/img/image17.png +0 -0
  378. package/yoga/website/blog/yoga-3-release/img/image2.png +0 -0
  379. package/yoga/website/blog/yoga-3-release/img/image3.png +0 -0
  380. package/yoga/website/blog/yoga-3-release/img/image4.png +0 -0
  381. package/yoga/website/blog/yoga-3-release/img/image5.png +0 -0
  382. package/yoga/website/blog/yoga-3-release/img/image6.png +0 -0
  383. package/yoga/website/blog/yoga-3-release/img/image7.png +0 -0
  384. package/yoga/website/blog/yoga-3-release/img/image8.png +0 -0
  385. package/yoga/website/blog/yoga-3-release/img/image9.png +0 -0
  386. package/yoga/website/docs/about-yoga.md +13 -0
  387. package/yoga/website/docs/advanced/_category_.json +4 -0
  388. package/yoga/website/docs/advanced/containing-block.md +89 -0
  389. package/yoga/website/docs/advanced/external-layout-systems.mdx +106 -0
  390. package/yoga/website/docs/advanced/incremental-layout.mdx +87 -0
  391. package/yoga/website/docs/getting-started/_category_.json +4 -0
  392. package/yoga/website/docs/getting-started/configuring-yoga.mdx +165 -0
  393. package/yoga/website/docs/getting-started/laying-out-a-tree.mdx +178 -0
  394. package/yoga/website/docs/img/config-contextual.svg +17 -0
  395. package/yoga/website/docs/img/config-per-node.svg +17 -0
  396. package/yoga/website/docs/img/config-uniform.svg +17 -0
  397. package/yoga/website/docs/img/invalidation-clean-tree.svg +17 -0
  398. package/yoga/website/docs/img/invalidation-dirtied-tree.svg +17 -0
  399. package/yoga/website/docs/img/invalidation-new-layout-tree.svg +17 -0
  400. package/yoga/website/docs/img/pixel-grid-after.png +0 -0
  401. package/yoga/website/docs/img/pixel-grid-before.png +0 -0
  402. package/yoga/website/docs/img/wireframe-example.svg +105 -0
  403. package/yoga/website/docs/styling/_category_.json +4 -0
  404. package/yoga/website/docs/styling/align-content.mdx +47 -0
  405. package/yoga/website/docs/styling/align-items-self.mdx +48 -0
  406. package/yoga/website/docs/styling/aspect-ratio.mdx +27 -0
  407. package/yoga/website/docs/styling/display.mdx +25 -0
  408. package/yoga/website/docs/styling/flex-basis-grow-shrink.mdx +65 -0
  409. package/yoga/website/docs/styling/flex-direction.mdx +37 -0
  410. package/yoga/website/docs/styling/flex-wrap.mdx +33 -0
  411. package/yoga/website/docs/styling/gap.mdx +49 -0
  412. package/yoga/website/docs/styling/index.md +48 -0
  413. package/yoga/website/docs/styling/insets.mdx +62 -0
  414. package/yoga/website/docs/styling/justify-content.mdx +43 -0
  415. package/yoga/website/docs/styling/layout-direction.mdx +34 -0
  416. package/yoga/website/docs/styling/margin-padding-border.mdx +41 -0
  417. package/yoga/website/docs/styling/min-max-width-height.mdx +52 -0
  418. package/yoga/website/docs/styling/position.mdx +37 -0
  419. package/yoga/website/docs/styling/width-height.mdx +37 -0
  420. package/yoga/website/docusaurus.config.js +113 -0
  421. package/yoga/website/package.json +43 -0
  422. package/yoga/website/sidebars.cjs +27 -0
  423. package/yoga/website/src/components/EditorToolbar.module.css +77 -0
  424. package/yoga/website/src/components/EditorToolbar.tsx +72 -0
  425. package/yoga/website/src/components/FlexStyle.ts +439 -0
  426. package/yoga/website/src/components/LayoutBox.module.css +68 -0
  427. package/yoga/website/src/components/LayoutBox.tsx +61 -0
  428. package/yoga/website/src/components/Playground.module.css +130 -0
  429. package/yoga/website/src/components/Playground.tsx +187 -0
  430. package/yoga/website/src/components/YogaViewer.tsx +128 -0
  431. package/yoga/website/src/css/custom.css +37 -0
  432. package/yoga/website/src/pages/index.module.css +34 -0
  433. package/yoga/website/src/pages/index.tsx +84 -0
  434. package/yoga/website/src/pages/markdown-page.md +7 -0
  435. package/yoga/website/src/pages/playground.module.css +11 -0
  436. package/yoga/website/src/pages/playground.tsx +56 -0
  437. package/yoga/website/static/.nojekyll +0 -0
  438. package/yoga/website/static/img/docusaurus.png +0 -0
  439. package/yoga/website/static/img/favicon.svg +17 -0
  440. package/yoga/website/static/img/link.svg +4 -0
  441. package/yoga/website/static/img/logo.svg +17 -0
  442. package/yoga/website/static/img/meta_oss.svg +1 -0
  443. package/yoga/website/static/img/opengraph.png +0 -0
  444. package/yoga/website/static/img/undraw_docusaurus_mountain.svg +171 -0
  445. package/yoga/website/static/img/undraw_docusaurus_react.svg +170 -0
  446. package/yoga/website/static/img/undraw_docusaurus_tree.svg +40 -0
  447. package/yoga/website/tsconfig.json +10 -0
  448. package/yoga/yarn.lock +11499 -0
  449. package/yoga/yoga/CMakeLists.txt +41 -0
  450. package/yoga/yoga/YGConfig.cpp +92 -0
  451. package/yoga/yoga/YGConfig.h +158 -0
  452. package/yoga/yoga/YGEnums.cpp +304 -0
  453. package/yoga/yoga/YGEnums.h +163 -0
  454. package/yoga/yoga/YGMacros.h +101 -0
  455. package/yoga/yoga/YGNode.cpp +407 -0
  456. package/yoga/yoga/YGNode.h +373 -0
  457. package/yoga/yoga/YGNodeLayout.cpp +100 -0
  458. package/yoga/yoga/YGNodeLayout.h +43 -0
  459. package/yoga/yoga/YGNodeStyle.cpp +774 -0
  460. package/yoga/yoga/YGNodeStyle.h +243 -0
  461. package/yoga/yoga/YGPixelGrid.cpp +22 -0
  462. package/yoga/yoga/YGPixelGrid.h +29 -0
  463. package/yoga/yoga/YGValue.cpp +20 -0
  464. package/yoga/yoga/YGValue.h +83 -0
  465. package/yoga/yoga/Yoga.h +21 -0
  466. package/yoga/yoga/algorithm/AbsoluteLayout.cpp +595 -0
  467. package/yoga/yoga/algorithm/AbsoluteLayout.h +41 -0
  468. package/yoga/yoga/algorithm/Align.h +83 -0
  469. package/yoga/yoga/algorithm/Baseline.cpp +78 -0
  470. package/yoga/yoga/algorithm/Baseline.h +21 -0
  471. package/yoga/yoga/algorithm/BoundAxis.h +79 -0
  472. package/yoga/yoga/algorithm/Cache.cpp +121 -0
  473. package/yoga/yoga/algorithm/Cache.h +30 -0
  474. package/yoga/yoga/algorithm/CalculateLayout.cpp +2968 -0
  475. package/yoga/yoga/algorithm/CalculateLayout.h +60 -0
  476. package/yoga/yoga/algorithm/FlexDirection.h +120 -0
  477. package/yoga/yoga/algorithm/FlexLine.cpp +124 -0
  478. package/yoga/yoga/algorithm/FlexLine.h +75 -0
  479. package/yoga/yoga/algorithm/PixelGrid.cpp +138 -0
  480. package/yoga/yoga/algorithm/PixelGrid.h +29 -0
  481. package/yoga/yoga/algorithm/SizingMode.h +73 -0
  482. package/yoga/yoga/algorithm/TrailingPosition.h +44 -0
  483. package/yoga/yoga/config/Config.cpp +135 -0
  484. package/yoga/yoga/config/Config.h +93 -0
  485. package/yoga/yoga/debug/AssertFatal.cpp +54 -0
  486. package/yoga/yoga/debug/AssertFatal.h +29 -0
  487. package/yoga/yoga/debug/Log.cpp +107 -0
  488. package/yoga/yoga/debug/Log.h +34 -0
  489. package/yoga/yoga/enums/Align.h +49 -0
  490. package/yoga/yoga/enums/BoxSizing.h +40 -0
  491. package/yoga/yoga/enums/Dimension.h +40 -0
  492. package/yoga/yoga/enums/Direction.h +41 -0
  493. package/yoga/yoga/enums/Display.h +42 -0
  494. package/yoga/yoga/enums/Edge.h +47 -0
  495. package/yoga/yoga/enums/Errata.h +43 -0
  496. package/yoga/yoga/enums/ExperimentalFeature.h +40 -0
  497. package/yoga/yoga/enums/FlexDirection.h +42 -0
  498. package/yoga/yoga/enums/GridTrackType.h +43 -0
  499. package/yoga/yoga/enums/Gutter.h +41 -0
  500. package/yoga/yoga/enums/Justify.h +48 -0
  501. package/yoga/yoga/enums/LogLevel.h +44 -0
  502. package/yoga/yoga/enums/MeasureMode.h +41 -0
  503. package/yoga/yoga/enums/NodeType.h +40 -0
  504. package/yoga/yoga/enums/Overflow.h +41 -0
  505. package/yoga/yoga/enums/PhysicalEdge.h +21 -0
  506. package/yoga/yoga/enums/PositionType.h +41 -0
  507. package/yoga/yoga/enums/Unit.h +45 -0
  508. package/yoga/yoga/enums/Wrap.h +41 -0
  509. package/yoga/yoga/enums/YogaEnums.h +84 -0
  510. package/yoga/yoga/event/event.cpp +89 -0
  511. package/yoga/yoga/event/event.h +131 -0
  512. package/yoga/yoga/module.modulemap +21 -0
  513. package/yoga/yoga/node/CachedMeasurement.h +53 -0
  514. package/yoga/yoga/node/LayoutResults.cpp +48 -0
  515. package/yoga/yoga/node/LayoutResults.h +136 -0
  516. package/yoga/yoga/node/LayoutableChildren.h +148 -0
  517. package/yoga/yoga/node/Node.cpp +509 -0
  518. package/yoga/yoga/node/Node.h +372 -0
  519. package/yoga/yoga/numeric/Comparison.h +81 -0
  520. package/yoga/yoga/numeric/FloatOptional.h +84 -0
  521. package/yoga/yoga/style/GridLine.h +53 -0
  522. package/yoga/yoga/style/GridStyle.h +80 -0
  523. package/yoga/yoga/style/GridTrack.h +63 -0
  524. package/yoga/yoga/style/SmallValueBuffer.h +133 -0
  525. package/yoga/yoga/style/Style.h +932 -0
  526. package/yoga/yoga/style/StyleLength.h +121 -0
  527. package/yoga/yoga/style/StyleSizeLength.h +152 -0
  528. package/yoga/yoga/style/StyleValueHandle.h +114 -0
  529. package/yoga/yoga/style/StyleValuePool.h +194 -0
@@ -0,0 +1,1657 @@
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
+ * @generated SignedSource<<02629f9b65f55a434c99a2af34b79a70>>
8
+ * generated by gentest/src/GentestDriver.ts from gentest/fixtures/YGMarginTest.html
9
+ */
10
+
11
+ import { intrinsicSizeMeasureFunc } from '../tools/utils.ts'
12
+ import Yoga from 'yoga-layout';
13
+ import {
14
+ Align,
15
+ BoxSizing,
16
+ Direction,
17
+ Display,
18
+ Edge,
19
+ Errata,
20
+ ExperimentalFeature,
21
+ FlexDirection,
22
+ Gutter,
23
+ Justify,
24
+ MeasureMode,
25
+ Overflow,
26
+ PositionType,
27
+ Unit,
28
+ Wrap,
29
+ } from 'yoga-layout';
30
+
31
+ test('margin_start', () => {
32
+ const config = Yoga.Config.create();
33
+
34
+ const root = Yoga.Node.create(config);
35
+ root.setPositionType(PositionType.Absolute);
36
+ root.setWidth(100);
37
+ root.setHeight(100);
38
+ root.setFlexDirection(FlexDirection.Row);
39
+
40
+ const root_child0 = Yoga.Node.create(config);
41
+ root_child0.setWidth(10);
42
+ root_child0.setMargin(Edge.Start, 10);
43
+ root.insertChild(root_child0, 0);
44
+ root.calculateLayout(undefined, undefined, Direction.LTR);
45
+
46
+ expect(root.getComputedLeft()).toBe(0);
47
+ expect(root.getComputedTop()).toBe(0);
48
+ expect(root.getComputedWidth()).toBe(100);
49
+ expect(root.getComputedHeight()).toBe(100);
50
+
51
+ expect(root_child0.getComputedLeft()).toBe(10);
52
+ expect(root_child0.getComputedTop()).toBe(0);
53
+ expect(root_child0.getComputedWidth()).toBe(10);
54
+ expect(root_child0.getComputedHeight()).toBe(100);
55
+
56
+ root.calculateLayout(undefined, undefined, Direction.RTL);
57
+
58
+ expect(root.getComputedLeft()).toBe(0);
59
+ expect(root.getComputedTop()).toBe(0);
60
+ expect(root.getComputedWidth()).toBe(100);
61
+ expect(root.getComputedHeight()).toBe(100);
62
+
63
+ expect(root_child0.getComputedLeft()).toBe(80);
64
+ expect(root_child0.getComputedTop()).toBe(0);
65
+ expect(root_child0.getComputedWidth()).toBe(10);
66
+ expect(root_child0.getComputedHeight()).toBe(100);
67
+ });
68
+ test('margin_top', () => {
69
+ const config = Yoga.Config.create();
70
+
71
+ const root = Yoga.Node.create(config);
72
+ root.setPositionType(PositionType.Absolute);
73
+ root.setWidth(100);
74
+ root.setHeight(100);
75
+
76
+ const root_child0 = Yoga.Node.create(config);
77
+ root_child0.setHeight(10);
78
+ root_child0.setMargin(Edge.Top, 10);
79
+ root.insertChild(root_child0, 0);
80
+ root.calculateLayout(undefined, undefined, Direction.LTR);
81
+
82
+ expect(root.getComputedLeft()).toBe(0);
83
+ expect(root.getComputedTop()).toBe(0);
84
+ expect(root.getComputedWidth()).toBe(100);
85
+ expect(root.getComputedHeight()).toBe(100);
86
+
87
+ expect(root_child0.getComputedLeft()).toBe(0);
88
+ expect(root_child0.getComputedTop()).toBe(10);
89
+ expect(root_child0.getComputedWidth()).toBe(100);
90
+ expect(root_child0.getComputedHeight()).toBe(10);
91
+
92
+ root.calculateLayout(undefined, undefined, Direction.RTL);
93
+
94
+ expect(root.getComputedLeft()).toBe(0);
95
+ expect(root.getComputedTop()).toBe(0);
96
+ expect(root.getComputedWidth()).toBe(100);
97
+ expect(root.getComputedHeight()).toBe(100);
98
+
99
+ expect(root_child0.getComputedLeft()).toBe(0);
100
+ expect(root_child0.getComputedTop()).toBe(10);
101
+ expect(root_child0.getComputedWidth()).toBe(100);
102
+ expect(root_child0.getComputedHeight()).toBe(10);
103
+ });
104
+ test('margin_end', () => {
105
+ const config = Yoga.Config.create();
106
+
107
+ const root = Yoga.Node.create(config);
108
+ root.setPositionType(PositionType.Absolute);
109
+ root.setWidth(100);
110
+ root.setHeight(100);
111
+ root.setFlexDirection(FlexDirection.Row);
112
+ root.setJustifyContent(Justify.FlexEnd);
113
+
114
+ const root_child0 = Yoga.Node.create(config);
115
+ root_child0.setWidth(10);
116
+ root_child0.setMargin(Edge.End, 10);
117
+ root.insertChild(root_child0, 0);
118
+ root.calculateLayout(undefined, undefined, Direction.LTR);
119
+
120
+ expect(root.getComputedLeft()).toBe(0);
121
+ expect(root.getComputedTop()).toBe(0);
122
+ expect(root.getComputedWidth()).toBe(100);
123
+ expect(root.getComputedHeight()).toBe(100);
124
+
125
+ expect(root_child0.getComputedLeft()).toBe(80);
126
+ expect(root_child0.getComputedTop()).toBe(0);
127
+ expect(root_child0.getComputedWidth()).toBe(10);
128
+ expect(root_child0.getComputedHeight()).toBe(100);
129
+
130
+ root.calculateLayout(undefined, undefined, Direction.RTL);
131
+
132
+ expect(root.getComputedLeft()).toBe(0);
133
+ expect(root.getComputedTop()).toBe(0);
134
+ expect(root.getComputedWidth()).toBe(100);
135
+ expect(root.getComputedHeight()).toBe(100);
136
+
137
+ expect(root_child0.getComputedLeft()).toBe(10);
138
+ expect(root_child0.getComputedTop()).toBe(0);
139
+ expect(root_child0.getComputedWidth()).toBe(10);
140
+ expect(root_child0.getComputedHeight()).toBe(100);
141
+ });
142
+ test('margin_bottom', () => {
143
+ const config = Yoga.Config.create();
144
+
145
+ const root = Yoga.Node.create(config);
146
+ root.setPositionType(PositionType.Absolute);
147
+ root.setWidth(100);
148
+ root.setHeight(100);
149
+ root.setJustifyContent(Justify.FlexEnd);
150
+
151
+ const root_child0 = Yoga.Node.create(config);
152
+ root_child0.setHeight(10);
153
+ root_child0.setMargin(Edge.Bottom, 10);
154
+ root.insertChild(root_child0, 0);
155
+ root.calculateLayout(undefined, undefined, Direction.LTR);
156
+
157
+ expect(root.getComputedLeft()).toBe(0);
158
+ expect(root.getComputedTop()).toBe(0);
159
+ expect(root.getComputedWidth()).toBe(100);
160
+ expect(root.getComputedHeight()).toBe(100);
161
+
162
+ expect(root_child0.getComputedLeft()).toBe(0);
163
+ expect(root_child0.getComputedTop()).toBe(80);
164
+ expect(root_child0.getComputedWidth()).toBe(100);
165
+ expect(root_child0.getComputedHeight()).toBe(10);
166
+
167
+ root.calculateLayout(undefined, undefined, Direction.RTL);
168
+
169
+ expect(root.getComputedLeft()).toBe(0);
170
+ expect(root.getComputedTop()).toBe(0);
171
+ expect(root.getComputedWidth()).toBe(100);
172
+ expect(root.getComputedHeight()).toBe(100);
173
+
174
+ expect(root_child0.getComputedLeft()).toBe(0);
175
+ expect(root_child0.getComputedTop()).toBe(80);
176
+ expect(root_child0.getComputedWidth()).toBe(100);
177
+ expect(root_child0.getComputedHeight()).toBe(10);
178
+ });
179
+ test('margin_and_flex_row', () => {
180
+ const config = Yoga.Config.create();
181
+
182
+ const root = Yoga.Node.create(config);
183
+ root.setPositionType(PositionType.Absolute);
184
+ root.setWidth(100);
185
+ root.setHeight(100);
186
+ root.setFlexDirection(FlexDirection.Row);
187
+
188
+ const root_child0 = Yoga.Node.create(config);
189
+ root_child0.setMargin(Edge.Start, 10);
190
+ root_child0.setMargin(Edge.End, 10);
191
+ root_child0.setFlexGrow(1);
192
+ root.insertChild(root_child0, 0);
193
+ root.calculateLayout(undefined, undefined, Direction.LTR);
194
+
195
+ expect(root.getComputedLeft()).toBe(0);
196
+ expect(root.getComputedTop()).toBe(0);
197
+ expect(root.getComputedWidth()).toBe(100);
198
+ expect(root.getComputedHeight()).toBe(100);
199
+
200
+ expect(root_child0.getComputedLeft()).toBe(10);
201
+ expect(root_child0.getComputedTop()).toBe(0);
202
+ expect(root_child0.getComputedWidth()).toBe(80);
203
+ expect(root_child0.getComputedHeight()).toBe(100);
204
+
205
+ root.calculateLayout(undefined, undefined, Direction.RTL);
206
+
207
+ expect(root.getComputedLeft()).toBe(0);
208
+ expect(root.getComputedTop()).toBe(0);
209
+ expect(root.getComputedWidth()).toBe(100);
210
+ expect(root.getComputedHeight()).toBe(100);
211
+
212
+ expect(root_child0.getComputedLeft()).toBe(10);
213
+ expect(root_child0.getComputedTop()).toBe(0);
214
+ expect(root_child0.getComputedWidth()).toBe(80);
215
+ expect(root_child0.getComputedHeight()).toBe(100);
216
+ });
217
+ test('margin_and_flex_column', () => {
218
+ const config = Yoga.Config.create();
219
+
220
+ const root = Yoga.Node.create(config);
221
+ root.setPositionType(PositionType.Absolute);
222
+ root.setWidth(100);
223
+ root.setHeight(100);
224
+
225
+ const root_child0 = Yoga.Node.create(config);
226
+ root_child0.setMargin(Edge.Top, 10);
227
+ root_child0.setMargin(Edge.Bottom, 10);
228
+ root_child0.setFlexGrow(1);
229
+ root.insertChild(root_child0, 0);
230
+ root.calculateLayout(undefined, undefined, Direction.LTR);
231
+
232
+ expect(root.getComputedLeft()).toBe(0);
233
+ expect(root.getComputedTop()).toBe(0);
234
+ expect(root.getComputedWidth()).toBe(100);
235
+ expect(root.getComputedHeight()).toBe(100);
236
+
237
+ expect(root_child0.getComputedLeft()).toBe(0);
238
+ expect(root_child0.getComputedTop()).toBe(10);
239
+ expect(root_child0.getComputedWidth()).toBe(100);
240
+ expect(root_child0.getComputedHeight()).toBe(80);
241
+
242
+ root.calculateLayout(undefined, undefined, Direction.RTL);
243
+
244
+ expect(root.getComputedLeft()).toBe(0);
245
+ expect(root.getComputedTop()).toBe(0);
246
+ expect(root.getComputedWidth()).toBe(100);
247
+ expect(root.getComputedHeight()).toBe(100);
248
+
249
+ expect(root_child0.getComputedLeft()).toBe(0);
250
+ expect(root_child0.getComputedTop()).toBe(10);
251
+ expect(root_child0.getComputedWidth()).toBe(100);
252
+ expect(root_child0.getComputedHeight()).toBe(80);
253
+ });
254
+ test('margin_and_stretch_row', () => {
255
+ const config = Yoga.Config.create();
256
+
257
+ const root = Yoga.Node.create(config);
258
+ root.setPositionType(PositionType.Absolute);
259
+ root.setWidth(100);
260
+ root.setHeight(100);
261
+ root.setFlexDirection(FlexDirection.Row);
262
+
263
+ const root_child0 = Yoga.Node.create(config);
264
+ root_child0.setMargin(Edge.Top, 10);
265
+ root_child0.setMargin(Edge.Bottom, 10);
266
+ root_child0.setFlexGrow(1);
267
+ root.insertChild(root_child0, 0);
268
+ root.calculateLayout(undefined, undefined, Direction.LTR);
269
+
270
+ expect(root.getComputedLeft()).toBe(0);
271
+ expect(root.getComputedTop()).toBe(0);
272
+ expect(root.getComputedWidth()).toBe(100);
273
+ expect(root.getComputedHeight()).toBe(100);
274
+
275
+ expect(root_child0.getComputedLeft()).toBe(0);
276
+ expect(root_child0.getComputedTop()).toBe(10);
277
+ expect(root_child0.getComputedWidth()).toBe(100);
278
+ expect(root_child0.getComputedHeight()).toBe(80);
279
+
280
+ root.calculateLayout(undefined, undefined, Direction.RTL);
281
+
282
+ expect(root.getComputedLeft()).toBe(0);
283
+ expect(root.getComputedTop()).toBe(0);
284
+ expect(root.getComputedWidth()).toBe(100);
285
+ expect(root.getComputedHeight()).toBe(100);
286
+
287
+ expect(root_child0.getComputedLeft()).toBe(0);
288
+ expect(root_child0.getComputedTop()).toBe(10);
289
+ expect(root_child0.getComputedWidth()).toBe(100);
290
+ expect(root_child0.getComputedHeight()).toBe(80);
291
+ });
292
+ test('margin_and_stretch_column', () => {
293
+ const config = Yoga.Config.create();
294
+
295
+ const root = Yoga.Node.create(config);
296
+ root.setPositionType(PositionType.Absolute);
297
+ root.setWidth(100);
298
+ root.setHeight(100);
299
+
300
+ const root_child0 = Yoga.Node.create(config);
301
+ root_child0.setMargin(Edge.Start, 10);
302
+ root_child0.setMargin(Edge.End, 10);
303
+ root_child0.setFlexGrow(1);
304
+ root.insertChild(root_child0, 0);
305
+ root.calculateLayout(undefined, undefined, Direction.LTR);
306
+
307
+ expect(root.getComputedLeft()).toBe(0);
308
+ expect(root.getComputedTop()).toBe(0);
309
+ expect(root.getComputedWidth()).toBe(100);
310
+ expect(root.getComputedHeight()).toBe(100);
311
+
312
+ expect(root_child0.getComputedLeft()).toBe(10);
313
+ expect(root_child0.getComputedTop()).toBe(0);
314
+ expect(root_child0.getComputedWidth()).toBe(80);
315
+ expect(root_child0.getComputedHeight()).toBe(100);
316
+
317
+ root.calculateLayout(undefined, undefined, Direction.RTL);
318
+
319
+ expect(root.getComputedLeft()).toBe(0);
320
+ expect(root.getComputedTop()).toBe(0);
321
+ expect(root.getComputedWidth()).toBe(100);
322
+ expect(root.getComputedHeight()).toBe(100);
323
+
324
+ expect(root_child0.getComputedLeft()).toBe(10);
325
+ expect(root_child0.getComputedTop()).toBe(0);
326
+ expect(root_child0.getComputedWidth()).toBe(80);
327
+ expect(root_child0.getComputedHeight()).toBe(100);
328
+ });
329
+ test('margin_with_sibling_row', () => {
330
+ const config = Yoga.Config.create();
331
+
332
+ const root = Yoga.Node.create(config);
333
+ root.setPositionType(PositionType.Absolute);
334
+ root.setWidth(100);
335
+ root.setHeight(100);
336
+ root.setFlexDirection(FlexDirection.Row);
337
+
338
+ const root_child0 = Yoga.Node.create(config);
339
+ root_child0.setMargin(Edge.End, 10);
340
+ root_child0.setFlexGrow(1);
341
+ root.insertChild(root_child0, 0);
342
+
343
+ const root_child1 = Yoga.Node.create(config);
344
+ root_child1.setFlexGrow(1);
345
+ root.insertChild(root_child1, 1);
346
+ root.calculateLayout(undefined, undefined, Direction.LTR);
347
+
348
+ expect(root.getComputedLeft()).toBe(0);
349
+ expect(root.getComputedTop()).toBe(0);
350
+ expect(root.getComputedWidth()).toBe(100);
351
+ expect(root.getComputedHeight()).toBe(100);
352
+
353
+ expect(root_child0.getComputedLeft()).toBe(0);
354
+ expect(root_child0.getComputedTop()).toBe(0);
355
+ expect(root_child0.getComputedWidth()).toBe(45);
356
+ expect(root_child0.getComputedHeight()).toBe(100);
357
+
358
+ expect(root_child1.getComputedLeft()).toBe(55);
359
+ expect(root_child1.getComputedTop()).toBe(0);
360
+ expect(root_child1.getComputedWidth()).toBe(45);
361
+ expect(root_child1.getComputedHeight()).toBe(100);
362
+
363
+ root.calculateLayout(undefined, undefined, Direction.RTL);
364
+
365
+ expect(root.getComputedLeft()).toBe(0);
366
+ expect(root.getComputedTop()).toBe(0);
367
+ expect(root.getComputedWidth()).toBe(100);
368
+ expect(root.getComputedHeight()).toBe(100);
369
+
370
+ expect(root_child0.getComputedLeft()).toBe(55);
371
+ expect(root_child0.getComputedTop()).toBe(0);
372
+ expect(root_child0.getComputedWidth()).toBe(45);
373
+ expect(root_child0.getComputedHeight()).toBe(100);
374
+
375
+ expect(root_child1.getComputedLeft()).toBe(0);
376
+ expect(root_child1.getComputedTop()).toBe(0);
377
+ expect(root_child1.getComputedWidth()).toBe(45);
378
+ expect(root_child1.getComputedHeight()).toBe(100);
379
+ });
380
+ test('margin_with_sibling_column', () => {
381
+ const config = Yoga.Config.create();
382
+
383
+ const root = Yoga.Node.create(config);
384
+ root.setPositionType(PositionType.Absolute);
385
+ root.setWidth(100);
386
+ root.setHeight(100);
387
+
388
+ const root_child0 = Yoga.Node.create(config);
389
+ root_child0.setMargin(Edge.Bottom, 10);
390
+ root_child0.setFlexGrow(1);
391
+ root.insertChild(root_child0, 0);
392
+
393
+ const root_child1 = Yoga.Node.create(config);
394
+ root_child1.setFlexGrow(1);
395
+ root.insertChild(root_child1, 1);
396
+ root.calculateLayout(undefined, undefined, Direction.LTR);
397
+
398
+ expect(root.getComputedLeft()).toBe(0);
399
+ expect(root.getComputedTop()).toBe(0);
400
+ expect(root.getComputedWidth()).toBe(100);
401
+ expect(root.getComputedHeight()).toBe(100);
402
+
403
+ expect(root_child0.getComputedLeft()).toBe(0);
404
+ expect(root_child0.getComputedTop()).toBe(0);
405
+ expect(root_child0.getComputedWidth()).toBe(100);
406
+ expect(root_child0.getComputedHeight()).toBe(45);
407
+
408
+ expect(root_child1.getComputedLeft()).toBe(0);
409
+ expect(root_child1.getComputedTop()).toBe(55);
410
+ expect(root_child1.getComputedWidth()).toBe(100);
411
+ expect(root_child1.getComputedHeight()).toBe(45);
412
+
413
+ root.calculateLayout(undefined, undefined, Direction.RTL);
414
+
415
+ expect(root.getComputedLeft()).toBe(0);
416
+ expect(root.getComputedTop()).toBe(0);
417
+ expect(root.getComputedWidth()).toBe(100);
418
+ expect(root.getComputedHeight()).toBe(100);
419
+
420
+ expect(root_child0.getComputedLeft()).toBe(0);
421
+ expect(root_child0.getComputedTop()).toBe(0);
422
+ expect(root_child0.getComputedWidth()).toBe(100);
423
+ expect(root_child0.getComputedHeight()).toBe(45);
424
+
425
+ expect(root_child1.getComputedLeft()).toBe(0);
426
+ expect(root_child1.getComputedTop()).toBe(55);
427
+ expect(root_child1.getComputedWidth()).toBe(100);
428
+ expect(root_child1.getComputedHeight()).toBe(45);
429
+ });
430
+ test('margin_auto_bottom', () => {
431
+ const config = Yoga.Config.create();
432
+
433
+ const root = Yoga.Node.create(config);
434
+ root.setPositionType(PositionType.Absolute);
435
+ root.setWidth(200);
436
+ root.setHeight(200);
437
+ root.setAlignItems(Align.Center);
438
+
439
+ const root_child0 = Yoga.Node.create(config);
440
+ root_child0.setWidth(50);
441
+ root_child0.setHeight(50);
442
+ root_child0.setMargin(Edge.Bottom, "auto");
443
+ root.insertChild(root_child0, 0);
444
+
445
+ const root_child1 = Yoga.Node.create(config);
446
+ root_child1.setWidth(50);
447
+ root_child1.setHeight(50);
448
+ root.insertChild(root_child1, 1);
449
+ root.calculateLayout(undefined, undefined, Direction.LTR);
450
+
451
+ expect(root.getComputedLeft()).toBe(0);
452
+ expect(root.getComputedTop()).toBe(0);
453
+ expect(root.getComputedWidth()).toBe(200);
454
+ expect(root.getComputedHeight()).toBe(200);
455
+
456
+ expect(root_child0.getComputedLeft()).toBe(75);
457
+ expect(root_child0.getComputedTop()).toBe(0);
458
+ expect(root_child0.getComputedWidth()).toBe(50);
459
+ expect(root_child0.getComputedHeight()).toBe(50);
460
+
461
+ expect(root_child1.getComputedLeft()).toBe(75);
462
+ expect(root_child1.getComputedTop()).toBe(150);
463
+ expect(root_child1.getComputedWidth()).toBe(50);
464
+ expect(root_child1.getComputedHeight()).toBe(50);
465
+
466
+ root.calculateLayout(undefined, undefined, Direction.RTL);
467
+
468
+ expect(root.getComputedLeft()).toBe(0);
469
+ expect(root.getComputedTop()).toBe(0);
470
+ expect(root.getComputedWidth()).toBe(200);
471
+ expect(root.getComputedHeight()).toBe(200);
472
+
473
+ expect(root_child0.getComputedLeft()).toBe(75);
474
+ expect(root_child0.getComputedTop()).toBe(0);
475
+ expect(root_child0.getComputedWidth()).toBe(50);
476
+ expect(root_child0.getComputedHeight()).toBe(50);
477
+
478
+ expect(root_child1.getComputedLeft()).toBe(75);
479
+ expect(root_child1.getComputedTop()).toBe(150);
480
+ expect(root_child1.getComputedWidth()).toBe(50);
481
+ expect(root_child1.getComputedHeight()).toBe(50);
482
+ });
483
+ test('margin_auto_top', () => {
484
+ const config = Yoga.Config.create();
485
+
486
+ const root = Yoga.Node.create(config);
487
+ root.setPositionType(PositionType.Absolute);
488
+ root.setWidth(200);
489
+ root.setHeight(200);
490
+ root.setAlignItems(Align.Center);
491
+
492
+ const root_child0 = Yoga.Node.create(config);
493
+ root_child0.setWidth(50);
494
+ root_child0.setHeight(50);
495
+ root_child0.setMargin(Edge.Top, "auto");
496
+ root.insertChild(root_child0, 0);
497
+
498
+ const root_child1 = Yoga.Node.create(config);
499
+ root_child1.setWidth(50);
500
+ root_child1.setHeight(50);
501
+ root.insertChild(root_child1, 1);
502
+ root.calculateLayout(undefined, undefined, Direction.LTR);
503
+
504
+ expect(root.getComputedLeft()).toBe(0);
505
+ expect(root.getComputedTop()).toBe(0);
506
+ expect(root.getComputedWidth()).toBe(200);
507
+ expect(root.getComputedHeight()).toBe(200);
508
+
509
+ expect(root_child0.getComputedLeft()).toBe(75);
510
+ expect(root_child0.getComputedTop()).toBe(100);
511
+ expect(root_child0.getComputedWidth()).toBe(50);
512
+ expect(root_child0.getComputedHeight()).toBe(50);
513
+
514
+ expect(root_child1.getComputedLeft()).toBe(75);
515
+ expect(root_child1.getComputedTop()).toBe(150);
516
+ expect(root_child1.getComputedWidth()).toBe(50);
517
+ expect(root_child1.getComputedHeight()).toBe(50);
518
+
519
+ root.calculateLayout(undefined, undefined, Direction.RTL);
520
+
521
+ expect(root.getComputedLeft()).toBe(0);
522
+ expect(root.getComputedTop()).toBe(0);
523
+ expect(root.getComputedWidth()).toBe(200);
524
+ expect(root.getComputedHeight()).toBe(200);
525
+
526
+ expect(root_child0.getComputedLeft()).toBe(75);
527
+ expect(root_child0.getComputedTop()).toBe(100);
528
+ expect(root_child0.getComputedWidth()).toBe(50);
529
+ expect(root_child0.getComputedHeight()).toBe(50);
530
+
531
+ expect(root_child1.getComputedLeft()).toBe(75);
532
+ expect(root_child1.getComputedTop()).toBe(150);
533
+ expect(root_child1.getComputedWidth()).toBe(50);
534
+ expect(root_child1.getComputedHeight()).toBe(50);
535
+ });
536
+ test('margin_auto_bottom_and_top', () => {
537
+ const config = Yoga.Config.create();
538
+
539
+ const root = Yoga.Node.create(config);
540
+ root.setPositionType(PositionType.Absolute);
541
+ root.setWidth(200);
542
+ root.setHeight(200);
543
+ root.setAlignItems(Align.Center);
544
+
545
+ const root_child0 = Yoga.Node.create(config);
546
+ root_child0.setWidth(50);
547
+ root_child0.setHeight(50);
548
+ root_child0.setMargin(Edge.Top, "auto");
549
+ root_child0.setMargin(Edge.Bottom, "auto");
550
+ root.insertChild(root_child0, 0);
551
+
552
+ const root_child1 = Yoga.Node.create(config);
553
+ root_child1.setWidth(50);
554
+ root_child1.setHeight(50);
555
+ root.insertChild(root_child1, 1);
556
+ root.calculateLayout(undefined, undefined, Direction.LTR);
557
+
558
+ expect(root.getComputedLeft()).toBe(0);
559
+ expect(root.getComputedTop()).toBe(0);
560
+ expect(root.getComputedWidth()).toBe(200);
561
+ expect(root.getComputedHeight()).toBe(200);
562
+
563
+ expect(root_child0.getComputedLeft()).toBe(75);
564
+ expect(root_child0.getComputedTop()).toBe(50);
565
+ expect(root_child0.getComputedWidth()).toBe(50);
566
+ expect(root_child0.getComputedHeight()).toBe(50);
567
+
568
+ expect(root_child1.getComputedLeft()).toBe(75);
569
+ expect(root_child1.getComputedTop()).toBe(150);
570
+ expect(root_child1.getComputedWidth()).toBe(50);
571
+ expect(root_child1.getComputedHeight()).toBe(50);
572
+
573
+ root.calculateLayout(undefined, undefined, Direction.RTL);
574
+
575
+ expect(root.getComputedLeft()).toBe(0);
576
+ expect(root.getComputedTop()).toBe(0);
577
+ expect(root.getComputedWidth()).toBe(200);
578
+ expect(root.getComputedHeight()).toBe(200);
579
+
580
+ expect(root_child0.getComputedLeft()).toBe(75);
581
+ expect(root_child0.getComputedTop()).toBe(50);
582
+ expect(root_child0.getComputedWidth()).toBe(50);
583
+ expect(root_child0.getComputedHeight()).toBe(50);
584
+
585
+ expect(root_child1.getComputedLeft()).toBe(75);
586
+ expect(root_child1.getComputedTop()).toBe(150);
587
+ expect(root_child1.getComputedWidth()).toBe(50);
588
+ expect(root_child1.getComputedHeight()).toBe(50);
589
+ });
590
+ test('margin_auto_bottom_and_top_justify_center', () => {
591
+ const config = Yoga.Config.create();
592
+
593
+ const root = Yoga.Node.create(config);
594
+ root.setPositionType(PositionType.Absolute);
595
+ root.setWidth(200);
596
+ root.setHeight(200);
597
+ root.setJustifyContent(Justify.Center);
598
+
599
+ const root_child0 = Yoga.Node.create(config);
600
+ root_child0.setWidth(50);
601
+ root_child0.setHeight(50);
602
+ root_child0.setMargin(Edge.Top, "auto");
603
+ root_child0.setMargin(Edge.Bottom, "auto");
604
+ root.insertChild(root_child0, 0);
605
+
606
+ const root_child1 = Yoga.Node.create(config);
607
+ root_child1.setWidth(50);
608
+ root_child1.setHeight(50);
609
+ root.insertChild(root_child1, 1);
610
+ root.calculateLayout(undefined, undefined, Direction.LTR);
611
+
612
+ expect(root.getComputedLeft()).toBe(0);
613
+ expect(root.getComputedTop()).toBe(0);
614
+ expect(root.getComputedWidth()).toBe(200);
615
+ expect(root.getComputedHeight()).toBe(200);
616
+
617
+ expect(root_child0.getComputedLeft()).toBe(0);
618
+ expect(root_child0.getComputedTop()).toBe(50);
619
+ expect(root_child0.getComputedWidth()).toBe(50);
620
+ expect(root_child0.getComputedHeight()).toBe(50);
621
+
622
+ expect(root_child1.getComputedLeft()).toBe(0);
623
+ expect(root_child1.getComputedTop()).toBe(150);
624
+ expect(root_child1.getComputedWidth()).toBe(50);
625
+ expect(root_child1.getComputedHeight()).toBe(50);
626
+
627
+ root.calculateLayout(undefined, undefined, Direction.RTL);
628
+
629
+ expect(root.getComputedLeft()).toBe(0);
630
+ expect(root.getComputedTop()).toBe(0);
631
+ expect(root.getComputedWidth()).toBe(200);
632
+ expect(root.getComputedHeight()).toBe(200);
633
+
634
+ expect(root_child0.getComputedLeft()).toBe(150);
635
+ expect(root_child0.getComputedTop()).toBe(50);
636
+ expect(root_child0.getComputedWidth()).toBe(50);
637
+ expect(root_child0.getComputedHeight()).toBe(50);
638
+
639
+ expect(root_child1.getComputedLeft()).toBe(150);
640
+ expect(root_child1.getComputedTop()).toBe(150);
641
+ expect(root_child1.getComputedWidth()).toBe(50);
642
+ expect(root_child1.getComputedHeight()).toBe(50);
643
+ });
644
+ test('margin_auto_multiple_children_column', () => {
645
+ const config = Yoga.Config.create();
646
+
647
+ const root = Yoga.Node.create(config);
648
+ root.setPositionType(PositionType.Absolute);
649
+ root.setWidth(200);
650
+ root.setHeight(200);
651
+ root.setAlignItems(Align.Center);
652
+
653
+ const root_child0 = Yoga.Node.create(config);
654
+ root_child0.setWidth(50);
655
+ root_child0.setHeight(50);
656
+ root_child0.setMargin(Edge.Top, "auto");
657
+ root.insertChild(root_child0, 0);
658
+
659
+ const root_child1 = Yoga.Node.create(config);
660
+ root_child1.setWidth(50);
661
+ root_child1.setHeight(50);
662
+ root_child1.setMargin(Edge.Top, "auto");
663
+ root.insertChild(root_child1, 1);
664
+
665
+ const root_child2 = Yoga.Node.create(config);
666
+ root_child2.setWidth(50);
667
+ root_child2.setHeight(50);
668
+ root.insertChild(root_child2, 2);
669
+ root.calculateLayout(undefined, undefined, Direction.LTR);
670
+
671
+ expect(root.getComputedLeft()).toBe(0);
672
+ expect(root.getComputedTop()).toBe(0);
673
+ expect(root.getComputedWidth()).toBe(200);
674
+ expect(root.getComputedHeight()).toBe(200);
675
+
676
+ expect(root_child0.getComputedLeft()).toBe(75);
677
+ expect(root_child0.getComputedTop()).toBe(25);
678
+ expect(root_child0.getComputedWidth()).toBe(50);
679
+ expect(root_child0.getComputedHeight()).toBe(50);
680
+
681
+ expect(root_child1.getComputedLeft()).toBe(75);
682
+ expect(root_child1.getComputedTop()).toBe(100);
683
+ expect(root_child1.getComputedWidth()).toBe(50);
684
+ expect(root_child1.getComputedHeight()).toBe(50);
685
+
686
+ expect(root_child2.getComputedLeft()).toBe(75);
687
+ expect(root_child2.getComputedTop()).toBe(150);
688
+ expect(root_child2.getComputedWidth()).toBe(50);
689
+ expect(root_child2.getComputedHeight()).toBe(50);
690
+
691
+ root.calculateLayout(undefined, undefined, Direction.RTL);
692
+
693
+ expect(root.getComputedLeft()).toBe(0);
694
+ expect(root.getComputedTop()).toBe(0);
695
+ expect(root.getComputedWidth()).toBe(200);
696
+ expect(root.getComputedHeight()).toBe(200);
697
+
698
+ expect(root_child0.getComputedLeft()).toBe(75);
699
+ expect(root_child0.getComputedTop()).toBe(25);
700
+ expect(root_child0.getComputedWidth()).toBe(50);
701
+ expect(root_child0.getComputedHeight()).toBe(50);
702
+
703
+ expect(root_child1.getComputedLeft()).toBe(75);
704
+ expect(root_child1.getComputedTop()).toBe(100);
705
+ expect(root_child1.getComputedWidth()).toBe(50);
706
+ expect(root_child1.getComputedHeight()).toBe(50);
707
+
708
+ expect(root_child2.getComputedLeft()).toBe(75);
709
+ expect(root_child2.getComputedTop()).toBe(150);
710
+ expect(root_child2.getComputedWidth()).toBe(50);
711
+ expect(root_child2.getComputedHeight()).toBe(50);
712
+ });
713
+ test('margin_auto_multiple_children_row', () => {
714
+ const config = Yoga.Config.create();
715
+
716
+ const root = Yoga.Node.create(config);
717
+ root.setPositionType(PositionType.Absolute);
718
+ root.setWidth(200);
719
+ root.setHeight(200);
720
+ root.setFlexDirection(FlexDirection.Row);
721
+ root.setAlignItems(Align.Center);
722
+
723
+ const root_child0 = Yoga.Node.create(config);
724
+ root_child0.setWidth(50);
725
+ root_child0.setHeight(50);
726
+ root_child0.setMargin(Edge.Right, "auto");
727
+ root.insertChild(root_child0, 0);
728
+
729
+ const root_child1 = Yoga.Node.create(config);
730
+ root_child1.setWidth(50);
731
+ root_child1.setHeight(50);
732
+ root_child1.setMargin(Edge.Right, "auto");
733
+ root.insertChild(root_child1, 1);
734
+
735
+ const root_child2 = Yoga.Node.create(config);
736
+ root_child2.setWidth(50);
737
+ root_child2.setHeight(50);
738
+ root.insertChild(root_child2, 2);
739
+ root.calculateLayout(undefined, undefined, Direction.LTR);
740
+
741
+ expect(root.getComputedLeft()).toBe(0);
742
+ expect(root.getComputedTop()).toBe(0);
743
+ expect(root.getComputedWidth()).toBe(200);
744
+ expect(root.getComputedHeight()).toBe(200);
745
+
746
+ expect(root_child0.getComputedLeft()).toBe(0);
747
+ expect(root_child0.getComputedTop()).toBe(75);
748
+ expect(root_child0.getComputedWidth()).toBe(50);
749
+ expect(root_child0.getComputedHeight()).toBe(50);
750
+
751
+ expect(root_child1.getComputedLeft()).toBe(75);
752
+ expect(root_child1.getComputedTop()).toBe(75);
753
+ expect(root_child1.getComputedWidth()).toBe(50);
754
+ expect(root_child1.getComputedHeight()).toBe(50);
755
+
756
+ expect(root_child2.getComputedLeft()).toBe(150);
757
+ expect(root_child2.getComputedTop()).toBe(75);
758
+ expect(root_child2.getComputedWidth()).toBe(50);
759
+ expect(root_child2.getComputedHeight()).toBe(50);
760
+
761
+ root.calculateLayout(undefined, undefined, Direction.RTL);
762
+
763
+ expect(root.getComputedLeft()).toBe(0);
764
+ expect(root.getComputedTop()).toBe(0);
765
+ expect(root.getComputedWidth()).toBe(200);
766
+ expect(root.getComputedHeight()).toBe(200);
767
+
768
+ expect(root_child0.getComputedLeft()).toBe(125);
769
+ expect(root_child0.getComputedTop()).toBe(75);
770
+ expect(root_child0.getComputedWidth()).toBe(50);
771
+ expect(root_child0.getComputedHeight()).toBe(50);
772
+
773
+ expect(root_child1.getComputedLeft()).toBe(50);
774
+ expect(root_child1.getComputedTop()).toBe(75);
775
+ expect(root_child1.getComputedWidth()).toBe(50);
776
+ expect(root_child1.getComputedHeight()).toBe(50);
777
+
778
+ expect(root_child2.getComputedLeft()).toBe(0);
779
+ expect(root_child2.getComputedTop()).toBe(75);
780
+ expect(root_child2.getComputedWidth()).toBe(50);
781
+ expect(root_child2.getComputedHeight()).toBe(50);
782
+ });
783
+ test('margin_auto_left_and_right_column', () => {
784
+ const config = Yoga.Config.create();
785
+
786
+ const root = Yoga.Node.create(config);
787
+ root.setPositionType(PositionType.Absolute);
788
+ root.setWidth(200);
789
+ root.setHeight(200);
790
+ root.setAlignItems(Align.Center);
791
+ root.setFlexDirection(FlexDirection.Row);
792
+
793
+ const root_child0 = Yoga.Node.create(config);
794
+ root_child0.setWidth(50);
795
+ root_child0.setHeight(50);
796
+ root_child0.setMargin(Edge.Left, "auto");
797
+ root_child0.setMargin(Edge.Right, "auto");
798
+ root.insertChild(root_child0, 0);
799
+
800
+ const root_child1 = Yoga.Node.create(config);
801
+ root_child1.setWidth(50);
802
+ root_child1.setHeight(50);
803
+ root.insertChild(root_child1, 1);
804
+ root.calculateLayout(undefined, undefined, Direction.LTR);
805
+
806
+ expect(root.getComputedLeft()).toBe(0);
807
+ expect(root.getComputedTop()).toBe(0);
808
+ expect(root.getComputedWidth()).toBe(200);
809
+ expect(root.getComputedHeight()).toBe(200);
810
+
811
+ expect(root_child0.getComputedLeft()).toBe(50);
812
+ expect(root_child0.getComputedTop()).toBe(75);
813
+ expect(root_child0.getComputedWidth()).toBe(50);
814
+ expect(root_child0.getComputedHeight()).toBe(50);
815
+
816
+ expect(root_child1.getComputedLeft()).toBe(150);
817
+ expect(root_child1.getComputedTop()).toBe(75);
818
+ expect(root_child1.getComputedWidth()).toBe(50);
819
+ expect(root_child1.getComputedHeight()).toBe(50);
820
+
821
+ root.calculateLayout(undefined, undefined, Direction.RTL);
822
+
823
+ expect(root.getComputedLeft()).toBe(0);
824
+ expect(root.getComputedTop()).toBe(0);
825
+ expect(root.getComputedWidth()).toBe(200);
826
+ expect(root.getComputedHeight()).toBe(200);
827
+
828
+ expect(root_child0.getComputedLeft()).toBe(100);
829
+ expect(root_child0.getComputedTop()).toBe(75);
830
+ expect(root_child0.getComputedWidth()).toBe(50);
831
+ expect(root_child0.getComputedHeight()).toBe(50);
832
+
833
+ expect(root_child1.getComputedLeft()).toBe(0);
834
+ expect(root_child1.getComputedTop()).toBe(75);
835
+ expect(root_child1.getComputedWidth()).toBe(50);
836
+ expect(root_child1.getComputedHeight()).toBe(50);
837
+ });
838
+ test('margin_auto_left_and_right', () => {
839
+ const config = Yoga.Config.create();
840
+
841
+ const root = Yoga.Node.create(config);
842
+ root.setPositionType(PositionType.Absolute);
843
+ root.setWidth(200);
844
+ root.setHeight(200);
845
+
846
+ const root_child0 = Yoga.Node.create(config);
847
+ root_child0.setWidth(50);
848
+ root_child0.setHeight(50);
849
+ root_child0.setMargin(Edge.Left, "auto");
850
+ root_child0.setMargin(Edge.Right, "auto");
851
+ root.insertChild(root_child0, 0);
852
+
853
+ const root_child1 = Yoga.Node.create(config);
854
+ root_child1.setWidth(50);
855
+ root_child1.setHeight(50);
856
+ root.insertChild(root_child1, 1);
857
+ root.calculateLayout(undefined, undefined, Direction.LTR);
858
+
859
+ expect(root.getComputedLeft()).toBe(0);
860
+ expect(root.getComputedTop()).toBe(0);
861
+ expect(root.getComputedWidth()).toBe(200);
862
+ expect(root.getComputedHeight()).toBe(200);
863
+
864
+ expect(root_child0.getComputedLeft()).toBe(75);
865
+ expect(root_child0.getComputedTop()).toBe(0);
866
+ expect(root_child0.getComputedWidth()).toBe(50);
867
+ expect(root_child0.getComputedHeight()).toBe(50);
868
+
869
+ expect(root_child1.getComputedLeft()).toBe(0);
870
+ expect(root_child1.getComputedTop()).toBe(50);
871
+ expect(root_child1.getComputedWidth()).toBe(50);
872
+ expect(root_child1.getComputedHeight()).toBe(50);
873
+
874
+ root.calculateLayout(undefined, undefined, Direction.RTL);
875
+
876
+ expect(root.getComputedLeft()).toBe(0);
877
+ expect(root.getComputedTop()).toBe(0);
878
+ expect(root.getComputedWidth()).toBe(200);
879
+ expect(root.getComputedHeight()).toBe(200);
880
+
881
+ expect(root_child0.getComputedLeft()).toBe(75);
882
+ expect(root_child0.getComputedTop()).toBe(0);
883
+ expect(root_child0.getComputedWidth()).toBe(50);
884
+ expect(root_child0.getComputedHeight()).toBe(50);
885
+
886
+ expect(root_child1.getComputedLeft()).toBe(150);
887
+ expect(root_child1.getComputedTop()).toBe(50);
888
+ expect(root_child1.getComputedWidth()).toBe(50);
889
+ expect(root_child1.getComputedHeight()).toBe(50);
890
+ });
891
+ test('margin_auto_start_and_end_column', () => {
892
+ const config = Yoga.Config.create();
893
+
894
+ const root = Yoga.Node.create(config);
895
+ root.setPositionType(PositionType.Absolute);
896
+ root.setWidth(200);
897
+ root.setHeight(200);
898
+ root.setAlignItems(Align.Center);
899
+ root.setFlexDirection(FlexDirection.Row);
900
+
901
+ const root_child0 = Yoga.Node.create(config);
902
+ root_child0.setWidth(50);
903
+ root_child0.setHeight(50);
904
+ root_child0.setMargin(Edge.Start, "auto");
905
+ root_child0.setMargin(Edge.End, "auto");
906
+ root.insertChild(root_child0, 0);
907
+
908
+ const root_child1 = Yoga.Node.create(config);
909
+ root_child1.setWidth(50);
910
+ root_child1.setHeight(50);
911
+ root.insertChild(root_child1, 1);
912
+ root.calculateLayout(undefined, undefined, Direction.LTR);
913
+
914
+ expect(root.getComputedLeft()).toBe(0);
915
+ expect(root.getComputedTop()).toBe(0);
916
+ expect(root.getComputedWidth()).toBe(200);
917
+ expect(root.getComputedHeight()).toBe(200);
918
+
919
+ expect(root_child0.getComputedLeft()).toBe(50);
920
+ expect(root_child0.getComputedTop()).toBe(75);
921
+ expect(root_child0.getComputedWidth()).toBe(50);
922
+ expect(root_child0.getComputedHeight()).toBe(50);
923
+
924
+ expect(root_child1.getComputedLeft()).toBe(150);
925
+ expect(root_child1.getComputedTop()).toBe(75);
926
+ expect(root_child1.getComputedWidth()).toBe(50);
927
+ expect(root_child1.getComputedHeight()).toBe(50);
928
+
929
+ root.calculateLayout(undefined, undefined, Direction.RTL);
930
+
931
+ expect(root.getComputedLeft()).toBe(0);
932
+ expect(root.getComputedTop()).toBe(0);
933
+ expect(root.getComputedWidth()).toBe(200);
934
+ expect(root.getComputedHeight()).toBe(200);
935
+
936
+ expect(root_child0.getComputedLeft()).toBe(100);
937
+ expect(root_child0.getComputedTop()).toBe(75);
938
+ expect(root_child0.getComputedWidth()).toBe(50);
939
+ expect(root_child0.getComputedHeight()).toBe(50);
940
+
941
+ expect(root_child1.getComputedLeft()).toBe(0);
942
+ expect(root_child1.getComputedTop()).toBe(75);
943
+ expect(root_child1.getComputedWidth()).toBe(50);
944
+ expect(root_child1.getComputedHeight()).toBe(50);
945
+ });
946
+ test('margin_auto_start_and_end', () => {
947
+ const config = Yoga.Config.create();
948
+
949
+ const root = Yoga.Node.create(config);
950
+ root.setPositionType(PositionType.Absolute);
951
+ root.setWidth(200);
952
+ root.setHeight(200);
953
+
954
+ const root_child0 = Yoga.Node.create(config);
955
+ root_child0.setWidth(50);
956
+ root_child0.setHeight(50);
957
+ root_child0.setMargin(Edge.Start, "auto");
958
+ root_child0.setMargin(Edge.End, "auto");
959
+ root.insertChild(root_child0, 0);
960
+
961
+ const root_child1 = Yoga.Node.create(config);
962
+ root_child1.setWidth(50);
963
+ root_child1.setHeight(50);
964
+ root.insertChild(root_child1, 1);
965
+ root.calculateLayout(undefined, undefined, Direction.LTR);
966
+
967
+ expect(root.getComputedLeft()).toBe(0);
968
+ expect(root.getComputedTop()).toBe(0);
969
+ expect(root.getComputedWidth()).toBe(200);
970
+ expect(root.getComputedHeight()).toBe(200);
971
+
972
+ expect(root_child0.getComputedLeft()).toBe(75);
973
+ expect(root_child0.getComputedTop()).toBe(0);
974
+ expect(root_child0.getComputedWidth()).toBe(50);
975
+ expect(root_child0.getComputedHeight()).toBe(50);
976
+
977
+ expect(root_child1.getComputedLeft()).toBe(0);
978
+ expect(root_child1.getComputedTop()).toBe(50);
979
+ expect(root_child1.getComputedWidth()).toBe(50);
980
+ expect(root_child1.getComputedHeight()).toBe(50);
981
+
982
+ root.calculateLayout(undefined, undefined, Direction.RTL);
983
+
984
+ expect(root.getComputedLeft()).toBe(0);
985
+ expect(root.getComputedTop()).toBe(0);
986
+ expect(root.getComputedWidth()).toBe(200);
987
+ expect(root.getComputedHeight()).toBe(200);
988
+
989
+ expect(root_child0.getComputedLeft()).toBe(75);
990
+ expect(root_child0.getComputedTop()).toBe(0);
991
+ expect(root_child0.getComputedWidth()).toBe(50);
992
+ expect(root_child0.getComputedHeight()).toBe(50);
993
+
994
+ expect(root_child1.getComputedLeft()).toBe(150);
995
+ expect(root_child1.getComputedTop()).toBe(50);
996
+ expect(root_child1.getComputedWidth()).toBe(50);
997
+ expect(root_child1.getComputedHeight()).toBe(50);
998
+ });
999
+ test('margin_auto_left_and_right_column_and_center', () => {
1000
+ const config = Yoga.Config.create();
1001
+
1002
+ const root = Yoga.Node.create(config);
1003
+ root.setPositionType(PositionType.Absolute);
1004
+ root.setWidth(200);
1005
+ root.setHeight(200);
1006
+ root.setAlignItems(Align.Center);
1007
+
1008
+ const root_child0 = Yoga.Node.create(config);
1009
+ root_child0.setWidth(50);
1010
+ root_child0.setHeight(50);
1011
+ root_child0.setMargin(Edge.Left, "auto");
1012
+ root_child0.setMargin(Edge.Right, "auto");
1013
+ root.insertChild(root_child0, 0);
1014
+
1015
+ const root_child1 = Yoga.Node.create(config);
1016
+ root_child1.setWidth(50);
1017
+ root_child1.setHeight(50);
1018
+ root.insertChild(root_child1, 1);
1019
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1020
+
1021
+ expect(root.getComputedLeft()).toBe(0);
1022
+ expect(root.getComputedTop()).toBe(0);
1023
+ expect(root.getComputedWidth()).toBe(200);
1024
+ expect(root.getComputedHeight()).toBe(200);
1025
+
1026
+ expect(root_child0.getComputedLeft()).toBe(75);
1027
+ expect(root_child0.getComputedTop()).toBe(0);
1028
+ expect(root_child0.getComputedWidth()).toBe(50);
1029
+ expect(root_child0.getComputedHeight()).toBe(50);
1030
+
1031
+ expect(root_child1.getComputedLeft()).toBe(75);
1032
+ expect(root_child1.getComputedTop()).toBe(50);
1033
+ expect(root_child1.getComputedWidth()).toBe(50);
1034
+ expect(root_child1.getComputedHeight()).toBe(50);
1035
+
1036
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1037
+
1038
+ expect(root.getComputedLeft()).toBe(0);
1039
+ expect(root.getComputedTop()).toBe(0);
1040
+ expect(root.getComputedWidth()).toBe(200);
1041
+ expect(root.getComputedHeight()).toBe(200);
1042
+
1043
+ expect(root_child0.getComputedLeft()).toBe(75);
1044
+ expect(root_child0.getComputedTop()).toBe(0);
1045
+ expect(root_child0.getComputedWidth()).toBe(50);
1046
+ expect(root_child0.getComputedHeight()).toBe(50);
1047
+
1048
+ expect(root_child1.getComputedLeft()).toBe(75);
1049
+ expect(root_child1.getComputedTop()).toBe(50);
1050
+ expect(root_child1.getComputedWidth()).toBe(50);
1051
+ expect(root_child1.getComputedHeight()).toBe(50);
1052
+ });
1053
+ test('margin_auto_left', () => {
1054
+ const config = Yoga.Config.create();
1055
+
1056
+ const root = Yoga.Node.create(config);
1057
+ root.setPositionType(PositionType.Absolute);
1058
+ root.setWidth(200);
1059
+ root.setHeight(200);
1060
+ root.setAlignItems(Align.Center);
1061
+
1062
+ const root_child0 = Yoga.Node.create(config);
1063
+ root_child0.setWidth(50);
1064
+ root_child0.setHeight(50);
1065
+ root_child0.setMargin(Edge.Left, "auto");
1066
+ root.insertChild(root_child0, 0);
1067
+
1068
+ const root_child1 = Yoga.Node.create(config);
1069
+ root_child1.setWidth(50);
1070
+ root_child1.setHeight(50);
1071
+ root.insertChild(root_child1, 1);
1072
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1073
+
1074
+ expect(root.getComputedLeft()).toBe(0);
1075
+ expect(root.getComputedTop()).toBe(0);
1076
+ expect(root.getComputedWidth()).toBe(200);
1077
+ expect(root.getComputedHeight()).toBe(200);
1078
+
1079
+ expect(root_child0.getComputedLeft()).toBe(150);
1080
+ expect(root_child0.getComputedTop()).toBe(0);
1081
+ expect(root_child0.getComputedWidth()).toBe(50);
1082
+ expect(root_child0.getComputedHeight()).toBe(50);
1083
+
1084
+ expect(root_child1.getComputedLeft()).toBe(75);
1085
+ expect(root_child1.getComputedTop()).toBe(50);
1086
+ expect(root_child1.getComputedWidth()).toBe(50);
1087
+ expect(root_child1.getComputedHeight()).toBe(50);
1088
+
1089
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1090
+
1091
+ expect(root.getComputedLeft()).toBe(0);
1092
+ expect(root.getComputedTop()).toBe(0);
1093
+ expect(root.getComputedWidth()).toBe(200);
1094
+ expect(root.getComputedHeight()).toBe(200);
1095
+
1096
+ expect(root_child0.getComputedLeft()).toBe(150);
1097
+ expect(root_child0.getComputedTop()).toBe(0);
1098
+ expect(root_child0.getComputedWidth()).toBe(50);
1099
+ expect(root_child0.getComputedHeight()).toBe(50);
1100
+
1101
+ expect(root_child1.getComputedLeft()).toBe(75);
1102
+ expect(root_child1.getComputedTop()).toBe(50);
1103
+ expect(root_child1.getComputedWidth()).toBe(50);
1104
+ expect(root_child1.getComputedHeight()).toBe(50);
1105
+ });
1106
+ test('margin_auto_right', () => {
1107
+ const config = Yoga.Config.create();
1108
+
1109
+ const root = Yoga.Node.create(config);
1110
+ root.setPositionType(PositionType.Absolute);
1111
+ root.setWidth(200);
1112
+ root.setHeight(200);
1113
+ root.setAlignItems(Align.Center);
1114
+
1115
+ const root_child0 = Yoga.Node.create(config);
1116
+ root_child0.setWidth(50);
1117
+ root_child0.setHeight(50);
1118
+ root_child0.setMargin(Edge.Right, "auto");
1119
+ root.insertChild(root_child0, 0);
1120
+
1121
+ const root_child1 = Yoga.Node.create(config);
1122
+ root_child1.setWidth(50);
1123
+ root_child1.setHeight(50);
1124
+ root.insertChild(root_child1, 1);
1125
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1126
+
1127
+ expect(root.getComputedLeft()).toBe(0);
1128
+ expect(root.getComputedTop()).toBe(0);
1129
+ expect(root.getComputedWidth()).toBe(200);
1130
+ expect(root.getComputedHeight()).toBe(200);
1131
+
1132
+ expect(root_child0.getComputedLeft()).toBe(0);
1133
+ expect(root_child0.getComputedTop()).toBe(0);
1134
+ expect(root_child0.getComputedWidth()).toBe(50);
1135
+ expect(root_child0.getComputedHeight()).toBe(50);
1136
+
1137
+ expect(root_child1.getComputedLeft()).toBe(75);
1138
+ expect(root_child1.getComputedTop()).toBe(50);
1139
+ expect(root_child1.getComputedWidth()).toBe(50);
1140
+ expect(root_child1.getComputedHeight()).toBe(50);
1141
+
1142
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1143
+
1144
+ expect(root.getComputedLeft()).toBe(0);
1145
+ expect(root.getComputedTop()).toBe(0);
1146
+ expect(root.getComputedWidth()).toBe(200);
1147
+ expect(root.getComputedHeight()).toBe(200);
1148
+
1149
+ expect(root_child0.getComputedLeft()).toBe(0);
1150
+ expect(root_child0.getComputedTop()).toBe(0);
1151
+ expect(root_child0.getComputedWidth()).toBe(50);
1152
+ expect(root_child0.getComputedHeight()).toBe(50);
1153
+
1154
+ expect(root_child1.getComputedLeft()).toBe(75);
1155
+ expect(root_child1.getComputedTop()).toBe(50);
1156
+ expect(root_child1.getComputedWidth()).toBe(50);
1157
+ expect(root_child1.getComputedHeight()).toBe(50);
1158
+ });
1159
+ test('margin_auto_left_and_right_stretch', () => {
1160
+ const config = Yoga.Config.create();
1161
+
1162
+ const root = Yoga.Node.create(config);
1163
+ root.setPositionType(PositionType.Absolute);
1164
+ root.setWidth(200);
1165
+ root.setHeight(200);
1166
+ root.setFlexDirection(FlexDirection.Row);
1167
+
1168
+ const root_child0 = Yoga.Node.create(config);
1169
+ root_child0.setWidth(50);
1170
+ root_child0.setHeight(50);
1171
+ root_child0.setMargin(Edge.Left, "auto");
1172
+ root_child0.setMargin(Edge.Right, "auto");
1173
+ root.insertChild(root_child0, 0);
1174
+
1175
+ const root_child1 = Yoga.Node.create(config);
1176
+ root_child1.setWidth(50);
1177
+ root_child1.setHeight(50);
1178
+ root.insertChild(root_child1, 1);
1179
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1180
+
1181
+ expect(root.getComputedLeft()).toBe(0);
1182
+ expect(root.getComputedTop()).toBe(0);
1183
+ expect(root.getComputedWidth()).toBe(200);
1184
+ expect(root.getComputedHeight()).toBe(200);
1185
+
1186
+ expect(root_child0.getComputedLeft()).toBe(50);
1187
+ expect(root_child0.getComputedTop()).toBe(0);
1188
+ expect(root_child0.getComputedWidth()).toBe(50);
1189
+ expect(root_child0.getComputedHeight()).toBe(50);
1190
+
1191
+ expect(root_child1.getComputedLeft()).toBe(150);
1192
+ expect(root_child1.getComputedTop()).toBe(0);
1193
+ expect(root_child1.getComputedWidth()).toBe(50);
1194
+ expect(root_child1.getComputedHeight()).toBe(50);
1195
+
1196
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1197
+
1198
+ expect(root.getComputedLeft()).toBe(0);
1199
+ expect(root.getComputedTop()).toBe(0);
1200
+ expect(root.getComputedWidth()).toBe(200);
1201
+ expect(root.getComputedHeight()).toBe(200);
1202
+
1203
+ expect(root_child0.getComputedLeft()).toBe(100);
1204
+ expect(root_child0.getComputedTop()).toBe(0);
1205
+ expect(root_child0.getComputedWidth()).toBe(50);
1206
+ expect(root_child0.getComputedHeight()).toBe(50);
1207
+
1208
+ expect(root_child1.getComputedLeft()).toBe(0);
1209
+ expect(root_child1.getComputedTop()).toBe(0);
1210
+ expect(root_child1.getComputedWidth()).toBe(50);
1211
+ expect(root_child1.getComputedHeight()).toBe(50);
1212
+ });
1213
+ test('margin_auto_top_and_bottom_stretch', () => {
1214
+ const config = Yoga.Config.create();
1215
+
1216
+ const root = Yoga.Node.create(config);
1217
+ root.setPositionType(PositionType.Absolute);
1218
+ root.setWidth(200);
1219
+ root.setHeight(200);
1220
+
1221
+ const root_child0 = Yoga.Node.create(config);
1222
+ root_child0.setWidth(50);
1223
+ root_child0.setHeight(50);
1224
+ root_child0.setMargin(Edge.Top, "auto");
1225
+ root_child0.setMargin(Edge.Bottom, "auto");
1226
+ root.insertChild(root_child0, 0);
1227
+
1228
+ const root_child1 = Yoga.Node.create(config);
1229
+ root_child1.setWidth(50);
1230
+ root_child1.setHeight(50);
1231
+ root.insertChild(root_child1, 1);
1232
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1233
+
1234
+ expect(root.getComputedLeft()).toBe(0);
1235
+ expect(root.getComputedTop()).toBe(0);
1236
+ expect(root.getComputedWidth()).toBe(200);
1237
+ expect(root.getComputedHeight()).toBe(200);
1238
+
1239
+ expect(root_child0.getComputedLeft()).toBe(0);
1240
+ expect(root_child0.getComputedTop()).toBe(50);
1241
+ expect(root_child0.getComputedWidth()).toBe(50);
1242
+ expect(root_child0.getComputedHeight()).toBe(50);
1243
+
1244
+ expect(root_child1.getComputedLeft()).toBe(0);
1245
+ expect(root_child1.getComputedTop()).toBe(150);
1246
+ expect(root_child1.getComputedWidth()).toBe(50);
1247
+ expect(root_child1.getComputedHeight()).toBe(50);
1248
+
1249
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1250
+
1251
+ expect(root.getComputedLeft()).toBe(0);
1252
+ expect(root.getComputedTop()).toBe(0);
1253
+ expect(root.getComputedWidth()).toBe(200);
1254
+ expect(root.getComputedHeight()).toBe(200);
1255
+
1256
+ expect(root_child0.getComputedLeft()).toBe(150);
1257
+ expect(root_child0.getComputedTop()).toBe(50);
1258
+ expect(root_child0.getComputedWidth()).toBe(50);
1259
+ expect(root_child0.getComputedHeight()).toBe(50);
1260
+
1261
+ expect(root_child1.getComputedLeft()).toBe(150);
1262
+ expect(root_child1.getComputedTop()).toBe(150);
1263
+ expect(root_child1.getComputedWidth()).toBe(50);
1264
+ expect(root_child1.getComputedHeight()).toBe(50);
1265
+ });
1266
+ test('margin_should_not_be_part_of_max_height', () => {
1267
+ const config = Yoga.Config.create();
1268
+
1269
+ const root = Yoga.Node.create(config);
1270
+ root.setPositionType(PositionType.Absolute);
1271
+ root.setWidth(250);
1272
+ root.setHeight(250);
1273
+
1274
+ const root_child0 = Yoga.Node.create(config);
1275
+ root_child0.setWidth(100);
1276
+ root_child0.setHeight(100);
1277
+ root_child0.setMaxHeight(100);
1278
+ root_child0.setMargin(Edge.Top, 20);
1279
+ root.insertChild(root_child0, 0);
1280
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1281
+
1282
+ expect(root.getComputedLeft()).toBe(0);
1283
+ expect(root.getComputedTop()).toBe(0);
1284
+ expect(root.getComputedWidth()).toBe(250);
1285
+ expect(root.getComputedHeight()).toBe(250);
1286
+
1287
+ expect(root_child0.getComputedLeft()).toBe(0);
1288
+ expect(root_child0.getComputedTop()).toBe(20);
1289
+ expect(root_child0.getComputedWidth()).toBe(100);
1290
+ expect(root_child0.getComputedHeight()).toBe(100);
1291
+
1292
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1293
+
1294
+ expect(root.getComputedLeft()).toBe(0);
1295
+ expect(root.getComputedTop()).toBe(0);
1296
+ expect(root.getComputedWidth()).toBe(250);
1297
+ expect(root.getComputedHeight()).toBe(250);
1298
+
1299
+ expect(root_child0.getComputedLeft()).toBe(150);
1300
+ expect(root_child0.getComputedTop()).toBe(20);
1301
+ expect(root_child0.getComputedWidth()).toBe(100);
1302
+ expect(root_child0.getComputedHeight()).toBe(100);
1303
+ });
1304
+ test('margin_should_not_be_part_of_max_width', () => {
1305
+ const config = Yoga.Config.create();
1306
+
1307
+ const root = Yoga.Node.create(config);
1308
+ root.setPositionType(PositionType.Absolute);
1309
+ root.setWidth(250);
1310
+ root.setHeight(250);
1311
+
1312
+ const root_child0 = Yoga.Node.create(config);
1313
+ root_child0.setWidth(100);
1314
+ root_child0.setHeight(100);
1315
+ root_child0.setMaxWidth(100);
1316
+ root_child0.setMargin(Edge.Left, 20);
1317
+ root.insertChild(root_child0, 0);
1318
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1319
+
1320
+ expect(root.getComputedLeft()).toBe(0);
1321
+ expect(root.getComputedTop()).toBe(0);
1322
+ expect(root.getComputedWidth()).toBe(250);
1323
+ expect(root.getComputedHeight()).toBe(250);
1324
+
1325
+ expect(root_child0.getComputedLeft()).toBe(20);
1326
+ expect(root_child0.getComputedTop()).toBe(0);
1327
+ expect(root_child0.getComputedWidth()).toBe(100);
1328
+ expect(root_child0.getComputedHeight()).toBe(100);
1329
+
1330
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1331
+
1332
+ expect(root.getComputedLeft()).toBe(0);
1333
+ expect(root.getComputedTop()).toBe(0);
1334
+ expect(root.getComputedWidth()).toBe(250);
1335
+ expect(root.getComputedHeight()).toBe(250);
1336
+
1337
+ expect(root_child0.getComputedLeft()).toBe(150);
1338
+ expect(root_child0.getComputedTop()).toBe(0);
1339
+ expect(root_child0.getComputedWidth()).toBe(100);
1340
+ expect(root_child0.getComputedHeight()).toBe(100);
1341
+ });
1342
+ test('margin_auto_left_right_child_bigger_than_parent', () => {
1343
+ const config = Yoga.Config.create();
1344
+
1345
+ const root = Yoga.Node.create(config);
1346
+ root.setPositionType(PositionType.Absolute);
1347
+ root.setHeight(52);
1348
+ root.setWidth(52);
1349
+ root.setJustifyContent(Justify.Center);
1350
+
1351
+ const root_child0 = Yoga.Node.create(config);
1352
+ root_child0.setWidth(72);
1353
+ root_child0.setHeight(72);
1354
+ root_child0.setMargin(Edge.Left, "auto");
1355
+ root_child0.setMargin(Edge.Right, "auto");
1356
+ root.insertChild(root_child0, 0);
1357
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1358
+
1359
+ expect(root.getComputedLeft()).toBe(0);
1360
+ expect(root.getComputedTop()).toBe(0);
1361
+ expect(root.getComputedWidth()).toBe(52);
1362
+ expect(root.getComputedHeight()).toBe(52);
1363
+
1364
+ expect(root_child0.getComputedLeft()).toBe(0);
1365
+ expect(root_child0.getComputedTop()).toBe(-10);
1366
+ expect(root_child0.getComputedWidth()).toBe(72);
1367
+ expect(root_child0.getComputedHeight()).toBe(72);
1368
+
1369
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1370
+
1371
+ expect(root.getComputedLeft()).toBe(0);
1372
+ expect(root.getComputedTop()).toBe(0);
1373
+ expect(root.getComputedWidth()).toBe(52);
1374
+ expect(root.getComputedHeight()).toBe(52);
1375
+
1376
+ expect(root_child0.getComputedLeft()).toBe(-20);
1377
+ expect(root_child0.getComputedTop()).toBe(-10);
1378
+ expect(root_child0.getComputedWidth()).toBe(72);
1379
+ expect(root_child0.getComputedHeight()).toBe(72);
1380
+ });
1381
+ test('margin_auto_left_child_bigger_than_parent', () => {
1382
+ const config = Yoga.Config.create();
1383
+
1384
+ const root = Yoga.Node.create(config);
1385
+ root.setPositionType(PositionType.Absolute);
1386
+ root.setHeight(52);
1387
+ root.setWidth(52);
1388
+ root.setJustifyContent(Justify.Center);
1389
+
1390
+ const root_child0 = Yoga.Node.create(config);
1391
+ root_child0.setWidth(72);
1392
+ root_child0.setHeight(72);
1393
+ root_child0.setMargin(Edge.Left, "auto");
1394
+ root.insertChild(root_child0, 0);
1395
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1396
+
1397
+ expect(root.getComputedLeft()).toBe(0);
1398
+ expect(root.getComputedTop()).toBe(0);
1399
+ expect(root.getComputedWidth()).toBe(52);
1400
+ expect(root.getComputedHeight()).toBe(52);
1401
+
1402
+ expect(root_child0.getComputedLeft()).toBe(0);
1403
+ expect(root_child0.getComputedTop()).toBe(-10);
1404
+ expect(root_child0.getComputedWidth()).toBe(72);
1405
+ expect(root_child0.getComputedHeight()).toBe(72);
1406
+
1407
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1408
+
1409
+ expect(root.getComputedLeft()).toBe(0);
1410
+ expect(root.getComputedTop()).toBe(0);
1411
+ expect(root.getComputedWidth()).toBe(52);
1412
+ expect(root.getComputedHeight()).toBe(52);
1413
+
1414
+ expect(root_child0.getComputedLeft()).toBe(-20);
1415
+ expect(root_child0.getComputedTop()).toBe(-10);
1416
+ expect(root_child0.getComputedWidth()).toBe(72);
1417
+ expect(root_child0.getComputedHeight()).toBe(72);
1418
+ });
1419
+ test('margin_fix_left_auto_right_child_bigger_than_parent', () => {
1420
+ const config = Yoga.Config.create();
1421
+
1422
+ const root = Yoga.Node.create(config);
1423
+ root.setPositionType(PositionType.Absolute);
1424
+ root.setHeight(52);
1425
+ root.setWidth(52);
1426
+ root.setJustifyContent(Justify.Center);
1427
+
1428
+ const root_child0 = Yoga.Node.create(config);
1429
+ root_child0.setWidth(72);
1430
+ root_child0.setHeight(72);
1431
+ root_child0.setMargin(Edge.Left, 10);
1432
+ root_child0.setMargin(Edge.Right, "auto");
1433
+ root.insertChild(root_child0, 0);
1434
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1435
+
1436
+ expect(root.getComputedLeft()).toBe(0);
1437
+ expect(root.getComputedTop()).toBe(0);
1438
+ expect(root.getComputedWidth()).toBe(52);
1439
+ expect(root.getComputedHeight()).toBe(52);
1440
+
1441
+ expect(root_child0.getComputedLeft()).toBe(10);
1442
+ expect(root_child0.getComputedTop()).toBe(-10);
1443
+ expect(root_child0.getComputedWidth()).toBe(72);
1444
+ expect(root_child0.getComputedHeight()).toBe(72);
1445
+
1446
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1447
+
1448
+ expect(root.getComputedLeft()).toBe(0);
1449
+ expect(root.getComputedTop()).toBe(0);
1450
+ expect(root.getComputedWidth()).toBe(52);
1451
+ expect(root.getComputedHeight()).toBe(52);
1452
+
1453
+ expect(root_child0.getComputedLeft()).toBe(-20);
1454
+ expect(root_child0.getComputedTop()).toBe(-10);
1455
+ expect(root_child0.getComputedWidth()).toBe(72);
1456
+ expect(root_child0.getComputedHeight()).toBe(72);
1457
+ });
1458
+ test('margin_auto_left_fix_right_child_bigger_than_parent', () => {
1459
+ const config = Yoga.Config.create();
1460
+
1461
+ const root = Yoga.Node.create(config);
1462
+ root.setPositionType(PositionType.Absolute);
1463
+ root.setHeight(52);
1464
+ root.setWidth(52);
1465
+ root.setJustifyContent(Justify.Center);
1466
+
1467
+ const root_child0 = Yoga.Node.create(config);
1468
+ root_child0.setWidth(72);
1469
+ root_child0.setHeight(72);
1470
+ root_child0.setMargin(Edge.Left, "auto");
1471
+ root_child0.setMargin(Edge.Right, 10);
1472
+ root.insertChild(root_child0, 0);
1473
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1474
+
1475
+ expect(root.getComputedLeft()).toBe(0);
1476
+ expect(root.getComputedTop()).toBe(0);
1477
+ expect(root.getComputedWidth()).toBe(52);
1478
+ expect(root.getComputedHeight()).toBe(52);
1479
+
1480
+ expect(root_child0.getComputedLeft()).toBe(0);
1481
+ expect(root_child0.getComputedTop()).toBe(-10);
1482
+ expect(root_child0.getComputedWidth()).toBe(72);
1483
+ expect(root_child0.getComputedHeight()).toBe(72);
1484
+
1485
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1486
+
1487
+ expect(root.getComputedLeft()).toBe(0);
1488
+ expect(root.getComputedTop()).toBe(0);
1489
+ expect(root.getComputedWidth()).toBe(52);
1490
+ expect(root.getComputedHeight()).toBe(52);
1491
+
1492
+ expect(root_child0.getComputedLeft()).toBe(-30);
1493
+ expect(root_child0.getComputedTop()).toBe(-10);
1494
+ expect(root_child0.getComputedWidth()).toBe(72);
1495
+ expect(root_child0.getComputedHeight()).toBe(72);
1496
+ });
1497
+ test('margin_auto_top_stretching_child', () => {
1498
+ const config = Yoga.Config.create();
1499
+
1500
+ const root = Yoga.Node.create(config);
1501
+ root.setPositionType(PositionType.Absolute);
1502
+ root.setWidth(200);
1503
+ root.setHeight(200);
1504
+ root.setAlignItems(Align.Center);
1505
+
1506
+ const root_child0 = Yoga.Node.create(config);
1507
+ root_child0.setFlexGrow(1);
1508
+ root_child0.setFlexShrink(1);
1509
+ root_child0.setFlexBasis("0%");
1510
+ root_child0.setMargin(Edge.Top, "auto");
1511
+ root.insertChild(root_child0, 0);
1512
+
1513
+ const root_child1 = Yoga.Node.create(config);
1514
+ root_child1.setWidth(50);
1515
+ root_child1.setHeight(50);
1516
+ root.insertChild(root_child1, 1);
1517
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1518
+
1519
+ expect(root.getComputedLeft()).toBe(0);
1520
+ expect(root.getComputedTop()).toBe(0);
1521
+ expect(root.getComputedWidth()).toBe(200);
1522
+ expect(root.getComputedHeight()).toBe(200);
1523
+
1524
+ expect(root_child0.getComputedLeft()).toBe(100);
1525
+ expect(root_child0.getComputedTop()).toBe(0);
1526
+ expect(root_child0.getComputedWidth()).toBe(0);
1527
+ expect(root_child0.getComputedHeight()).toBe(150);
1528
+
1529
+ expect(root_child1.getComputedLeft()).toBe(75);
1530
+ expect(root_child1.getComputedTop()).toBe(150);
1531
+ expect(root_child1.getComputedWidth()).toBe(50);
1532
+ expect(root_child1.getComputedHeight()).toBe(50);
1533
+
1534
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1535
+
1536
+ expect(root.getComputedLeft()).toBe(0);
1537
+ expect(root.getComputedTop()).toBe(0);
1538
+ expect(root.getComputedWidth()).toBe(200);
1539
+ expect(root.getComputedHeight()).toBe(200);
1540
+
1541
+ expect(root_child0.getComputedLeft()).toBe(100);
1542
+ expect(root_child0.getComputedTop()).toBe(0);
1543
+ expect(root_child0.getComputedWidth()).toBe(0);
1544
+ expect(root_child0.getComputedHeight()).toBe(150);
1545
+
1546
+ expect(root_child1.getComputedLeft()).toBe(75);
1547
+ expect(root_child1.getComputedTop()).toBe(150);
1548
+ expect(root_child1.getComputedWidth()).toBe(50);
1549
+ expect(root_child1.getComputedHeight()).toBe(50);
1550
+ });
1551
+ test('margin_auto_left_stretching_child', () => {
1552
+ const config = Yoga.Config.create();
1553
+
1554
+ const root = Yoga.Node.create(config);
1555
+ root.setPositionType(PositionType.Absolute);
1556
+ root.setWidth(200);
1557
+ root.setHeight(200);
1558
+ root.setAlignItems(Align.Center);
1559
+
1560
+ const root_child0 = Yoga.Node.create(config);
1561
+ root_child0.setFlexGrow(1);
1562
+ root_child0.setFlexShrink(1);
1563
+ root_child0.setFlexBasis("0%");
1564
+ root_child0.setMargin(Edge.Left, "auto");
1565
+ root.insertChild(root_child0, 0);
1566
+
1567
+ const root_child1 = Yoga.Node.create(config);
1568
+ root_child1.setWidth(50);
1569
+ root_child1.setHeight(50);
1570
+ root.insertChild(root_child1, 1);
1571
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1572
+
1573
+ expect(root.getComputedLeft()).toBe(0);
1574
+ expect(root.getComputedTop()).toBe(0);
1575
+ expect(root.getComputedWidth()).toBe(200);
1576
+ expect(root.getComputedHeight()).toBe(200);
1577
+
1578
+ expect(root_child0.getComputedLeft()).toBe(200);
1579
+ expect(root_child0.getComputedTop()).toBe(0);
1580
+ expect(root_child0.getComputedWidth()).toBe(0);
1581
+ expect(root_child0.getComputedHeight()).toBe(150);
1582
+
1583
+ expect(root_child1.getComputedLeft()).toBe(75);
1584
+ expect(root_child1.getComputedTop()).toBe(150);
1585
+ expect(root_child1.getComputedWidth()).toBe(50);
1586
+ expect(root_child1.getComputedHeight()).toBe(50);
1587
+
1588
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1589
+
1590
+ expect(root.getComputedLeft()).toBe(0);
1591
+ expect(root.getComputedTop()).toBe(0);
1592
+ expect(root.getComputedWidth()).toBe(200);
1593
+ expect(root.getComputedHeight()).toBe(200);
1594
+
1595
+ expect(root_child0.getComputedLeft()).toBe(200);
1596
+ expect(root_child0.getComputedTop()).toBe(0);
1597
+ expect(root_child0.getComputedWidth()).toBe(0);
1598
+ expect(root_child0.getComputedHeight()).toBe(150);
1599
+
1600
+ expect(root_child1.getComputedLeft()).toBe(75);
1601
+ expect(root_child1.getComputedTop()).toBe(150);
1602
+ expect(root_child1.getComputedWidth()).toBe(50);
1603
+ expect(root_child1.getComputedHeight()).toBe(50);
1604
+ });
1605
+ test('margin_auto_overflowing_container', () => {
1606
+ const config = Yoga.Config.create();
1607
+
1608
+ const root = Yoga.Node.create(config);
1609
+ root.setPositionType(PositionType.Absolute);
1610
+ root.setWidth(200);
1611
+ root.setHeight(200);
1612
+ root.setAlignItems(Align.Center);
1613
+
1614
+ const root_child0 = Yoga.Node.create(config);
1615
+ root_child0.setWidth(50);
1616
+ root_child0.setHeight(150);
1617
+ root_child0.setMargin(Edge.Bottom, "auto");
1618
+ root.insertChild(root_child0, 0);
1619
+
1620
+ const root_child1 = Yoga.Node.create(config);
1621
+ root_child1.setWidth(50);
1622
+ root_child1.setHeight(150);
1623
+ root.insertChild(root_child1, 1);
1624
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1625
+
1626
+ expect(root.getComputedLeft()).toBe(0);
1627
+ expect(root.getComputedTop()).toBe(0);
1628
+ expect(root.getComputedWidth()).toBe(200);
1629
+ expect(root.getComputedHeight()).toBe(200);
1630
+
1631
+ expect(root_child0.getComputedLeft()).toBe(75);
1632
+ expect(root_child0.getComputedTop()).toBe(0);
1633
+ expect(root_child0.getComputedWidth()).toBe(50);
1634
+ expect(root_child0.getComputedHeight()).toBe(150);
1635
+
1636
+ expect(root_child1.getComputedLeft()).toBe(75);
1637
+ expect(root_child1.getComputedTop()).toBe(150);
1638
+ expect(root_child1.getComputedWidth()).toBe(50);
1639
+ expect(root_child1.getComputedHeight()).toBe(150);
1640
+
1641
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1642
+
1643
+ expect(root.getComputedLeft()).toBe(0);
1644
+ expect(root.getComputedTop()).toBe(0);
1645
+ expect(root.getComputedWidth()).toBe(200);
1646
+ expect(root.getComputedHeight()).toBe(200);
1647
+
1648
+ expect(root_child0.getComputedLeft()).toBe(75);
1649
+ expect(root_child0.getComputedTop()).toBe(0);
1650
+ expect(root_child0.getComputedWidth()).toBe(50);
1651
+ expect(root_child0.getComputedHeight()).toBe(150);
1652
+
1653
+ expect(root_child1.getComputedLeft()).toBe(75);
1654
+ expect(root_child1.getComputedTop()).toBe(150);
1655
+ expect(root_child1.getComputedWidth()).toBe(50);
1656
+ expect(root_child1.getComputedHeight()).toBe(150);
1657
+ });