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,1978 @@
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<<a412a7c5a9ab605a584532557337f2be>>
8
+ * generated by gentest/src/GentestDriver.ts from gentest/fixtures/YGBoxSizingTest.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('box_sizing_content_box_simple', () => {
32
+ const config = Yoga.Config.create();
33
+
34
+ const root = Yoga.Node.create(config);
35
+ root.setPositionType(PositionType.Absolute);
36
+ root.setWidth(100);
37
+ root.setHeight(100);
38
+ root.setPadding(Edge.All, 5);
39
+ root.setBorder(Edge.All, 10);
40
+ root.setBoxSizing(BoxSizing.ContentBox);
41
+ root.calculateLayout(undefined, undefined, Direction.LTR);
42
+
43
+ expect(root.getComputedLeft()).toBe(0);
44
+ expect(root.getComputedTop()).toBe(0);
45
+ expect(root.getComputedWidth()).toBe(130);
46
+ expect(root.getComputedHeight()).toBe(130);
47
+
48
+ root.calculateLayout(undefined, undefined, Direction.RTL);
49
+
50
+ expect(root.getComputedLeft()).toBe(0);
51
+ expect(root.getComputedTop()).toBe(0);
52
+ expect(root.getComputedWidth()).toBe(130);
53
+ expect(root.getComputedHeight()).toBe(130);
54
+ });
55
+ test('box_sizing_border_box_simple', () => {
56
+ const config = Yoga.Config.create();
57
+
58
+ const root = Yoga.Node.create(config);
59
+ root.setPositionType(PositionType.Absolute);
60
+ root.setWidth(100);
61
+ root.setHeight(100);
62
+ root.setPadding(Edge.All, 5);
63
+ root.setBorder(Edge.All, 10);
64
+ root.calculateLayout(undefined, undefined, Direction.LTR);
65
+
66
+ expect(root.getComputedLeft()).toBe(0);
67
+ expect(root.getComputedTop()).toBe(0);
68
+ expect(root.getComputedWidth()).toBe(100);
69
+ expect(root.getComputedHeight()).toBe(100);
70
+
71
+ root.calculateLayout(undefined, undefined, Direction.RTL);
72
+
73
+ expect(root.getComputedLeft()).toBe(0);
74
+ expect(root.getComputedTop()).toBe(0);
75
+ expect(root.getComputedWidth()).toBe(100);
76
+ expect(root.getComputedHeight()).toBe(100);
77
+ });
78
+ test('box_sizing_content_box_percent', () => {
79
+ const config = Yoga.Config.create();
80
+
81
+ const root = Yoga.Node.create(config);
82
+ root.setPositionType(PositionType.Absolute);
83
+ root.setWidth(100);
84
+ root.setHeight(100);
85
+
86
+ const root_child0 = Yoga.Node.create(config);
87
+ root_child0.setWidth("50%");
88
+ root_child0.setHeight("25%");
89
+ root_child0.setPadding(Edge.All, 4);
90
+ root_child0.setBorder(Edge.All, 16);
91
+ root_child0.setBoxSizing(BoxSizing.ContentBox);
92
+ root.insertChild(root_child0, 0);
93
+ root.calculateLayout(undefined, undefined, Direction.LTR);
94
+
95
+ expect(root.getComputedLeft()).toBe(0);
96
+ expect(root.getComputedTop()).toBe(0);
97
+ expect(root.getComputedWidth()).toBe(100);
98
+ expect(root.getComputedHeight()).toBe(100);
99
+
100
+ expect(root_child0.getComputedLeft()).toBe(0);
101
+ expect(root_child0.getComputedTop()).toBe(0);
102
+ expect(root_child0.getComputedWidth()).toBe(90);
103
+ expect(root_child0.getComputedHeight()).toBe(65);
104
+
105
+ root.calculateLayout(undefined, undefined, Direction.RTL);
106
+
107
+ expect(root.getComputedLeft()).toBe(0);
108
+ expect(root.getComputedTop()).toBe(0);
109
+ expect(root.getComputedWidth()).toBe(100);
110
+ expect(root.getComputedHeight()).toBe(100);
111
+
112
+ expect(root_child0.getComputedLeft()).toBe(10);
113
+ expect(root_child0.getComputedTop()).toBe(0);
114
+ expect(root_child0.getComputedWidth()).toBe(90);
115
+ expect(root_child0.getComputedHeight()).toBe(65);
116
+ });
117
+ test('box_sizing_border_box_percent', () => {
118
+ const config = Yoga.Config.create();
119
+
120
+ const root = Yoga.Node.create(config);
121
+ root.setPositionType(PositionType.Absolute);
122
+ root.setWidth(100);
123
+ root.setHeight(100);
124
+
125
+ const root_child0 = Yoga.Node.create(config);
126
+ root_child0.setWidth("50%");
127
+ root_child0.setHeight("25%");
128
+ root_child0.setPadding(Edge.All, 4);
129
+ root_child0.setBorder(Edge.All, 16);
130
+ root.insertChild(root_child0, 0);
131
+ root.calculateLayout(undefined, undefined, Direction.LTR);
132
+
133
+ expect(root.getComputedLeft()).toBe(0);
134
+ expect(root.getComputedTop()).toBe(0);
135
+ expect(root.getComputedWidth()).toBe(100);
136
+ expect(root.getComputedHeight()).toBe(100);
137
+
138
+ expect(root_child0.getComputedLeft()).toBe(0);
139
+ expect(root_child0.getComputedTop()).toBe(0);
140
+ expect(root_child0.getComputedWidth()).toBe(50);
141
+ expect(root_child0.getComputedHeight()).toBe(40);
142
+
143
+ root.calculateLayout(undefined, undefined, Direction.RTL);
144
+
145
+ expect(root.getComputedLeft()).toBe(0);
146
+ expect(root.getComputedTop()).toBe(0);
147
+ expect(root.getComputedWidth()).toBe(100);
148
+ expect(root.getComputedHeight()).toBe(100);
149
+
150
+ expect(root_child0.getComputedLeft()).toBe(50);
151
+ expect(root_child0.getComputedTop()).toBe(0);
152
+ expect(root_child0.getComputedWidth()).toBe(50);
153
+ expect(root_child0.getComputedHeight()).toBe(40);
154
+ });
155
+ test('box_sizing_content_box_absolute', () => {
156
+ const config = Yoga.Config.create();
157
+
158
+ const root = Yoga.Node.create(config);
159
+ root.setPositionType(PositionType.Absolute);
160
+ root.setWidth(100);
161
+ root.setHeight(100);
162
+
163
+ const root_child0 = Yoga.Node.create(config);
164
+ root_child0.setHeight("25%");
165
+ root_child0.setPadding(Edge.All, 12);
166
+ root_child0.setBorder(Edge.All, 8);
167
+ root_child0.setBoxSizing(BoxSizing.ContentBox);
168
+ root_child0.setPositionType(PositionType.Absolute);
169
+ root.insertChild(root_child0, 0);
170
+ root.calculateLayout(undefined, undefined, Direction.LTR);
171
+
172
+ expect(root.getComputedLeft()).toBe(0);
173
+ expect(root.getComputedTop()).toBe(0);
174
+ expect(root.getComputedWidth()).toBe(100);
175
+ expect(root.getComputedHeight()).toBe(100);
176
+
177
+ expect(root_child0.getComputedLeft()).toBe(0);
178
+ expect(root_child0.getComputedTop()).toBe(0);
179
+ expect(root_child0.getComputedWidth()).toBe(40);
180
+ expect(root_child0.getComputedHeight()).toBe(65);
181
+
182
+ root.calculateLayout(undefined, undefined, Direction.RTL);
183
+
184
+ expect(root.getComputedLeft()).toBe(0);
185
+ expect(root.getComputedTop()).toBe(0);
186
+ expect(root.getComputedWidth()).toBe(100);
187
+ expect(root.getComputedHeight()).toBe(100);
188
+
189
+ expect(root_child0.getComputedLeft()).toBe(60);
190
+ expect(root_child0.getComputedTop()).toBe(0);
191
+ expect(root_child0.getComputedWidth()).toBe(40);
192
+ expect(root_child0.getComputedHeight()).toBe(65);
193
+ });
194
+ test('box_sizing_border_box_absolute', () => {
195
+ const config = Yoga.Config.create();
196
+
197
+ const root = Yoga.Node.create(config);
198
+ root.setPositionType(PositionType.Absolute);
199
+ root.setWidth(100);
200
+ root.setHeight(100);
201
+
202
+ const root_child0 = Yoga.Node.create(config);
203
+ root_child0.setHeight("25%");
204
+ root_child0.setPadding(Edge.All, 12);
205
+ root_child0.setBorder(Edge.All, 8);
206
+ root_child0.setPositionType(PositionType.Absolute);
207
+ root.insertChild(root_child0, 0);
208
+ root.calculateLayout(undefined, undefined, Direction.LTR);
209
+
210
+ expect(root.getComputedLeft()).toBe(0);
211
+ expect(root.getComputedTop()).toBe(0);
212
+ expect(root.getComputedWidth()).toBe(100);
213
+ expect(root.getComputedHeight()).toBe(100);
214
+
215
+ expect(root_child0.getComputedLeft()).toBe(0);
216
+ expect(root_child0.getComputedTop()).toBe(0);
217
+ expect(root_child0.getComputedWidth()).toBe(40);
218
+ expect(root_child0.getComputedHeight()).toBe(40);
219
+
220
+ root.calculateLayout(undefined, undefined, Direction.RTL);
221
+
222
+ expect(root.getComputedLeft()).toBe(0);
223
+ expect(root.getComputedTop()).toBe(0);
224
+ expect(root.getComputedWidth()).toBe(100);
225
+ expect(root.getComputedHeight()).toBe(100);
226
+
227
+ expect(root_child0.getComputedLeft()).toBe(60);
228
+ expect(root_child0.getComputedTop()).toBe(0);
229
+ expect(root_child0.getComputedWidth()).toBe(40);
230
+ expect(root_child0.getComputedHeight()).toBe(40);
231
+ });
232
+ test('box_sizing_content_box_comtaining_block', () => {
233
+ const config = Yoga.Config.create();
234
+
235
+ const root = Yoga.Node.create(config);
236
+ root.setPositionType(PositionType.Absolute);
237
+ root.setWidth(100);
238
+ root.setHeight(100);
239
+ root.setPadding(Edge.All, 12);
240
+ root.setBorder(Edge.All, 8);
241
+ root.setBoxSizing(BoxSizing.ContentBox);
242
+
243
+ const root_child0 = Yoga.Node.create(config);
244
+ root_child0.setPositionType(PositionType.Static);
245
+ root.insertChild(root_child0, 0);
246
+
247
+ const root_child0_child0 = Yoga.Node.create(config);
248
+ root_child0_child0.setWidth(50);
249
+ root_child0_child0.setHeight("25%");
250
+ root_child0_child0.setPositionType(PositionType.Absolute);
251
+ root_child0.insertChild(root_child0_child0, 0);
252
+ root.calculateLayout(undefined, undefined, Direction.LTR);
253
+
254
+ expect(root.getComputedLeft()).toBe(0);
255
+ expect(root.getComputedTop()).toBe(0);
256
+ expect(root.getComputedWidth()).toBe(140);
257
+ expect(root.getComputedHeight()).toBe(140);
258
+
259
+ expect(root_child0.getComputedLeft()).toBe(20);
260
+ expect(root_child0.getComputedTop()).toBe(20);
261
+ expect(root_child0.getComputedWidth()).toBe(100);
262
+ expect(root_child0.getComputedHeight()).toBe(0);
263
+
264
+ expect(root_child0_child0.getComputedLeft()).toBe(0);
265
+ expect(root_child0_child0.getComputedTop()).toBe(0);
266
+ expect(root_child0_child0.getComputedWidth()).toBe(50);
267
+ expect(root_child0_child0.getComputedHeight()).toBe(31);
268
+
269
+ root.calculateLayout(undefined, undefined, Direction.RTL);
270
+
271
+ expect(root.getComputedLeft()).toBe(0);
272
+ expect(root.getComputedTop()).toBe(0);
273
+ expect(root.getComputedWidth()).toBe(140);
274
+ expect(root.getComputedHeight()).toBe(140);
275
+
276
+ expect(root_child0.getComputedLeft()).toBe(20);
277
+ expect(root_child0.getComputedTop()).toBe(20);
278
+ expect(root_child0.getComputedWidth()).toBe(100);
279
+ expect(root_child0.getComputedHeight()).toBe(0);
280
+
281
+ expect(root_child0_child0.getComputedLeft()).toBe(50);
282
+ expect(root_child0_child0.getComputedTop()).toBe(0);
283
+ expect(root_child0_child0.getComputedWidth()).toBe(50);
284
+ expect(root_child0_child0.getComputedHeight()).toBe(31);
285
+ });
286
+ test('box_sizing_border_box_comtaining_block', () => {
287
+ const config = Yoga.Config.create();
288
+
289
+ const root = Yoga.Node.create(config);
290
+ root.setPositionType(PositionType.Absolute);
291
+ root.setWidth(100);
292
+ root.setHeight(100);
293
+ root.setPadding(Edge.All, 12);
294
+ root.setBorder(Edge.All, 8);
295
+
296
+ const root_child0 = Yoga.Node.create(config);
297
+ root_child0.setPositionType(PositionType.Static);
298
+ root.insertChild(root_child0, 0);
299
+
300
+ const root_child0_child0 = Yoga.Node.create(config);
301
+ root_child0_child0.setWidth(50);
302
+ root_child0_child0.setHeight("25%");
303
+ root_child0_child0.setPositionType(PositionType.Absolute);
304
+ root_child0.insertChild(root_child0_child0, 0);
305
+ root.calculateLayout(undefined, undefined, Direction.LTR);
306
+
307
+ expect(root.getComputedLeft()).toBe(0);
308
+ expect(root.getComputedTop()).toBe(0);
309
+ expect(root.getComputedWidth()).toBe(100);
310
+ expect(root.getComputedHeight()).toBe(100);
311
+
312
+ expect(root_child0.getComputedLeft()).toBe(20);
313
+ expect(root_child0.getComputedTop()).toBe(20);
314
+ expect(root_child0.getComputedWidth()).toBe(60);
315
+ expect(root_child0.getComputedHeight()).toBe(0);
316
+
317
+ expect(root_child0_child0.getComputedLeft()).toBe(0);
318
+ expect(root_child0_child0.getComputedTop()).toBe(0);
319
+ expect(root_child0_child0.getComputedWidth()).toBe(50);
320
+ expect(root_child0_child0.getComputedHeight()).toBe(21);
321
+
322
+ root.calculateLayout(undefined, undefined, Direction.RTL);
323
+
324
+ expect(root.getComputedLeft()).toBe(0);
325
+ expect(root.getComputedTop()).toBe(0);
326
+ expect(root.getComputedWidth()).toBe(100);
327
+ expect(root.getComputedHeight()).toBe(100);
328
+
329
+ expect(root_child0.getComputedLeft()).toBe(20);
330
+ expect(root_child0.getComputedTop()).toBe(20);
331
+ expect(root_child0.getComputedWidth()).toBe(60);
332
+ expect(root_child0.getComputedHeight()).toBe(0);
333
+
334
+ expect(root_child0_child0.getComputedLeft()).toBe(10);
335
+ expect(root_child0_child0.getComputedTop()).toBe(0);
336
+ expect(root_child0_child0.getComputedWidth()).toBe(50);
337
+ expect(root_child0_child0.getComputedHeight()).toBe(21);
338
+ });
339
+ test('box_sizing_content_box_padding_only', () => {
340
+ const config = Yoga.Config.create();
341
+
342
+ const root = Yoga.Node.create(config);
343
+ root.setPositionType(PositionType.Absolute);
344
+ root.setWidth(100);
345
+ root.setHeight(100);
346
+ root.setPadding(Edge.All, 5);
347
+ root.setBoxSizing(BoxSizing.ContentBox);
348
+ root.calculateLayout(undefined, undefined, Direction.LTR);
349
+
350
+ expect(root.getComputedLeft()).toBe(0);
351
+ expect(root.getComputedTop()).toBe(0);
352
+ expect(root.getComputedWidth()).toBe(110);
353
+ expect(root.getComputedHeight()).toBe(110);
354
+
355
+ root.calculateLayout(undefined, undefined, Direction.RTL);
356
+
357
+ expect(root.getComputedLeft()).toBe(0);
358
+ expect(root.getComputedTop()).toBe(0);
359
+ expect(root.getComputedWidth()).toBe(110);
360
+ expect(root.getComputedHeight()).toBe(110);
361
+ });
362
+ test('box_sizing_content_box_padding_only_percent', () => {
363
+ const config = Yoga.Config.create();
364
+
365
+ const root = Yoga.Node.create(config);
366
+ root.setPositionType(PositionType.Absolute);
367
+ root.setWidth(100);
368
+ root.setHeight(150);
369
+
370
+ const root_child0 = Yoga.Node.create(config);
371
+ root_child0.setWidth(50);
372
+ root_child0.setHeight(75);
373
+ root_child0.setPadding(Edge.All, "10%");
374
+ root_child0.setBoxSizing(BoxSizing.ContentBox);
375
+ root.insertChild(root_child0, 0);
376
+ root.calculateLayout(undefined, undefined, Direction.LTR);
377
+
378
+ expect(root.getComputedLeft()).toBe(0);
379
+ expect(root.getComputedTop()).toBe(0);
380
+ expect(root.getComputedWidth()).toBe(100);
381
+ expect(root.getComputedHeight()).toBe(150);
382
+
383
+ expect(root_child0.getComputedLeft()).toBe(0);
384
+ expect(root_child0.getComputedTop()).toBe(0);
385
+ expect(root_child0.getComputedWidth()).toBe(70);
386
+ expect(root_child0.getComputedHeight()).toBe(95);
387
+
388
+ root.calculateLayout(undefined, undefined, Direction.RTL);
389
+
390
+ expect(root.getComputedLeft()).toBe(0);
391
+ expect(root.getComputedTop()).toBe(0);
392
+ expect(root.getComputedWidth()).toBe(100);
393
+ expect(root.getComputedHeight()).toBe(150);
394
+
395
+ expect(root_child0.getComputedLeft()).toBe(30);
396
+ expect(root_child0.getComputedTop()).toBe(0);
397
+ expect(root_child0.getComputedWidth()).toBe(70);
398
+ expect(root_child0.getComputedHeight()).toBe(95);
399
+ });
400
+ test('box_sizing_border_box_padding_only', () => {
401
+ const config = Yoga.Config.create();
402
+
403
+ const root = Yoga.Node.create(config);
404
+ root.setPositionType(PositionType.Absolute);
405
+ root.setWidth(100);
406
+ root.setHeight(100);
407
+ root.setPadding(Edge.All, 5);
408
+ root.calculateLayout(undefined, undefined, Direction.LTR);
409
+
410
+ expect(root.getComputedLeft()).toBe(0);
411
+ expect(root.getComputedTop()).toBe(0);
412
+ expect(root.getComputedWidth()).toBe(100);
413
+ expect(root.getComputedHeight()).toBe(100);
414
+
415
+ root.calculateLayout(undefined, undefined, Direction.RTL);
416
+
417
+ expect(root.getComputedLeft()).toBe(0);
418
+ expect(root.getComputedTop()).toBe(0);
419
+ expect(root.getComputedWidth()).toBe(100);
420
+ expect(root.getComputedHeight()).toBe(100);
421
+ });
422
+ test('box_sizing_border_box_padding_only_percent', () => {
423
+ const config = Yoga.Config.create();
424
+
425
+ const root = Yoga.Node.create(config);
426
+ root.setPositionType(PositionType.Absolute);
427
+ root.setWidth(100);
428
+ root.setHeight(150);
429
+
430
+ const root_child0 = Yoga.Node.create(config);
431
+ root_child0.setWidth(50);
432
+ root_child0.setHeight(75);
433
+ root_child0.setPadding(Edge.All, "10%");
434
+ root.insertChild(root_child0, 0);
435
+ root.calculateLayout(undefined, undefined, Direction.LTR);
436
+
437
+ expect(root.getComputedLeft()).toBe(0);
438
+ expect(root.getComputedTop()).toBe(0);
439
+ expect(root.getComputedWidth()).toBe(100);
440
+ expect(root.getComputedHeight()).toBe(150);
441
+
442
+ expect(root_child0.getComputedLeft()).toBe(0);
443
+ expect(root_child0.getComputedTop()).toBe(0);
444
+ expect(root_child0.getComputedWidth()).toBe(50);
445
+ expect(root_child0.getComputedHeight()).toBe(75);
446
+
447
+ root.calculateLayout(undefined, undefined, Direction.RTL);
448
+
449
+ expect(root.getComputedLeft()).toBe(0);
450
+ expect(root.getComputedTop()).toBe(0);
451
+ expect(root.getComputedWidth()).toBe(100);
452
+ expect(root.getComputedHeight()).toBe(150);
453
+
454
+ expect(root_child0.getComputedLeft()).toBe(50);
455
+ expect(root_child0.getComputedTop()).toBe(0);
456
+ expect(root_child0.getComputedWidth()).toBe(50);
457
+ expect(root_child0.getComputedHeight()).toBe(75);
458
+ });
459
+ test('box_sizing_content_box_border_only', () => {
460
+ const config = Yoga.Config.create();
461
+
462
+ const root = Yoga.Node.create(config);
463
+ root.setPositionType(PositionType.Absolute);
464
+ root.setWidth(100);
465
+ root.setHeight(100);
466
+ root.setBorder(Edge.All, 10);
467
+ root.setBoxSizing(BoxSizing.ContentBox);
468
+ root.calculateLayout(undefined, undefined, Direction.LTR);
469
+
470
+ expect(root.getComputedLeft()).toBe(0);
471
+ expect(root.getComputedTop()).toBe(0);
472
+ expect(root.getComputedWidth()).toBe(120);
473
+ expect(root.getComputedHeight()).toBe(120);
474
+
475
+ root.calculateLayout(undefined, undefined, Direction.RTL);
476
+
477
+ expect(root.getComputedLeft()).toBe(0);
478
+ expect(root.getComputedTop()).toBe(0);
479
+ expect(root.getComputedWidth()).toBe(120);
480
+ expect(root.getComputedHeight()).toBe(120);
481
+ });
482
+ test('box_sizing_content_box_border_only_percent', () => {
483
+ const config = Yoga.Config.create();
484
+
485
+ const root = Yoga.Node.create(config);
486
+ root.setPositionType(PositionType.Absolute);
487
+ root.setWidth(100);
488
+ root.setHeight(100);
489
+
490
+ const root_child0 = Yoga.Node.create(config);
491
+ root_child0.setWidth("50%");
492
+ root_child0.setBoxSizing(BoxSizing.ContentBox);
493
+ root.insertChild(root_child0, 0);
494
+ root.calculateLayout(undefined, undefined, Direction.LTR);
495
+
496
+ expect(root.getComputedLeft()).toBe(0);
497
+ expect(root.getComputedTop()).toBe(0);
498
+ expect(root.getComputedWidth()).toBe(100);
499
+ expect(root.getComputedHeight()).toBe(100);
500
+
501
+ expect(root_child0.getComputedLeft()).toBe(0);
502
+ expect(root_child0.getComputedTop()).toBe(0);
503
+ expect(root_child0.getComputedWidth()).toBe(50);
504
+ expect(root_child0.getComputedHeight()).toBe(0);
505
+
506
+ root.calculateLayout(undefined, undefined, Direction.RTL);
507
+
508
+ expect(root.getComputedLeft()).toBe(0);
509
+ expect(root.getComputedTop()).toBe(0);
510
+ expect(root.getComputedWidth()).toBe(100);
511
+ expect(root.getComputedHeight()).toBe(100);
512
+
513
+ expect(root_child0.getComputedLeft()).toBe(50);
514
+ expect(root_child0.getComputedTop()).toBe(0);
515
+ expect(root_child0.getComputedWidth()).toBe(50);
516
+ expect(root_child0.getComputedHeight()).toBe(0);
517
+ });
518
+ test('box_sizing_border_box_border_only', () => {
519
+ const config = Yoga.Config.create();
520
+
521
+ const root = Yoga.Node.create(config);
522
+ root.setPositionType(PositionType.Absolute);
523
+ root.setWidth(100);
524
+ root.setHeight(100);
525
+ root.setBorder(Edge.All, 10);
526
+ root.calculateLayout(undefined, undefined, Direction.LTR);
527
+
528
+ expect(root.getComputedLeft()).toBe(0);
529
+ expect(root.getComputedTop()).toBe(0);
530
+ expect(root.getComputedWidth()).toBe(100);
531
+ expect(root.getComputedHeight()).toBe(100);
532
+
533
+ root.calculateLayout(undefined, undefined, Direction.RTL);
534
+
535
+ expect(root.getComputedLeft()).toBe(0);
536
+ expect(root.getComputedTop()).toBe(0);
537
+ expect(root.getComputedWidth()).toBe(100);
538
+ expect(root.getComputedHeight()).toBe(100);
539
+ });
540
+ test('box_sizing_border_box_border_only_percent', () => {
541
+ const config = Yoga.Config.create();
542
+
543
+ const root = Yoga.Node.create(config);
544
+ root.setPositionType(PositionType.Absolute);
545
+ root.setWidth(100);
546
+ root.setHeight(100);
547
+
548
+ const root_child0 = Yoga.Node.create(config);
549
+ root_child0.setWidth("50%");
550
+ root.insertChild(root_child0, 0);
551
+ root.calculateLayout(undefined, undefined, Direction.LTR);
552
+
553
+ expect(root.getComputedLeft()).toBe(0);
554
+ expect(root.getComputedTop()).toBe(0);
555
+ expect(root.getComputedWidth()).toBe(100);
556
+ expect(root.getComputedHeight()).toBe(100);
557
+
558
+ expect(root_child0.getComputedLeft()).toBe(0);
559
+ expect(root_child0.getComputedTop()).toBe(0);
560
+ expect(root_child0.getComputedWidth()).toBe(50);
561
+ expect(root_child0.getComputedHeight()).toBe(0);
562
+
563
+ root.calculateLayout(undefined, undefined, Direction.RTL);
564
+
565
+ expect(root.getComputedLeft()).toBe(0);
566
+ expect(root.getComputedTop()).toBe(0);
567
+ expect(root.getComputedWidth()).toBe(100);
568
+ expect(root.getComputedHeight()).toBe(100);
569
+
570
+ expect(root_child0.getComputedLeft()).toBe(50);
571
+ expect(root_child0.getComputedTop()).toBe(0);
572
+ expect(root_child0.getComputedWidth()).toBe(50);
573
+ expect(root_child0.getComputedHeight()).toBe(0);
574
+ });
575
+ test('box_sizing_content_box_no_padding_no_border', () => {
576
+ const config = Yoga.Config.create();
577
+
578
+ const root = Yoga.Node.create(config);
579
+ root.setPositionType(PositionType.Absolute);
580
+ root.setWidth(100);
581
+ root.setHeight(100);
582
+ root.setBoxSizing(BoxSizing.ContentBox);
583
+ root.calculateLayout(undefined, undefined, Direction.LTR);
584
+
585
+ expect(root.getComputedLeft()).toBe(0);
586
+ expect(root.getComputedTop()).toBe(0);
587
+ expect(root.getComputedWidth()).toBe(100);
588
+ expect(root.getComputedHeight()).toBe(100);
589
+
590
+ root.calculateLayout(undefined, undefined, Direction.RTL);
591
+
592
+ expect(root.getComputedLeft()).toBe(0);
593
+ expect(root.getComputedTop()).toBe(0);
594
+ expect(root.getComputedWidth()).toBe(100);
595
+ expect(root.getComputedHeight()).toBe(100);
596
+ });
597
+ test('box_sizing_border_box_no_padding_no_border', () => {
598
+ const config = Yoga.Config.create();
599
+
600
+ const root = Yoga.Node.create(config);
601
+ root.setPositionType(PositionType.Absolute);
602
+ root.setWidth(100);
603
+ root.setHeight(100);
604
+ root.calculateLayout(undefined, undefined, Direction.LTR);
605
+
606
+ expect(root.getComputedLeft()).toBe(0);
607
+ expect(root.getComputedTop()).toBe(0);
608
+ expect(root.getComputedWidth()).toBe(100);
609
+ expect(root.getComputedHeight()).toBe(100);
610
+
611
+ root.calculateLayout(undefined, undefined, Direction.RTL);
612
+
613
+ expect(root.getComputedLeft()).toBe(0);
614
+ expect(root.getComputedTop()).toBe(0);
615
+ expect(root.getComputedWidth()).toBe(100);
616
+ expect(root.getComputedHeight()).toBe(100);
617
+ });
618
+ test('box_sizing_content_box_children', () => {
619
+ const config = Yoga.Config.create();
620
+
621
+ const root = Yoga.Node.create(config);
622
+ root.setPositionType(PositionType.Absolute);
623
+ root.setWidth(100);
624
+ root.setHeight(100);
625
+ root.setPadding(Edge.All, 5);
626
+ root.setBorder(Edge.All, 10);
627
+ root.setBoxSizing(BoxSizing.ContentBox);
628
+
629
+ const root_child0 = Yoga.Node.create(config);
630
+ root_child0.setWidth(25);
631
+ root_child0.setHeight(25);
632
+ root.insertChild(root_child0, 0);
633
+
634
+ const root_child1 = Yoga.Node.create(config);
635
+ root_child1.setWidth(25);
636
+ root_child1.setHeight(25);
637
+ root.insertChild(root_child1, 1);
638
+
639
+ const root_child2 = Yoga.Node.create(config);
640
+ root_child2.setWidth(25);
641
+ root_child2.setHeight(25);
642
+ root.insertChild(root_child2, 2);
643
+
644
+ const root_child3 = Yoga.Node.create(config);
645
+ root_child3.setWidth(25);
646
+ root_child3.setHeight(25);
647
+ root.insertChild(root_child3, 3);
648
+ root.calculateLayout(undefined, undefined, Direction.LTR);
649
+
650
+ expect(root.getComputedLeft()).toBe(0);
651
+ expect(root.getComputedTop()).toBe(0);
652
+ expect(root.getComputedWidth()).toBe(130);
653
+ expect(root.getComputedHeight()).toBe(130);
654
+
655
+ expect(root_child0.getComputedLeft()).toBe(15);
656
+ expect(root_child0.getComputedTop()).toBe(15);
657
+ expect(root_child0.getComputedWidth()).toBe(25);
658
+ expect(root_child0.getComputedHeight()).toBe(25);
659
+
660
+ expect(root_child1.getComputedLeft()).toBe(15);
661
+ expect(root_child1.getComputedTop()).toBe(40);
662
+ expect(root_child1.getComputedWidth()).toBe(25);
663
+ expect(root_child1.getComputedHeight()).toBe(25);
664
+
665
+ expect(root_child2.getComputedLeft()).toBe(15);
666
+ expect(root_child2.getComputedTop()).toBe(65);
667
+ expect(root_child2.getComputedWidth()).toBe(25);
668
+ expect(root_child2.getComputedHeight()).toBe(25);
669
+
670
+ expect(root_child3.getComputedLeft()).toBe(15);
671
+ expect(root_child3.getComputedTop()).toBe(90);
672
+ expect(root_child3.getComputedWidth()).toBe(25);
673
+ expect(root_child3.getComputedHeight()).toBe(25);
674
+
675
+ root.calculateLayout(undefined, undefined, Direction.RTL);
676
+
677
+ expect(root.getComputedLeft()).toBe(0);
678
+ expect(root.getComputedTop()).toBe(0);
679
+ expect(root.getComputedWidth()).toBe(130);
680
+ expect(root.getComputedHeight()).toBe(130);
681
+
682
+ expect(root_child0.getComputedLeft()).toBe(90);
683
+ expect(root_child0.getComputedTop()).toBe(15);
684
+ expect(root_child0.getComputedWidth()).toBe(25);
685
+ expect(root_child0.getComputedHeight()).toBe(25);
686
+
687
+ expect(root_child1.getComputedLeft()).toBe(90);
688
+ expect(root_child1.getComputedTop()).toBe(40);
689
+ expect(root_child1.getComputedWidth()).toBe(25);
690
+ expect(root_child1.getComputedHeight()).toBe(25);
691
+
692
+ expect(root_child2.getComputedLeft()).toBe(90);
693
+ expect(root_child2.getComputedTop()).toBe(65);
694
+ expect(root_child2.getComputedWidth()).toBe(25);
695
+ expect(root_child2.getComputedHeight()).toBe(25);
696
+
697
+ expect(root_child3.getComputedLeft()).toBe(90);
698
+ expect(root_child3.getComputedTop()).toBe(90);
699
+ expect(root_child3.getComputedWidth()).toBe(25);
700
+ expect(root_child3.getComputedHeight()).toBe(25);
701
+ });
702
+ test('box_sizing_border_box_children', () => {
703
+ const config = Yoga.Config.create();
704
+
705
+ const root = Yoga.Node.create(config);
706
+ root.setPositionType(PositionType.Absolute);
707
+ root.setWidth(100);
708
+ root.setHeight(100);
709
+ root.setPadding(Edge.All, 5);
710
+ root.setBorder(Edge.All, 10);
711
+
712
+ const root_child0 = Yoga.Node.create(config);
713
+ root_child0.setWidth(25);
714
+ root_child0.setHeight(25);
715
+ root.insertChild(root_child0, 0);
716
+
717
+ const root_child1 = Yoga.Node.create(config);
718
+ root_child1.setWidth(25);
719
+ root_child1.setHeight(25);
720
+ root.insertChild(root_child1, 1);
721
+
722
+ const root_child2 = Yoga.Node.create(config);
723
+ root_child2.setWidth(25);
724
+ root_child2.setHeight(25);
725
+ root.insertChild(root_child2, 2);
726
+
727
+ const root_child3 = Yoga.Node.create(config);
728
+ root_child3.setWidth(25);
729
+ root_child3.setHeight(25);
730
+ root.insertChild(root_child3, 3);
731
+ root.calculateLayout(undefined, undefined, Direction.LTR);
732
+
733
+ expect(root.getComputedLeft()).toBe(0);
734
+ expect(root.getComputedTop()).toBe(0);
735
+ expect(root.getComputedWidth()).toBe(100);
736
+ expect(root.getComputedHeight()).toBe(100);
737
+
738
+ expect(root_child0.getComputedLeft()).toBe(15);
739
+ expect(root_child0.getComputedTop()).toBe(15);
740
+ expect(root_child0.getComputedWidth()).toBe(25);
741
+ expect(root_child0.getComputedHeight()).toBe(25);
742
+
743
+ expect(root_child1.getComputedLeft()).toBe(15);
744
+ expect(root_child1.getComputedTop()).toBe(40);
745
+ expect(root_child1.getComputedWidth()).toBe(25);
746
+ expect(root_child1.getComputedHeight()).toBe(25);
747
+
748
+ expect(root_child2.getComputedLeft()).toBe(15);
749
+ expect(root_child2.getComputedTop()).toBe(65);
750
+ expect(root_child2.getComputedWidth()).toBe(25);
751
+ expect(root_child2.getComputedHeight()).toBe(25);
752
+
753
+ expect(root_child3.getComputedLeft()).toBe(15);
754
+ expect(root_child3.getComputedTop()).toBe(90);
755
+ expect(root_child3.getComputedWidth()).toBe(25);
756
+ expect(root_child3.getComputedHeight()).toBe(25);
757
+
758
+ root.calculateLayout(undefined, undefined, Direction.RTL);
759
+
760
+ expect(root.getComputedLeft()).toBe(0);
761
+ expect(root.getComputedTop()).toBe(0);
762
+ expect(root.getComputedWidth()).toBe(100);
763
+ expect(root.getComputedHeight()).toBe(100);
764
+
765
+ expect(root_child0.getComputedLeft()).toBe(60);
766
+ expect(root_child0.getComputedTop()).toBe(15);
767
+ expect(root_child0.getComputedWidth()).toBe(25);
768
+ expect(root_child0.getComputedHeight()).toBe(25);
769
+
770
+ expect(root_child1.getComputedLeft()).toBe(60);
771
+ expect(root_child1.getComputedTop()).toBe(40);
772
+ expect(root_child1.getComputedWidth()).toBe(25);
773
+ expect(root_child1.getComputedHeight()).toBe(25);
774
+
775
+ expect(root_child2.getComputedLeft()).toBe(60);
776
+ expect(root_child2.getComputedTop()).toBe(65);
777
+ expect(root_child2.getComputedWidth()).toBe(25);
778
+ expect(root_child2.getComputedHeight()).toBe(25);
779
+
780
+ expect(root_child3.getComputedLeft()).toBe(60);
781
+ expect(root_child3.getComputedTop()).toBe(90);
782
+ expect(root_child3.getComputedWidth()).toBe(25);
783
+ expect(root_child3.getComputedHeight()).toBe(25);
784
+ });
785
+ test('box_sizing_content_box_siblings', () => {
786
+ const config = Yoga.Config.create();
787
+
788
+ const root = Yoga.Node.create(config);
789
+ root.setPositionType(PositionType.Absolute);
790
+ root.setWidth(100);
791
+ root.setHeight(100);
792
+
793
+ const root_child0 = Yoga.Node.create(config);
794
+ root_child0.setWidth(25);
795
+ root_child0.setHeight(25);
796
+ root.insertChild(root_child0, 0);
797
+
798
+ const root_child1 = Yoga.Node.create(config);
799
+ root_child1.setWidth(25);
800
+ root_child1.setHeight(25);
801
+ root_child1.setBoxSizing(BoxSizing.ContentBox);
802
+ root_child1.setPadding(Edge.All, 10);
803
+ root_child1.setBorder(Edge.All, 10);
804
+ root.insertChild(root_child1, 1);
805
+
806
+ const root_child2 = Yoga.Node.create(config);
807
+ root_child2.setWidth(25);
808
+ root_child2.setHeight(25);
809
+ root.insertChild(root_child2, 2);
810
+
811
+ const root_child3 = Yoga.Node.create(config);
812
+ root_child3.setWidth(25);
813
+ root_child3.setHeight(25);
814
+ root.insertChild(root_child3, 3);
815
+ root.calculateLayout(undefined, undefined, Direction.LTR);
816
+
817
+ expect(root.getComputedLeft()).toBe(0);
818
+ expect(root.getComputedTop()).toBe(0);
819
+ expect(root.getComputedWidth()).toBe(100);
820
+ expect(root.getComputedHeight()).toBe(100);
821
+
822
+ expect(root_child0.getComputedLeft()).toBe(0);
823
+ expect(root_child0.getComputedTop()).toBe(0);
824
+ expect(root_child0.getComputedWidth()).toBe(25);
825
+ expect(root_child0.getComputedHeight()).toBe(25);
826
+
827
+ expect(root_child1.getComputedLeft()).toBe(0);
828
+ expect(root_child1.getComputedTop()).toBe(25);
829
+ expect(root_child1.getComputedWidth()).toBe(65);
830
+ expect(root_child1.getComputedHeight()).toBe(65);
831
+
832
+ expect(root_child2.getComputedLeft()).toBe(0);
833
+ expect(root_child2.getComputedTop()).toBe(90);
834
+ expect(root_child2.getComputedWidth()).toBe(25);
835
+ expect(root_child2.getComputedHeight()).toBe(25);
836
+
837
+ expect(root_child3.getComputedLeft()).toBe(0);
838
+ expect(root_child3.getComputedTop()).toBe(115);
839
+ expect(root_child3.getComputedWidth()).toBe(25);
840
+ expect(root_child3.getComputedHeight()).toBe(25);
841
+
842
+ root.calculateLayout(undefined, undefined, Direction.RTL);
843
+
844
+ expect(root.getComputedLeft()).toBe(0);
845
+ expect(root.getComputedTop()).toBe(0);
846
+ expect(root.getComputedWidth()).toBe(100);
847
+ expect(root.getComputedHeight()).toBe(100);
848
+
849
+ expect(root_child0.getComputedLeft()).toBe(75);
850
+ expect(root_child0.getComputedTop()).toBe(0);
851
+ expect(root_child0.getComputedWidth()).toBe(25);
852
+ expect(root_child0.getComputedHeight()).toBe(25);
853
+
854
+ expect(root_child1.getComputedLeft()).toBe(35);
855
+ expect(root_child1.getComputedTop()).toBe(25);
856
+ expect(root_child1.getComputedWidth()).toBe(65);
857
+ expect(root_child1.getComputedHeight()).toBe(65);
858
+
859
+ expect(root_child2.getComputedLeft()).toBe(75);
860
+ expect(root_child2.getComputedTop()).toBe(90);
861
+ expect(root_child2.getComputedWidth()).toBe(25);
862
+ expect(root_child2.getComputedHeight()).toBe(25);
863
+
864
+ expect(root_child3.getComputedLeft()).toBe(75);
865
+ expect(root_child3.getComputedTop()).toBe(115);
866
+ expect(root_child3.getComputedWidth()).toBe(25);
867
+ expect(root_child3.getComputedHeight()).toBe(25);
868
+ });
869
+ test('box_sizing_border_box_siblings', () => {
870
+ const config = Yoga.Config.create();
871
+
872
+ const root = Yoga.Node.create(config);
873
+ root.setPositionType(PositionType.Absolute);
874
+ root.setWidth(100);
875
+ root.setHeight(100);
876
+
877
+ const root_child0 = Yoga.Node.create(config);
878
+ root_child0.setWidth(25);
879
+ root_child0.setHeight(25);
880
+ root.insertChild(root_child0, 0);
881
+
882
+ const root_child1 = Yoga.Node.create(config);
883
+ root_child1.setWidth(25);
884
+ root_child1.setHeight(25);
885
+ root_child1.setPadding(Edge.All, 10);
886
+ root_child1.setBorder(Edge.All, 10);
887
+ root.insertChild(root_child1, 1);
888
+
889
+ const root_child2 = Yoga.Node.create(config);
890
+ root_child2.setWidth(25);
891
+ root_child2.setHeight(25);
892
+ root.insertChild(root_child2, 2);
893
+
894
+ const root_child3 = Yoga.Node.create(config);
895
+ root_child3.setWidth(25);
896
+ root_child3.setHeight(25);
897
+ root.insertChild(root_child3, 3);
898
+ root.calculateLayout(undefined, undefined, Direction.LTR);
899
+
900
+ expect(root.getComputedLeft()).toBe(0);
901
+ expect(root.getComputedTop()).toBe(0);
902
+ expect(root.getComputedWidth()).toBe(100);
903
+ expect(root.getComputedHeight()).toBe(100);
904
+
905
+ expect(root_child0.getComputedLeft()).toBe(0);
906
+ expect(root_child0.getComputedTop()).toBe(0);
907
+ expect(root_child0.getComputedWidth()).toBe(25);
908
+ expect(root_child0.getComputedHeight()).toBe(25);
909
+
910
+ expect(root_child1.getComputedLeft()).toBe(0);
911
+ expect(root_child1.getComputedTop()).toBe(25);
912
+ expect(root_child1.getComputedWidth()).toBe(40);
913
+ expect(root_child1.getComputedHeight()).toBe(40);
914
+
915
+ expect(root_child2.getComputedLeft()).toBe(0);
916
+ expect(root_child2.getComputedTop()).toBe(65);
917
+ expect(root_child2.getComputedWidth()).toBe(25);
918
+ expect(root_child2.getComputedHeight()).toBe(25);
919
+
920
+ expect(root_child3.getComputedLeft()).toBe(0);
921
+ expect(root_child3.getComputedTop()).toBe(90);
922
+ expect(root_child3.getComputedWidth()).toBe(25);
923
+ expect(root_child3.getComputedHeight()).toBe(25);
924
+
925
+ root.calculateLayout(undefined, undefined, Direction.RTL);
926
+
927
+ expect(root.getComputedLeft()).toBe(0);
928
+ expect(root.getComputedTop()).toBe(0);
929
+ expect(root.getComputedWidth()).toBe(100);
930
+ expect(root.getComputedHeight()).toBe(100);
931
+
932
+ expect(root_child0.getComputedLeft()).toBe(75);
933
+ expect(root_child0.getComputedTop()).toBe(0);
934
+ expect(root_child0.getComputedWidth()).toBe(25);
935
+ expect(root_child0.getComputedHeight()).toBe(25);
936
+
937
+ expect(root_child1.getComputedLeft()).toBe(60);
938
+ expect(root_child1.getComputedTop()).toBe(25);
939
+ expect(root_child1.getComputedWidth()).toBe(40);
940
+ expect(root_child1.getComputedHeight()).toBe(40);
941
+
942
+ expect(root_child2.getComputedLeft()).toBe(75);
943
+ expect(root_child2.getComputedTop()).toBe(65);
944
+ expect(root_child2.getComputedWidth()).toBe(25);
945
+ expect(root_child2.getComputedHeight()).toBe(25);
946
+
947
+ expect(root_child3.getComputedLeft()).toBe(75);
948
+ expect(root_child3.getComputedTop()).toBe(90);
949
+ expect(root_child3.getComputedWidth()).toBe(25);
950
+ expect(root_child3.getComputedHeight()).toBe(25);
951
+ });
952
+ test('box_sizing_content_box_max_width', () => {
953
+ const config = Yoga.Config.create();
954
+
955
+ const root = Yoga.Node.create(config);
956
+ root.setPositionType(PositionType.Absolute);
957
+ root.setWidth(100);
958
+ root.setHeight(100);
959
+
960
+ const root_child0 = Yoga.Node.create(config);
961
+ root_child0.setMaxWidth(50);
962
+ root_child0.setHeight(25);
963
+ root_child0.setBoxSizing(BoxSizing.ContentBox);
964
+ root_child0.setPadding(Edge.All, 5);
965
+ root_child0.setBorder(Edge.All, 15);
966
+ root.insertChild(root_child0, 0);
967
+
968
+ const root_child1 = Yoga.Node.create(config);
969
+ root_child1.setWidth(25);
970
+ root_child1.setHeight(25);
971
+ root.insertChild(root_child1, 1);
972
+ root.calculateLayout(undefined, undefined, Direction.LTR);
973
+
974
+ expect(root.getComputedLeft()).toBe(0);
975
+ expect(root.getComputedTop()).toBe(0);
976
+ expect(root.getComputedWidth()).toBe(100);
977
+ expect(root.getComputedHeight()).toBe(100);
978
+
979
+ expect(root_child0.getComputedLeft()).toBe(0);
980
+ expect(root_child0.getComputedTop()).toBe(0);
981
+ expect(root_child0.getComputedWidth()).toBe(90);
982
+ expect(root_child0.getComputedHeight()).toBe(65);
983
+
984
+ expect(root_child1.getComputedLeft()).toBe(0);
985
+ expect(root_child1.getComputedTop()).toBe(65);
986
+ expect(root_child1.getComputedWidth()).toBe(25);
987
+ expect(root_child1.getComputedHeight()).toBe(25);
988
+
989
+ root.calculateLayout(undefined, undefined, Direction.RTL);
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(10);
997
+ expect(root_child0.getComputedTop()).toBe(0);
998
+ expect(root_child0.getComputedWidth()).toBe(90);
999
+ expect(root_child0.getComputedHeight()).toBe(65);
1000
+
1001
+ expect(root_child1.getComputedLeft()).toBe(75);
1002
+ expect(root_child1.getComputedTop()).toBe(65);
1003
+ expect(root_child1.getComputedWidth()).toBe(25);
1004
+ expect(root_child1.getComputedHeight()).toBe(25);
1005
+ });
1006
+ test('box_sizing_border_box_max_width', () => {
1007
+ const config = Yoga.Config.create();
1008
+
1009
+ const root = Yoga.Node.create(config);
1010
+ root.setPositionType(PositionType.Absolute);
1011
+ root.setWidth(100);
1012
+ root.setHeight(100);
1013
+
1014
+ const root_child0 = Yoga.Node.create(config);
1015
+ root_child0.setMaxWidth(50);
1016
+ root_child0.setHeight(25);
1017
+ root_child0.setPadding(Edge.All, 5);
1018
+ root_child0.setBorder(Edge.All, 15);
1019
+ root.insertChild(root_child0, 0);
1020
+
1021
+ const root_child1 = Yoga.Node.create(config);
1022
+ root_child1.setWidth(25);
1023
+ root_child1.setHeight(25);
1024
+ root.insertChild(root_child1, 1);
1025
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1026
+
1027
+ expect(root.getComputedLeft()).toBe(0);
1028
+ expect(root.getComputedTop()).toBe(0);
1029
+ expect(root.getComputedWidth()).toBe(100);
1030
+ expect(root.getComputedHeight()).toBe(100);
1031
+
1032
+ expect(root_child0.getComputedLeft()).toBe(0);
1033
+ expect(root_child0.getComputedTop()).toBe(0);
1034
+ expect(root_child0.getComputedWidth()).toBe(50);
1035
+ expect(root_child0.getComputedHeight()).toBe(40);
1036
+
1037
+ expect(root_child1.getComputedLeft()).toBe(0);
1038
+ expect(root_child1.getComputedTop()).toBe(40);
1039
+ expect(root_child1.getComputedWidth()).toBe(25);
1040
+ expect(root_child1.getComputedHeight()).toBe(25);
1041
+
1042
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1043
+
1044
+ expect(root.getComputedLeft()).toBe(0);
1045
+ expect(root.getComputedTop()).toBe(0);
1046
+ expect(root.getComputedWidth()).toBe(100);
1047
+ expect(root.getComputedHeight()).toBe(100);
1048
+
1049
+ expect(root_child0.getComputedLeft()).toBe(50);
1050
+ expect(root_child0.getComputedTop()).toBe(0);
1051
+ expect(root_child0.getComputedWidth()).toBe(50);
1052
+ expect(root_child0.getComputedHeight()).toBe(40);
1053
+
1054
+ expect(root_child1.getComputedLeft()).toBe(75);
1055
+ expect(root_child1.getComputedTop()).toBe(40);
1056
+ expect(root_child1.getComputedWidth()).toBe(25);
1057
+ expect(root_child1.getComputedHeight()).toBe(25);
1058
+ });
1059
+ test('box_sizing_content_box_max_height', () => {
1060
+ const config = Yoga.Config.create();
1061
+
1062
+ const root = Yoga.Node.create(config);
1063
+ root.setPositionType(PositionType.Absolute);
1064
+ root.setWidth(100);
1065
+ root.setHeight(100);
1066
+
1067
+ const root_child0 = Yoga.Node.create(config);
1068
+ root_child0.setWidth(50);
1069
+ root_child0.setMaxHeight(50);
1070
+ root_child0.setBoxSizing(BoxSizing.ContentBox);
1071
+ root_child0.setPadding(Edge.All, 5);
1072
+ root_child0.setBorder(Edge.All, 15);
1073
+ root.insertChild(root_child0, 0);
1074
+
1075
+ const root_child1 = Yoga.Node.create(config);
1076
+ root_child1.setWidth(25);
1077
+ root_child1.setHeight(25);
1078
+ root.insertChild(root_child1, 1);
1079
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1080
+
1081
+ expect(root.getComputedLeft()).toBe(0);
1082
+ expect(root.getComputedTop()).toBe(0);
1083
+ expect(root.getComputedWidth()).toBe(100);
1084
+ expect(root.getComputedHeight()).toBe(100);
1085
+
1086
+ expect(root_child0.getComputedLeft()).toBe(0);
1087
+ expect(root_child0.getComputedTop()).toBe(0);
1088
+ expect(root_child0.getComputedWidth()).toBe(90);
1089
+ expect(root_child0.getComputedHeight()).toBe(40);
1090
+
1091
+ expect(root_child1.getComputedLeft()).toBe(0);
1092
+ expect(root_child1.getComputedTop()).toBe(40);
1093
+ expect(root_child1.getComputedWidth()).toBe(25);
1094
+ expect(root_child1.getComputedHeight()).toBe(25);
1095
+
1096
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1097
+
1098
+ expect(root.getComputedLeft()).toBe(0);
1099
+ expect(root.getComputedTop()).toBe(0);
1100
+ expect(root.getComputedWidth()).toBe(100);
1101
+ expect(root.getComputedHeight()).toBe(100);
1102
+
1103
+ expect(root_child0.getComputedLeft()).toBe(10);
1104
+ expect(root_child0.getComputedTop()).toBe(0);
1105
+ expect(root_child0.getComputedWidth()).toBe(90);
1106
+ expect(root_child0.getComputedHeight()).toBe(40);
1107
+
1108
+ expect(root_child1.getComputedLeft()).toBe(75);
1109
+ expect(root_child1.getComputedTop()).toBe(40);
1110
+ expect(root_child1.getComputedWidth()).toBe(25);
1111
+ expect(root_child1.getComputedHeight()).toBe(25);
1112
+ });
1113
+ test('box_sizing_border_box_max_height', () => {
1114
+ const config = Yoga.Config.create();
1115
+
1116
+ const root = Yoga.Node.create(config);
1117
+ root.setPositionType(PositionType.Absolute);
1118
+ root.setWidth(100);
1119
+ root.setHeight(100);
1120
+
1121
+ const root_child0 = Yoga.Node.create(config);
1122
+ root_child0.setWidth(50);
1123
+ root_child0.setMaxHeight(50);
1124
+ root_child0.setPadding(Edge.All, 5);
1125
+ root_child0.setBorder(Edge.All, 15);
1126
+ root.insertChild(root_child0, 0);
1127
+
1128
+ const root_child1 = Yoga.Node.create(config);
1129
+ root_child1.setWidth(25);
1130
+ root_child1.setHeight(25);
1131
+ root.insertChild(root_child1, 1);
1132
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1133
+
1134
+ expect(root.getComputedLeft()).toBe(0);
1135
+ expect(root.getComputedTop()).toBe(0);
1136
+ expect(root.getComputedWidth()).toBe(100);
1137
+ expect(root.getComputedHeight()).toBe(100);
1138
+
1139
+ expect(root_child0.getComputedLeft()).toBe(0);
1140
+ expect(root_child0.getComputedTop()).toBe(0);
1141
+ expect(root_child0.getComputedWidth()).toBe(50);
1142
+ expect(root_child0.getComputedHeight()).toBe(40);
1143
+
1144
+ expect(root_child1.getComputedLeft()).toBe(0);
1145
+ expect(root_child1.getComputedTop()).toBe(40);
1146
+ expect(root_child1.getComputedWidth()).toBe(25);
1147
+ expect(root_child1.getComputedHeight()).toBe(25);
1148
+
1149
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1150
+
1151
+ expect(root.getComputedLeft()).toBe(0);
1152
+ expect(root.getComputedTop()).toBe(0);
1153
+ expect(root.getComputedWidth()).toBe(100);
1154
+ expect(root.getComputedHeight()).toBe(100);
1155
+
1156
+ expect(root_child0.getComputedLeft()).toBe(50);
1157
+ expect(root_child0.getComputedTop()).toBe(0);
1158
+ expect(root_child0.getComputedWidth()).toBe(50);
1159
+ expect(root_child0.getComputedHeight()).toBe(40);
1160
+
1161
+ expect(root_child1.getComputedLeft()).toBe(75);
1162
+ expect(root_child1.getComputedTop()).toBe(40);
1163
+ expect(root_child1.getComputedWidth()).toBe(25);
1164
+ expect(root_child1.getComputedHeight()).toBe(25);
1165
+ });
1166
+ test('box_sizing_content_box_min_width', () => {
1167
+ const config = Yoga.Config.create();
1168
+
1169
+ const root = Yoga.Node.create(config);
1170
+ root.setPositionType(PositionType.Absolute);
1171
+ root.setWidth(100);
1172
+ root.setHeight(100);
1173
+
1174
+ const root_child0 = Yoga.Node.create(config);
1175
+ root_child0.setMinWidth(50);
1176
+ root_child0.setHeight(25);
1177
+ root_child0.setBoxSizing(BoxSizing.ContentBox);
1178
+ root_child0.setPadding(Edge.All, 5);
1179
+ root_child0.setBorder(Edge.All, 15);
1180
+ root.insertChild(root_child0, 0);
1181
+
1182
+ const root_child1 = Yoga.Node.create(config);
1183
+ root_child1.setWidth(25);
1184
+ root_child1.setHeight(25);
1185
+ root.insertChild(root_child1, 1);
1186
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1187
+
1188
+ expect(root.getComputedLeft()).toBe(0);
1189
+ expect(root.getComputedTop()).toBe(0);
1190
+ expect(root.getComputedWidth()).toBe(100);
1191
+ expect(root.getComputedHeight()).toBe(100);
1192
+
1193
+ expect(root_child0.getComputedLeft()).toBe(0);
1194
+ expect(root_child0.getComputedTop()).toBe(0);
1195
+ expect(root_child0.getComputedWidth()).toBe(100);
1196
+ expect(root_child0.getComputedHeight()).toBe(65);
1197
+
1198
+ expect(root_child1.getComputedLeft()).toBe(0);
1199
+ expect(root_child1.getComputedTop()).toBe(65);
1200
+ expect(root_child1.getComputedWidth()).toBe(25);
1201
+ expect(root_child1.getComputedHeight()).toBe(25);
1202
+
1203
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1204
+
1205
+ expect(root.getComputedLeft()).toBe(0);
1206
+ expect(root.getComputedTop()).toBe(0);
1207
+ expect(root.getComputedWidth()).toBe(100);
1208
+ expect(root.getComputedHeight()).toBe(100);
1209
+
1210
+ expect(root_child0.getComputedLeft()).toBe(0);
1211
+ expect(root_child0.getComputedTop()).toBe(0);
1212
+ expect(root_child0.getComputedWidth()).toBe(100);
1213
+ expect(root_child0.getComputedHeight()).toBe(65);
1214
+
1215
+ expect(root_child1.getComputedLeft()).toBe(75);
1216
+ expect(root_child1.getComputedTop()).toBe(65);
1217
+ expect(root_child1.getComputedWidth()).toBe(25);
1218
+ expect(root_child1.getComputedHeight()).toBe(25);
1219
+ });
1220
+ test('box_sizing_border_box_min_width', () => {
1221
+ const config = Yoga.Config.create();
1222
+
1223
+ const root = Yoga.Node.create(config);
1224
+ root.setPositionType(PositionType.Absolute);
1225
+ root.setWidth(100);
1226
+ root.setHeight(100);
1227
+
1228
+ const root_child0 = Yoga.Node.create(config);
1229
+ root_child0.setMinWidth(50);
1230
+ root_child0.setHeight(25);
1231
+ root_child0.setPadding(Edge.All, 5);
1232
+ root_child0.setBorder(Edge.All, 15);
1233
+ root.insertChild(root_child0, 0);
1234
+
1235
+ const root_child1 = Yoga.Node.create(config);
1236
+ root_child1.setWidth(25);
1237
+ root_child1.setHeight(25);
1238
+ root.insertChild(root_child1, 1);
1239
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1240
+
1241
+ expect(root.getComputedLeft()).toBe(0);
1242
+ expect(root.getComputedTop()).toBe(0);
1243
+ expect(root.getComputedWidth()).toBe(100);
1244
+ expect(root.getComputedHeight()).toBe(100);
1245
+
1246
+ expect(root_child0.getComputedLeft()).toBe(0);
1247
+ expect(root_child0.getComputedTop()).toBe(0);
1248
+ expect(root_child0.getComputedWidth()).toBe(100);
1249
+ expect(root_child0.getComputedHeight()).toBe(40);
1250
+
1251
+ expect(root_child1.getComputedLeft()).toBe(0);
1252
+ expect(root_child1.getComputedTop()).toBe(40);
1253
+ expect(root_child1.getComputedWidth()).toBe(25);
1254
+ expect(root_child1.getComputedHeight()).toBe(25);
1255
+
1256
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1257
+
1258
+ expect(root.getComputedLeft()).toBe(0);
1259
+ expect(root.getComputedTop()).toBe(0);
1260
+ expect(root.getComputedWidth()).toBe(100);
1261
+ expect(root.getComputedHeight()).toBe(100);
1262
+
1263
+ expect(root_child0.getComputedLeft()).toBe(0);
1264
+ expect(root_child0.getComputedTop()).toBe(0);
1265
+ expect(root_child0.getComputedWidth()).toBe(100);
1266
+ expect(root_child0.getComputedHeight()).toBe(40);
1267
+
1268
+ expect(root_child1.getComputedLeft()).toBe(75);
1269
+ expect(root_child1.getComputedTop()).toBe(40);
1270
+ expect(root_child1.getComputedWidth()).toBe(25);
1271
+ expect(root_child1.getComputedHeight()).toBe(25);
1272
+ });
1273
+ test('box_sizing_content_box_min_height', () => {
1274
+ const config = Yoga.Config.create();
1275
+
1276
+ const root = Yoga.Node.create(config);
1277
+ root.setPositionType(PositionType.Absolute);
1278
+ root.setWidth(100);
1279
+ root.setHeight(100);
1280
+
1281
+ const root_child0 = Yoga.Node.create(config);
1282
+ root_child0.setWidth(50);
1283
+ root_child0.setMinHeight(50);
1284
+ root_child0.setBoxSizing(BoxSizing.ContentBox);
1285
+ root_child0.setPadding(Edge.All, 5);
1286
+ root_child0.setBorder(Edge.All, 15);
1287
+ root.insertChild(root_child0, 0);
1288
+
1289
+ const root_child1 = Yoga.Node.create(config);
1290
+ root_child1.setWidth(25);
1291
+ root_child1.setHeight(25);
1292
+ root.insertChild(root_child1, 1);
1293
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1294
+
1295
+ expect(root.getComputedLeft()).toBe(0);
1296
+ expect(root.getComputedTop()).toBe(0);
1297
+ expect(root.getComputedWidth()).toBe(100);
1298
+ expect(root.getComputedHeight()).toBe(100);
1299
+
1300
+ expect(root_child0.getComputedLeft()).toBe(0);
1301
+ expect(root_child0.getComputedTop()).toBe(0);
1302
+ expect(root_child0.getComputedWidth()).toBe(90);
1303
+ expect(root_child0.getComputedHeight()).toBe(90);
1304
+
1305
+ expect(root_child1.getComputedLeft()).toBe(0);
1306
+ expect(root_child1.getComputedTop()).toBe(90);
1307
+ expect(root_child1.getComputedWidth()).toBe(25);
1308
+ expect(root_child1.getComputedHeight()).toBe(25);
1309
+
1310
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1311
+
1312
+ expect(root.getComputedLeft()).toBe(0);
1313
+ expect(root.getComputedTop()).toBe(0);
1314
+ expect(root.getComputedWidth()).toBe(100);
1315
+ expect(root.getComputedHeight()).toBe(100);
1316
+
1317
+ expect(root_child0.getComputedLeft()).toBe(10);
1318
+ expect(root_child0.getComputedTop()).toBe(0);
1319
+ expect(root_child0.getComputedWidth()).toBe(90);
1320
+ expect(root_child0.getComputedHeight()).toBe(90);
1321
+
1322
+ expect(root_child1.getComputedLeft()).toBe(75);
1323
+ expect(root_child1.getComputedTop()).toBe(90);
1324
+ expect(root_child1.getComputedWidth()).toBe(25);
1325
+ expect(root_child1.getComputedHeight()).toBe(25);
1326
+ });
1327
+ test('box_sizing_border_box_min_height', () => {
1328
+ const config = Yoga.Config.create();
1329
+
1330
+ const root = Yoga.Node.create(config);
1331
+ root.setPositionType(PositionType.Absolute);
1332
+ root.setWidth(100);
1333
+ root.setHeight(100);
1334
+
1335
+ const root_child0 = Yoga.Node.create(config);
1336
+ root_child0.setWidth(50);
1337
+ root_child0.setMinHeight(50);
1338
+ root_child0.setPadding(Edge.All, 5);
1339
+ root_child0.setBorder(Edge.All, 15);
1340
+ root.insertChild(root_child0, 0);
1341
+
1342
+ const root_child1 = Yoga.Node.create(config);
1343
+ root_child1.setWidth(25);
1344
+ root_child1.setHeight(25);
1345
+ root.insertChild(root_child1, 1);
1346
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1347
+
1348
+ expect(root.getComputedLeft()).toBe(0);
1349
+ expect(root.getComputedTop()).toBe(0);
1350
+ expect(root.getComputedWidth()).toBe(100);
1351
+ expect(root.getComputedHeight()).toBe(100);
1352
+
1353
+ expect(root_child0.getComputedLeft()).toBe(0);
1354
+ expect(root_child0.getComputedTop()).toBe(0);
1355
+ expect(root_child0.getComputedWidth()).toBe(50);
1356
+ expect(root_child0.getComputedHeight()).toBe(50);
1357
+
1358
+ expect(root_child1.getComputedLeft()).toBe(0);
1359
+ expect(root_child1.getComputedTop()).toBe(50);
1360
+ expect(root_child1.getComputedWidth()).toBe(25);
1361
+ expect(root_child1.getComputedHeight()).toBe(25);
1362
+
1363
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1364
+
1365
+ expect(root.getComputedLeft()).toBe(0);
1366
+ expect(root.getComputedTop()).toBe(0);
1367
+ expect(root.getComputedWidth()).toBe(100);
1368
+ expect(root.getComputedHeight()).toBe(100);
1369
+
1370
+ expect(root_child0.getComputedLeft()).toBe(50);
1371
+ expect(root_child0.getComputedTop()).toBe(0);
1372
+ expect(root_child0.getComputedWidth()).toBe(50);
1373
+ expect(root_child0.getComputedHeight()).toBe(50);
1374
+
1375
+ expect(root_child1.getComputedLeft()).toBe(75);
1376
+ expect(root_child1.getComputedTop()).toBe(50);
1377
+ expect(root_child1.getComputedWidth()).toBe(25);
1378
+ expect(root_child1.getComputedHeight()).toBe(25);
1379
+ });
1380
+ test('box_sizing_content_box_no_height_no_width', () => {
1381
+ const config = Yoga.Config.create();
1382
+
1383
+ const root = Yoga.Node.create(config);
1384
+ root.setPositionType(PositionType.Absolute);
1385
+ root.setWidth(100);
1386
+ root.setHeight(100);
1387
+
1388
+ const root_child0 = Yoga.Node.create(config);
1389
+ root_child0.setBoxSizing(BoxSizing.ContentBox);
1390
+ root_child0.setPadding(Edge.All, 2);
1391
+ root_child0.setBorder(Edge.All, 7);
1392
+ root.insertChild(root_child0, 0);
1393
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1394
+
1395
+ expect(root.getComputedLeft()).toBe(0);
1396
+ expect(root.getComputedTop()).toBe(0);
1397
+ expect(root.getComputedWidth()).toBe(100);
1398
+ expect(root.getComputedHeight()).toBe(100);
1399
+
1400
+ expect(root_child0.getComputedLeft()).toBe(0);
1401
+ expect(root_child0.getComputedTop()).toBe(0);
1402
+ expect(root_child0.getComputedWidth()).toBe(100);
1403
+ expect(root_child0.getComputedHeight()).toBe(18);
1404
+
1405
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1406
+
1407
+ expect(root.getComputedLeft()).toBe(0);
1408
+ expect(root.getComputedTop()).toBe(0);
1409
+ expect(root.getComputedWidth()).toBe(100);
1410
+ expect(root.getComputedHeight()).toBe(100);
1411
+
1412
+ expect(root_child0.getComputedLeft()).toBe(0);
1413
+ expect(root_child0.getComputedTop()).toBe(0);
1414
+ expect(root_child0.getComputedWidth()).toBe(100);
1415
+ expect(root_child0.getComputedHeight()).toBe(18);
1416
+ });
1417
+ test('box_sizing_border_box_no_height_no_width', () => {
1418
+ const config = Yoga.Config.create();
1419
+
1420
+ const root = Yoga.Node.create(config);
1421
+ root.setPositionType(PositionType.Absolute);
1422
+ root.setWidth(100);
1423
+ root.setHeight(100);
1424
+
1425
+ const root_child0 = Yoga.Node.create(config);
1426
+ root_child0.setPadding(Edge.All, 2);
1427
+ root_child0.setBorder(Edge.All, 7);
1428
+ root.insertChild(root_child0, 0);
1429
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1430
+
1431
+ expect(root.getComputedLeft()).toBe(0);
1432
+ expect(root.getComputedTop()).toBe(0);
1433
+ expect(root.getComputedWidth()).toBe(100);
1434
+ expect(root.getComputedHeight()).toBe(100);
1435
+
1436
+ expect(root_child0.getComputedLeft()).toBe(0);
1437
+ expect(root_child0.getComputedTop()).toBe(0);
1438
+ expect(root_child0.getComputedWidth()).toBe(100);
1439
+ expect(root_child0.getComputedHeight()).toBe(18);
1440
+
1441
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1442
+
1443
+ expect(root.getComputedLeft()).toBe(0);
1444
+ expect(root.getComputedTop()).toBe(0);
1445
+ expect(root.getComputedWidth()).toBe(100);
1446
+ expect(root.getComputedHeight()).toBe(100);
1447
+
1448
+ expect(root_child0.getComputedLeft()).toBe(0);
1449
+ expect(root_child0.getComputedTop()).toBe(0);
1450
+ expect(root_child0.getComputedWidth()).toBe(100);
1451
+ expect(root_child0.getComputedHeight()).toBe(18);
1452
+ });
1453
+ test('box_sizing_content_box_nested', () => {
1454
+ const config = Yoga.Config.create();
1455
+
1456
+ const root = Yoga.Node.create(config);
1457
+ root.setPositionType(PositionType.Absolute);
1458
+ root.setWidth(100);
1459
+ root.setHeight(100);
1460
+ root.setBoxSizing(BoxSizing.ContentBox);
1461
+ root.setPadding(Edge.All, 15);
1462
+ root.setBorder(Edge.All, 3);
1463
+
1464
+ const root_child0 = Yoga.Node.create(config);
1465
+ root_child0.setWidth(20);
1466
+ root_child0.setHeight(20);
1467
+ root_child0.setBoxSizing(BoxSizing.ContentBox);
1468
+ root_child0.setPadding(Edge.All, 2);
1469
+ root_child0.setBorder(Edge.All, 7);
1470
+ root.insertChild(root_child0, 0);
1471
+
1472
+ const root_child0_child0 = Yoga.Node.create(config);
1473
+ root_child0_child0.setWidth(10);
1474
+ root_child0_child0.setHeight(5);
1475
+ root_child0_child0.setBoxSizing(BoxSizing.ContentBox);
1476
+ root_child0_child0.setPadding(Edge.All, 1);
1477
+ root_child0_child0.setBorder(Edge.All, 2);
1478
+ root_child0.insertChild(root_child0_child0, 0);
1479
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1480
+
1481
+ expect(root.getComputedLeft()).toBe(0);
1482
+ expect(root.getComputedTop()).toBe(0);
1483
+ expect(root.getComputedWidth()).toBe(136);
1484
+ expect(root.getComputedHeight()).toBe(136);
1485
+
1486
+ expect(root_child0.getComputedLeft()).toBe(18);
1487
+ expect(root_child0.getComputedTop()).toBe(18);
1488
+ expect(root_child0.getComputedWidth()).toBe(38);
1489
+ expect(root_child0.getComputedHeight()).toBe(38);
1490
+
1491
+ expect(root_child0_child0.getComputedLeft()).toBe(9);
1492
+ expect(root_child0_child0.getComputedTop()).toBe(9);
1493
+ expect(root_child0_child0.getComputedWidth()).toBe(16);
1494
+ expect(root_child0_child0.getComputedHeight()).toBe(11);
1495
+
1496
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1497
+
1498
+ expect(root.getComputedLeft()).toBe(0);
1499
+ expect(root.getComputedTop()).toBe(0);
1500
+ expect(root.getComputedWidth()).toBe(136);
1501
+ expect(root.getComputedHeight()).toBe(136);
1502
+
1503
+ expect(root_child0.getComputedLeft()).toBe(80);
1504
+ expect(root_child0.getComputedTop()).toBe(18);
1505
+ expect(root_child0.getComputedWidth()).toBe(38);
1506
+ expect(root_child0.getComputedHeight()).toBe(38);
1507
+
1508
+ expect(root_child0_child0.getComputedLeft()).toBe(13);
1509
+ expect(root_child0_child0.getComputedTop()).toBe(9);
1510
+ expect(root_child0_child0.getComputedWidth()).toBe(16);
1511
+ expect(root_child0_child0.getComputedHeight()).toBe(11);
1512
+ });
1513
+ test('box_sizing_border_box_nested', () => {
1514
+ const config = Yoga.Config.create();
1515
+
1516
+ const root = Yoga.Node.create(config);
1517
+ root.setPositionType(PositionType.Absolute);
1518
+ root.setWidth(100);
1519
+ root.setHeight(100);
1520
+ root.setPadding(Edge.All, 15);
1521
+ root.setBorder(Edge.All, 3);
1522
+
1523
+ const root_child0 = Yoga.Node.create(config);
1524
+ root_child0.setWidth(20);
1525
+ root_child0.setHeight(20);
1526
+ root_child0.setPadding(Edge.All, 2);
1527
+ root_child0.setBorder(Edge.All, 7);
1528
+ root.insertChild(root_child0, 0);
1529
+
1530
+ const root_child0_child0 = Yoga.Node.create(config);
1531
+ root_child0_child0.setWidth(10);
1532
+ root_child0_child0.setHeight(5);
1533
+ root_child0_child0.setPadding(Edge.All, 1);
1534
+ root_child0_child0.setBorder(Edge.All, 2);
1535
+ root_child0.insertChild(root_child0_child0, 0);
1536
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1537
+
1538
+ expect(root.getComputedLeft()).toBe(0);
1539
+ expect(root.getComputedTop()).toBe(0);
1540
+ expect(root.getComputedWidth()).toBe(100);
1541
+ expect(root.getComputedHeight()).toBe(100);
1542
+
1543
+ expect(root_child0.getComputedLeft()).toBe(18);
1544
+ expect(root_child0.getComputedTop()).toBe(18);
1545
+ expect(root_child0.getComputedWidth()).toBe(20);
1546
+ expect(root_child0.getComputedHeight()).toBe(20);
1547
+
1548
+ expect(root_child0_child0.getComputedLeft()).toBe(9);
1549
+ expect(root_child0_child0.getComputedTop()).toBe(9);
1550
+ expect(root_child0_child0.getComputedWidth()).toBe(10);
1551
+ expect(root_child0_child0.getComputedHeight()).toBe(6);
1552
+
1553
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1554
+
1555
+ expect(root.getComputedLeft()).toBe(0);
1556
+ expect(root.getComputedTop()).toBe(0);
1557
+ expect(root.getComputedWidth()).toBe(100);
1558
+ expect(root.getComputedHeight()).toBe(100);
1559
+
1560
+ expect(root_child0.getComputedLeft()).toBe(62);
1561
+ expect(root_child0.getComputedTop()).toBe(18);
1562
+ expect(root_child0.getComputedWidth()).toBe(20);
1563
+ expect(root_child0.getComputedHeight()).toBe(20);
1564
+
1565
+ expect(root_child0_child0.getComputedLeft()).toBe(1);
1566
+ expect(root_child0_child0.getComputedTop()).toBe(9);
1567
+ expect(root_child0_child0.getComputedWidth()).toBe(10);
1568
+ expect(root_child0_child0.getComputedHeight()).toBe(6);
1569
+ });
1570
+ test('box_sizing_content_box_nested_alternating', () => {
1571
+ const config = Yoga.Config.create();
1572
+
1573
+ const root = Yoga.Node.create(config);
1574
+ root.setPositionType(PositionType.Absolute);
1575
+ root.setWidth(100);
1576
+ root.setHeight(100);
1577
+ root.setBoxSizing(BoxSizing.ContentBox);
1578
+ root.setPadding(Edge.All, 3);
1579
+ root.setBorder(Edge.All, 2);
1580
+
1581
+ const root_child0 = Yoga.Node.create(config);
1582
+ root_child0.setWidth(40);
1583
+ root_child0.setHeight(40);
1584
+ root_child0.setPadding(Edge.All, 8);
1585
+ root_child0.setBorder(Edge.All, 2);
1586
+ root.insertChild(root_child0, 0);
1587
+
1588
+ const root_child0_child0 = Yoga.Node.create(config);
1589
+ root_child0_child0.setWidth(20);
1590
+ root_child0_child0.setHeight(25);
1591
+ root_child0_child0.setBoxSizing(BoxSizing.ContentBox);
1592
+ root_child0_child0.setPadding(Edge.All, 3);
1593
+ root_child0_child0.setBorder(Edge.All, 6);
1594
+ root_child0.insertChild(root_child0_child0, 0);
1595
+
1596
+ const root_child0_child0_child0 = Yoga.Node.create(config);
1597
+ root_child0_child0_child0.setWidth(10);
1598
+ root_child0_child0_child0.setHeight(5);
1599
+ root_child0_child0_child0.setPadding(Edge.All, 1);
1600
+ root_child0_child0_child0.setBorder(Edge.All, 1);
1601
+ root_child0_child0.insertChild(root_child0_child0_child0, 0);
1602
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1603
+
1604
+ expect(root.getComputedLeft()).toBe(0);
1605
+ expect(root.getComputedTop()).toBe(0);
1606
+ expect(root.getComputedWidth()).toBe(110);
1607
+ expect(root.getComputedHeight()).toBe(110);
1608
+
1609
+ expect(root_child0.getComputedLeft()).toBe(5);
1610
+ expect(root_child0.getComputedTop()).toBe(5);
1611
+ expect(root_child0.getComputedWidth()).toBe(40);
1612
+ expect(root_child0.getComputedHeight()).toBe(40);
1613
+
1614
+ expect(root_child0_child0.getComputedLeft()).toBe(10);
1615
+ expect(root_child0_child0.getComputedTop()).toBe(10);
1616
+ expect(root_child0_child0.getComputedWidth()).toBe(38);
1617
+ expect(root_child0_child0.getComputedHeight()).toBe(43);
1618
+
1619
+ expect(root_child0_child0_child0.getComputedLeft()).toBe(9);
1620
+ expect(root_child0_child0_child0.getComputedTop()).toBe(9);
1621
+ expect(root_child0_child0_child0.getComputedWidth()).toBe(10);
1622
+ expect(root_child0_child0_child0.getComputedHeight()).toBe(5);
1623
+
1624
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1625
+
1626
+ expect(root.getComputedLeft()).toBe(0);
1627
+ expect(root.getComputedTop()).toBe(0);
1628
+ expect(root.getComputedWidth()).toBe(110);
1629
+ expect(root.getComputedHeight()).toBe(110);
1630
+
1631
+ expect(root_child0.getComputedLeft()).toBe(65);
1632
+ expect(root_child0.getComputedTop()).toBe(5);
1633
+ expect(root_child0.getComputedWidth()).toBe(40);
1634
+ expect(root_child0.getComputedHeight()).toBe(40);
1635
+
1636
+ expect(root_child0_child0.getComputedLeft()).toBe(-8);
1637
+ expect(root_child0_child0.getComputedTop()).toBe(10);
1638
+ expect(root_child0_child0.getComputedWidth()).toBe(38);
1639
+ expect(root_child0_child0.getComputedHeight()).toBe(43);
1640
+
1641
+ expect(root_child0_child0_child0.getComputedLeft()).toBe(19);
1642
+ expect(root_child0_child0_child0.getComputedTop()).toBe(9);
1643
+ expect(root_child0_child0_child0.getComputedWidth()).toBe(10);
1644
+ expect(root_child0_child0_child0.getComputedHeight()).toBe(5);
1645
+ });
1646
+ test('box_sizing_border_box_nested_alternating', () => {
1647
+ const config = Yoga.Config.create();
1648
+
1649
+ const root = Yoga.Node.create(config);
1650
+ root.setPositionType(PositionType.Absolute);
1651
+ root.setWidth(100);
1652
+ root.setHeight(100);
1653
+ root.setPadding(Edge.All, 3);
1654
+ root.setBorder(Edge.All, 2);
1655
+
1656
+ const root_child0 = Yoga.Node.create(config);
1657
+ root_child0.setWidth(40);
1658
+ root_child0.setHeight(40);
1659
+ root_child0.setBoxSizing(BoxSizing.ContentBox);
1660
+ root_child0.setPadding(Edge.All, 8);
1661
+ root_child0.setBorder(Edge.All, 2);
1662
+ root.insertChild(root_child0, 0);
1663
+
1664
+ const root_child0_child0 = Yoga.Node.create(config);
1665
+ root_child0_child0.setWidth(20);
1666
+ root_child0_child0.setHeight(25);
1667
+ root_child0_child0.setPadding(Edge.All, 3);
1668
+ root_child0_child0.setBorder(Edge.All, 6);
1669
+ root_child0.insertChild(root_child0_child0, 0);
1670
+
1671
+ const root_child0_child0_child0 = Yoga.Node.create(config);
1672
+ root_child0_child0_child0.setWidth(10);
1673
+ root_child0_child0_child0.setHeight(5);
1674
+ root_child0_child0_child0.setBoxSizing(BoxSizing.ContentBox);
1675
+ root_child0_child0_child0.setPadding(Edge.All, 1);
1676
+ root_child0_child0_child0.setBorder(Edge.All, 1);
1677
+ root_child0_child0.insertChild(root_child0_child0_child0, 0);
1678
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1679
+
1680
+ expect(root.getComputedLeft()).toBe(0);
1681
+ expect(root.getComputedTop()).toBe(0);
1682
+ expect(root.getComputedWidth()).toBe(100);
1683
+ expect(root.getComputedHeight()).toBe(100);
1684
+
1685
+ expect(root_child0.getComputedLeft()).toBe(5);
1686
+ expect(root_child0.getComputedTop()).toBe(5);
1687
+ expect(root_child0.getComputedWidth()).toBe(60);
1688
+ expect(root_child0.getComputedHeight()).toBe(60);
1689
+
1690
+ expect(root_child0_child0.getComputedLeft()).toBe(10);
1691
+ expect(root_child0_child0.getComputedTop()).toBe(10);
1692
+ expect(root_child0_child0.getComputedWidth()).toBe(20);
1693
+ expect(root_child0_child0.getComputedHeight()).toBe(25);
1694
+
1695
+ expect(root_child0_child0_child0.getComputedLeft()).toBe(9);
1696
+ expect(root_child0_child0_child0.getComputedTop()).toBe(9);
1697
+ expect(root_child0_child0_child0.getComputedWidth()).toBe(14);
1698
+ expect(root_child0_child0_child0.getComputedHeight()).toBe(9);
1699
+
1700
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1701
+
1702
+ expect(root.getComputedLeft()).toBe(0);
1703
+ expect(root.getComputedTop()).toBe(0);
1704
+ expect(root.getComputedWidth()).toBe(100);
1705
+ expect(root.getComputedHeight()).toBe(100);
1706
+
1707
+ expect(root_child0.getComputedLeft()).toBe(35);
1708
+ expect(root_child0.getComputedTop()).toBe(5);
1709
+ expect(root_child0.getComputedWidth()).toBe(60);
1710
+ expect(root_child0.getComputedHeight()).toBe(60);
1711
+
1712
+ expect(root_child0_child0.getComputedLeft()).toBe(30);
1713
+ expect(root_child0_child0.getComputedTop()).toBe(10);
1714
+ expect(root_child0_child0.getComputedWidth()).toBe(20);
1715
+ expect(root_child0_child0.getComputedHeight()).toBe(25);
1716
+
1717
+ expect(root_child0_child0_child0.getComputedLeft()).toBe(-3);
1718
+ expect(root_child0_child0_child0.getComputedTop()).toBe(9);
1719
+ expect(root_child0_child0_child0.getComputedWidth()).toBe(14);
1720
+ expect(root_child0_child0_child0.getComputedHeight()).toBe(9);
1721
+ });
1722
+ test('box_sizing_border_box_flex_basis_row', () => {
1723
+ const config = Yoga.Config.create();
1724
+
1725
+ const root = Yoga.Node.create(config);
1726
+ root.setPositionType(PositionType.Absolute);
1727
+ root.setWidth(100);
1728
+ root.setHeight(100);
1729
+ root.setFlexDirection(FlexDirection.Row);
1730
+
1731
+ const root_child0 = Yoga.Node.create(config);
1732
+ root_child0.setFlexBasis(50);
1733
+ root_child0.setHeight(25);
1734
+ root_child0.setPadding(Edge.All, 5);
1735
+ root_child0.setBorder(Edge.All, 10);
1736
+ root.insertChild(root_child0, 0);
1737
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1738
+
1739
+ expect(root.getComputedLeft()).toBe(0);
1740
+ expect(root.getComputedTop()).toBe(0);
1741
+ expect(root.getComputedWidth()).toBe(100);
1742
+ expect(root.getComputedHeight()).toBe(100);
1743
+
1744
+ expect(root_child0.getComputedLeft()).toBe(0);
1745
+ expect(root_child0.getComputedTop()).toBe(0);
1746
+ expect(root_child0.getComputedWidth()).toBe(50);
1747
+ expect(root_child0.getComputedHeight()).toBe(30);
1748
+
1749
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1750
+
1751
+ expect(root.getComputedLeft()).toBe(0);
1752
+ expect(root.getComputedTop()).toBe(0);
1753
+ expect(root.getComputedWidth()).toBe(100);
1754
+ expect(root.getComputedHeight()).toBe(100);
1755
+
1756
+ expect(root_child0.getComputedLeft()).toBe(50);
1757
+ expect(root_child0.getComputedTop()).toBe(0);
1758
+ expect(root_child0.getComputedWidth()).toBe(50);
1759
+ expect(root_child0.getComputedHeight()).toBe(30);
1760
+ });
1761
+ test('box_sizing_border_box_flex_basis_column', () => {
1762
+ const config = Yoga.Config.create();
1763
+
1764
+ const root = Yoga.Node.create(config);
1765
+ root.setPositionType(PositionType.Absolute);
1766
+ root.setWidth(100);
1767
+ root.setHeight(100);
1768
+
1769
+ const root_child0 = Yoga.Node.create(config);
1770
+ root_child0.setFlexBasis(50);
1771
+ root_child0.setHeight(25);
1772
+ root_child0.setPadding(Edge.All, 5);
1773
+ root_child0.setBorder(Edge.All, 10);
1774
+ root.insertChild(root_child0, 0);
1775
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1776
+
1777
+ expect(root.getComputedLeft()).toBe(0);
1778
+ expect(root.getComputedTop()).toBe(0);
1779
+ expect(root.getComputedWidth()).toBe(100);
1780
+ expect(root.getComputedHeight()).toBe(100);
1781
+
1782
+ expect(root_child0.getComputedLeft()).toBe(0);
1783
+ expect(root_child0.getComputedTop()).toBe(0);
1784
+ expect(root_child0.getComputedWidth()).toBe(100);
1785
+ expect(root_child0.getComputedHeight()).toBe(50);
1786
+
1787
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1788
+
1789
+ expect(root.getComputedLeft()).toBe(0);
1790
+ expect(root.getComputedTop()).toBe(0);
1791
+ expect(root.getComputedWidth()).toBe(100);
1792
+ expect(root.getComputedHeight()).toBe(100);
1793
+
1794
+ expect(root_child0.getComputedLeft()).toBe(0);
1795
+ expect(root_child0.getComputedTop()).toBe(0);
1796
+ expect(root_child0.getComputedWidth()).toBe(100);
1797
+ expect(root_child0.getComputedHeight()).toBe(50);
1798
+ });
1799
+ test('box_sizing_content_box_padding_start', () => {
1800
+ const config = Yoga.Config.create();
1801
+
1802
+ const root = Yoga.Node.create(config);
1803
+ root.setPositionType(PositionType.Absolute);
1804
+ root.setWidth(100);
1805
+ root.setHeight(100);
1806
+ root.setPadding(Edge.Start, 5);
1807
+ root.setBoxSizing(BoxSizing.ContentBox);
1808
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1809
+
1810
+ expect(root.getComputedLeft()).toBe(0);
1811
+ expect(root.getComputedTop()).toBe(0);
1812
+ expect(root.getComputedWidth()).toBe(105);
1813
+ expect(root.getComputedHeight()).toBe(100);
1814
+
1815
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1816
+
1817
+ expect(root.getComputedLeft()).toBe(0);
1818
+ expect(root.getComputedTop()).toBe(0);
1819
+ expect(root.getComputedWidth()).toBe(105);
1820
+ expect(root.getComputedHeight()).toBe(100);
1821
+ });
1822
+ test('box_sizing_border_box_padding_start', () => {
1823
+ const config = Yoga.Config.create();
1824
+
1825
+ const root = Yoga.Node.create(config);
1826
+ root.setPositionType(PositionType.Absolute);
1827
+ root.setWidth(100);
1828
+ root.setHeight(100);
1829
+ root.setPadding(Edge.Start, 5);
1830
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1831
+
1832
+ expect(root.getComputedLeft()).toBe(0);
1833
+ expect(root.getComputedTop()).toBe(0);
1834
+ expect(root.getComputedWidth()).toBe(100);
1835
+ expect(root.getComputedHeight()).toBe(100);
1836
+
1837
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1838
+
1839
+ expect(root.getComputedLeft()).toBe(0);
1840
+ expect(root.getComputedTop()).toBe(0);
1841
+ expect(root.getComputedWidth()).toBe(100);
1842
+ expect(root.getComputedHeight()).toBe(100);
1843
+ });
1844
+ test('box_sizing_content_box_padding_end', () => {
1845
+ const config = Yoga.Config.create();
1846
+
1847
+ const root = Yoga.Node.create(config);
1848
+ root.setPositionType(PositionType.Absolute);
1849
+ root.setWidth(100);
1850
+ root.setHeight(100);
1851
+ root.setPadding(Edge.End, 5);
1852
+ root.setBoxSizing(BoxSizing.ContentBox);
1853
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1854
+
1855
+ expect(root.getComputedLeft()).toBe(0);
1856
+ expect(root.getComputedTop()).toBe(0);
1857
+ expect(root.getComputedWidth()).toBe(105);
1858
+ expect(root.getComputedHeight()).toBe(100);
1859
+
1860
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1861
+
1862
+ expect(root.getComputedLeft()).toBe(0);
1863
+ expect(root.getComputedTop()).toBe(0);
1864
+ expect(root.getComputedWidth()).toBe(105);
1865
+ expect(root.getComputedHeight()).toBe(100);
1866
+ });
1867
+ test('box_sizing_border_box_padding_end', () => {
1868
+ const config = Yoga.Config.create();
1869
+
1870
+ const root = Yoga.Node.create(config);
1871
+ root.setPositionType(PositionType.Absolute);
1872
+ root.setWidth(100);
1873
+ root.setHeight(100);
1874
+ root.setPadding(Edge.End, 5);
1875
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1876
+
1877
+ expect(root.getComputedLeft()).toBe(0);
1878
+ expect(root.getComputedTop()).toBe(0);
1879
+ expect(root.getComputedWidth()).toBe(100);
1880
+ expect(root.getComputedHeight()).toBe(100);
1881
+
1882
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1883
+
1884
+ expect(root.getComputedLeft()).toBe(0);
1885
+ expect(root.getComputedTop()).toBe(0);
1886
+ expect(root.getComputedWidth()).toBe(100);
1887
+ expect(root.getComputedHeight()).toBe(100);
1888
+ });
1889
+ test('box_sizing_content_box_border_start', () => {
1890
+ const config = Yoga.Config.create();
1891
+
1892
+ const root = Yoga.Node.create(config);
1893
+ root.setPositionType(PositionType.Absolute);
1894
+ root.setWidth(100);
1895
+ root.setHeight(100);
1896
+ root.setBorder(Edge.Start, 5);
1897
+ root.setBoxSizing(BoxSizing.ContentBox);
1898
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1899
+
1900
+ expect(root.getComputedLeft()).toBe(0);
1901
+ expect(root.getComputedTop()).toBe(0);
1902
+ expect(root.getComputedWidth()).toBe(105);
1903
+ expect(root.getComputedHeight()).toBe(100);
1904
+
1905
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1906
+
1907
+ expect(root.getComputedLeft()).toBe(0);
1908
+ expect(root.getComputedTop()).toBe(0);
1909
+ expect(root.getComputedWidth()).toBe(105);
1910
+ expect(root.getComputedHeight()).toBe(100);
1911
+ });
1912
+ test('box_sizing_border_box_border_start', () => {
1913
+ const config = Yoga.Config.create();
1914
+
1915
+ const root = Yoga.Node.create(config);
1916
+ root.setPositionType(PositionType.Absolute);
1917
+ root.setWidth(100);
1918
+ root.setHeight(100);
1919
+ root.setBorder(Edge.Start, 5);
1920
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1921
+
1922
+ expect(root.getComputedLeft()).toBe(0);
1923
+ expect(root.getComputedTop()).toBe(0);
1924
+ expect(root.getComputedWidth()).toBe(100);
1925
+ expect(root.getComputedHeight()).toBe(100);
1926
+
1927
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1928
+
1929
+ expect(root.getComputedLeft()).toBe(0);
1930
+ expect(root.getComputedTop()).toBe(0);
1931
+ expect(root.getComputedWidth()).toBe(100);
1932
+ expect(root.getComputedHeight()).toBe(100);
1933
+ });
1934
+ test('box_sizing_content_box_border_end', () => {
1935
+ const config = Yoga.Config.create();
1936
+
1937
+ const root = Yoga.Node.create(config);
1938
+ root.setPositionType(PositionType.Absolute);
1939
+ root.setWidth(100);
1940
+ root.setHeight(100);
1941
+ root.setBorder(Edge.End, 5);
1942
+ root.setBoxSizing(BoxSizing.ContentBox);
1943
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1944
+
1945
+ expect(root.getComputedLeft()).toBe(0);
1946
+ expect(root.getComputedTop()).toBe(0);
1947
+ expect(root.getComputedWidth()).toBe(105);
1948
+ expect(root.getComputedHeight()).toBe(100);
1949
+
1950
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1951
+
1952
+ expect(root.getComputedLeft()).toBe(0);
1953
+ expect(root.getComputedTop()).toBe(0);
1954
+ expect(root.getComputedWidth()).toBe(105);
1955
+ expect(root.getComputedHeight()).toBe(100);
1956
+ });
1957
+ test('box_sizing_border_box_border_end', () => {
1958
+ const config = Yoga.Config.create();
1959
+
1960
+ const root = Yoga.Node.create(config);
1961
+ root.setPositionType(PositionType.Absolute);
1962
+ root.setWidth(100);
1963
+ root.setHeight(100);
1964
+ root.setBorder(Edge.End, 5);
1965
+ root.calculateLayout(undefined, undefined, Direction.LTR);
1966
+
1967
+ expect(root.getComputedLeft()).toBe(0);
1968
+ expect(root.getComputedTop()).toBe(0);
1969
+ expect(root.getComputedWidth()).toBe(100);
1970
+ expect(root.getComputedHeight()).toBe(100);
1971
+
1972
+ root.calculateLayout(undefined, undefined, Direction.RTL);
1973
+
1974
+ expect(root.getComputedLeft()).toBe(0);
1975
+ expect(root.getComputedTop()).toBe(0);
1976
+ expect(root.getComputedWidth()).toBe(100);
1977
+ expect(root.getComputedHeight()).toBe(100);
1978
+ });