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,2857 @@
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<<eb3abc007264798e54d041b2e3f979a0>>
8
+ * generated by gentest/src/GentestDriver.ts from gentest/fixtures/YGGapTest.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('column_gap_flexible', () => {
32
+ const config = Yoga.Config.create();
33
+
34
+ const root = Yoga.Node.create(config);
35
+ root.setPositionType(PositionType.Absolute);
36
+ root.setFlexDirection(FlexDirection.Row);
37
+ root.setWidth(80);
38
+ root.setHeight(100);
39
+ root.setGap(Gutter.Column, 10);
40
+ root.setGap(Gutter.Row, 20);
41
+
42
+ const root_child0 = Yoga.Node.create(config);
43
+ root_child0.setFlexGrow(1);
44
+ root_child0.setFlexShrink(1);
45
+ root_child0.setFlexBasis("0%");
46
+ root.insertChild(root_child0, 0);
47
+
48
+ const root_child1 = Yoga.Node.create(config);
49
+ root_child1.setFlexGrow(1);
50
+ root_child1.setFlexShrink(1);
51
+ root_child1.setFlexBasis("0%");
52
+ root.insertChild(root_child1, 1);
53
+
54
+ const root_child2 = Yoga.Node.create(config);
55
+ root_child2.setFlexGrow(1);
56
+ root_child2.setFlexShrink(1);
57
+ root_child2.setFlexBasis("0%");
58
+ root.insertChild(root_child2, 2);
59
+ root.calculateLayout(undefined, undefined, Direction.LTR);
60
+
61
+ expect(root.getComputedLeft()).toBe(0);
62
+ expect(root.getComputedTop()).toBe(0);
63
+ expect(root.getComputedWidth()).toBe(80);
64
+ expect(root.getComputedHeight()).toBe(100);
65
+
66
+ expect(root_child0.getComputedLeft()).toBe(0);
67
+ expect(root_child0.getComputedTop()).toBe(0);
68
+ expect(root_child0.getComputedWidth()).toBe(20);
69
+ expect(root_child0.getComputedHeight()).toBe(100);
70
+
71
+ expect(root_child1.getComputedLeft()).toBe(30);
72
+ expect(root_child1.getComputedTop()).toBe(0);
73
+ expect(root_child1.getComputedWidth()).toBe(20);
74
+ expect(root_child1.getComputedHeight()).toBe(100);
75
+
76
+ expect(root_child2.getComputedLeft()).toBe(60);
77
+ expect(root_child2.getComputedTop()).toBe(0);
78
+ expect(root_child2.getComputedWidth()).toBe(20);
79
+ expect(root_child2.getComputedHeight()).toBe(100);
80
+
81
+ root.calculateLayout(undefined, undefined, Direction.RTL);
82
+
83
+ expect(root.getComputedLeft()).toBe(0);
84
+ expect(root.getComputedTop()).toBe(0);
85
+ expect(root.getComputedWidth()).toBe(80);
86
+ expect(root.getComputedHeight()).toBe(100);
87
+
88
+ expect(root_child0.getComputedLeft()).toBe(60);
89
+ expect(root_child0.getComputedTop()).toBe(0);
90
+ expect(root_child0.getComputedWidth()).toBe(20);
91
+ expect(root_child0.getComputedHeight()).toBe(100);
92
+
93
+ expect(root_child1.getComputedLeft()).toBe(30);
94
+ expect(root_child1.getComputedTop()).toBe(0);
95
+ expect(root_child1.getComputedWidth()).toBe(20);
96
+ expect(root_child1.getComputedHeight()).toBe(100);
97
+
98
+ expect(root_child2.getComputedLeft()).toBe(0);
99
+ expect(root_child2.getComputedTop()).toBe(0);
100
+ expect(root_child2.getComputedWidth()).toBe(20);
101
+ expect(root_child2.getComputedHeight()).toBe(100);
102
+ });
103
+ test('column_gap_inflexible', () => {
104
+ const config = Yoga.Config.create();
105
+
106
+ const root = Yoga.Node.create(config);
107
+ root.setPositionType(PositionType.Absolute);
108
+ root.setFlexDirection(FlexDirection.Row);
109
+ root.setWidth(80);
110
+ root.setHeight(100);
111
+ root.setGap(Gutter.Column, 10);
112
+
113
+ const root_child0 = Yoga.Node.create(config);
114
+ root_child0.setWidth(20);
115
+ root.insertChild(root_child0, 0);
116
+
117
+ const root_child1 = Yoga.Node.create(config);
118
+ root_child1.setWidth(20);
119
+ root.insertChild(root_child1, 1);
120
+
121
+ const root_child2 = Yoga.Node.create(config);
122
+ root_child2.setWidth(20);
123
+ root.insertChild(root_child2, 2);
124
+ root.calculateLayout(undefined, undefined, Direction.LTR);
125
+
126
+ expect(root.getComputedLeft()).toBe(0);
127
+ expect(root.getComputedTop()).toBe(0);
128
+ expect(root.getComputedWidth()).toBe(80);
129
+ expect(root.getComputedHeight()).toBe(100);
130
+
131
+ expect(root_child0.getComputedLeft()).toBe(0);
132
+ expect(root_child0.getComputedTop()).toBe(0);
133
+ expect(root_child0.getComputedWidth()).toBe(20);
134
+ expect(root_child0.getComputedHeight()).toBe(100);
135
+
136
+ expect(root_child1.getComputedLeft()).toBe(30);
137
+ expect(root_child1.getComputedTop()).toBe(0);
138
+ expect(root_child1.getComputedWidth()).toBe(20);
139
+ expect(root_child1.getComputedHeight()).toBe(100);
140
+
141
+ expect(root_child2.getComputedLeft()).toBe(60);
142
+ expect(root_child2.getComputedTop()).toBe(0);
143
+ expect(root_child2.getComputedWidth()).toBe(20);
144
+ expect(root_child2.getComputedHeight()).toBe(100);
145
+
146
+ root.calculateLayout(undefined, undefined, Direction.RTL);
147
+
148
+ expect(root.getComputedLeft()).toBe(0);
149
+ expect(root.getComputedTop()).toBe(0);
150
+ expect(root.getComputedWidth()).toBe(80);
151
+ expect(root.getComputedHeight()).toBe(100);
152
+
153
+ expect(root_child0.getComputedLeft()).toBe(60);
154
+ expect(root_child0.getComputedTop()).toBe(0);
155
+ expect(root_child0.getComputedWidth()).toBe(20);
156
+ expect(root_child0.getComputedHeight()).toBe(100);
157
+
158
+ expect(root_child1.getComputedLeft()).toBe(30);
159
+ expect(root_child1.getComputedTop()).toBe(0);
160
+ expect(root_child1.getComputedWidth()).toBe(20);
161
+ expect(root_child1.getComputedHeight()).toBe(100);
162
+
163
+ expect(root_child2.getComputedLeft()).toBe(0);
164
+ expect(root_child2.getComputedTop()).toBe(0);
165
+ expect(root_child2.getComputedWidth()).toBe(20);
166
+ expect(root_child2.getComputedHeight()).toBe(100);
167
+ });
168
+ test('column_gap_mixed_flexible', () => {
169
+ const config = Yoga.Config.create();
170
+
171
+ const root = Yoga.Node.create(config);
172
+ root.setPositionType(PositionType.Absolute);
173
+ root.setFlexDirection(FlexDirection.Row);
174
+ root.setWidth(80);
175
+ root.setHeight(100);
176
+ root.setGap(Gutter.Column, 10);
177
+
178
+ const root_child0 = Yoga.Node.create(config);
179
+ root_child0.setWidth(20);
180
+ root.insertChild(root_child0, 0);
181
+
182
+ const root_child1 = Yoga.Node.create(config);
183
+ root_child1.setFlexGrow(1);
184
+ root_child1.setFlexShrink(1);
185
+ root_child1.setFlexBasis("0%");
186
+ root.insertChild(root_child1, 1);
187
+
188
+ const root_child2 = Yoga.Node.create(config);
189
+ root_child2.setWidth(20);
190
+ root.insertChild(root_child2, 2);
191
+ root.calculateLayout(undefined, undefined, Direction.LTR);
192
+
193
+ expect(root.getComputedLeft()).toBe(0);
194
+ expect(root.getComputedTop()).toBe(0);
195
+ expect(root.getComputedWidth()).toBe(80);
196
+ expect(root.getComputedHeight()).toBe(100);
197
+
198
+ expect(root_child0.getComputedLeft()).toBe(0);
199
+ expect(root_child0.getComputedTop()).toBe(0);
200
+ expect(root_child0.getComputedWidth()).toBe(20);
201
+ expect(root_child0.getComputedHeight()).toBe(100);
202
+
203
+ expect(root_child1.getComputedLeft()).toBe(30);
204
+ expect(root_child1.getComputedTop()).toBe(0);
205
+ expect(root_child1.getComputedWidth()).toBe(20);
206
+ expect(root_child1.getComputedHeight()).toBe(100);
207
+
208
+ expect(root_child2.getComputedLeft()).toBe(60);
209
+ expect(root_child2.getComputedTop()).toBe(0);
210
+ expect(root_child2.getComputedWidth()).toBe(20);
211
+ expect(root_child2.getComputedHeight()).toBe(100);
212
+
213
+ root.calculateLayout(undefined, undefined, Direction.RTL);
214
+
215
+ expect(root.getComputedLeft()).toBe(0);
216
+ expect(root.getComputedTop()).toBe(0);
217
+ expect(root.getComputedWidth()).toBe(80);
218
+ expect(root.getComputedHeight()).toBe(100);
219
+
220
+ expect(root_child0.getComputedLeft()).toBe(60);
221
+ expect(root_child0.getComputedTop()).toBe(0);
222
+ expect(root_child0.getComputedWidth()).toBe(20);
223
+ expect(root_child0.getComputedHeight()).toBe(100);
224
+
225
+ expect(root_child1.getComputedLeft()).toBe(30);
226
+ expect(root_child1.getComputedTop()).toBe(0);
227
+ expect(root_child1.getComputedWidth()).toBe(20);
228
+ expect(root_child1.getComputedHeight()).toBe(100);
229
+
230
+ expect(root_child2.getComputedLeft()).toBe(0);
231
+ expect(root_child2.getComputedTop()).toBe(0);
232
+ expect(root_child2.getComputedWidth()).toBe(20);
233
+ expect(root_child2.getComputedHeight()).toBe(100);
234
+ });
235
+ test('column_gap_child_margins', () => {
236
+ const config = Yoga.Config.create();
237
+
238
+ const root = Yoga.Node.create(config);
239
+ root.setPositionType(PositionType.Absolute);
240
+ root.setFlexDirection(FlexDirection.Row);
241
+ root.setWidth(80);
242
+ root.setHeight(100);
243
+ root.setGap(Gutter.Column, 10);
244
+
245
+ const root_child0 = Yoga.Node.create(config);
246
+ root_child0.setFlexGrow(1);
247
+ root_child0.setFlexShrink(1);
248
+ root_child0.setFlexBasis("0%");
249
+ root_child0.setMargin(Edge.Horizontal, 2);
250
+ root.insertChild(root_child0, 0);
251
+
252
+ const root_child1 = Yoga.Node.create(config);
253
+ root_child1.setFlexGrow(1);
254
+ root_child1.setFlexShrink(1);
255
+ root_child1.setFlexBasis("0%");
256
+ root_child1.setMargin(Edge.Horizontal, 10);
257
+ root.insertChild(root_child1, 1);
258
+
259
+ const root_child2 = Yoga.Node.create(config);
260
+ root_child2.setFlexGrow(1);
261
+ root_child2.setFlexShrink(1);
262
+ root_child2.setFlexBasis("0%");
263
+ root_child2.setMargin(Edge.Horizontal, 15);
264
+ root.insertChild(root_child2, 2);
265
+ root.calculateLayout(undefined, undefined, Direction.LTR);
266
+
267
+ expect(root.getComputedLeft()).toBe(0);
268
+ expect(root.getComputedTop()).toBe(0);
269
+ expect(root.getComputedWidth()).toBe(80);
270
+ expect(root.getComputedHeight()).toBe(100);
271
+
272
+ expect(root_child0.getComputedLeft()).toBe(2);
273
+ expect(root_child0.getComputedTop()).toBe(0);
274
+ expect(root_child0.getComputedWidth()).toBe(2);
275
+ expect(root_child0.getComputedHeight()).toBe(100);
276
+
277
+ expect(root_child1.getComputedLeft()).toBe(26);
278
+ expect(root_child1.getComputedTop()).toBe(0);
279
+ expect(root_child1.getComputedWidth()).toBe(2);
280
+ expect(root_child1.getComputedHeight()).toBe(100);
281
+
282
+ expect(root_child2.getComputedLeft()).toBe(63);
283
+ expect(root_child2.getComputedTop()).toBe(0);
284
+ expect(root_child2.getComputedWidth()).toBe(2);
285
+ expect(root_child2.getComputedHeight()).toBe(100);
286
+
287
+ root.calculateLayout(undefined, undefined, Direction.RTL);
288
+
289
+ expect(root.getComputedLeft()).toBe(0);
290
+ expect(root.getComputedTop()).toBe(0);
291
+ expect(root.getComputedWidth()).toBe(80);
292
+ expect(root.getComputedHeight()).toBe(100);
293
+
294
+ expect(root_child0.getComputedLeft()).toBe(76);
295
+ expect(root_child0.getComputedTop()).toBe(0);
296
+ expect(root_child0.getComputedWidth()).toBe(2);
297
+ expect(root_child0.getComputedHeight()).toBe(100);
298
+
299
+ expect(root_child1.getComputedLeft()).toBe(52);
300
+ expect(root_child1.getComputedTop()).toBe(0);
301
+ expect(root_child1.getComputedWidth()).toBe(2);
302
+ expect(root_child1.getComputedHeight()).toBe(100);
303
+
304
+ expect(root_child2.getComputedLeft()).toBe(15);
305
+ expect(root_child2.getComputedTop()).toBe(0);
306
+ expect(root_child2.getComputedWidth()).toBe(2);
307
+ expect(root_child2.getComputedHeight()).toBe(100);
308
+ });
309
+ test('column_row_gap_wrapping', () => {
310
+ const config = Yoga.Config.create();
311
+
312
+ const root = Yoga.Node.create(config);
313
+ root.setPositionType(PositionType.Absolute);
314
+ root.setFlexDirection(FlexDirection.Row);
315
+ root.setFlexWrap(Wrap.Wrap);
316
+ root.setWidth(80);
317
+ root.setGap(Gutter.Column, 10);
318
+ root.setGap(Gutter.Row, 20);
319
+
320
+ const root_child0 = Yoga.Node.create(config);
321
+ root_child0.setWidth(20);
322
+ root_child0.setHeight(20);
323
+ root.insertChild(root_child0, 0);
324
+
325
+ const root_child1 = Yoga.Node.create(config);
326
+ root_child1.setWidth(20);
327
+ root_child1.setHeight(20);
328
+ root.insertChild(root_child1, 1);
329
+
330
+ const root_child2 = Yoga.Node.create(config);
331
+ root_child2.setWidth(20);
332
+ root_child2.setHeight(20);
333
+ root.insertChild(root_child2, 2);
334
+
335
+ const root_child3 = Yoga.Node.create(config);
336
+ root_child3.setWidth(20);
337
+ root_child3.setHeight(20);
338
+ root.insertChild(root_child3, 3);
339
+
340
+ const root_child4 = Yoga.Node.create(config);
341
+ root_child4.setWidth(20);
342
+ root_child4.setHeight(20);
343
+ root.insertChild(root_child4, 4);
344
+
345
+ const root_child5 = Yoga.Node.create(config);
346
+ root_child5.setWidth(20);
347
+ root_child5.setHeight(20);
348
+ root.insertChild(root_child5, 5);
349
+
350
+ const root_child6 = Yoga.Node.create(config);
351
+ root_child6.setWidth(20);
352
+ root_child6.setHeight(20);
353
+ root.insertChild(root_child6, 6);
354
+
355
+ const root_child7 = Yoga.Node.create(config);
356
+ root_child7.setWidth(20);
357
+ root_child7.setHeight(20);
358
+ root.insertChild(root_child7, 7);
359
+
360
+ const root_child8 = Yoga.Node.create(config);
361
+ root_child8.setWidth(20);
362
+ root_child8.setHeight(20);
363
+ root.insertChild(root_child8, 8);
364
+ root.calculateLayout(undefined, undefined, Direction.LTR);
365
+
366
+ expect(root.getComputedLeft()).toBe(0);
367
+ expect(root.getComputedTop()).toBe(0);
368
+ expect(root.getComputedWidth()).toBe(80);
369
+ expect(root.getComputedHeight()).toBe(100);
370
+
371
+ expect(root_child0.getComputedLeft()).toBe(0);
372
+ expect(root_child0.getComputedTop()).toBe(0);
373
+ expect(root_child0.getComputedWidth()).toBe(20);
374
+ expect(root_child0.getComputedHeight()).toBe(20);
375
+
376
+ expect(root_child1.getComputedLeft()).toBe(30);
377
+ expect(root_child1.getComputedTop()).toBe(0);
378
+ expect(root_child1.getComputedWidth()).toBe(20);
379
+ expect(root_child1.getComputedHeight()).toBe(20);
380
+
381
+ expect(root_child2.getComputedLeft()).toBe(60);
382
+ expect(root_child2.getComputedTop()).toBe(0);
383
+ expect(root_child2.getComputedWidth()).toBe(20);
384
+ expect(root_child2.getComputedHeight()).toBe(20);
385
+
386
+ expect(root_child3.getComputedLeft()).toBe(0);
387
+ expect(root_child3.getComputedTop()).toBe(40);
388
+ expect(root_child3.getComputedWidth()).toBe(20);
389
+ expect(root_child3.getComputedHeight()).toBe(20);
390
+
391
+ expect(root_child4.getComputedLeft()).toBe(30);
392
+ expect(root_child4.getComputedTop()).toBe(40);
393
+ expect(root_child4.getComputedWidth()).toBe(20);
394
+ expect(root_child4.getComputedHeight()).toBe(20);
395
+
396
+ expect(root_child5.getComputedLeft()).toBe(60);
397
+ expect(root_child5.getComputedTop()).toBe(40);
398
+ expect(root_child5.getComputedWidth()).toBe(20);
399
+ expect(root_child5.getComputedHeight()).toBe(20);
400
+
401
+ expect(root_child6.getComputedLeft()).toBe(0);
402
+ expect(root_child6.getComputedTop()).toBe(80);
403
+ expect(root_child6.getComputedWidth()).toBe(20);
404
+ expect(root_child6.getComputedHeight()).toBe(20);
405
+
406
+ expect(root_child7.getComputedLeft()).toBe(30);
407
+ expect(root_child7.getComputedTop()).toBe(80);
408
+ expect(root_child7.getComputedWidth()).toBe(20);
409
+ expect(root_child7.getComputedHeight()).toBe(20);
410
+
411
+ expect(root_child8.getComputedLeft()).toBe(60);
412
+ expect(root_child8.getComputedTop()).toBe(80);
413
+ expect(root_child8.getComputedWidth()).toBe(20);
414
+ expect(root_child8.getComputedHeight()).toBe(20);
415
+
416
+ root.calculateLayout(undefined, undefined, Direction.RTL);
417
+
418
+ expect(root.getComputedLeft()).toBe(0);
419
+ expect(root.getComputedTop()).toBe(0);
420
+ expect(root.getComputedWidth()).toBe(80);
421
+ expect(root.getComputedHeight()).toBe(100);
422
+
423
+ expect(root_child0.getComputedLeft()).toBe(60);
424
+ expect(root_child0.getComputedTop()).toBe(0);
425
+ expect(root_child0.getComputedWidth()).toBe(20);
426
+ expect(root_child0.getComputedHeight()).toBe(20);
427
+
428
+ expect(root_child1.getComputedLeft()).toBe(30);
429
+ expect(root_child1.getComputedTop()).toBe(0);
430
+ expect(root_child1.getComputedWidth()).toBe(20);
431
+ expect(root_child1.getComputedHeight()).toBe(20);
432
+
433
+ expect(root_child2.getComputedLeft()).toBe(0);
434
+ expect(root_child2.getComputedTop()).toBe(0);
435
+ expect(root_child2.getComputedWidth()).toBe(20);
436
+ expect(root_child2.getComputedHeight()).toBe(20);
437
+
438
+ expect(root_child3.getComputedLeft()).toBe(60);
439
+ expect(root_child3.getComputedTop()).toBe(40);
440
+ expect(root_child3.getComputedWidth()).toBe(20);
441
+ expect(root_child3.getComputedHeight()).toBe(20);
442
+
443
+ expect(root_child4.getComputedLeft()).toBe(30);
444
+ expect(root_child4.getComputedTop()).toBe(40);
445
+ expect(root_child4.getComputedWidth()).toBe(20);
446
+ expect(root_child4.getComputedHeight()).toBe(20);
447
+
448
+ expect(root_child5.getComputedLeft()).toBe(0);
449
+ expect(root_child5.getComputedTop()).toBe(40);
450
+ expect(root_child5.getComputedWidth()).toBe(20);
451
+ expect(root_child5.getComputedHeight()).toBe(20);
452
+
453
+ expect(root_child6.getComputedLeft()).toBe(60);
454
+ expect(root_child6.getComputedTop()).toBe(80);
455
+ expect(root_child6.getComputedWidth()).toBe(20);
456
+ expect(root_child6.getComputedHeight()).toBe(20);
457
+
458
+ expect(root_child7.getComputedLeft()).toBe(30);
459
+ expect(root_child7.getComputedTop()).toBe(80);
460
+ expect(root_child7.getComputedWidth()).toBe(20);
461
+ expect(root_child7.getComputedHeight()).toBe(20);
462
+
463
+ expect(root_child8.getComputedLeft()).toBe(0);
464
+ expect(root_child8.getComputedTop()).toBe(80);
465
+ expect(root_child8.getComputedWidth()).toBe(20);
466
+ expect(root_child8.getComputedHeight()).toBe(20);
467
+ });
468
+ test('column_gap_start_index', () => {
469
+ const config = Yoga.Config.create();
470
+
471
+ const root = Yoga.Node.create(config);
472
+ root.setPositionType(PositionType.Absolute);
473
+ root.setFlexDirection(FlexDirection.Row);
474
+ root.setFlexWrap(Wrap.Wrap);
475
+ root.setWidth(80);
476
+ root.setGap(Gutter.Column, 10);
477
+ root.setGap(Gutter.Row, 20);
478
+
479
+ const root_child0 = Yoga.Node.create(config);
480
+ root_child0.setWidth(20);
481
+ root_child0.setHeight(20);
482
+ root_child0.setPositionType(PositionType.Absolute);
483
+ root.insertChild(root_child0, 0);
484
+
485
+ const root_child1 = Yoga.Node.create(config);
486
+ root_child1.setWidth(20);
487
+ root_child1.setHeight(20);
488
+ root.insertChild(root_child1, 1);
489
+
490
+ const root_child2 = Yoga.Node.create(config);
491
+ root_child2.setWidth(20);
492
+ root_child2.setHeight(20);
493
+ root.insertChild(root_child2, 2);
494
+
495
+ const root_child3 = Yoga.Node.create(config);
496
+ root_child3.setWidth(20);
497
+ root_child3.setHeight(20);
498
+ root.insertChild(root_child3, 3);
499
+ root.calculateLayout(undefined, undefined, Direction.LTR);
500
+
501
+ expect(root.getComputedLeft()).toBe(0);
502
+ expect(root.getComputedTop()).toBe(0);
503
+ expect(root.getComputedWidth()).toBe(80);
504
+ expect(root.getComputedHeight()).toBe(20);
505
+
506
+ expect(root_child0.getComputedLeft()).toBe(0);
507
+ expect(root_child0.getComputedTop()).toBe(0);
508
+ expect(root_child0.getComputedWidth()).toBe(20);
509
+ expect(root_child0.getComputedHeight()).toBe(20);
510
+
511
+ expect(root_child1.getComputedLeft()).toBe(0);
512
+ expect(root_child1.getComputedTop()).toBe(0);
513
+ expect(root_child1.getComputedWidth()).toBe(20);
514
+ expect(root_child1.getComputedHeight()).toBe(20);
515
+
516
+ expect(root_child2.getComputedLeft()).toBe(30);
517
+ expect(root_child2.getComputedTop()).toBe(0);
518
+ expect(root_child2.getComputedWidth()).toBe(20);
519
+ expect(root_child2.getComputedHeight()).toBe(20);
520
+
521
+ expect(root_child3.getComputedLeft()).toBe(60);
522
+ expect(root_child3.getComputedTop()).toBe(0);
523
+ expect(root_child3.getComputedWidth()).toBe(20);
524
+ expect(root_child3.getComputedHeight()).toBe(20);
525
+
526
+ root.calculateLayout(undefined, undefined, Direction.RTL);
527
+
528
+ expect(root.getComputedLeft()).toBe(0);
529
+ expect(root.getComputedTop()).toBe(0);
530
+ expect(root.getComputedWidth()).toBe(80);
531
+ expect(root.getComputedHeight()).toBe(20);
532
+
533
+ expect(root_child0.getComputedLeft()).toBe(60);
534
+ expect(root_child0.getComputedTop()).toBe(0);
535
+ expect(root_child0.getComputedWidth()).toBe(20);
536
+ expect(root_child0.getComputedHeight()).toBe(20);
537
+
538
+ expect(root_child1.getComputedLeft()).toBe(60);
539
+ expect(root_child1.getComputedTop()).toBe(0);
540
+ expect(root_child1.getComputedWidth()).toBe(20);
541
+ expect(root_child1.getComputedHeight()).toBe(20);
542
+
543
+ expect(root_child2.getComputedLeft()).toBe(30);
544
+ expect(root_child2.getComputedTop()).toBe(0);
545
+ expect(root_child2.getComputedWidth()).toBe(20);
546
+ expect(root_child2.getComputedHeight()).toBe(20);
547
+
548
+ expect(root_child3.getComputedLeft()).toBe(0);
549
+ expect(root_child3.getComputedTop()).toBe(0);
550
+ expect(root_child3.getComputedWidth()).toBe(20);
551
+ expect(root_child3.getComputedHeight()).toBe(20);
552
+ });
553
+ test('column_gap_justify_flex_start', () => {
554
+ const config = Yoga.Config.create();
555
+
556
+ const root = Yoga.Node.create(config);
557
+ root.setPositionType(PositionType.Absolute);
558
+ root.setFlexDirection(FlexDirection.Row);
559
+ root.setWidth(100);
560
+ root.setHeight(100);
561
+ root.setGap(Gutter.Column, 10);
562
+
563
+ const root_child0 = Yoga.Node.create(config);
564
+ root_child0.setWidth(20);
565
+ root.insertChild(root_child0, 0);
566
+
567
+ const root_child1 = Yoga.Node.create(config);
568
+ root_child1.setWidth(20);
569
+ root.insertChild(root_child1, 1);
570
+
571
+ const root_child2 = Yoga.Node.create(config);
572
+ root_child2.setWidth(20);
573
+ root.insertChild(root_child2, 2);
574
+ root.calculateLayout(undefined, undefined, Direction.LTR);
575
+
576
+ expect(root.getComputedLeft()).toBe(0);
577
+ expect(root.getComputedTop()).toBe(0);
578
+ expect(root.getComputedWidth()).toBe(100);
579
+ expect(root.getComputedHeight()).toBe(100);
580
+
581
+ expect(root_child0.getComputedLeft()).toBe(0);
582
+ expect(root_child0.getComputedTop()).toBe(0);
583
+ expect(root_child0.getComputedWidth()).toBe(20);
584
+ expect(root_child0.getComputedHeight()).toBe(100);
585
+
586
+ expect(root_child1.getComputedLeft()).toBe(30);
587
+ expect(root_child1.getComputedTop()).toBe(0);
588
+ expect(root_child1.getComputedWidth()).toBe(20);
589
+ expect(root_child1.getComputedHeight()).toBe(100);
590
+
591
+ expect(root_child2.getComputedLeft()).toBe(60);
592
+ expect(root_child2.getComputedTop()).toBe(0);
593
+ expect(root_child2.getComputedWidth()).toBe(20);
594
+ expect(root_child2.getComputedHeight()).toBe(100);
595
+
596
+ root.calculateLayout(undefined, undefined, Direction.RTL);
597
+
598
+ expect(root.getComputedLeft()).toBe(0);
599
+ expect(root.getComputedTop()).toBe(0);
600
+ expect(root.getComputedWidth()).toBe(100);
601
+ expect(root.getComputedHeight()).toBe(100);
602
+
603
+ expect(root_child0.getComputedLeft()).toBe(80);
604
+ expect(root_child0.getComputedTop()).toBe(0);
605
+ expect(root_child0.getComputedWidth()).toBe(20);
606
+ expect(root_child0.getComputedHeight()).toBe(100);
607
+
608
+ expect(root_child1.getComputedLeft()).toBe(50);
609
+ expect(root_child1.getComputedTop()).toBe(0);
610
+ expect(root_child1.getComputedWidth()).toBe(20);
611
+ expect(root_child1.getComputedHeight()).toBe(100);
612
+
613
+ expect(root_child2.getComputedLeft()).toBe(20);
614
+ expect(root_child2.getComputedTop()).toBe(0);
615
+ expect(root_child2.getComputedWidth()).toBe(20);
616
+ expect(root_child2.getComputedHeight()).toBe(100);
617
+ });
618
+ test('column_gap_justify_center', () => {
619
+ const config = Yoga.Config.create();
620
+
621
+ const root = Yoga.Node.create(config);
622
+ root.setPositionType(PositionType.Absolute);
623
+ root.setFlexDirection(FlexDirection.Row);
624
+ root.setJustifyContent(Justify.Center);
625
+ root.setWidth(100);
626
+ root.setHeight(100);
627
+ root.setGap(Gutter.Column, 10);
628
+
629
+ const root_child0 = Yoga.Node.create(config);
630
+ root_child0.setWidth(20);
631
+ root.insertChild(root_child0, 0);
632
+
633
+ const root_child1 = Yoga.Node.create(config);
634
+ root_child1.setWidth(20);
635
+ root.insertChild(root_child1, 1);
636
+
637
+ const root_child2 = Yoga.Node.create(config);
638
+ root_child2.setWidth(20);
639
+ root.insertChild(root_child2, 2);
640
+ root.calculateLayout(undefined, undefined, Direction.LTR);
641
+
642
+ expect(root.getComputedLeft()).toBe(0);
643
+ expect(root.getComputedTop()).toBe(0);
644
+ expect(root.getComputedWidth()).toBe(100);
645
+ expect(root.getComputedHeight()).toBe(100);
646
+
647
+ expect(root_child0.getComputedLeft()).toBe(10);
648
+ expect(root_child0.getComputedTop()).toBe(0);
649
+ expect(root_child0.getComputedWidth()).toBe(20);
650
+ expect(root_child0.getComputedHeight()).toBe(100);
651
+
652
+ expect(root_child1.getComputedLeft()).toBe(40);
653
+ expect(root_child1.getComputedTop()).toBe(0);
654
+ expect(root_child1.getComputedWidth()).toBe(20);
655
+ expect(root_child1.getComputedHeight()).toBe(100);
656
+
657
+ expect(root_child2.getComputedLeft()).toBe(70);
658
+ expect(root_child2.getComputedTop()).toBe(0);
659
+ expect(root_child2.getComputedWidth()).toBe(20);
660
+ expect(root_child2.getComputedHeight()).toBe(100);
661
+
662
+ root.calculateLayout(undefined, undefined, Direction.RTL);
663
+
664
+ expect(root.getComputedLeft()).toBe(0);
665
+ expect(root.getComputedTop()).toBe(0);
666
+ expect(root.getComputedWidth()).toBe(100);
667
+ expect(root.getComputedHeight()).toBe(100);
668
+
669
+ expect(root_child0.getComputedLeft()).toBe(70);
670
+ expect(root_child0.getComputedTop()).toBe(0);
671
+ expect(root_child0.getComputedWidth()).toBe(20);
672
+ expect(root_child0.getComputedHeight()).toBe(100);
673
+
674
+ expect(root_child1.getComputedLeft()).toBe(40);
675
+ expect(root_child1.getComputedTop()).toBe(0);
676
+ expect(root_child1.getComputedWidth()).toBe(20);
677
+ expect(root_child1.getComputedHeight()).toBe(100);
678
+
679
+ expect(root_child2.getComputedLeft()).toBe(10);
680
+ expect(root_child2.getComputedTop()).toBe(0);
681
+ expect(root_child2.getComputedWidth()).toBe(20);
682
+ expect(root_child2.getComputedHeight()).toBe(100);
683
+ });
684
+ test('column_gap_justify_flex_end', () => {
685
+ const config = Yoga.Config.create();
686
+
687
+ const root = Yoga.Node.create(config);
688
+ root.setPositionType(PositionType.Absolute);
689
+ root.setFlexDirection(FlexDirection.Row);
690
+ root.setJustifyContent(Justify.FlexEnd);
691
+ root.setWidth(100);
692
+ root.setHeight(100);
693
+ root.setGap(Gutter.Column, 10);
694
+
695
+ const root_child0 = Yoga.Node.create(config);
696
+ root_child0.setWidth(20);
697
+ root.insertChild(root_child0, 0);
698
+
699
+ const root_child1 = Yoga.Node.create(config);
700
+ root_child1.setWidth(20);
701
+ root.insertChild(root_child1, 1);
702
+
703
+ const root_child2 = Yoga.Node.create(config);
704
+ root_child2.setWidth(20);
705
+ root.insertChild(root_child2, 2);
706
+ root.calculateLayout(undefined, undefined, Direction.LTR);
707
+
708
+ expect(root.getComputedLeft()).toBe(0);
709
+ expect(root.getComputedTop()).toBe(0);
710
+ expect(root.getComputedWidth()).toBe(100);
711
+ expect(root.getComputedHeight()).toBe(100);
712
+
713
+ expect(root_child0.getComputedLeft()).toBe(20);
714
+ expect(root_child0.getComputedTop()).toBe(0);
715
+ expect(root_child0.getComputedWidth()).toBe(20);
716
+ expect(root_child0.getComputedHeight()).toBe(100);
717
+
718
+ expect(root_child1.getComputedLeft()).toBe(50);
719
+ expect(root_child1.getComputedTop()).toBe(0);
720
+ expect(root_child1.getComputedWidth()).toBe(20);
721
+ expect(root_child1.getComputedHeight()).toBe(100);
722
+
723
+ expect(root_child2.getComputedLeft()).toBe(80);
724
+ expect(root_child2.getComputedTop()).toBe(0);
725
+ expect(root_child2.getComputedWidth()).toBe(20);
726
+ expect(root_child2.getComputedHeight()).toBe(100);
727
+
728
+ root.calculateLayout(undefined, undefined, Direction.RTL);
729
+
730
+ expect(root.getComputedLeft()).toBe(0);
731
+ expect(root.getComputedTop()).toBe(0);
732
+ expect(root.getComputedWidth()).toBe(100);
733
+ expect(root.getComputedHeight()).toBe(100);
734
+
735
+ expect(root_child0.getComputedLeft()).toBe(60);
736
+ expect(root_child0.getComputedTop()).toBe(0);
737
+ expect(root_child0.getComputedWidth()).toBe(20);
738
+ expect(root_child0.getComputedHeight()).toBe(100);
739
+
740
+ expect(root_child1.getComputedLeft()).toBe(30);
741
+ expect(root_child1.getComputedTop()).toBe(0);
742
+ expect(root_child1.getComputedWidth()).toBe(20);
743
+ expect(root_child1.getComputedHeight()).toBe(100);
744
+
745
+ expect(root_child2.getComputedLeft()).toBe(0);
746
+ expect(root_child2.getComputedTop()).toBe(0);
747
+ expect(root_child2.getComputedWidth()).toBe(20);
748
+ expect(root_child2.getComputedHeight()).toBe(100);
749
+ });
750
+ test('column_gap_justify_space_between', () => {
751
+ const config = Yoga.Config.create();
752
+
753
+ const root = Yoga.Node.create(config);
754
+ root.setPositionType(PositionType.Absolute);
755
+ root.setFlexDirection(FlexDirection.Row);
756
+ root.setJustifyContent(Justify.SpaceBetween);
757
+ root.setWidth(100);
758
+ root.setHeight(100);
759
+ root.setGap(Gutter.Column, 10);
760
+
761
+ const root_child0 = Yoga.Node.create(config);
762
+ root_child0.setWidth(20);
763
+ root.insertChild(root_child0, 0);
764
+
765
+ const root_child1 = Yoga.Node.create(config);
766
+ root_child1.setWidth(20);
767
+ root.insertChild(root_child1, 1);
768
+
769
+ const root_child2 = Yoga.Node.create(config);
770
+ root_child2.setWidth(20);
771
+ root.insertChild(root_child2, 2);
772
+ root.calculateLayout(undefined, undefined, Direction.LTR);
773
+
774
+ expect(root.getComputedLeft()).toBe(0);
775
+ expect(root.getComputedTop()).toBe(0);
776
+ expect(root.getComputedWidth()).toBe(100);
777
+ expect(root.getComputedHeight()).toBe(100);
778
+
779
+ expect(root_child0.getComputedLeft()).toBe(0);
780
+ expect(root_child0.getComputedTop()).toBe(0);
781
+ expect(root_child0.getComputedWidth()).toBe(20);
782
+ expect(root_child0.getComputedHeight()).toBe(100);
783
+
784
+ expect(root_child1.getComputedLeft()).toBe(40);
785
+ expect(root_child1.getComputedTop()).toBe(0);
786
+ expect(root_child1.getComputedWidth()).toBe(20);
787
+ expect(root_child1.getComputedHeight()).toBe(100);
788
+
789
+ expect(root_child2.getComputedLeft()).toBe(80);
790
+ expect(root_child2.getComputedTop()).toBe(0);
791
+ expect(root_child2.getComputedWidth()).toBe(20);
792
+ expect(root_child2.getComputedHeight()).toBe(100);
793
+
794
+ root.calculateLayout(undefined, undefined, Direction.RTL);
795
+
796
+ expect(root.getComputedLeft()).toBe(0);
797
+ expect(root.getComputedTop()).toBe(0);
798
+ expect(root.getComputedWidth()).toBe(100);
799
+ expect(root.getComputedHeight()).toBe(100);
800
+
801
+ expect(root_child0.getComputedLeft()).toBe(80);
802
+ expect(root_child0.getComputedTop()).toBe(0);
803
+ expect(root_child0.getComputedWidth()).toBe(20);
804
+ expect(root_child0.getComputedHeight()).toBe(100);
805
+
806
+ expect(root_child1.getComputedLeft()).toBe(40);
807
+ expect(root_child1.getComputedTop()).toBe(0);
808
+ expect(root_child1.getComputedWidth()).toBe(20);
809
+ expect(root_child1.getComputedHeight()).toBe(100);
810
+
811
+ expect(root_child2.getComputedLeft()).toBe(0);
812
+ expect(root_child2.getComputedTop()).toBe(0);
813
+ expect(root_child2.getComputedWidth()).toBe(20);
814
+ expect(root_child2.getComputedHeight()).toBe(100);
815
+ });
816
+ test('column_gap_justify_space_around', () => {
817
+ const config = Yoga.Config.create();
818
+
819
+ const root = Yoga.Node.create(config);
820
+ root.setPositionType(PositionType.Absolute);
821
+ root.setFlexDirection(FlexDirection.Row);
822
+ root.setJustifyContent(Justify.SpaceAround);
823
+ root.setWidth(100);
824
+ root.setHeight(100);
825
+ root.setGap(Gutter.Column, 10);
826
+
827
+ const root_child0 = Yoga.Node.create(config);
828
+ root_child0.setWidth(20);
829
+ root.insertChild(root_child0, 0);
830
+
831
+ const root_child1 = Yoga.Node.create(config);
832
+ root_child1.setWidth(20);
833
+ root.insertChild(root_child1, 1);
834
+
835
+ const root_child2 = Yoga.Node.create(config);
836
+ root_child2.setWidth(20);
837
+ root.insertChild(root_child2, 2);
838
+ root.calculateLayout(undefined, undefined, Direction.LTR);
839
+
840
+ expect(root.getComputedLeft()).toBe(0);
841
+ expect(root.getComputedTop()).toBe(0);
842
+ expect(root.getComputedWidth()).toBe(100);
843
+ expect(root.getComputedHeight()).toBe(100);
844
+
845
+ expect(root_child0.getComputedLeft()).toBe(3);
846
+ expect(root_child0.getComputedTop()).toBe(0);
847
+ expect(root_child0.getComputedWidth()).toBe(20);
848
+ expect(root_child0.getComputedHeight()).toBe(100);
849
+
850
+ expect(root_child1.getComputedLeft()).toBe(40);
851
+ expect(root_child1.getComputedTop()).toBe(0);
852
+ expect(root_child1.getComputedWidth()).toBe(20);
853
+ expect(root_child1.getComputedHeight()).toBe(100);
854
+
855
+ expect(root_child2.getComputedLeft()).toBe(77);
856
+ expect(root_child2.getComputedTop()).toBe(0);
857
+ expect(root_child2.getComputedWidth()).toBe(20);
858
+ expect(root_child2.getComputedHeight()).toBe(100);
859
+
860
+ root.calculateLayout(undefined, undefined, Direction.RTL);
861
+
862
+ expect(root.getComputedLeft()).toBe(0);
863
+ expect(root.getComputedTop()).toBe(0);
864
+ expect(root.getComputedWidth()).toBe(100);
865
+ expect(root.getComputedHeight()).toBe(100);
866
+
867
+ expect(root_child0.getComputedLeft()).toBe(77);
868
+ expect(root_child0.getComputedTop()).toBe(0);
869
+ expect(root_child0.getComputedWidth()).toBe(20);
870
+ expect(root_child0.getComputedHeight()).toBe(100);
871
+
872
+ expect(root_child1.getComputedLeft()).toBe(40);
873
+ expect(root_child1.getComputedTop()).toBe(0);
874
+ expect(root_child1.getComputedWidth()).toBe(20);
875
+ expect(root_child1.getComputedHeight()).toBe(100);
876
+
877
+ expect(root_child2.getComputedLeft()).toBe(3);
878
+ expect(root_child2.getComputedTop()).toBe(0);
879
+ expect(root_child2.getComputedWidth()).toBe(20);
880
+ expect(root_child2.getComputedHeight()).toBe(100);
881
+ });
882
+ test('column_gap_justify_space_evenly', () => {
883
+ const config = Yoga.Config.create();
884
+
885
+ const root = Yoga.Node.create(config);
886
+ root.setPositionType(PositionType.Absolute);
887
+ root.setFlexDirection(FlexDirection.Row);
888
+ root.setJustifyContent(Justify.SpaceEvenly);
889
+ root.setWidth(100);
890
+ root.setHeight(100);
891
+ root.setGap(Gutter.Column, 10);
892
+
893
+ const root_child0 = Yoga.Node.create(config);
894
+ root_child0.setWidth(20);
895
+ root.insertChild(root_child0, 0);
896
+
897
+ const root_child1 = Yoga.Node.create(config);
898
+ root_child1.setWidth(20);
899
+ root.insertChild(root_child1, 1);
900
+
901
+ const root_child2 = Yoga.Node.create(config);
902
+ root_child2.setWidth(20);
903
+ root.insertChild(root_child2, 2);
904
+ root.calculateLayout(undefined, undefined, Direction.LTR);
905
+
906
+ expect(root.getComputedLeft()).toBe(0);
907
+ expect(root.getComputedTop()).toBe(0);
908
+ expect(root.getComputedWidth()).toBe(100);
909
+ expect(root.getComputedHeight()).toBe(100);
910
+
911
+ expect(root_child0.getComputedLeft()).toBe(5);
912
+ expect(root_child0.getComputedTop()).toBe(0);
913
+ expect(root_child0.getComputedWidth()).toBe(20);
914
+ expect(root_child0.getComputedHeight()).toBe(100);
915
+
916
+ expect(root_child1.getComputedLeft()).toBe(40);
917
+ expect(root_child1.getComputedTop()).toBe(0);
918
+ expect(root_child1.getComputedWidth()).toBe(20);
919
+ expect(root_child1.getComputedHeight()).toBe(100);
920
+
921
+ expect(root_child2.getComputedLeft()).toBe(75);
922
+ expect(root_child2.getComputedTop()).toBe(0);
923
+ expect(root_child2.getComputedWidth()).toBe(20);
924
+ expect(root_child2.getComputedHeight()).toBe(100);
925
+
926
+ root.calculateLayout(undefined, undefined, Direction.RTL);
927
+
928
+ expect(root.getComputedLeft()).toBe(0);
929
+ expect(root.getComputedTop()).toBe(0);
930
+ expect(root.getComputedWidth()).toBe(100);
931
+ expect(root.getComputedHeight()).toBe(100);
932
+
933
+ expect(root_child0.getComputedLeft()).toBe(75);
934
+ expect(root_child0.getComputedTop()).toBe(0);
935
+ expect(root_child0.getComputedWidth()).toBe(20);
936
+ expect(root_child0.getComputedHeight()).toBe(100);
937
+
938
+ expect(root_child1.getComputedLeft()).toBe(40);
939
+ expect(root_child1.getComputedTop()).toBe(0);
940
+ expect(root_child1.getComputedWidth()).toBe(20);
941
+ expect(root_child1.getComputedHeight()).toBe(100);
942
+
943
+ expect(root_child2.getComputedLeft()).toBe(5);
944
+ expect(root_child2.getComputedTop()).toBe(0);
945
+ expect(root_child2.getComputedWidth()).toBe(20);
946
+ expect(root_child2.getComputedHeight()).toBe(100);
947
+ });
948
+ test('column_gap_wrap_align_flex_start', () => {
949
+ const config = Yoga.Config.create();
950
+
951
+ const root = Yoga.Node.create(config);
952
+ root.setPositionType(PositionType.Absolute);
953
+ root.setFlexDirection(FlexDirection.Row);
954
+ root.setFlexWrap(Wrap.Wrap);
955
+ root.setWidth(100);
956
+ root.setHeight(100);
957
+ root.setGap(Gutter.Column, 10);
958
+ root.setGap(Gutter.Row, 20);
959
+
960
+ const root_child0 = Yoga.Node.create(config);
961
+ root_child0.setWidth(20);
962
+ root_child0.setHeight(20);
963
+ root.insertChild(root_child0, 0);
964
+
965
+ const root_child1 = Yoga.Node.create(config);
966
+ root_child1.setWidth(20);
967
+ root_child1.setHeight(20);
968
+ root.insertChild(root_child1, 1);
969
+
970
+ const root_child2 = Yoga.Node.create(config);
971
+ root_child2.setWidth(20);
972
+ root_child2.setHeight(20);
973
+ root.insertChild(root_child2, 2);
974
+
975
+ const root_child3 = Yoga.Node.create(config);
976
+ root_child3.setWidth(20);
977
+ root_child3.setHeight(20);
978
+ root.insertChild(root_child3, 3);
979
+
980
+ const root_child4 = Yoga.Node.create(config);
981
+ root_child4.setWidth(20);
982
+ root_child4.setHeight(20);
983
+ root.insertChild(root_child4, 4);
984
+
985
+ const root_child5 = Yoga.Node.create(config);
986
+ root_child5.setWidth(20);
987
+ root_child5.setHeight(20);
988
+ root.insertChild(root_child5, 5);
989
+ root.calculateLayout(undefined, undefined, Direction.LTR);
990
+
991
+ expect(root.getComputedLeft()).toBe(0);
992
+ expect(root.getComputedTop()).toBe(0);
993
+ expect(root.getComputedWidth()).toBe(100);
994
+ expect(root.getComputedHeight()).toBe(100);
995
+
996
+ expect(root_child0.getComputedLeft()).toBe(0);
997
+ expect(root_child0.getComputedTop()).toBe(0);
998
+ expect(root_child0.getComputedWidth()).toBe(20);
999
+ expect(root_child0.getComputedHeight()).toBe(20);
1000
+
1001
+ expect(root_child1.getComputedLeft()).toBe(30);
1002
+ expect(root_child1.getComputedTop()).toBe(0);
1003
+ expect(root_child1.getComputedWidth()).toBe(20);
1004
+ expect(root_child1.getComputedHeight()).toBe(20);
1005
+
1006
+ expect(root_child2.getComputedLeft()).toBe(60);
1007
+ expect(root_child2.getComputedTop()).toBe(0);
1008
+ expect(root_child2.getComputedWidth()).toBe(20);
1009
+ expect(root_child2.getComputedHeight()).toBe(20);
1010
+
1011
+ expect(root_child3.getComputedLeft()).toBe(0);
1012
+ expect(root_child3.getComputedTop()).toBe(40);
1013
+ expect(root_child3.getComputedWidth()).toBe(20);
1014
+ expect(root_child3.getComputedHeight()).toBe(20);
1015
+
1016
+ expect(root_child4.getComputedLeft()).toBe(30);
1017
+ expect(root_child4.getComputedTop()).toBe(40);
1018
+ expect(root_child4.getComputedWidth()).toBe(20);
1019
+ expect(root_child4.getComputedHeight()).toBe(20);
1020
+
1021
+ expect(root_child5.getComputedLeft()).toBe(60);
1022
+ expect(root_child5.getComputedTop()).toBe(40);
1023
+ expect(root_child5.getComputedWidth()).toBe(20);
1024
+ expect(root_child5.getComputedHeight()).toBe(20);
1025
+
1026
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1027
+
1028
+ expect(root.getComputedLeft()).toBe(0);
1029
+ expect(root.getComputedTop()).toBe(0);
1030
+ expect(root.getComputedWidth()).toBe(100);
1031
+ expect(root.getComputedHeight()).toBe(100);
1032
+
1033
+ expect(root_child0.getComputedLeft()).toBe(80);
1034
+ expect(root_child0.getComputedTop()).toBe(0);
1035
+ expect(root_child0.getComputedWidth()).toBe(20);
1036
+ expect(root_child0.getComputedHeight()).toBe(20);
1037
+
1038
+ expect(root_child1.getComputedLeft()).toBe(50);
1039
+ expect(root_child1.getComputedTop()).toBe(0);
1040
+ expect(root_child1.getComputedWidth()).toBe(20);
1041
+ expect(root_child1.getComputedHeight()).toBe(20);
1042
+
1043
+ expect(root_child2.getComputedLeft()).toBe(20);
1044
+ expect(root_child2.getComputedTop()).toBe(0);
1045
+ expect(root_child2.getComputedWidth()).toBe(20);
1046
+ expect(root_child2.getComputedHeight()).toBe(20);
1047
+
1048
+ expect(root_child3.getComputedLeft()).toBe(80);
1049
+ expect(root_child3.getComputedTop()).toBe(40);
1050
+ expect(root_child3.getComputedWidth()).toBe(20);
1051
+ expect(root_child3.getComputedHeight()).toBe(20);
1052
+
1053
+ expect(root_child4.getComputedLeft()).toBe(50);
1054
+ expect(root_child4.getComputedTop()).toBe(40);
1055
+ expect(root_child4.getComputedWidth()).toBe(20);
1056
+ expect(root_child4.getComputedHeight()).toBe(20);
1057
+
1058
+ expect(root_child5.getComputedLeft()).toBe(20);
1059
+ expect(root_child5.getComputedTop()).toBe(40);
1060
+ expect(root_child5.getComputedWidth()).toBe(20);
1061
+ expect(root_child5.getComputedHeight()).toBe(20);
1062
+ });
1063
+ test('column_gap_wrap_align_center', () => {
1064
+ const config = Yoga.Config.create();
1065
+
1066
+ const root = Yoga.Node.create(config);
1067
+ root.setPositionType(PositionType.Absolute);
1068
+ root.setFlexDirection(FlexDirection.Row);
1069
+ root.setFlexWrap(Wrap.Wrap);
1070
+ root.setAlignContent(Align.Center);
1071
+ root.setWidth(100);
1072
+ root.setHeight(100);
1073
+ root.setGap(Gutter.Column, 10);
1074
+ root.setGap(Gutter.Row, 20);
1075
+
1076
+ const root_child0 = Yoga.Node.create(config);
1077
+ root_child0.setWidth(20);
1078
+ root_child0.setHeight(20);
1079
+ root.insertChild(root_child0, 0);
1080
+
1081
+ const root_child1 = Yoga.Node.create(config);
1082
+ root_child1.setWidth(20);
1083
+ root_child1.setHeight(20);
1084
+ root.insertChild(root_child1, 1);
1085
+
1086
+ const root_child2 = Yoga.Node.create(config);
1087
+ root_child2.setWidth(20);
1088
+ root_child2.setHeight(20);
1089
+ root.insertChild(root_child2, 2);
1090
+
1091
+ const root_child3 = Yoga.Node.create(config);
1092
+ root_child3.setWidth(20);
1093
+ root_child3.setHeight(20);
1094
+ root.insertChild(root_child3, 3);
1095
+
1096
+ const root_child4 = Yoga.Node.create(config);
1097
+ root_child4.setWidth(20);
1098
+ root_child4.setHeight(20);
1099
+ root.insertChild(root_child4, 4);
1100
+
1101
+ const root_child5 = Yoga.Node.create(config);
1102
+ root_child5.setWidth(20);
1103
+ root_child5.setHeight(20);
1104
+ root.insertChild(root_child5, 5);
1105
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1106
+
1107
+ expect(root.getComputedLeft()).toBe(0);
1108
+ expect(root.getComputedTop()).toBe(0);
1109
+ expect(root.getComputedWidth()).toBe(100);
1110
+ expect(root.getComputedHeight()).toBe(100);
1111
+
1112
+ expect(root_child0.getComputedLeft()).toBe(0);
1113
+ expect(root_child0.getComputedTop()).toBe(20);
1114
+ expect(root_child0.getComputedWidth()).toBe(20);
1115
+ expect(root_child0.getComputedHeight()).toBe(20);
1116
+
1117
+ expect(root_child1.getComputedLeft()).toBe(30);
1118
+ expect(root_child1.getComputedTop()).toBe(20);
1119
+ expect(root_child1.getComputedWidth()).toBe(20);
1120
+ expect(root_child1.getComputedHeight()).toBe(20);
1121
+
1122
+ expect(root_child2.getComputedLeft()).toBe(60);
1123
+ expect(root_child2.getComputedTop()).toBe(20);
1124
+ expect(root_child2.getComputedWidth()).toBe(20);
1125
+ expect(root_child2.getComputedHeight()).toBe(20);
1126
+
1127
+ expect(root_child3.getComputedLeft()).toBe(0);
1128
+ expect(root_child3.getComputedTop()).toBe(60);
1129
+ expect(root_child3.getComputedWidth()).toBe(20);
1130
+ expect(root_child3.getComputedHeight()).toBe(20);
1131
+
1132
+ expect(root_child4.getComputedLeft()).toBe(30);
1133
+ expect(root_child4.getComputedTop()).toBe(60);
1134
+ expect(root_child4.getComputedWidth()).toBe(20);
1135
+ expect(root_child4.getComputedHeight()).toBe(20);
1136
+
1137
+ expect(root_child5.getComputedLeft()).toBe(60);
1138
+ expect(root_child5.getComputedTop()).toBe(60);
1139
+ expect(root_child5.getComputedWidth()).toBe(20);
1140
+ expect(root_child5.getComputedHeight()).toBe(20);
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(100);
1147
+ expect(root.getComputedHeight()).toBe(100);
1148
+
1149
+ expect(root_child0.getComputedLeft()).toBe(80);
1150
+ expect(root_child0.getComputedTop()).toBe(20);
1151
+ expect(root_child0.getComputedWidth()).toBe(20);
1152
+ expect(root_child0.getComputedHeight()).toBe(20);
1153
+
1154
+ expect(root_child1.getComputedLeft()).toBe(50);
1155
+ expect(root_child1.getComputedTop()).toBe(20);
1156
+ expect(root_child1.getComputedWidth()).toBe(20);
1157
+ expect(root_child1.getComputedHeight()).toBe(20);
1158
+
1159
+ expect(root_child2.getComputedLeft()).toBe(20);
1160
+ expect(root_child2.getComputedTop()).toBe(20);
1161
+ expect(root_child2.getComputedWidth()).toBe(20);
1162
+ expect(root_child2.getComputedHeight()).toBe(20);
1163
+
1164
+ expect(root_child3.getComputedLeft()).toBe(80);
1165
+ expect(root_child3.getComputedTop()).toBe(60);
1166
+ expect(root_child3.getComputedWidth()).toBe(20);
1167
+ expect(root_child3.getComputedHeight()).toBe(20);
1168
+
1169
+ expect(root_child4.getComputedLeft()).toBe(50);
1170
+ expect(root_child4.getComputedTop()).toBe(60);
1171
+ expect(root_child4.getComputedWidth()).toBe(20);
1172
+ expect(root_child4.getComputedHeight()).toBe(20);
1173
+
1174
+ expect(root_child5.getComputedLeft()).toBe(20);
1175
+ expect(root_child5.getComputedTop()).toBe(60);
1176
+ expect(root_child5.getComputedWidth()).toBe(20);
1177
+ expect(root_child5.getComputedHeight()).toBe(20);
1178
+ });
1179
+ test('column_gap_wrap_align_flex_end', () => {
1180
+ const config = Yoga.Config.create();
1181
+
1182
+ const root = Yoga.Node.create(config);
1183
+ root.setPositionType(PositionType.Absolute);
1184
+ root.setFlexDirection(FlexDirection.Row);
1185
+ root.setFlexWrap(Wrap.Wrap);
1186
+ root.setAlignContent(Align.FlexEnd);
1187
+ root.setWidth(100);
1188
+ root.setHeight(100);
1189
+ root.setGap(Gutter.Column, 10);
1190
+ root.setGap(Gutter.Row, 20);
1191
+
1192
+ const root_child0 = Yoga.Node.create(config);
1193
+ root_child0.setWidth(20);
1194
+ root_child0.setHeight(20);
1195
+ root.insertChild(root_child0, 0);
1196
+
1197
+ const root_child1 = Yoga.Node.create(config);
1198
+ root_child1.setWidth(20);
1199
+ root_child1.setHeight(20);
1200
+ root.insertChild(root_child1, 1);
1201
+
1202
+ const root_child2 = Yoga.Node.create(config);
1203
+ root_child2.setWidth(20);
1204
+ root_child2.setHeight(20);
1205
+ root.insertChild(root_child2, 2);
1206
+
1207
+ const root_child3 = Yoga.Node.create(config);
1208
+ root_child3.setWidth(20);
1209
+ root_child3.setHeight(20);
1210
+ root.insertChild(root_child3, 3);
1211
+
1212
+ const root_child4 = Yoga.Node.create(config);
1213
+ root_child4.setWidth(20);
1214
+ root_child4.setHeight(20);
1215
+ root.insertChild(root_child4, 4);
1216
+
1217
+ const root_child5 = Yoga.Node.create(config);
1218
+ root_child5.setWidth(20);
1219
+ root_child5.setHeight(20);
1220
+ root.insertChild(root_child5, 5);
1221
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1222
+
1223
+ expect(root.getComputedLeft()).toBe(0);
1224
+ expect(root.getComputedTop()).toBe(0);
1225
+ expect(root.getComputedWidth()).toBe(100);
1226
+ expect(root.getComputedHeight()).toBe(100);
1227
+
1228
+ expect(root_child0.getComputedLeft()).toBe(0);
1229
+ expect(root_child0.getComputedTop()).toBe(40);
1230
+ expect(root_child0.getComputedWidth()).toBe(20);
1231
+ expect(root_child0.getComputedHeight()).toBe(20);
1232
+
1233
+ expect(root_child1.getComputedLeft()).toBe(30);
1234
+ expect(root_child1.getComputedTop()).toBe(40);
1235
+ expect(root_child1.getComputedWidth()).toBe(20);
1236
+ expect(root_child1.getComputedHeight()).toBe(20);
1237
+
1238
+ expect(root_child2.getComputedLeft()).toBe(60);
1239
+ expect(root_child2.getComputedTop()).toBe(40);
1240
+ expect(root_child2.getComputedWidth()).toBe(20);
1241
+ expect(root_child2.getComputedHeight()).toBe(20);
1242
+
1243
+ expect(root_child3.getComputedLeft()).toBe(0);
1244
+ expect(root_child3.getComputedTop()).toBe(80);
1245
+ expect(root_child3.getComputedWidth()).toBe(20);
1246
+ expect(root_child3.getComputedHeight()).toBe(20);
1247
+
1248
+ expect(root_child4.getComputedLeft()).toBe(30);
1249
+ expect(root_child4.getComputedTop()).toBe(80);
1250
+ expect(root_child4.getComputedWidth()).toBe(20);
1251
+ expect(root_child4.getComputedHeight()).toBe(20);
1252
+
1253
+ expect(root_child5.getComputedLeft()).toBe(60);
1254
+ expect(root_child5.getComputedTop()).toBe(80);
1255
+ expect(root_child5.getComputedWidth()).toBe(20);
1256
+ expect(root_child5.getComputedHeight()).toBe(20);
1257
+
1258
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1259
+
1260
+ expect(root.getComputedLeft()).toBe(0);
1261
+ expect(root.getComputedTop()).toBe(0);
1262
+ expect(root.getComputedWidth()).toBe(100);
1263
+ expect(root.getComputedHeight()).toBe(100);
1264
+
1265
+ expect(root_child0.getComputedLeft()).toBe(80);
1266
+ expect(root_child0.getComputedTop()).toBe(40);
1267
+ expect(root_child0.getComputedWidth()).toBe(20);
1268
+ expect(root_child0.getComputedHeight()).toBe(20);
1269
+
1270
+ expect(root_child1.getComputedLeft()).toBe(50);
1271
+ expect(root_child1.getComputedTop()).toBe(40);
1272
+ expect(root_child1.getComputedWidth()).toBe(20);
1273
+ expect(root_child1.getComputedHeight()).toBe(20);
1274
+
1275
+ expect(root_child2.getComputedLeft()).toBe(20);
1276
+ expect(root_child2.getComputedTop()).toBe(40);
1277
+ expect(root_child2.getComputedWidth()).toBe(20);
1278
+ expect(root_child2.getComputedHeight()).toBe(20);
1279
+
1280
+ expect(root_child3.getComputedLeft()).toBe(80);
1281
+ expect(root_child3.getComputedTop()).toBe(80);
1282
+ expect(root_child3.getComputedWidth()).toBe(20);
1283
+ expect(root_child3.getComputedHeight()).toBe(20);
1284
+
1285
+ expect(root_child4.getComputedLeft()).toBe(50);
1286
+ expect(root_child4.getComputedTop()).toBe(80);
1287
+ expect(root_child4.getComputedWidth()).toBe(20);
1288
+ expect(root_child4.getComputedHeight()).toBe(20);
1289
+
1290
+ expect(root_child5.getComputedLeft()).toBe(20);
1291
+ expect(root_child5.getComputedTop()).toBe(80);
1292
+ expect(root_child5.getComputedWidth()).toBe(20);
1293
+ expect(root_child5.getComputedHeight()).toBe(20);
1294
+ });
1295
+ test('column_gap_wrap_align_space_between', () => {
1296
+ const config = Yoga.Config.create();
1297
+
1298
+ const root = Yoga.Node.create(config);
1299
+ root.setPositionType(PositionType.Absolute);
1300
+ root.setFlexDirection(FlexDirection.Row);
1301
+ root.setFlexWrap(Wrap.Wrap);
1302
+ root.setAlignContent(Align.SpaceBetween);
1303
+ root.setWidth(100);
1304
+ root.setHeight(100);
1305
+ root.setGap(Gutter.Column, 10);
1306
+ root.setGap(Gutter.Row, 20);
1307
+
1308
+ const root_child0 = Yoga.Node.create(config);
1309
+ root_child0.setWidth(20);
1310
+ root_child0.setHeight(20);
1311
+ root.insertChild(root_child0, 0);
1312
+
1313
+ const root_child1 = Yoga.Node.create(config);
1314
+ root_child1.setWidth(20);
1315
+ root_child1.setHeight(20);
1316
+ root.insertChild(root_child1, 1);
1317
+
1318
+ const root_child2 = Yoga.Node.create(config);
1319
+ root_child2.setWidth(20);
1320
+ root_child2.setHeight(20);
1321
+ root.insertChild(root_child2, 2);
1322
+
1323
+ const root_child3 = Yoga.Node.create(config);
1324
+ root_child3.setWidth(20);
1325
+ root_child3.setHeight(20);
1326
+ root.insertChild(root_child3, 3);
1327
+
1328
+ const root_child4 = Yoga.Node.create(config);
1329
+ root_child4.setWidth(20);
1330
+ root_child4.setHeight(20);
1331
+ root.insertChild(root_child4, 4);
1332
+
1333
+ const root_child5 = Yoga.Node.create(config);
1334
+ root_child5.setWidth(20);
1335
+ root_child5.setHeight(20);
1336
+ root.insertChild(root_child5, 5);
1337
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1338
+
1339
+ expect(root.getComputedLeft()).toBe(0);
1340
+ expect(root.getComputedTop()).toBe(0);
1341
+ expect(root.getComputedWidth()).toBe(100);
1342
+ expect(root.getComputedHeight()).toBe(100);
1343
+
1344
+ expect(root_child0.getComputedLeft()).toBe(0);
1345
+ expect(root_child0.getComputedTop()).toBe(0);
1346
+ expect(root_child0.getComputedWidth()).toBe(20);
1347
+ expect(root_child0.getComputedHeight()).toBe(20);
1348
+
1349
+ expect(root_child1.getComputedLeft()).toBe(30);
1350
+ expect(root_child1.getComputedTop()).toBe(0);
1351
+ expect(root_child1.getComputedWidth()).toBe(20);
1352
+ expect(root_child1.getComputedHeight()).toBe(20);
1353
+
1354
+ expect(root_child2.getComputedLeft()).toBe(60);
1355
+ expect(root_child2.getComputedTop()).toBe(0);
1356
+ expect(root_child2.getComputedWidth()).toBe(20);
1357
+ expect(root_child2.getComputedHeight()).toBe(20);
1358
+
1359
+ expect(root_child3.getComputedLeft()).toBe(0);
1360
+ expect(root_child3.getComputedTop()).toBe(80);
1361
+ expect(root_child3.getComputedWidth()).toBe(20);
1362
+ expect(root_child3.getComputedHeight()).toBe(20);
1363
+
1364
+ expect(root_child4.getComputedLeft()).toBe(30);
1365
+ expect(root_child4.getComputedTop()).toBe(80);
1366
+ expect(root_child4.getComputedWidth()).toBe(20);
1367
+ expect(root_child4.getComputedHeight()).toBe(20);
1368
+
1369
+ expect(root_child5.getComputedLeft()).toBe(60);
1370
+ expect(root_child5.getComputedTop()).toBe(80);
1371
+ expect(root_child5.getComputedWidth()).toBe(20);
1372
+ expect(root_child5.getComputedHeight()).toBe(20);
1373
+
1374
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1375
+
1376
+ expect(root.getComputedLeft()).toBe(0);
1377
+ expect(root.getComputedTop()).toBe(0);
1378
+ expect(root.getComputedWidth()).toBe(100);
1379
+ expect(root.getComputedHeight()).toBe(100);
1380
+
1381
+ expect(root_child0.getComputedLeft()).toBe(80);
1382
+ expect(root_child0.getComputedTop()).toBe(0);
1383
+ expect(root_child0.getComputedWidth()).toBe(20);
1384
+ expect(root_child0.getComputedHeight()).toBe(20);
1385
+
1386
+ expect(root_child1.getComputedLeft()).toBe(50);
1387
+ expect(root_child1.getComputedTop()).toBe(0);
1388
+ expect(root_child1.getComputedWidth()).toBe(20);
1389
+ expect(root_child1.getComputedHeight()).toBe(20);
1390
+
1391
+ expect(root_child2.getComputedLeft()).toBe(20);
1392
+ expect(root_child2.getComputedTop()).toBe(0);
1393
+ expect(root_child2.getComputedWidth()).toBe(20);
1394
+ expect(root_child2.getComputedHeight()).toBe(20);
1395
+
1396
+ expect(root_child3.getComputedLeft()).toBe(80);
1397
+ expect(root_child3.getComputedTop()).toBe(80);
1398
+ expect(root_child3.getComputedWidth()).toBe(20);
1399
+ expect(root_child3.getComputedHeight()).toBe(20);
1400
+
1401
+ expect(root_child4.getComputedLeft()).toBe(50);
1402
+ expect(root_child4.getComputedTop()).toBe(80);
1403
+ expect(root_child4.getComputedWidth()).toBe(20);
1404
+ expect(root_child4.getComputedHeight()).toBe(20);
1405
+
1406
+ expect(root_child5.getComputedLeft()).toBe(20);
1407
+ expect(root_child5.getComputedTop()).toBe(80);
1408
+ expect(root_child5.getComputedWidth()).toBe(20);
1409
+ expect(root_child5.getComputedHeight()).toBe(20);
1410
+ });
1411
+ test('column_gap_wrap_align_space_around', () => {
1412
+ const config = Yoga.Config.create();
1413
+
1414
+ const root = Yoga.Node.create(config);
1415
+ root.setPositionType(PositionType.Absolute);
1416
+ root.setFlexDirection(FlexDirection.Row);
1417
+ root.setFlexWrap(Wrap.Wrap);
1418
+ root.setAlignContent(Align.SpaceAround);
1419
+ root.setWidth(100);
1420
+ root.setHeight(100);
1421
+ root.setGap(Gutter.Column, 10);
1422
+ root.setGap(Gutter.Row, 20);
1423
+
1424
+ const root_child0 = Yoga.Node.create(config);
1425
+ root_child0.setWidth(20);
1426
+ root_child0.setHeight(20);
1427
+ root.insertChild(root_child0, 0);
1428
+
1429
+ const root_child1 = Yoga.Node.create(config);
1430
+ root_child1.setWidth(20);
1431
+ root_child1.setHeight(20);
1432
+ root.insertChild(root_child1, 1);
1433
+
1434
+ const root_child2 = Yoga.Node.create(config);
1435
+ root_child2.setWidth(20);
1436
+ root_child2.setHeight(20);
1437
+ root.insertChild(root_child2, 2);
1438
+
1439
+ const root_child3 = Yoga.Node.create(config);
1440
+ root_child3.setWidth(20);
1441
+ root_child3.setHeight(20);
1442
+ root.insertChild(root_child3, 3);
1443
+
1444
+ const root_child4 = Yoga.Node.create(config);
1445
+ root_child4.setWidth(20);
1446
+ root_child4.setHeight(20);
1447
+ root.insertChild(root_child4, 4);
1448
+
1449
+ const root_child5 = Yoga.Node.create(config);
1450
+ root_child5.setWidth(20);
1451
+ root_child5.setHeight(20);
1452
+ root.insertChild(root_child5, 5);
1453
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1454
+
1455
+ expect(root.getComputedLeft()).toBe(0);
1456
+ expect(root.getComputedTop()).toBe(0);
1457
+ expect(root.getComputedWidth()).toBe(100);
1458
+ expect(root.getComputedHeight()).toBe(100);
1459
+
1460
+ expect(root_child0.getComputedLeft()).toBe(0);
1461
+ expect(root_child0.getComputedTop()).toBe(10);
1462
+ expect(root_child0.getComputedWidth()).toBe(20);
1463
+ expect(root_child0.getComputedHeight()).toBe(20);
1464
+
1465
+ expect(root_child1.getComputedLeft()).toBe(30);
1466
+ expect(root_child1.getComputedTop()).toBe(10);
1467
+ expect(root_child1.getComputedWidth()).toBe(20);
1468
+ expect(root_child1.getComputedHeight()).toBe(20);
1469
+
1470
+ expect(root_child2.getComputedLeft()).toBe(60);
1471
+ expect(root_child2.getComputedTop()).toBe(10);
1472
+ expect(root_child2.getComputedWidth()).toBe(20);
1473
+ expect(root_child2.getComputedHeight()).toBe(20);
1474
+
1475
+ expect(root_child3.getComputedLeft()).toBe(0);
1476
+ expect(root_child3.getComputedTop()).toBe(70);
1477
+ expect(root_child3.getComputedWidth()).toBe(20);
1478
+ expect(root_child3.getComputedHeight()).toBe(20);
1479
+
1480
+ expect(root_child4.getComputedLeft()).toBe(30);
1481
+ expect(root_child4.getComputedTop()).toBe(70);
1482
+ expect(root_child4.getComputedWidth()).toBe(20);
1483
+ expect(root_child4.getComputedHeight()).toBe(20);
1484
+
1485
+ expect(root_child5.getComputedLeft()).toBe(60);
1486
+ expect(root_child5.getComputedTop()).toBe(70);
1487
+ expect(root_child5.getComputedWidth()).toBe(20);
1488
+ expect(root_child5.getComputedHeight()).toBe(20);
1489
+
1490
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1491
+
1492
+ expect(root.getComputedLeft()).toBe(0);
1493
+ expect(root.getComputedTop()).toBe(0);
1494
+ expect(root.getComputedWidth()).toBe(100);
1495
+ expect(root.getComputedHeight()).toBe(100);
1496
+
1497
+ expect(root_child0.getComputedLeft()).toBe(80);
1498
+ expect(root_child0.getComputedTop()).toBe(10);
1499
+ expect(root_child0.getComputedWidth()).toBe(20);
1500
+ expect(root_child0.getComputedHeight()).toBe(20);
1501
+
1502
+ expect(root_child1.getComputedLeft()).toBe(50);
1503
+ expect(root_child1.getComputedTop()).toBe(10);
1504
+ expect(root_child1.getComputedWidth()).toBe(20);
1505
+ expect(root_child1.getComputedHeight()).toBe(20);
1506
+
1507
+ expect(root_child2.getComputedLeft()).toBe(20);
1508
+ expect(root_child2.getComputedTop()).toBe(10);
1509
+ expect(root_child2.getComputedWidth()).toBe(20);
1510
+ expect(root_child2.getComputedHeight()).toBe(20);
1511
+
1512
+ expect(root_child3.getComputedLeft()).toBe(80);
1513
+ expect(root_child3.getComputedTop()).toBe(70);
1514
+ expect(root_child3.getComputedWidth()).toBe(20);
1515
+ expect(root_child3.getComputedHeight()).toBe(20);
1516
+
1517
+ expect(root_child4.getComputedLeft()).toBe(50);
1518
+ expect(root_child4.getComputedTop()).toBe(70);
1519
+ expect(root_child4.getComputedWidth()).toBe(20);
1520
+ expect(root_child4.getComputedHeight()).toBe(20);
1521
+
1522
+ expect(root_child5.getComputedLeft()).toBe(20);
1523
+ expect(root_child5.getComputedTop()).toBe(70);
1524
+ expect(root_child5.getComputedWidth()).toBe(20);
1525
+ expect(root_child5.getComputedHeight()).toBe(20);
1526
+ });
1527
+ test('column_gap_wrap_align_stretch', () => {
1528
+ const config = Yoga.Config.create();
1529
+
1530
+ const root = Yoga.Node.create(config);
1531
+ root.setPositionType(PositionType.Absolute);
1532
+ root.setFlexDirection(FlexDirection.Row);
1533
+ root.setFlexWrap(Wrap.Wrap);
1534
+ root.setWidth(300);
1535
+ root.setHeight(300);
1536
+ root.setGap(Gutter.Column, 5);
1537
+ root.setAlignContent(Align.Stretch);
1538
+
1539
+ const root_child0 = Yoga.Node.create(config);
1540
+ root_child0.setMinWidth(60);
1541
+ root_child0.setFlexGrow(1);
1542
+ root.insertChild(root_child0, 0);
1543
+
1544
+ const root_child1 = Yoga.Node.create(config);
1545
+ root_child1.setMinWidth(60);
1546
+ root_child1.setFlexGrow(1);
1547
+ root.insertChild(root_child1, 1);
1548
+
1549
+ const root_child2 = Yoga.Node.create(config);
1550
+ root_child2.setMinWidth(60);
1551
+ root_child2.setFlexGrow(1);
1552
+ root.insertChild(root_child2, 2);
1553
+
1554
+ const root_child3 = Yoga.Node.create(config);
1555
+ root_child3.setMinWidth(60);
1556
+ root_child3.setFlexGrow(1);
1557
+ root.insertChild(root_child3, 3);
1558
+
1559
+ const root_child4 = Yoga.Node.create(config);
1560
+ root_child4.setMinWidth(60);
1561
+ root_child4.setFlexGrow(1);
1562
+ root.insertChild(root_child4, 4);
1563
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1564
+
1565
+ expect(root.getComputedLeft()).toBe(0);
1566
+ expect(root.getComputedTop()).toBe(0);
1567
+ expect(root.getComputedWidth()).toBe(300);
1568
+ expect(root.getComputedHeight()).toBe(300);
1569
+
1570
+ expect(root_child0.getComputedLeft()).toBe(0);
1571
+ expect(root_child0.getComputedTop()).toBe(0);
1572
+ expect(root_child0.getComputedWidth()).toBe(71);
1573
+ expect(root_child0.getComputedHeight()).toBe(150);
1574
+
1575
+ expect(root_child1.getComputedLeft()).toBe(76);
1576
+ expect(root_child1.getComputedTop()).toBe(0);
1577
+ expect(root_child1.getComputedWidth()).toBe(72);
1578
+ expect(root_child1.getComputedHeight()).toBe(150);
1579
+
1580
+ expect(root_child2.getComputedLeft()).toBe(153);
1581
+ expect(root_child2.getComputedTop()).toBe(0);
1582
+ expect(root_child2.getComputedWidth()).toBe(71);
1583
+ expect(root_child2.getComputedHeight()).toBe(150);
1584
+
1585
+ expect(root_child3.getComputedLeft()).toBe(229);
1586
+ expect(root_child3.getComputedTop()).toBe(0);
1587
+ expect(root_child3.getComputedWidth()).toBe(71);
1588
+ expect(root_child3.getComputedHeight()).toBe(150);
1589
+
1590
+ expect(root_child4.getComputedLeft()).toBe(0);
1591
+ expect(root_child4.getComputedTop()).toBe(150);
1592
+ expect(root_child4.getComputedWidth()).toBe(300);
1593
+ expect(root_child4.getComputedHeight()).toBe(150);
1594
+
1595
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1596
+
1597
+ expect(root.getComputedLeft()).toBe(0);
1598
+ expect(root.getComputedTop()).toBe(0);
1599
+ expect(root.getComputedWidth()).toBe(300);
1600
+ expect(root.getComputedHeight()).toBe(300);
1601
+
1602
+ expect(root_child0.getComputedLeft()).toBe(229);
1603
+ expect(root_child0.getComputedTop()).toBe(0);
1604
+ expect(root_child0.getComputedWidth()).toBe(71);
1605
+ expect(root_child0.getComputedHeight()).toBe(150);
1606
+
1607
+ expect(root_child1.getComputedLeft()).toBe(153);
1608
+ expect(root_child1.getComputedTop()).toBe(0);
1609
+ expect(root_child1.getComputedWidth()).toBe(71);
1610
+ expect(root_child1.getComputedHeight()).toBe(150);
1611
+
1612
+ expect(root_child2.getComputedLeft()).toBe(76);
1613
+ expect(root_child2.getComputedTop()).toBe(0);
1614
+ expect(root_child2.getComputedWidth()).toBe(72);
1615
+ expect(root_child2.getComputedHeight()).toBe(150);
1616
+
1617
+ expect(root_child3.getComputedLeft()).toBe(0);
1618
+ expect(root_child3.getComputedTop()).toBe(0);
1619
+ expect(root_child3.getComputedWidth()).toBe(71);
1620
+ expect(root_child3.getComputedHeight()).toBe(150);
1621
+
1622
+ expect(root_child4.getComputedLeft()).toBe(0);
1623
+ expect(root_child4.getComputedTop()).toBe(150);
1624
+ expect(root_child4.getComputedWidth()).toBe(300);
1625
+ expect(root_child4.getComputedHeight()).toBe(150);
1626
+ });
1627
+ test('column_gap_determines_parent_width', () => {
1628
+ const config = Yoga.Config.create();
1629
+
1630
+ const root = Yoga.Node.create(config);
1631
+ root.setPositionType(PositionType.Absolute);
1632
+ root.setFlexDirection(FlexDirection.Row);
1633
+ root.setHeight(100);
1634
+ root.setGap(Gutter.Column, 10);
1635
+
1636
+ const root_child0 = Yoga.Node.create(config);
1637
+ root_child0.setWidth(10);
1638
+ root.insertChild(root_child0, 0);
1639
+
1640
+ const root_child1 = Yoga.Node.create(config);
1641
+ root_child1.setWidth(20);
1642
+ root.insertChild(root_child1, 1);
1643
+
1644
+ const root_child2 = Yoga.Node.create(config);
1645
+ root_child2.setWidth(30);
1646
+ root.insertChild(root_child2, 2);
1647
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1648
+
1649
+ expect(root.getComputedLeft()).toBe(0);
1650
+ expect(root.getComputedTop()).toBe(0);
1651
+ expect(root.getComputedWidth()).toBe(80);
1652
+ expect(root.getComputedHeight()).toBe(100);
1653
+
1654
+ expect(root_child0.getComputedLeft()).toBe(0);
1655
+ expect(root_child0.getComputedTop()).toBe(0);
1656
+ expect(root_child0.getComputedWidth()).toBe(10);
1657
+ expect(root_child0.getComputedHeight()).toBe(100);
1658
+
1659
+ expect(root_child1.getComputedLeft()).toBe(20);
1660
+ expect(root_child1.getComputedTop()).toBe(0);
1661
+ expect(root_child1.getComputedWidth()).toBe(20);
1662
+ expect(root_child1.getComputedHeight()).toBe(100);
1663
+
1664
+ expect(root_child2.getComputedLeft()).toBe(50);
1665
+ expect(root_child2.getComputedTop()).toBe(0);
1666
+ expect(root_child2.getComputedWidth()).toBe(30);
1667
+ expect(root_child2.getComputedHeight()).toBe(100);
1668
+
1669
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1670
+
1671
+ expect(root.getComputedLeft()).toBe(0);
1672
+ expect(root.getComputedTop()).toBe(0);
1673
+ expect(root.getComputedWidth()).toBe(80);
1674
+ expect(root.getComputedHeight()).toBe(100);
1675
+
1676
+ expect(root_child0.getComputedLeft()).toBe(70);
1677
+ expect(root_child0.getComputedTop()).toBe(0);
1678
+ expect(root_child0.getComputedWidth()).toBe(10);
1679
+ expect(root_child0.getComputedHeight()).toBe(100);
1680
+
1681
+ expect(root_child1.getComputedLeft()).toBe(40);
1682
+ expect(root_child1.getComputedTop()).toBe(0);
1683
+ expect(root_child1.getComputedWidth()).toBe(20);
1684
+ expect(root_child1.getComputedHeight()).toBe(100);
1685
+
1686
+ expect(root_child2.getComputedLeft()).toBe(0);
1687
+ expect(root_child2.getComputedTop()).toBe(0);
1688
+ expect(root_child2.getComputedWidth()).toBe(30);
1689
+ expect(root_child2.getComputedHeight()).toBe(100);
1690
+ });
1691
+ test('row_gap_align_items_stretch', () => {
1692
+ const config = Yoga.Config.create();
1693
+
1694
+ const root = Yoga.Node.create(config);
1695
+ root.setPositionType(PositionType.Absolute);
1696
+ root.setFlexDirection(FlexDirection.Row);
1697
+ root.setFlexWrap(Wrap.Wrap);
1698
+ root.setWidth(100);
1699
+ root.setHeight(200);
1700
+ root.setGap(Gutter.Column, 10);
1701
+ root.setGap(Gutter.Row, 20);
1702
+ root.setAlignContent(Align.Stretch);
1703
+
1704
+ const root_child0 = Yoga.Node.create(config);
1705
+ root_child0.setWidth(20);
1706
+ root.insertChild(root_child0, 0);
1707
+
1708
+ const root_child1 = Yoga.Node.create(config);
1709
+ root_child1.setWidth(20);
1710
+ root.insertChild(root_child1, 1);
1711
+
1712
+ const root_child2 = Yoga.Node.create(config);
1713
+ root_child2.setWidth(20);
1714
+ root.insertChild(root_child2, 2);
1715
+
1716
+ const root_child3 = Yoga.Node.create(config);
1717
+ root_child3.setWidth(20);
1718
+ root.insertChild(root_child3, 3);
1719
+
1720
+ const root_child4 = Yoga.Node.create(config);
1721
+ root_child4.setWidth(20);
1722
+ root.insertChild(root_child4, 4);
1723
+
1724
+ const root_child5 = Yoga.Node.create(config);
1725
+ root_child5.setWidth(20);
1726
+ root.insertChild(root_child5, 5);
1727
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1728
+
1729
+ expect(root.getComputedLeft()).toBe(0);
1730
+ expect(root.getComputedTop()).toBe(0);
1731
+ expect(root.getComputedWidth()).toBe(100);
1732
+ expect(root.getComputedHeight()).toBe(200);
1733
+
1734
+ expect(root_child0.getComputedLeft()).toBe(0);
1735
+ expect(root_child0.getComputedTop()).toBe(0);
1736
+ expect(root_child0.getComputedWidth()).toBe(20);
1737
+ expect(root_child0.getComputedHeight()).toBe(90);
1738
+
1739
+ expect(root_child1.getComputedLeft()).toBe(30);
1740
+ expect(root_child1.getComputedTop()).toBe(0);
1741
+ expect(root_child1.getComputedWidth()).toBe(20);
1742
+ expect(root_child1.getComputedHeight()).toBe(90);
1743
+
1744
+ expect(root_child2.getComputedLeft()).toBe(60);
1745
+ expect(root_child2.getComputedTop()).toBe(0);
1746
+ expect(root_child2.getComputedWidth()).toBe(20);
1747
+ expect(root_child2.getComputedHeight()).toBe(90);
1748
+
1749
+ expect(root_child3.getComputedLeft()).toBe(0);
1750
+ expect(root_child3.getComputedTop()).toBe(110);
1751
+ expect(root_child3.getComputedWidth()).toBe(20);
1752
+ expect(root_child3.getComputedHeight()).toBe(90);
1753
+
1754
+ expect(root_child4.getComputedLeft()).toBe(30);
1755
+ expect(root_child4.getComputedTop()).toBe(110);
1756
+ expect(root_child4.getComputedWidth()).toBe(20);
1757
+ expect(root_child4.getComputedHeight()).toBe(90);
1758
+
1759
+ expect(root_child5.getComputedLeft()).toBe(60);
1760
+ expect(root_child5.getComputedTop()).toBe(110);
1761
+ expect(root_child5.getComputedWidth()).toBe(20);
1762
+ expect(root_child5.getComputedHeight()).toBe(90);
1763
+
1764
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1765
+
1766
+ expect(root.getComputedLeft()).toBe(0);
1767
+ expect(root.getComputedTop()).toBe(0);
1768
+ expect(root.getComputedWidth()).toBe(100);
1769
+ expect(root.getComputedHeight()).toBe(200);
1770
+
1771
+ expect(root_child0.getComputedLeft()).toBe(80);
1772
+ expect(root_child0.getComputedTop()).toBe(0);
1773
+ expect(root_child0.getComputedWidth()).toBe(20);
1774
+ expect(root_child0.getComputedHeight()).toBe(90);
1775
+
1776
+ expect(root_child1.getComputedLeft()).toBe(50);
1777
+ expect(root_child1.getComputedTop()).toBe(0);
1778
+ expect(root_child1.getComputedWidth()).toBe(20);
1779
+ expect(root_child1.getComputedHeight()).toBe(90);
1780
+
1781
+ expect(root_child2.getComputedLeft()).toBe(20);
1782
+ expect(root_child2.getComputedTop()).toBe(0);
1783
+ expect(root_child2.getComputedWidth()).toBe(20);
1784
+ expect(root_child2.getComputedHeight()).toBe(90);
1785
+
1786
+ expect(root_child3.getComputedLeft()).toBe(80);
1787
+ expect(root_child3.getComputedTop()).toBe(110);
1788
+ expect(root_child3.getComputedWidth()).toBe(20);
1789
+ expect(root_child3.getComputedHeight()).toBe(90);
1790
+
1791
+ expect(root_child4.getComputedLeft()).toBe(50);
1792
+ expect(root_child4.getComputedTop()).toBe(110);
1793
+ expect(root_child4.getComputedWidth()).toBe(20);
1794
+ expect(root_child4.getComputedHeight()).toBe(90);
1795
+
1796
+ expect(root_child5.getComputedLeft()).toBe(20);
1797
+ expect(root_child5.getComputedTop()).toBe(110);
1798
+ expect(root_child5.getComputedWidth()).toBe(20);
1799
+ expect(root_child5.getComputedHeight()).toBe(90);
1800
+ });
1801
+ test('row_gap_align_items_end', () => {
1802
+ const config = Yoga.Config.create();
1803
+
1804
+ const root = Yoga.Node.create(config);
1805
+ root.setPositionType(PositionType.Absolute);
1806
+ root.setFlexDirection(FlexDirection.Row);
1807
+ root.setFlexWrap(Wrap.Wrap);
1808
+ root.setWidth(100);
1809
+ root.setHeight(200);
1810
+ root.setGap(Gutter.Column, 10);
1811
+ root.setGap(Gutter.Row, 20);
1812
+ root.setAlignItems(Align.FlexEnd);
1813
+
1814
+ const root_child0 = Yoga.Node.create(config);
1815
+ root_child0.setWidth(20);
1816
+ root.insertChild(root_child0, 0);
1817
+
1818
+ const root_child1 = Yoga.Node.create(config);
1819
+ root_child1.setWidth(20);
1820
+ root.insertChild(root_child1, 1);
1821
+
1822
+ const root_child2 = Yoga.Node.create(config);
1823
+ root_child2.setWidth(20);
1824
+ root.insertChild(root_child2, 2);
1825
+
1826
+ const root_child3 = Yoga.Node.create(config);
1827
+ root_child3.setWidth(20);
1828
+ root.insertChild(root_child3, 3);
1829
+
1830
+ const root_child4 = Yoga.Node.create(config);
1831
+ root_child4.setWidth(20);
1832
+ root.insertChild(root_child4, 4);
1833
+
1834
+ const root_child5 = Yoga.Node.create(config);
1835
+ root_child5.setWidth(20);
1836
+ root.insertChild(root_child5, 5);
1837
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1838
+
1839
+ expect(root.getComputedLeft()).toBe(0);
1840
+ expect(root.getComputedTop()).toBe(0);
1841
+ expect(root.getComputedWidth()).toBe(100);
1842
+ expect(root.getComputedHeight()).toBe(200);
1843
+
1844
+ expect(root_child0.getComputedLeft()).toBe(0);
1845
+ expect(root_child0.getComputedTop()).toBe(0);
1846
+ expect(root_child0.getComputedWidth()).toBe(20);
1847
+ expect(root_child0.getComputedHeight()).toBe(0);
1848
+
1849
+ expect(root_child1.getComputedLeft()).toBe(30);
1850
+ expect(root_child1.getComputedTop()).toBe(0);
1851
+ expect(root_child1.getComputedWidth()).toBe(20);
1852
+ expect(root_child1.getComputedHeight()).toBe(0);
1853
+
1854
+ expect(root_child2.getComputedLeft()).toBe(60);
1855
+ expect(root_child2.getComputedTop()).toBe(0);
1856
+ expect(root_child2.getComputedWidth()).toBe(20);
1857
+ expect(root_child2.getComputedHeight()).toBe(0);
1858
+
1859
+ expect(root_child3.getComputedLeft()).toBe(0);
1860
+ expect(root_child3.getComputedTop()).toBe(20);
1861
+ expect(root_child3.getComputedWidth()).toBe(20);
1862
+ expect(root_child3.getComputedHeight()).toBe(0);
1863
+
1864
+ expect(root_child4.getComputedLeft()).toBe(30);
1865
+ expect(root_child4.getComputedTop()).toBe(20);
1866
+ expect(root_child4.getComputedWidth()).toBe(20);
1867
+ expect(root_child4.getComputedHeight()).toBe(0);
1868
+
1869
+ expect(root_child5.getComputedLeft()).toBe(60);
1870
+ expect(root_child5.getComputedTop()).toBe(20);
1871
+ expect(root_child5.getComputedWidth()).toBe(20);
1872
+ expect(root_child5.getComputedHeight()).toBe(0);
1873
+
1874
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1875
+
1876
+ expect(root.getComputedLeft()).toBe(0);
1877
+ expect(root.getComputedTop()).toBe(0);
1878
+ expect(root.getComputedWidth()).toBe(100);
1879
+ expect(root.getComputedHeight()).toBe(200);
1880
+
1881
+ expect(root_child0.getComputedLeft()).toBe(80);
1882
+ expect(root_child0.getComputedTop()).toBe(0);
1883
+ expect(root_child0.getComputedWidth()).toBe(20);
1884
+ expect(root_child0.getComputedHeight()).toBe(0);
1885
+
1886
+ expect(root_child1.getComputedLeft()).toBe(50);
1887
+ expect(root_child1.getComputedTop()).toBe(0);
1888
+ expect(root_child1.getComputedWidth()).toBe(20);
1889
+ expect(root_child1.getComputedHeight()).toBe(0);
1890
+
1891
+ expect(root_child2.getComputedLeft()).toBe(20);
1892
+ expect(root_child2.getComputedTop()).toBe(0);
1893
+ expect(root_child2.getComputedWidth()).toBe(20);
1894
+ expect(root_child2.getComputedHeight()).toBe(0);
1895
+
1896
+ expect(root_child3.getComputedLeft()).toBe(80);
1897
+ expect(root_child3.getComputedTop()).toBe(20);
1898
+ expect(root_child3.getComputedWidth()).toBe(20);
1899
+ expect(root_child3.getComputedHeight()).toBe(0);
1900
+
1901
+ expect(root_child4.getComputedLeft()).toBe(50);
1902
+ expect(root_child4.getComputedTop()).toBe(20);
1903
+ expect(root_child4.getComputedWidth()).toBe(20);
1904
+ expect(root_child4.getComputedHeight()).toBe(0);
1905
+
1906
+ expect(root_child5.getComputedLeft()).toBe(20);
1907
+ expect(root_child5.getComputedTop()).toBe(20);
1908
+ expect(root_child5.getComputedWidth()).toBe(20);
1909
+ expect(root_child5.getComputedHeight()).toBe(0);
1910
+ });
1911
+ test('row_gap_column_child_margins', () => {
1912
+ const config = Yoga.Config.create();
1913
+
1914
+ const root = Yoga.Node.create(config);
1915
+ root.setPositionType(PositionType.Absolute);
1916
+ root.setWidth(100);
1917
+ root.setHeight(200);
1918
+ root.setGap(Gutter.Row, 10);
1919
+
1920
+ const root_child0 = Yoga.Node.create(config);
1921
+ root_child0.setFlexGrow(1);
1922
+ root_child0.setFlexShrink(1);
1923
+ root_child0.setFlexBasis("0%");
1924
+ root_child0.setMargin(Edge.Vertical, 2);
1925
+ root.insertChild(root_child0, 0);
1926
+
1927
+ const root_child1 = Yoga.Node.create(config);
1928
+ root_child1.setFlexGrow(1);
1929
+ root_child1.setFlexShrink(1);
1930
+ root_child1.setFlexBasis("0%");
1931
+ root_child1.setMargin(Edge.Vertical, 10);
1932
+ root.insertChild(root_child1, 1);
1933
+
1934
+ const root_child2 = Yoga.Node.create(config);
1935
+ root_child2.setFlexGrow(1);
1936
+ root_child2.setFlexShrink(1);
1937
+ root_child2.setFlexBasis("0%");
1938
+ root_child2.setMargin(Edge.Vertical, 15);
1939
+ root.insertChild(root_child2, 2);
1940
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1941
+
1942
+ expect(root.getComputedLeft()).toBe(0);
1943
+ expect(root.getComputedTop()).toBe(0);
1944
+ expect(root.getComputedWidth()).toBe(100);
1945
+ expect(root.getComputedHeight()).toBe(200);
1946
+
1947
+ expect(root_child0.getComputedLeft()).toBe(0);
1948
+ expect(root_child0.getComputedTop()).toBe(2);
1949
+ expect(root_child0.getComputedWidth()).toBe(100);
1950
+ expect(root_child0.getComputedHeight()).toBe(42);
1951
+
1952
+ expect(root_child1.getComputedLeft()).toBe(0);
1953
+ expect(root_child1.getComputedTop()).toBe(66);
1954
+ expect(root_child1.getComputedWidth()).toBe(100);
1955
+ expect(root_child1.getComputedHeight()).toBe(42);
1956
+
1957
+ expect(root_child2.getComputedLeft()).toBe(0);
1958
+ expect(root_child2.getComputedTop()).toBe(143);
1959
+ expect(root_child2.getComputedWidth()).toBe(100);
1960
+ expect(root_child2.getComputedHeight()).toBe(42);
1961
+
1962
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1963
+
1964
+ expect(root.getComputedLeft()).toBe(0);
1965
+ expect(root.getComputedTop()).toBe(0);
1966
+ expect(root.getComputedWidth()).toBe(100);
1967
+ expect(root.getComputedHeight()).toBe(200);
1968
+
1969
+ expect(root_child0.getComputedLeft()).toBe(0);
1970
+ expect(root_child0.getComputedTop()).toBe(2);
1971
+ expect(root_child0.getComputedWidth()).toBe(100);
1972
+ expect(root_child0.getComputedHeight()).toBe(42);
1973
+
1974
+ expect(root_child1.getComputedLeft()).toBe(0);
1975
+ expect(root_child1.getComputedTop()).toBe(66);
1976
+ expect(root_child1.getComputedWidth()).toBe(100);
1977
+ expect(root_child1.getComputedHeight()).toBe(42);
1978
+
1979
+ expect(root_child2.getComputedLeft()).toBe(0);
1980
+ expect(root_child2.getComputedTop()).toBe(143);
1981
+ expect(root_child2.getComputedWidth()).toBe(100);
1982
+ expect(root_child2.getComputedHeight()).toBe(42);
1983
+ });
1984
+ test('row_gap_row_wrap_child_margins', () => {
1985
+ const config = Yoga.Config.create();
1986
+
1987
+ const root = Yoga.Node.create(config);
1988
+ root.setPositionType(PositionType.Absolute);
1989
+ root.setFlexDirection(FlexDirection.Row);
1990
+ root.setFlexWrap(Wrap.Wrap);
1991
+ root.setWidth(100);
1992
+ root.setHeight(200);
1993
+ root.setGap(Gutter.Row, 10);
1994
+
1995
+ const root_child0 = Yoga.Node.create(config);
1996
+ root_child0.setWidth(60);
1997
+ root_child0.setMargin(Edge.Vertical, 2);
1998
+ root.insertChild(root_child0, 0);
1999
+
2000
+ const root_child1 = Yoga.Node.create(config);
2001
+ root_child1.setWidth(60);
2002
+ root_child1.setMargin(Edge.Vertical, 10);
2003
+ root.insertChild(root_child1, 1);
2004
+
2005
+ const root_child2 = Yoga.Node.create(config);
2006
+ root_child2.setWidth(60);
2007
+ root_child2.setMargin(Edge.Vertical, 15);
2008
+ root.insertChild(root_child2, 2);
2009
+ root.calculateLayout(undefined, undefined, Direction.LTR);
2010
+
2011
+ expect(root.getComputedLeft()).toBe(0);
2012
+ expect(root.getComputedTop()).toBe(0);
2013
+ expect(root.getComputedWidth()).toBe(100);
2014
+ expect(root.getComputedHeight()).toBe(200);
2015
+
2016
+ expect(root_child0.getComputedLeft()).toBe(0);
2017
+ expect(root_child0.getComputedTop()).toBe(2);
2018
+ expect(root_child0.getComputedWidth()).toBe(60);
2019
+ expect(root_child0.getComputedHeight()).toBe(0);
2020
+
2021
+ expect(root_child1.getComputedLeft()).toBe(0);
2022
+ expect(root_child1.getComputedTop()).toBe(24);
2023
+ expect(root_child1.getComputedWidth()).toBe(60);
2024
+ expect(root_child1.getComputedHeight()).toBe(0);
2025
+
2026
+ expect(root_child2.getComputedLeft()).toBe(0);
2027
+ expect(root_child2.getComputedTop()).toBe(59);
2028
+ expect(root_child2.getComputedWidth()).toBe(60);
2029
+ expect(root_child2.getComputedHeight()).toBe(0);
2030
+
2031
+ root.calculateLayout(undefined, undefined, Direction.RTL);
2032
+
2033
+ expect(root.getComputedLeft()).toBe(0);
2034
+ expect(root.getComputedTop()).toBe(0);
2035
+ expect(root.getComputedWidth()).toBe(100);
2036
+ expect(root.getComputedHeight()).toBe(200);
2037
+
2038
+ expect(root_child0.getComputedLeft()).toBe(40);
2039
+ expect(root_child0.getComputedTop()).toBe(2);
2040
+ expect(root_child0.getComputedWidth()).toBe(60);
2041
+ expect(root_child0.getComputedHeight()).toBe(0);
2042
+
2043
+ expect(root_child1.getComputedLeft()).toBe(40);
2044
+ expect(root_child1.getComputedTop()).toBe(24);
2045
+ expect(root_child1.getComputedWidth()).toBe(60);
2046
+ expect(root_child1.getComputedHeight()).toBe(0);
2047
+
2048
+ expect(root_child2.getComputedLeft()).toBe(40);
2049
+ expect(root_child2.getComputedTop()).toBe(59);
2050
+ expect(root_child2.getComputedWidth()).toBe(60);
2051
+ expect(root_child2.getComputedHeight()).toBe(0);
2052
+ });
2053
+ test('row_gap_determines_parent_height', () => {
2054
+ const config = Yoga.Config.create();
2055
+
2056
+ const root = Yoga.Node.create(config);
2057
+ root.setPositionType(PositionType.Absolute);
2058
+ root.setWidth(100);
2059
+ root.setGap(Gutter.Row, 10);
2060
+
2061
+ const root_child0 = Yoga.Node.create(config);
2062
+ root_child0.setHeight(10);
2063
+ root.insertChild(root_child0, 0);
2064
+
2065
+ const root_child1 = Yoga.Node.create(config);
2066
+ root_child1.setHeight(20);
2067
+ root.insertChild(root_child1, 1);
2068
+
2069
+ const root_child2 = Yoga.Node.create(config);
2070
+ root_child2.setHeight(30);
2071
+ root.insertChild(root_child2, 2);
2072
+ root.calculateLayout(undefined, undefined, Direction.LTR);
2073
+
2074
+ expect(root.getComputedLeft()).toBe(0);
2075
+ expect(root.getComputedTop()).toBe(0);
2076
+ expect(root.getComputedWidth()).toBe(100);
2077
+ expect(root.getComputedHeight()).toBe(80);
2078
+
2079
+ expect(root_child0.getComputedLeft()).toBe(0);
2080
+ expect(root_child0.getComputedTop()).toBe(0);
2081
+ expect(root_child0.getComputedWidth()).toBe(100);
2082
+ expect(root_child0.getComputedHeight()).toBe(10);
2083
+
2084
+ expect(root_child1.getComputedLeft()).toBe(0);
2085
+ expect(root_child1.getComputedTop()).toBe(20);
2086
+ expect(root_child1.getComputedWidth()).toBe(100);
2087
+ expect(root_child1.getComputedHeight()).toBe(20);
2088
+
2089
+ expect(root_child2.getComputedLeft()).toBe(0);
2090
+ expect(root_child2.getComputedTop()).toBe(50);
2091
+ expect(root_child2.getComputedWidth()).toBe(100);
2092
+ expect(root_child2.getComputedHeight()).toBe(30);
2093
+
2094
+ root.calculateLayout(undefined, undefined, Direction.RTL);
2095
+
2096
+ expect(root.getComputedLeft()).toBe(0);
2097
+ expect(root.getComputedTop()).toBe(0);
2098
+ expect(root.getComputedWidth()).toBe(100);
2099
+ expect(root.getComputedHeight()).toBe(80);
2100
+
2101
+ expect(root_child0.getComputedLeft()).toBe(0);
2102
+ expect(root_child0.getComputedTop()).toBe(0);
2103
+ expect(root_child0.getComputedWidth()).toBe(100);
2104
+ expect(root_child0.getComputedHeight()).toBe(10);
2105
+
2106
+ expect(root_child1.getComputedLeft()).toBe(0);
2107
+ expect(root_child1.getComputedTop()).toBe(20);
2108
+ expect(root_child1.getComputedWidth()).toBe(100);
2109
+ expect(root_child1.getComputedHeight()).toBe(20);
2110
+
2111
+ expect(root_child2.getComputedLeft()).toBe(0);
2112
+ expect(root_child2.getComputedTop()).toBe(50);
2113
+ expect(root_child2.getComputedWidth()).toBe(100);
2114
+ expect(root_child2.getComputedHeight()).toBe(30);
2115
+ });
2116
+ test('row_gap_percent_wrapping', () => {
2117
+ const config = Yoga.Config.create();
2118
+
2119
+ const root = Yoga.Node.create(config);
2120
+ root.setPositionType(PositionType.Absolute);
2121
+ root.setFlexDirection(FlexDirection.Row);
2122
+ root.setWidth(300);
2123
+ root.setHeight(700);
2124
+ root.setPadding(Edge.All, 10);
2125
+ root.setGap(Gutter.All, "10%");
2126
+ root.setFlexWrap(Wrap.Wrap);
2127
+
2128
+ const root_child0 = Yoga.Node.create(config);
2129
+ root_child0.setWidth(100);
2130
+ root_child0.setHeight(100);
2131
+ root.insertChild(root_child0, 0);
2132
+
2133
+ const root_child1 = Yoga.Node.create(config);
2134
+ root_child1.setWidth(100);
2135
+ root_child1.setHeight(100);
2136
+ root.insertChild(root_child1, 1);
2137
+
2138
+ const root_child2 = Yoga.Node.create(config);
2139
+ root_child2.setWidth(100);
2140
+ root_child2.setHeight(100);
2141
+ root.insertChild(root_child2, 2);
2142
+
2143
+ const root_child3 = Yoga.Node.create(config);
2144
+ root_child3.setWidth(100);
2145
+ root_child3.setHeight(100);
2146
+ root.insertChild(root_child3, 3);
2147
+
2148
+ const root_child4 = Yoga.Node.create(config);
2149
+ root_child4.setWidth(100);
2150
+ root_child4.setHeight(100);
2151
+ root.insertChild(root_child4, 4);
2152
+ root.calculateLayout(undefined, undefined, Direction.LTR);
2153
+
2154
+ expect(root.getComputedLeft()).toBe(0);
2155
+ expect(root.getComputedTop()).toBe(0);
2156
+ expect(root.getComputedWidth()).toBe(300);
2157
+ expect(root.getComputedHeight()).toBe(700);
2158
+
2159
+ expect(root_child0.getComputedLeft()).toBe(10);
2160
+ expect(root_child0.getComputedTop()).toBe(10);
2161
+ expect(root_child0.getComputedWidth()).toBe(100);
2162
+ expect(root_child0.getComputedHeight()).toBe(100);
2163
+
2164
+ expect(root_child1.getComputedLeft()).toBe(138);
2165
+ expect(root_child1.getComputedTop()).toBe(10);
2166
+ expect(root_child1.getComputedWidth()).toBe(100);
2167
+ expect(root_child1.getComputedHeight()).toBe(100);
2168
+
2169
+ expect(root_child2.getComputedLeft()).toBe(10);
2170
+ expect(root_child2.getComputedTop()).toBe(178);
2171
+ expect(root_child2.getComputedWidth()).toBe(100);
2172
+ expect(root_child2.getComputedHeight()).toBe(100);
2173
+
2174
+ expect(root_child3.getComputedLeft()).toBe(138);
2175
+ expect(root_child3.getComputedTop()).toBe(178);
2176
+ expect(root_child3.getComputedWidth()).toBe(100);
2177
+ expect(root_child3.getComputedHeight()).toBe(100);
2178
+
2179
+ expect(root_child4.getComputedLeft()).toBe(10);
2180
+ expect(root_child4.getComputedTop()).toBe(346);
2181
+ expect(root_child4.getComputedWidth()).toBe(100);
2182
+ expect(root_child4.getComputedHeight()).toBe(100);
2183
+
2184
+ root.calculateLayout(undefined, undefined, Direction.RTL);
2185
+
2186
+ expect(root.getComputedLeft()).toBe(0);
2187
+ expect(root.getComputedTop()).toBe(0);
2188
+ expect(root.getComputedWidth()).toBe(300);
2189
+ expect(root.getComputedHeight()).toBe(700);
2190
+
2191
+ expect(root_child0.getComputedLeft()).toBe(190);
2192
+ expect(root_child0.getComputedTop()).toBe(10);
2193
+ expect(root_child0.getComputedWidth()).toBe(100);
2194
+ expect(root_child0.getComputedHeight()).toBe(100);
2195
+
2196
+ expect(root_child1.getComputedLeft()).toBe(62);
2197
+ expect(root_child1.getComputedTop()).toBe(10);
2198
+ expect(root_child1.getComputedWidth()).toBe(100);
2199
+ expect(root_child1.getComputedHeight()).toBe(100);
2200
+
2201
+ expect(root_child2.getComputedLeft()).toBe(190);
2202
+ expect(root_child2.getComputedTop()).toBe(178);
2203
+ expect(root_child2.getComputedWidth()).toBe(100);
2204
+ expect(root_child2.getComputedHeight()).toBe(100);
2205
+
2206
+ expect(root_child3.getComputedLeft()).toBe(62);
2207
+ expect(root_child3.getComputedTop()).toBe(178);
2208
+ expect(root_child3.getComputedWidth()).toBe(100);
2209
+ expect(root_child3.getComputedHeight()).toBe(100);
2210
+
2211
+ expect(root_child4.getComputedLeft()).toBe(190);
2212
+ expect(root_child4.getComputedTop()).toBe(346);
2213
+ expect(root_child4.getComputedWidth()).toBe(100);
2214
+ expect(root_child4.getComputedHeight()).toBe(100);
2215
+ });
2216
+ test('row_gap_percent_determines_parent_height', () => {
2217
+ const config = Yoga.Config.create();
2218
+
2219
+ const root = Yoga.Node.create(config);
2220
+ root.setPositionType(PositionType.Absolute);
2221
+ root.setFlexDirection(FlexDirection.Row);
2222
+ root.setWidth(300);
2223
+ root.setGap(Gutter.All, "10%");
2224
+ root.setFlexWrap(Wrap.Wrap);
2225
+
2226
+ const root_child0 = Yoga.Node.create(config);
2227
+ root_child0.setWidth(100);
2228
+ root_child0.setHeight(100);
2229
+ root.insertChild(root_child0, 0);
2230
+
2231
+ const root_child1 = Yoga.Node.create(config);
2232
+ root_child1.setWidth(100);
2233
+ root_child1.setHeight(100);
2234
+ root.insertChild(root_child1, 1);
2235
+
2236
+ const root_child2 = Yoga.Node.create(config);
2237
+ root_child2.setWidth(100);
2238
+ root_child2.setHeight(100);
2239
+ root.insertChild(root_child2, 2);
2240
+
2241
+ const root_child3 = Yoga.Node.create(config);
2242
+ root_child3.setWidth(100);
2243
+ root_child3.setHeight(100);
2244
+ root.insertChild(root_child3, 3);
2245
+
2246
+ const root_child4 = Yoga.Node.create(config);
2247
+ root_child4.setWidth(100);
2248
+ root_child4.setHeight(100);
2249
+ root.insertChild(root_child4, 4);
2250
+ root.calculateLayout(undefined, undefined, Direction.LTR);
2251
+
2252
+ expect(root.getComputedLeft()).toBe(0);
2253
+ expect(root.getComputedTop()).toBe(0);
2254
+ expect(root.getComputedWidth()).toBe(300);
2255
+ expect(root.getComputedHeight()).toBe(300);
2256
+
2257
+ expect(root_child0.getComputedLeft()).toBe(0);
2258
+ expect(root_child0.getComputedTop()).toBe(0);
2259
+ expect(root_child0.getComputedWidth()).toBe(100);
2260
+ expect(root_child0.getComputedHeight()).toBe(100);
2261
+
2262
+ expect(root_child1.getComputedLeft()).toBe(130);
2263
+ expect(root_child1.getComputedTop()).toBe(0);
2264
+ expect(root_child1.getComputedWidth()).toBe(100);
2265
+ expect(root_child1.getComputedHeight()).toBe(100);
2266
+
2267
+ expect(root_child2.getComputedLeft()).toBe(0);
2268
+ expect(root_child2.getComputedTop()).toBe(100);
2269
+ expect(root_child2.getComputedWidth()).toBe(100);
2270
+ expect(root_child2.getComputedHeight()).toBe(100);
2271
+
2272
+ expect(root_child3.getComputedLeft()).toBe(130);
2273
+ expect(root_child3.getComputedTop()).toBe(100);
2274
+ expect(root_child3.getComputedWidth()).toBe(100);
2275
+ expect(root_child3.getComputedHeight()).toBe(100);
2276
+
2277
+ expect(root_child4.getComputedLeft()).toBe(0);
2278
+ expect(root_child4.getComputedTop()).toBe(200);
2279
+ expect(root_child4.getComputedWidth()).toBe(100);
2280
+ expect(root_child4.getComputedHeight()).toBe(100);
2281
+
2282
+ root.calculateLayout(undefined, undefined, Direction.RTL);
2283
+
2284
+ expect(root.getComputedLeft()).toBe(0);
2285
+ expect(root.getComputedTop()).toBe(0);
2286
+ expect(root.getComputedWidth()).toBe(300);
2287
+ expect(root.getComputedHeight()).toBe(300);
2288
+
2289
+ expect(root_child0.getComputedLeft()).toBe(200);
2290
+ expect(root_child0.getComputedTop()).toBe(0);
2291
+ expect(root_child0.getComputedWidth()).toBe(100);
2292
+ expect(root_child0.getComputedHeight()).toBe(100);
2293
+
2294
+ expect(root_child1.getComputedLeft()).toBe(70);
2295
+ expect(root_child1.getComputedTop()).toBe(0);
2296
+ expect(root_child1.getComputedWidth()).toBe(100);
2297
+ expect(root_child1.getComputedHeight()).toBe(100);
2298
+
2299
+ expect(root_child2.getComputedLeft()).toBe(200);
2300
+ expect(root_child2.getComputedTop()).toBe(100);
2301
+ expect(root_child2.getComputedWidth()).toBe(100);
2302
+ expect(root_child2.getComputedHeight()).toBe(100);
2303
+
2304
+ expect(root_child3.getComputedLeft()).toBe(70);
2305
+ expect(root_child3.getComputedTop()).toBe(100);
2306
+ expect(root_child3.getComputedWidth()).toBe(100);
2307
+ expect(root_child3.getComputedHeight()).toBe(100);
2308
+
2309
+ expect(root_child4.getComputedLeft()).toBe(200);
2310
+ expect(root_child4.getComputedTop()).toBe(200);
2311
+ expect(root_child4.getComputedWidth()).toBe(100);
2312
+ expect(root_child4.getComputedHeight()).toBe(100);
2313
+ });
2314
+ test('row_gap_percent_wrapping_with_both_content_padding_and_item_padding', () => {
2315
+ const config = Yoga.Config.create();
2316
+
2317
+ const root = Yoga.Node.create(config);
2318
+ root.setPositionType(PositionType.Absolute);
2319
+ root.setFlexDirection(FlexDirection.Row);
2320
+ root.setWidth(300);
2321
+ root.setHeight(700);
2322
+ root.setPadding(Edge.All, 10);
2323
+ root.setGap(Gutter.All, "10%");
2324
+ root.setFlexWrap(Wrap.Wrap);
2325
+
2326
+ const root_child0 = Yoga.Node.create(config);
2327
+ root_child0.setWidth(100);
2328
+ root_child0.setHeight(100);
2329
+ root_child0.setPadding(Edge.All, 10);
2330
+ root.insertChild(root_child0, 0);
2331
+
2332
+ const root_child1 = Yoga.Node.create(config);
2333
+ root_child1.setWidth(100);
2334
+ root_child1.setHeight(100);
2335
+ root_child1.setPadding(Edge.All, 10);
2336
+ root.insertChild(root_child1, 1);
2337
+
2338
+ const root_child2 = Yoga.Node.create(config);
2339
+ root_child2.setWidth(100);
2340
+ root_child2.setHeight(100);
2341
+ root_child2.setPadding(Edge.All, 10);
2342
+ root.insertChild(root_child2, 2);
2343
+
2344
+ const root_child3 = Yoga.Node.create(config);
2345
+ root_child3.setWidth(100);
2346
+ root_child3.setHeight(100);
2347
+ root_child3.setPadding(Edge.All, 10);
2348
+ root.insertChild(root_child3, 3);
2349
+
2350
+ const root_child4 = Yoga.Node.create(config);
2351
+ root_child4.setWidth(100);
2352
+ root_child4.setHeight(100);
2353
+ root_child4.setPadding(Edge.All, 10);
2354
+ root.insertChild(root_child4, 4);
2355
+ root.calculateLayout(undefined, undefined, Direction.LTR);
2356
+
2357
+ expect(root.getComputedLeft()).toBe(0);
2358
+ expect(root.getComputedTop()).toBe(0);
2359
+ expect(root.getComputedWidth()).toBe(300);
2360
+ expect(root.getComputedHeight()).toBe(700);
2361
+
2362
+ expect(root_child0.getComputedLeft()).toBe(10);
2363
+ expect(root_child0.getComputedTop()).toBe(10);
2364
+ expect(root_child0.getComputedWidth()).toBe(100);
2365
+ expect(root_child0.getComputedHeight()).toBe(100);
2366
+
2367
+ expect(root_child1.getComputedLeft()).toBe(138);
2368
+ expect(root_child1.getComputedTop()).toBe(10);
2369
+ expect(root_child1.getComputedWidth()).toBe(100);
2370
+ expect(root_child1.getComputedHeight()).toBe(100);
2371
+
2372
+ expect(root_child2.getComputedLeft()).toBe(10);
2373
+ expect(root_child2.getComputedTop()).toBe(178);
2374
+ expect(root_child2.getComputedWidth()).toBe(100);
2375
+ expect(root_child2.getComputedHeight()).toBe(100);
2376
+
2377
+ expect(root_child3.getComputedLeft()).toBe(138);
2378
+ expect(root_child3.getComputedTop()).toBe(178);
2379
+ expect(root_child3.getComputedWidth()).toBe(100);
2380
+ expect(root_child3.getComputedHeight()).toBe(100);
2381
+
2382
+ expect(root_child4.getComputedLeft()).toBe(10);
2383
+ expect(root_child4.getComputedTop()).toBe(346);
2384
+ expect(root_child4.getComputedWidth()).toBe(100);
2385
+ expect(root_child4.getComputedHeight()).toBe(100);
2386
+
2387
+ root.calculateLayout(undefined, undefined, Direction.RTL);
2388
+
2389
+ expect(root.getComputedLeft()).toBe(0);
2390
+ expect(root.getComputedTop()).toBe(0);
2391
+ expect(root.getComputedWidth()).toBe(300);
2392
+ expect(root.getComputedHeight()).toBe(700);
2393
+
2394
+ expect(root_child0.getComputedLeft()).toBe(190);
2395
+ expect(root_child0.getComputedTop()).toBe(10);
2396
+ expect(root_child0.getComputedWidth()).toBe(100);
2397
+ expect(root_child0.getComputedHeight()).toBe(100);
2398
+
2399
+ expect(root_child1.getComputedLeft()).toBe(62);
2400
+ expect(root_child1.getComputedTop()).toBe(10);
2401
+ expect(root_child1.getComputedWidth()).toBe(100);
2402
+ expect(root_child1.getComputedHeight()).toBe(100);
2403
+
2404
+ expect(root_child2.getComputedLeft()).toBe(190);
2405
+ expect(root_child2.getComputedTop()).toBe(178);
2406
+ expect(root_child2.getComputedWidth()).toBe(100);
2407
+ expect(root_child2.getComputedHeight()).toBe(100);
2408
+
2409
+ expect(root_child3.getComputedLeft()).toBe(62);
2410
+ expect(root_child3.getComputedTop()).toBe(178);
2411
+ expect(root_child3.getComputedWidth()).toBe(100);
2412
+ expect(root_child3.getComputedHeight()).toBe(100);
2413
+
2414
+ expect(root_child4.getComputedLeft()).toBe(190);
2415
+ expect(root_child4.getComputedTop()).toBe(346);
2416
+ expect(root_child4.getComputedWidth()).toBe(100);
2417
+ expect(root_child4.getComputedHeight()).toBe(100);
2418
+ });
2419
+ test('row_gap_percent_wrapping_with_both_content_padding', () => {
2420
+ const config = Yoga.Config.create();
2421
+
2422
+ const root = Yoga.Node.create(config);
2423
+ root.setPositionType(PositionType.Absolute);
2424
+ root.setFlexDirection(FlexDirection.Row);
2425
+ root.setWidth(300);
2426
+ root.setHeight(700);
2427
+ root.setPadding(Edge.All, 10);
2428
+ root.setGap(Gutter.All, "10%");
2429
+ root.setFlexWrap(Wrap.Wrap);
2430
+
2431
+ const root_child0 = Yoga.Node.create(config);
2432
+ root_child0.setWidth(100);
2433
+ root_child0.setHeight(100);
2434
+ root.insertChild(root_child0, 0);
2435
+
2436
+ const root_child1 = Yoga.Node.create(config);
2437
+ root_child1.setWidth(100);
2438
+ root_child1.setHeight(100);
2439
+ root.insertChild(root_child1, 1);
2440
+
2441
+ const root_child2 = Yoga.Node.create(config);
2442
+ root_child2.setWidth(100);
2443
+ root_child2.setHeight(100);
2444
+ root.insertChild(root_child2, 2);
2445
+
2446
+ const root_child3 = Yoga.Node.create(config);
2447
+ root_child3.setWidth(100);
2448
+ root_child3.setHeight(100);
2449
+ root.insertChild(root_child3, 3);
2450
+
2451
+ const root_child4 = Yoga.Node.create(config);
2452
+ root_child4.setWidth(100);
2453
+ root_child4.setHeight(100);
2454
+ root.insertChild(root_child4, 4);
2455
+ root.calculateLayout(undefined, undefined, Direction.LTR);
2456
+
2457
+ expect(root.getComputedLeft()).toBe(0);
2458
+ expect(root.getComputedTop()).toBe(0);
2459
+ expect(root.getComputedWidth()).toBe(300);
2460
+ expect(root.getComputedHeight()).toBe(700);
2461
+
2462
+ expect(root_child0.getComputedLeft()).toBe(10);
2463
+ expect(root_child0.getComputedTop()).toBe(10);
2464
+ expect(root_child0.getComputedWidth()).toBe(100);
2465
+ expect(root_child0.getComputedHeight()).toBe(100);
2466
+
2467
+ expect(root_child1.getComputedLeft()).toBe(138);
2468
+ expect(root_child1.getComputedTop()).toBe(10);
2469
+ expect(root_child1.getComputedWidth()).toBe(100);
2470
+ expect(root_child1.getComputedHeight()).toBe(100);
2471
+
2472
+ expect(root_child2.getComputedLeft()).toBe(10);
2473
+ expect(root_child2.getComputedTop()).toBe(178);
2474
+ expect(root_child2.getComputedWidth()).toBe(100);
2475
+ expect(root_child2.getComputedHeight()).toBe(100);
2476
+
2477
+ expect(root_child3.getComputedLeft()).toBe(138);
2478
+ expect(root_child3.getComputedTop()).toBe(178);
2479
+ expect(root_child3.getComputedWidth()).toBe(100);
2480
+ expect(root_child3.getComputedHeight()).toBe(100);
2481
+
2482
+ expect(root_child4.getComputedLeft()).toBe(10);
2483
+ expect(root_child4.getComputedTop()).toBe(346);
2484
+ expect(root_child4.getComputedWidth()).toBe(100);
2485
+ expect(root_child4.getComputedHeight()).toBe(100);
2486
+
2487
+ root.calculateLayout(undefined, undefined, Direction.RTL);
2488
+
2489
+ expect(root.getComputedLeft()).toBe(0);
2490
+ expect(root.getComputedTop()).toBe(0);
2491
+ expect(root.getComputedWidth()).toBe(300);
2492
+ expect(root.getComputedHeight()).toBe(700);
2493
+
2494
+ expect(root_child0.getComputedLeft()).toBe(190);
2495
+ expect(root_child0.getComputedTop()).toBe(10);
2496
+ expect(root_child0.getComputedWidth()).toBe(100);
2497
+ expect(root_child0.getComputedHeight()).toBe(100);
2498
+
2499
+ expect(root_child1.getComputedLeft()).toBe(62);
2500
+ expect(root_child1.getComputedTop()).toBe(10);
2501
+ expect(root_child1.getComputedWidth()).toBe(100);
2502
+ expect(root_child1.getComputedHeight()).toBe(100);
2503
+
2504
+ expect(root_child2.getComputedLeft()).toBe(190);
2505
+ expect(root_child2.getComputedTop()).toBe(178);
2506
+ expect(root_child2.getComputedWidth()).toBe(100);
2507
+ expect(root_child2.getComputedHeight()).toBe(100);
2508
+
2509
+ expect(root_child3.getComputedLeft()).toBe(62);
2510
+ expect(root_child3.getComputedTop()).toBe(178);
2511
+ expect(root_child3.getComputedWidth()).toBe(100);
2512
+ expect(root_child3.getComputedHeight()).toBe(100);
2513
+
2514
+ expect(root_child4.getComputedLeft()).toBe(190);
2515
+ expect(root_child4.getComputedTop()).toBe(346);
2516
+ expect(root_child4.getComputedWidth()).toBe(100);
2517
+ expect(root_child4.getComputedHeight()).toBe(100);
2518
+ });
2519
+ test('row_gap_percent_wrapping_with_content_margin', () => {
2520
+ const config = Yoga.Config.create();
2521
+
2522
+ const root = Yoga.Node.create(config);
2523
+ root.setPositionType(PositionType.Absolute);
2524
+ root.setFlexDirection(FlexDirection.Row);
2525
+ root.setWidth(300);
2526
+ root.setHeight(700);
2527
+ root.setMargin(Edge.All, 10);
2528
+ root.setGap(Gutter.All, "10%");
2529
+ root.setFlexWrap(Wrap.Wrap);
2530
+
2531
+ const root_child0 = Yoga.Node.create(config);
2532
+ root_child0.setWidth(100);
2533
+ root_child0.setHeight(100);
2534
+ root.insertChild(root_child0, 0);
2535
+
2536
+ const root_child1 = Yoga.Node.create(config);
2537
+ root_child1.setWidth(100);
2538
+ root_child1.setHeight(100);
2539
+ root.insertChild(root_child1, 1);
2540
+
2541
+ const root_child2 = Yoga.Node.create(config);
2542
+ root_child2.setWidth(100);
2543
+ root_child2.setHeight(100);
2544
+ root.insertChild(root_child2, 2);
2545
+
2546
+ const root_child3 = Yoga.Node.create(config);
2547
+ root_child3.setWidth(100);
2548
+ root_child3.setHeight(100);
2549
+ root.insertChild(root_child3, 3);
2550
+
2551
+ const root_child4 = Yoga.Node.create(config);
2552
+ root_child4.setWidth(100);
2553
+ root_child4.setHeight(100);
2554
+ root.insertChild(root_child4, 4);
2555
+ root.calculateLayout(undefined, undefined, Direction.LTR);
2556
+
2557
+ expect(root.getComputedLeft()).toBe(10);
2558
+ expect(root.getComputedTop()).toBe(10);
2559
+ expect(root.getComputedWidth()).toBe(300);
2560
+ expect(root.getComputedHeight()).toBe(700);
2561
+
2562
+ expect(root_child0.getComputedLeft()).toBe(0);
2563
+ expect(root_child0.getComputedTop()).toBe(0);
2564
+ expect(root_child0.getComputedWidth()).toBe(100);
2565
+ expect(root_child0.getComputedHeight()).toBe(100);
2566
+
2567
+ expect(root_child1.getComputedLeft()).toBe(130);
2568
+ expect(root_child1.getComputedTop()).toBe(0);
2569
+ expect(root_child1.getComputedWidth()).toBe(100);
2570
+ expect(root_child1.getComputedHeight()).toBe(100);
2571
+
2572
+ expect(root_child2.getComputedLeft()).toBe(0);
2573
+ expect(root_child2.getComputedTop()).toBe(170);
2574
+ expect(root_child2.getComputedWidth()).toBe(100);
2575
+ expect(root_child2.getComputedHeight()).toBe(100);
2576
+
2577
+ expect(root_child3.getComputedLeft()).toBe(130);
2578
+ expect(root_child3.getComputedTop()).toBe(170);
2579
+ expect(root_child3.getComputedWidth()).toBe(100);
2580
+ expect(root_child3.getComputedHeight()).toBe(100);
2581
+
2582
+ expect(root_child4.getComputedLeft()).toBe(0);
2583
+ expect(root_child4.getComputedTop()).toBe(340);
2584
+ expect(root_child4.getComputedWidth()).toBe(100);
2585
+ expect(root_child4.getComputedHeight()).toBe(100);
2586
+
2587
+ root.calculateLayout(undefined, undefined, Direction.RTL);
2588
+
2589
+ expect(root.getComputedLeft()).toBe(10);
2590
+ expect(root.getComputedTop()).toBe(10);
2591
+ expect(root.getComputedWidth()).toBe(300);
2592
+ expect(root.getComputedHeight()).toBe(700);
2593
+
2594
+ expect(root_child0.getComputedLeft()).toBe(200);
2595
+ expect(root_child0.getComputedTop()).toBe(0);
2596
+ expect(root_child0.getComputedWidth()).toBe(100);
2597
+ expect(root_child0.getComputedHeight()).toBe(100);
2598
+
2599
+ expect(root_child1.getComputedLeft()).toBe(70);
2600
+ expect(root_child1.getComputedTop()).toBe(0);
2601
+ expect(root_child1.getComputedWidth()).toBe(100);
2602
+ expect(root_child1.getComputedHeight()).toBe(100);
2603
+
2604
+ expect(root_child2.getComputedLeft()).toBe(200);
2605
+ expect(root_child2.getComputedTop()).toBe(170);
2606
+ expect(root_child2.getComputedWidth()).toBe(100);
2607
+ expect(root_child2.getComputedHeight()).toBe(100);
2608
+
2609
+ expect(root_child3.getComputedLeft()).toBe(70);
2610
+ expect(root_child3.getComputedTop()).toBe(170);
2611
+ expect(root_child3.getComputedWidth()).toBe(100);
2612
+ expect(root_child3.getComputedHeight()).toBe(100);
2613
+
2614
+ expect(root_child4.getComputedLeft()).toBe(200);
2615
+ expect(root_child4.getComputedTop()).toBe(340);
2616
+ expect(root_child4.getComputedWidth()).toBe(100);
2617
+ expect(root_child4.getComputedHeight()).toBe(100);
2618
+ });
2619
+ test('row_gap_percent_wrapping_with_content_margin_and_padding', () => {
2620
+ const config = Yoga.Config.create();
2621
+
2622
+ const root = Yoga.Node.create(config);
2623
+ root.setPositionType(PositionType.Absolute);
2624
+ root.setFlexDirection(FlexDirection.Row);
2625
+ root.setWidth(300);
2626
+ root.setHeight(700);
2627
+ root.setMargin(Edge.All, 10);
2628
+ root.setPadding(Edge.All, 10);
2629
+ root.setGap(Gutter.All, "10%");
2630
+ root.setFlexWrap(Wrap.Wrap);
2631
+
2632
+ const root_child0 = Yoga.Node.create(config);
2633
+ root_child0.setWidth(100);
2634
+ root_child0.setHeight(100);
2635
+ root.insertChild(root_child0, 0);
2636
+
2637
+ const root_child1 = Yoga.Node.create(config);
2638
+ root_child1.setWidth(100);
2639
+ root_child1.setHeight(100);
2640
+ root.insertChild(root_child1, 1);
2641
+
2642
+ const root_child2 = Yoga.Node.create(config);
2643
+ root_child2.setWidth(100);
2644
+ root_child2.setHeight(100);
2645
+ root.insertChild(root_child2, 2);
2646
+
2647
+ const root_child3 = Yoga.Node.create(config);
2648
+ root_child3.setWidth(100);
2649
+ root_child3.setHeight(100);
2650
+ root.insertChild(root_child3, 3);
2651
+
2652
+ const root_child4 = Yoga.Node.create(config);
2653
+ root_child4.setWidth(100);
2654
+ root_child4.setHeight(100);
2655
+ root.insertChild(root_child4, 4);
2656
+ root.calculateLayout(undefined, undefined, Direction.LTR);
2657
+
2658
+ expect(root.getComputedLeft()).toBe(10);
2659
+ expect(root.getComputedTop()).toBe(10);
2660
+ expect(root.getComputedWidth()).toBe(300);
2661
+ expect(root.getComputedHeight()).toBe(700);
2662
+
2663
+ expect(root_child0.getComputedLeft()).toBe(10);
2664
+ expect(root_child0.getComputedTop()).toBe(10);
2665
+ expect(root_child0.getComputedWidth()).toBe(100);
2666
+ expect(root_child0.getComputedHeight()).toBe(100);
2667
+
2668
+ expect(root_child1.getComputedLeft()).toBe(138);
2669
+ expect(root_child1.getComputedTop()).toBe(10);
2670
+ expect(root_child1.getComputedWidth()).toBe(100);
2671
+ expect(root_child1.getComputedHeight()).toBe(100);
2672
+
2673
+ expect(root_child2.getComputedLeft()).toBe(10);
2674
+ expect(root_child2.getComputedTop()).toBe(178);
2675
+ expect(root_child2.getComputedWidth()).toBe(100);
2676
+ expect(root_child2.getComputedHeight()).toBe(100);
2677
+
2678
+ expect(root_child3.getComputedLeft()).toBe(138);
2679
+ expect(root_child3.getComputedTop()).toBe(178);
2680
+ expect(root_child3.getComputedWidth()).toBe(100);
2681
+ expect(root_child3.getComputedHeight()).toBe(100);
2682
+
2683
+ expect(root_child4.getComputedLeft()).toBe(10);
2684
+ expect(root_child4.getComputedTop()).toBe(346);
2685
+ expect(root_child4.getComputedWidth()).toBe(100);
2686
+ expect(root_child4.getComputedHeight()).toBe(100);
2687
+
2688
+ root.calculateLayout(undefined, undefined, Direction.RTL);
2689
+
2690
+ expect(root.getComputedLeft()).toBe(10);
2691
+ expect(root.getComputedTop()).toBe(10);
2692
+ expect(root.getComputedWidth()).toBe(300);
2693
+ expect(root.getComputedHeight()).toBe(700);
2694
+
2695
+ expect(root_child0.getComputedLeft()).toBe(190);
2696
+ expect(root_child0.getComputedTop()).toBe(10);
2697
+ expect(root_child0.getComputedWidth()).toBe(100);
2698
+ expect(root_child0.getComputedHeight()).toBe(100);
2699
+
2700
+ expect(root_child1.getComputedLeft()).toBe(62);
2701
+ expect(root_child1.getComputedTop()).toBe(10);
2702
+ expect(root_child1.getComputedWidth()).toBe(100);
2703
+ expect(root_child1.getComputedHeight()).toBe(100);
2704
+
2705
+ expect(root_child2.getComputedLeft()).toBe(190);
2706
+ expect(root_child2.getComputedTop()).toBe(178);
2707
+ expect(root_child2.getComputedWidth()).toBe(100);
2708
+ expect(root_child2.getComputedHeight()).toBe(100);
2709
+
2710
+ expect(root_child3.getComputedLeft()).toBe(62);
2711
+ expect(root_child3.getComputedTop()).toBe(178);
2712
+ expect(root_child3.getComputedWidth()).toBe(100);
2713
+ expect(root_child3.getComputedHeight()).toBe(100);
2714
+
2715
+ expect(root_child4.getComputedLeft()).toBe(190);
2716
+ expect(root_child4.getComputedTop()).toBe(346);
2717
+ expect(root_child4.getComputedWidth()).toBe(100);
2718
+ expect(root_child4.getComputedHeight()).toBe(100);
2719
+ });
2720
+ test('row_gap_percent_wrapping_with_flexible_content', () => {
2721
+ const config = Yoga.Config.create();
2722
+
2723
+ const root = Yoga.Node.create(config);
2724
+ root.setPositionType(PositionType.Absolute);
2725
+ root.setFlexDirection(FlexDirection.Row);
2726
+ root.setWidth(300);
2727
+ root.setHeight(300);
2728
+ root.setGap(Gutter.All, "10%");
2729
+
2730
+ const root_child0 = Yoga.Node.create(config);
2731
+ root_child0.setFlexGrow(1);
2732
+ root_child0.setFlexShrink(1);
2733
+ root_child0.setFlexBasis("0%");
2734
+ root.insertChild(root_child0, 0);
2735
+
2736
+ const root_child1 = Yoga.Node.create(config);
2737
+ root_child1.setFlexGrow(1);
2738
+ root_child1.setFlexShrink(1);
2739
+ root_child1.setFlexBasis("0%");
2740
+ root.insertChild(root_child1, 1);
2741
+
2742
+ const root_child2 = Yoga.Node.create(config);
2743
+ root_child2.setFlexGrow(1);
2744
+ root_child2.setFlexShrink(1);
2745
+ root_child2.setFlexBasis("0%");
2746
+ root.insertChild(root_child2, 2);
2747
+ root.calculateLayout(undefined, undefined, Direction.LTR);
2748
+
2749
+ expect(root.getComputedLeft()).toBe(0);
2750
+ expect(root.getComputedTop()).toBe(0);
2751
+ expect(root.getComputedWidth()).toBe(300);
2752
+ expect(root.getComputedHeight()).toBe(300);
2753
+
2754
+ expect(root_child0.getComputedLeft()).toBe(0);
2755
+ expect(root_child0.getComputedTop()).toBe(0);
2756
+ expect(root_child0.getComputedWidth()).toBe(80);
2757
+ expect(root_child0.getComputedHeight()).toBe(300);
2758
+
2759
+ expect(root_child1.getComputedLeft()).toBe(110);
2760
+ expect(root_child1.getComputedTop()).toBe(0);
2761
+ expect(root_child1.getComputedWidth()).toBe(80);
2762
+ expect(root_child1.getComputedHeight()).toBe(300);
2763
+
2764
+ expect(root_child2.getComputedLeft()).toBe(220);
2765
+ expect(root_child2.getComputedTop()).toBe(0);
2766
+ expect(root_child2.getComputedWidth()).toBe(80);
2767
+ expect(root_child2.getComputedHeight()).toBe(300);
2768
+
2769
+ root.calculateLayout(undefined, undefined, Direction.RTL);
2770
+
2771
+ expect(root.getComputedLeft()).toBe(0);
2772
+ expect(root.getComputedTop()).toBe(0);
2773
+ expect(root.getComputedWidth()).toBe(300);
2774
+ expect(root.getComputedHeight()).toBe(300);
2775
+
2776
+ expect(root_child0.getComputedLeft()).toBe(220);
2777
+ expect(root_child0.getComputedTop()).toBe(0);
2778
+ expect(root_child0.getComputedWidth()).toBe(80);
2779
+ expect(root_child0.getComputedHeight()).toBe(300);
2780
+
2781
+ expect(root_child1.getComputedLeft()).toBe(110);
2782
+ expect(root_child1.getComputedTop()).toBe(0);
2783
+ expect(root_child1.getComputedWidth()).toBe(80);
2784
+ expect(root_child1.getComputedHeight()).toBe(300);
2785
+
2786
+ expect(root_child2.getComputedLeft()).toBe(0);
2787
+ expect(root_child2.getComputedTop()).toBe(0);
2788
+ expect(root_child2.getComputedWidth()).toBe(80);
2789
+ expect(root_child2.getComputedHeight()).toBe(300);
2790
+ });
2791
+ test('row_gap_percent_wrapping_with_mixed_flexible_content', () => {
2792
+ const config = Yoga.Config.create();
2793
+
2794
+ const root = Yoga.Node.create(config);
2795
+ root.setPositionType(PositionType.Absolute);
2796
+ root.setFlexDirection(FlexDirection.Row);
2797
+ root.setWidth(300);
2798
+ root.setHeight(300);
2799
+ root.setGap(Gutter.All, "10%");
2800
+
2801
+ const root_child0 = Yoga.Node.create(config);
2802
+ root_child0.setWidth(10);
2803
+ root.insertChild(root_child0, 0);
2804
+
2805
+ const root_child1 = Yoga.Node.create(config);
2806
+ root_child1.setFlexGrow(1);
2807
+ root_child1.setFlexShrink(1);
2808
+ root_child1.setFlexBasis("0%");
2809
+ root.insertChild(root_child1, 1);
2810
+
2811
+ const root_child2 = Yoga.Node.create(config);
2812
+ root_child2.setWidth("10%");
2813
+ root.insertChild(root_child2, 2);
2814
+ root.calculateLayout(undefined, undefined, Direction.LTR);
2815
+
2816
+ expect(root.getComputedLeft()).toBe(0);
2817
+ expect(root.getComputedTop()).toBe(0);
2818
+ expect(root.getComputedWidth()).toBe(300);
2819
+ expect(root.getComputedHeight()).toBe(300);
2820
+
2821
+ expect(root_child0.getComputedLeft()).toBe(0);
2822
+ expect(root_child0.getComputedTop()).toBe(0);
2823
+ expect(root_child0.getComputedWidth()).toBe(10);
2824
+ expect(root_child0.getComputedHeight()).toBe(300);
2825
+
2826
+ expect(root_child1.getComputedLeft()).toBe(40);
2827
+ expect(root_child1.getComputedTop()).toBe(0);
2828
+ expect(root_child1.getComputedWidth()).toBe(200);
2829
+ expect(root_child1.getComputedHeight()).toBe(300);
2830
+
2831
+ expect(root_child2.getComputedLeft()).toBe(270);
2832
+ expect(root_child2.getComputedTop()).toBe(0);
2833
+ expect(root_child2.getComputedWidth()).toBe(30);
2834
+ expect(root_child2.getComputedHeight()).toBe(300);
2835
+
2836
+ root.calculateLayout(undefined, undefined, Direction.RTL);
2837
+
2838
+ expect(root.getComputedLeft()).toBe(0);
2839
+ expect(root.getComputedTop()).toBe(0);
2840
+ expect(root.getComputedWidth()).toBe(300);
2841
+ expect(root.getComputedHeight()).toBe(300);
2842
+
2843
+ expect(root_child0.getComputedLeft()).toBe(290);
2844
+ expect(root_child0.getComputedTop()).toBe(0);
2845
+ expect(root_child0.getComputedWidth()).toBe(10);
2846
+ expect(root_child0.getComputedHeight()).toBe(300);
2847
+
2848
+ expect(root_child1.getComputedLeft()).toBe(60);
2849
+ expect(root_child1.getComputedTop()).toBe(0);
2850
+ expect(root_child1.getComputedWidth()).toBe(200);
2851
+ expect(root_child1.getComputedHeight()).toBe(300);
2852
+
2853
+ expect(root_child2.getComputedLeft()).toBe(0);
2854
+ expect(root_child2.getComputedTop()).toBe(0);
2855
+ expect(root_child2.getComputedWidth()).toBe(30);
2856
+ expect(root_child2.getComputedHeight()).toBe(300);
2857
+ });