@xincli/opentui-core 0.4.6

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 (476) hide show
  1. package/README.md +63 -0
  2. package/dev/keypress-debug-renderer.ts +148 -0
  3. package/dev/keypress-debug.ts +43 -0
  4. package/dev/print-env-vars.ts +32 -0
  5. package/dev/test-tmux-graphics-334.sh +68 -0
  6. package/dev/test-tmux-theme-queries.sh +151 -0
  7. package/dev/thai-debug-test.ts +68 -0
  8. package/dev/theme-mode.ts +290 -0
  9. package/docs/development.md +144 -0
  10. package/package.json +102 -0
  11. package/prebuilt/aarch64-android/libopentui.so +0 -0
  12. package/scripts/build-android.ts +226 -0
  13. package/scripts/build-native-termux.sh +525 -0
  14. package/scripts/build.ts +530 -0
  15. package/scripts/dist-test.ts +312 -0
  16. package/scripts/package-prebuilt.ts +110 -0
  17. package/scripts/publish.ts +60 -0
  18. package/scripts/test-node-hook.mjs +16 -0
  19. package/scripts/test-node.ts +241 -0
  20. package/scripts/vendor-deps.sh +73 -0
  21. package/src/NativeSpanFeed.ts +375 -0
  22. package/src/Renderable.ts +1878 -0
  23. package/src/__snapshots__/buffer.test.ts.snap +28 -0
  24. package/src/animation/Timeline.test.ts +2709 -0
  25. package/src/animation/Timeline.ts +598 -0
  26. package/src/ansi.ts +22 -0
  27. package/src/audio.ts +479 -0
  28. package/src/benchmark/attenuation-benchmark.ts +81 -0
  29. package/src/benchmark/audio-playback-benchmark.ts +344 -0
  30. package/src/benchmark/box-draw-benchmark.ts +1042 -0
  31. package/src/benchmark/colormatrix-benchmark.ts +123 -0
  32. package/src/benchmark/gain-benchmark.ts +80 -0
  33. package/src/benchmark/latest-all-bench-run.json +707 -0
  34. package/src/benchmark/latest-async-bench-run.json +336 -0
  35. package/src/benchmark/latest-default-bench-run.json +657 -0
  36. package/src/benchmark/latest-large-bench-run.json +707 -0
  37. package/src/benchmark/latest-quick-bench-run.json +207 -0
  38. package/src/benchmark/layout-benchmark.ts +2547 -0
  39. package/src/benchmark/markdown-benchmark.ts +1796 -0
  40. package/src/benchmark/native-span-feed-async-benchmark.ts +355 -0
  41. package/src/benchmark/native-span-feed-benchmark.md +56 -0
  42. package/src/benchmark/native-span-feed-benchmark.ts +596 -0
  43. package/src/benchmark/native-span-feed-compare.ts +280 -0
  44. package/src/benchmark/render-traversal-benchmark.ts +928 -0
  45. package/src/benchmark/text-buffer-render-benchmark.ts +874 -0
  46. package/src/benchmark/text-table-benchmark.ts +948 -0
  47. package/src/buffer.test.ts +292 -0
  48. package/src/buffer.ts +564 -0
  49. package/src/console.test.ts +629 -0
  50. package/src/console.ts +1253 -0
  51. package/src/edit-buffer.test.ts +1852 -0
  52. package/src/edit-buffer.ts +417 -0
  53. package/src/editor-view.test.ts +1056 -0
  54. package/src/editor-view.ts +290 -0
  55. package/src/index.ts +25 -0
  56. package/src/lib/KeyHandler.integration.test.ts +292 -0
  57. package/src/lib/KeyHandler.stopPropagation.test.ts +289 -0
  58. package/src/lib/KeyHandler.test.ts +662 -0
  59. package/src/lib/KeyHandler.ts +222 -0
  60. package/src/lib/RGBA.test.ts +60 -0
  61. package/src/lib/RGBA.ts +343 -0
  62. package/src/lib/ascii.font.ts +330 -0
  63. package/src/lib/border.test.ts +83 -0
  64. package/src/lib/border.ts +170 -0
  65. package/src/lib/bunfs.test.ts +27 -0
  66. package/src/lib/bunfs.ts +18 -0
  67. package/src/lib/clipboard.test.ts +63 -0
  68. package/src/lib/clipboard.ts +41 -0
  69. package/src/lib/clock.ts +35 -0
  70. package/src/lib/data-paths.test.ts +133 -0
  71. package/src/lib/data-paths.ts +109 -0
  72. package/src/lib/debounce.ts +106 -0
  73. package/src/lib/detect-links.test.ts +98 -0
  74. package/src/lib/detect-links.ts +56 -0
  75. package/src/lib/env.test.ts +228 -0
  76. package/src/lib/env.ts +209 -0
  77. package/src/lib/extmarks-history.ts +51 -0
  78. package/src/lib/extmarks-multiwidth.test.ts +324 -0
  79. package/src/lib/extmarks.test.ts +3547 -0
  80. package/src/lib/extmarks.ts +861 -0
  81. package/src/lib/fonts/block.json +405 -0
  82. package/src/lib/fonts/grid.json +265 -0
  83. package/src/lib/fonts/huge.json +741 -0
  84. package/src/lib/fonts/pallet.json +314 -0
  85. package/src/lib/fonts/shade.json +591 -0
  86. package/src/lib/fonts/slick.json +321 -0
  87. package/src/lib/fonts/tiny.json +69 -0
  88. package/src/lib/hast-styled-text.ts +59 -0
  89. package/src/lib/index.ts +22 -0
  90. package/src/lib/keybinding.internal.test.ts +342 -0
  91. package/src/lib/keybinding.internal.ts +182 -0
  92. package/src/lib/objects-in-viewport.test.ts +789 -0
  93. package/src/lib/objects-in-viewport.ts +153 -0
  94. package/src/lib/output.capture.ts +58 -0
  95. package/src/lib/parse.keypress-kitty.protocol.test.ts +347 -0
  96. package/src/lib/parse.keypress-kitty.test.ts +712 -0
  97. package/src/lib/parse.keypress-kitty.ts +470 -0
  98. package/src/lib/parse.keypress.test.ts +2020 -0
  99. package/src/lib/parse.keypress.ts +480 -0
  100. package/src/lib/parse.mouse.test.ts +552 -0
  101. package/src/lib/parse.mouse.ts +232 -0
  102. package/src/lib/paste.ts +18 -0
  103. package/src/lib/queue.ts +65 -0
  104. package/src/lib/render-geometry.ts +36 -0
  105. package/src/lib/renderable.validations.test.ts +87 -0
  106. package/src/lib/renderable.validations.ts +83 -0
  107. package/src/lib/scroll-acceleration.ts +98 -0
  108. package/src/lib/selection.ts +261 -0
  109. package/src/lib/singleton.ts +34 -0
  110. package/src/lib/stdin-parser.test.ts +2439 -0
  111. package/src/lib/stdin-parser.ts +2007 -0
  112. package/src/lib/styled-text.ts +178 -0
  113. package/src/lib/terminal-capability-detection.test.ts +226 -0
  114. package/src/lib/terminal-capability-detection.ts +98 -0
  115. package/src/lib/terminal-palette.test.ts +954 -0
  116. package/src/lib/terminal-palette.ts +441 -0
  117. package/src/lib/tree-sitter/assets/README.md +119 -0
  118. package/src/lib/tree-sitter/assets/javascript/highlights.scm +205 -0
  119. package/src/lib/tree-sitter/assets/javascript/tree-sitter-javascript.wasm +0 -0
  120. package/src/lib/tree-sitter/assets/markdown/highlights.scm +150 -0
  121. package/src/lib/tree-sitter/assets/markdown/injections.scm +27 -0
  122. package/src/lib/tree-sitter/assets/markdown/tree-sitter-markdown.wasm +0 -0
  123. package/src/lib/tree-sitter/assets/markdown_inline/highlights.scm +115 -0
  124. package/src/lib/tree-sitter/assets/markdown_inline/tree-sitter-markdown_inline.wasm +0 -0
  125. package/src/lib/tree-sitter/assets/typescript/highlights.scm +604 -0
  126. package/src/lib/tree-sitter/assets/typescript/tree-sitter-typescript.wasm +0 -0
  127. package/src/lib/tree-sitter/assets/update.ts +360 -0
  128. package/src/lib/tree-sitter/assets/zig/highlights.scm +284 -0
  129. package/src/lib/tree-sitter/assets/zig/tree-sitter-zig.wasm +0 -0
  130. package/src/lib/tree-sitter/assets.d.ts +9 -0
  131. package/src/lib/tree-sitter/cache.test.ts +291 -0
  132. package/src/lib/tree-sitter/client.test.ts +1434 -0
  133. package/src/lib/tree-sitter/client.ts +847 -0
  134. package/src/lib/tree-sitter/default-parsers.ts +133 -0
  135. package/src/lib/tree-sitter/download-utils.ts +148 -0
  136. package/src/lib/tree-sitter/index.ts +75 -0
  137. package/src/lib/tree-sitter/parser.worker.ts +1098 -0
  138. package/src/lib/tree-sitter/parsers-config.ts +81 -0
  139. package/src/lib/tree-sitter/resolve-ft.test.ts +55 -0
  140. package/src/lib/tree-sitter/resolve-ft.ts +189 -0
  141. package/src/lib/tree-sitter/types.ts +132 -0
  142. package/src/lib/tree-sitter/update-assets.ts +10 -0
  143. package/src/lib/tree-sitter-styled-text.test.ts +1253 -0
  144. package/src/lib/tree-sitter-styled-text.ts +314 -0
  145. package/src/lib/validate-dir-name.ts +55 -0
  146. package/src/lib/yoga.options.test.ts +628 -0
  147. package/src/lib/yoga.options.ts +346 -0
  148. package/src/native-event-worker-repro.test.ts +48 -0
  149. package/src/native-event-worker-repro.worker.ts +9 -0
  150. package/src/native-handle.test.ts +221 -0
  151. package/src/platform/ffi.test.ts +516 -0
  152. package/src/platform/ffi.ts +653 -0
  153. package/src/platform/runtime.test.ts +52 -0
  154. package/src/platform/runtime.ts +121 -0
  155. package/src/platform/test.ts +45 -0
  156. package/src/platform/worker-handler-cleanup.fixture.ts +12 -0
  157. package/src/platform/worker-onmessage-startup.fixture.ts +10 -0
  158. package/src/platform/worker-startup.fixture.ts +9 -0
  159. package/src/platform/worker.node-test.ts +153 -0
  160. package/src/platform/worker.ts +425 -0
  161. package/src/plugins/core-slot.ts +579 -0
  162. package/src/plugins/registry.ts +402 -0
  163. package/src/plugins/types.ts +46 -0
  164. package/src/post/effects.ts +948 -0
  165. package/src/post/filters.ts +512 -0
  166. package/src/post/matrices.ts +288 -0
  167. package/src/renderables/ASCIIFont.ts +219 -0
  168. package/src/renderables/Box.test.ts +474 -0
  169. package/src/renderables/Box.ts +353 -0
  170. package/src/renderables/Code.test.ts +2388 -0
  171. package/src/renderables/Code.ts +555 -0
  172. package/src/renderables/Diff.regression.test.ts +381 -0
  173. package/src/renderables/Diff.test.ts +3212 -0
  174. package/src/renderables/Diff.ts +1278 -0
  175. package/src/renderables/EditBufferRenderable.test.ts +288 -0
  176. package/src/renderables/EditBufferRenderable.ts +1152 -0
  177. package/src/renderables/FrameBuffer.ts +47 -0
  178. package/src/renderables/Input.test.ts +1310 -0
  179. package/src/renderables/Input.ts +273 -0
  180. package/src/renderables/LineNumberRenderable.ts +725 -0
  181. package/src/renderables/Markdown.ts +2144 -0
  182. package/src/renderables/ScrollBar.ts +423 -0
  183. package/src/renderables/ScrollBox.ts +903 -0
  184. package/src/renderables/Select.test.ts +1134 -0
  185. package/src/renderables/Select.ts +535 -0
  186. package/src/renderables/Slider.test.ts +456 -0
  187. package/src/renderables/Slider.ts +342 -0
  188. package/src/renderables/TabSelect.test.ts +238 -0
  189. package/src/renderables/TabSelect.ts +447 -0
  190. package/src/renderables/Text.selection-buffer.test.ts +118 -0
  191. package/src/renderables/Text.test.ts +2662 -0
  192. package/src/renderables/Text.ts +147 -0
  193. package/src/renderables/TextBufferRenderable.ts +504 -0
  194. package/src/renderables/TextNode.test.ts +1137 -0
  195. package/src/renderables/TextNode.ts +379 -0
  196. package/src/renderables/TextTable.test.ts +1411 -0
  197. package/src/renderables/TextTable.ts +1434 -0
  198. package/src/renderables/Textarea.ts +425 -0
  199. package/src/renderables/TimeToFirstDraw.ts +89 -0
  200. package/src/renderables/__snapshots__/Code.test.ts.snap +13 -0
  201. package/src/renderables/__snapshots__/Diff.test.ts.snap +785 -0
  202. package/src/renderables/__snapshots__/Text.test.ts.snap +421 -0
  203. package/src/renderables/__snapshots__/TextTable.test.ts.snap +215 -0
  204. package/src/renderables/__tests__/Code.test.ts +55 -0
  205. package/src/renderables/__tests__/LineNumberRenderable.scrollbox-simple.test.ts +144 -0
  206. package/src/renderables/__tests__/LineNumberRenderable.scrollbox.test.ts +827 -0
  207. package/src/renderables/__tests__/LineNumberRenderable.test.ts +1906 -0
  208. package/src/renderables/__tests__/LineNumberRenderable.wrapping.test.ts +85 -0
  209. package/src/renderables/__tests__/Markdown.code-colors.test.ts +288 -0
  210. package/src/renderables/__tests__/Markdown.test.ts +4175 -0
  211. package/src/renderables/__tests__/MultiRenderable.selection.test.ts +87 -0
  212. package/src/renderables/__tests__/Textarea.buffer.test.ts +683 -0
  213. package/src/renderables/__tests__/Textarea.destroyed-events.test.ts +675 -0
  214. package/src/renderables/__tests__/Textarea.editing.test.ts +2120 -0
  215. package/src/renderables/__tests__/Textarea.error-handling.test.ts +35 -0
  216. package/src/renderables/__tests__/Textarea.events.test.ts +738 -0
  217. package/src/renderables/__tests__/Textarea.highlights.test.ts +590 -0
  218. package/src/renderables/__tests__/Textarea.keybinding.test.ts +3275 -0
  219. package/src/renderables/__tests__/Textarea.paste.test.ts +357 -0
  220. package/src/renderables/__tests__/Textarea.rendering.test.ts +1927 -0
  221. package/src/renderables/__tests__/Textarea.scroll.test.ts +733 -0
  222. package/src/renderables/__tests__/Textarea.selection.test.ts +1589 -0
  223. package/src/renderables/__tests__/Textarea.stress.test.ts +670 -0
  224. package/src/renderables/__tests__/Textarea.undo-redo.test.ts +383 -0
  225. package/src/renderables/__tests__/Textarea.visual-lines.test.ts +310 -0
  226. package/src/renderables/__tests__/__snapshots__/LineNumberRenderable.code.test.ts.snap +221 -0
  227. package/src/renderables/__tests__/__snapshots__/LineNumberRenderable.scrollbox-simple.test.ts.snap +89 -0
  228. package/src/renderables/__tests__/__snapshots__/LineNumberRenderable.scrollbox.test.ts.snap +457 -0
  229. package/src/renderables/__tests__/__snapshots__/LineNumberRenderable.test.ts.snap +158 -0
  230. package/src/renderables/__tests__/__snapshots__/Textarea.rendering.test.ts.snap +387 -0
  231. package/src/renderables/__tests__/markdown-parser.test.ts +241 -0
  232. package/src/renderables/__tests__/renderable-test-utils.ts +60 -0
  233. package/src/renderables/composition/README.md +8 -0
  234. package/src/renderables/composition/VRenderable.ts +32 -0
  235. package/src/renderables/composition/constructs.ts +127 -0
  236. package/src/renderables/composition/vnode.ts +277 -0
  237. package/src/renderables/index.ts +23 -0
  238. package/src/renderables/markdown-parser.ts +79 -0
  239. package/src/renderer-theme-mode.ts +199 -0
  240. package/src/renderer.ts +4975 -0
  241. package/src/runtime-plugin-support-configure.ts +63 -0
  242. package/src/runtime-plugin-support.ts +13 -0
  243. package/src/runtime-plugin.ts +626 -0
  244. package/src/specs/terminal-startup.md +64 -0
  245. package/src/syntax-style.test.ts +841 -0
  246. package/src/syntax-style.ts +274 -0
  247. package/src/testing/README.md +219 -0
  248. package/src/testing/bun-test-node.ts +880 -0
  249. package/src/testing/capture-spans.test.ts +216 -0
  250. package/src/testing/integration.test.ts +276 -0
  251. package/src/testing/manual-clock.ts +117 -0
  252. package/src/testing/mock-keys.test.ts +1378 -0
  253. package/src/testing/mock-keys.ts +457 -0
  254. package/src/testing/mock-mouse.test.ts +218 -0
  255. package/src/testing/mock-mouse.ts +247 -0
  256. package/src/testing/mock-tree-sitter-client.ts +81 -0
  257. package/src/testing/spy.ts +13 -0
  258. package/src/testing/terminal-capabilities.ts +47 -0
  259. package/src/testing/test-recorder.test.ts +410 -0
  260. package/src/testing/test-recorder.ts +133 -0
  261. package/src/testing/test-renderer.ts +375 -0
  262. package/src/testing/test-renderer.wait.test.ts +278 -0
  263. package/src/testing/test-streams.ts +31 -0
  264. package/src/testing.ts +9 -0
  265. package/src/tests/__snapshots__/absolute-positioning.snapshot.test.ts.snap +481 -0
  266. package/src/tests/__snapshots__/renderable.snapshot.test.ts.snap +19 -0
  267. package/src/tests/__snapshots__/scrollbox.test.ts.snap +29 -0
  268. package/src/tests/absolute-positioning.snapshot.test.ts +638 -0
  269. package/src/tests/allocator-stats.test.ts +53 -0
  270. package/src/tests/audio.test.ts +303 -0
  271. package/src/tests/destroy-during-render.test.ts +200 -0
  272. package/src/tests/destroy-on-exit.fixture.ts +36 -0
  273. package/src/tests/destroy-on-exit.test.ts +62 -0
  274. package/src/tests/ffi-borrowed-pointer-callsites.test.ts +153 -0
  275. package/src/tests/hover-cursor.test.ts +98 -0
  276. package/src/tests/native-backed-measurement-lifecycle.test.ts +133 -0
  277. package/src/tests/native-backed-measurement-parity.test.ts +322 -0
  278. package/src/tests/native-span-feed-async.test.ts +173 -0
  279. package/src/tests/native-span-feed-close.test.ts +120 -0
  280. package/src/tests/native-span-feed-coverage.test.ts +227 -0
  281. package/src/tests/native-span-feed-edge-cases.test.ts +384 -0
  282. package/src/tests/native-span-feed-use-after-free.test.ts +45 -0
  283. package/src/tests/opacity.test.ts +123 -0
  284. package/src/tests/renderable.snapshot.test.ts +524 -0
  285. package/src/tests/renderable.test.ts +1851 -0
  286. package/src/tests/renderer.clock.test.ts +270 -0
  287. package/src/tests/renderer.console-startup.test.ts +2151 -0
  288. package/src/tests/renderer.control.test.ts +458 -0
  289. package/src/tests/renderer.core-slot-binding.test.ts +962 -0
  290. package/src/tests/renderer.cursor.test.ts +26 -0
  291. package/src/tests/renderer.custom-stdout.test.ts +1112 -0
  292. package/src/tests/renderer.destroy-during-render.test.ts +147 -0
  293. package/src/tests/renderer.focus-restore.test.ts +257 -0
  294. package/src/tests/renderer.focus.test.ts +329 -0
  295. package/src/tests/renderer.idle.test.ts +219 -0
  296. package/src/tests/renderer.input.test.ts +2615 -0
  297. package/src/tests/renderer.kitty-flags.test.ts +195 -0
  298. package/src/tests/renderer.lifecycle.test.ts +34 -0
  299. package/src/tests/renderer.mouse.test.ts +1315 -0
  300. package/src/tests/renderer.notifications.test.ts +27 -0
  301. package/src/tests/renderer.palette.test.ts +1199 -0
  302. package/src/tests/renderer.remote.test.ts +247 -0
  303. package/src/tests/renderer.render-stats.test.ts +146 -0
  304. package/src/tests/renderer.scrollback-surface.test.ts +474 -0
  305. package/src/tests/renderer.selection.test.ts +138 -0
  306. package/src/tests/renderer.slot-registry.test.ts +684 -0
  307. package/src/tests/renderer.tracker.test.ts +202 -0
  308. package/src/tests/renderer.useMouse.test.ts +83 -0
  309. package/src/tests/runtime-plugin-node-modules-cycle.fixture.ts +76 -0
  310. package/src/tests/runtime-plugin-node-modules-import-like-string.fixture.ts +48 -0
  311. package/src/tests/runtime-plugin-node-modules-mjs.fixture.ts +43 -0
  312. package/src/tests/runtime-plugin-node-modules-no-bare-rewrite.fixture.ts +67 -0
  313. package/src/tests/runtime-plugin-node-modules-package-type-cache.fixture.ts +72 -0
  314. package/src/tests/runtime-plugin-node-modules-runtime-specifier.fixture.ts +44 -0
  315. package/src/tests/runtime-plugin-node-modules-scoped-package-bare-rewrite.fixture.ts +85 -0
  316. package/src/tests/runtime-plugin-path-alias.fixture.ts +43 -0
  317. package/src/tests/runtime-plugin-resolve-roots.fixture.ts +65 -0
  318. package/src/tests/runtime-plugin-support-configure.fixture.ts +31 -0
  319. package/src/tests/runtime-plugin-support-late-addition.fixture.ts +17 -0
  320. package/src/tests/runtime-plugin-support.fixture.ts +11 -0
  321. package/src/tests/runtime-plugin-support.test.ts +54 -0
  322. package/src/tests/runtime-plugin-windows-file-url.fixture.ts +30 -0
  323. package/src/tests/runtime-plugin.fixture.ts +40 -0
  324. package/src/tests/runtime-plugin.test.ts +369 -0
  325. package/src/tests/scrollbox-culling-bug.test.ts +114 -0
  326. package/src/tests/scrollbox-hitgrid-resize.test.ts +136 -0
  327. package/src/tests/scrollbox-hitgrid.test.ts +909 -0
  328. package/src/tests/scrollbox.test.ts +1895 -0
  329. package/src/tests/wrap-resize-perf.test.ts +276 -0
  330. package/src/tests/yoga-api-coverage.test.ts +409 -0
  331. package/src/tests/yoga-callback-stress.test.ts +122 -0
  332. package/src/tests/yoga-ffi.test.ts +117 -0
  333. package/src/tests/yoga-setters.test.ts +921 -0
  334. package/src/tests/yoga-upstream/YGAlignBaselineTest.test.ts +124 -0
  335. package/src/tests/yoga-upstream/YGComputedBorderTest.test.ts +27 -0
  336. package/src/tests/yoga-upstream/YGComputedMarginTest.test.ts +27 -0
  337. package/src/tests/yoga-upstream/YGComputedPaddingTest.test.ts +27 -0
  338. package/src/tests/yoga-upstream/YGDirtiedTest.test.ts +157 -0
  339. package/src/tests/yoga-upstream/YGErrataTest.test.ts +40 -0
  340. package/src/tests/yoga-upstream/YGFlexBasisAuto.test.ts +23 -0
  341. package/src/tests/yoga-upstream/YGHasNewLayout.test.ts +81 -0
  342. package/src/tests/yoga-upstream/YGMeasureCacheTest.test.ts +31 -0
  343. package/src/tests/yoga-upstream/YGMeasureTest.test.ts +70 -0
  344. package/src/tests/yoga-upstream/generated/YGAbsolutePositionTest.test.ts +1864 -0
  345. package/src/tests/yoga-upstream/generated/YGAlignContentTest.test.ts +5829 -0
  346. package/src/tests/yoga-upstream/generated/YGAlignItemsTest.test.ts +2444 -0
  347. package/src/tests/yoga-upstream/generated/YGAlignSelfTest.test.ts +293 -0
  348. package/src/tests/yoga-upstream/generated/YGAndroidNewsFeed.test.ts +315 -0
  349. package/src/tests/yoga-upstream/generated/YGAspectRatioTest.test.ts +231 -0
  350. package/src/tests/yoga-upstream/generated/YGAutoTest.test.ts +347 -0
  351. package/src/tests/yoga-upstream/generated/YGBorderTest.test.ts +256 -0
  352. package/src/tests/yoga-upstream/generated/YGBoxSizingTest.test.ts +2747 -0
  353. package/src/tests/yoga-upstream/generated/YGDimensionTest.test.ts +129 -0
  354. package/src/tests/yoga-upstream/generated/YGDisplayContentsTest.test.ts +109 -0
  355. package/src/tests/yoga-upstream/generated/YGDisplayTest.test.ts +1097 -0
  356. package/src/tests/yoga-upstream/generated/YGFlexDirectionTest.test.ts +4562 -0
  357. package/src/tests/yoga-upstream/generated/YGFlexTest.test.ts +677 -0
  358. package/src/tests/yoga-upstream/generated/YGFlexWrapTest.test.ts +2071 -0
  359. package/src/tests/yoga-upstream/generated/YGGapTest.test.ts +3303 -0
  360. package/src/tests/yoga-upstream/generated/YGIntrinsicSizeTest.test.ts +582 -0
  361. package/src/tests/yoga-upstream/generated/YGJustifyContentTest.test.ts +2150 -0
  362. package/src/tests/yoga-upstream/generated/YGMarginTest.test.ts +1963 -0
  363. package/src/tests/yoga-upstream/generated/YGMinMaxDimensionTest.test.ts +1446 -0
  364. package/src/tests/yoga-upstream/generated/YGPaddingTest.test.ts +354 -0
  365. package/src/tests/yoga-upstream/generated/YGPercentageTest.test.ts +1760 -0
  366. package/src/tests/yoga-upstream/generated/YGRoundingTest.test.ts +1161 -0
  367. package/src/tests/yoga-upstream/generated/YGSizeOverflowTest.test.ts +207 -0
  368. package/src/tests/yoga-upstream/generated/YGStaticPositionTest.test.ts +6338 -0
  369. package/src/tests/yoga-upstream/tools/MeasureCounter.ts +54 -0
  370. package/src/tests/yoga-upstream/tools/utils.ts +81 -0
  371. package/src/text-buffer-view.test.ts +722 -0
  372. package/src/text-buffer-view.ts +193 -0
  373. package/src/text-buffer.test.ts +512 -0
  374. package/src/text-buffer.ts +250 -0
  375. package/src/types.ts +199 -0
  376. package/src/utils.ts +88 -0
  377. package/src/yoga.ts +1146 -0
  378. package/src/zig/ansi.zig +502 -0
  379. package/src/zig/audio.zig +1206 -0
  380. package/src/zig/bench/README.md +50 -0
  381. package/src/zig/bench/buffer-color-blending_bench.zig +350 -0
  382. package/src/zig/bench/buffer-draw-box_bench.zig +786 -0
  383. package/src/zig/bench/buffer-draw-text-buffer_bench.zig +894 -0
  384. package/src/zig/bench/edit-buffer_bench.zig +476 -0
  385. package/src/zig/bench/editor-view_bench.zig +169 -0
  386. package/src/zig/bench/native-span-feed_bench.zig +107 -0
  387. package/src/zig/bench/rope-markers_bench.zig +713 -0
  388. package/src/zig/bench/rope_bench.zig +514 -0
  389. package/src/zig/bench/styled-text_bench.zig +476 -0
  390. package/src/zig/bench/text-buffer-coords_bench.zig +362 -0
  391. package/src/zig/bench/text-buffer-view_bench.zig +459 -0
  392. package/src/zig/bench/text-chunk-graphemes_bench.zig +272 -0
  393. package/src/zig/bench/utf8_bench.zig +799 -0
  394. package/src/zig/bench-utils.zig +431 -0
  395. package/src/zig/bench.zig +223 -0
  396. package/src/zig/buffer-methods.zig +215 -0
  397. package/src/zig/buffer.zig +2515 -0
  398. package/src/zig/build.zig +700 -0
  399. package/src/zig/build.zig.zon +19 -0
  400. package/src/zig/edit-buffer.zig +900 -0
  401. package/src/zig/editor-view.zig +812 -0
  402. package/src/zig/event-bus.zig +28 -0
  403. package/src/zig/event-emitter.zig +65 -0
  404. package/src/zig/file-logger.zig +92 -0
  405. package/src/zig/grapheme.zig +838 -0
  406. package/src/zig/handles.zig +267 -0
  407. package/src/zig/lib.zig +2813 -0
  408. package/src/zig/link.zig +349 -0
  409. package/src/zig/logger.zig +43 -0
  410. package/src/zig/mem-registry.zig +126 -0
  411. package/src/zig/miniaudio_shim.c +21 -0
  412. package/src/zig/native-renderable.zig +112 -0
  413. package/src/zig/native-span-feed-bench-lib.zig +7 -0
  414. package/src/zig/native-span-feed.zig +747 -0
  415. package/src/zig/renderer-output.zig +677 -0
  416. package/src/zig/renderer.zig +2106 -0
  417. package/src/zig/rope.zig +1220 -0
  418. package/src/zig/split-scrollback.zig +88 -0
  419. package/src/zig/syntax-style.zig +174 -0
  420. package/src/zig/terminal.zig +1652 -0
  421. package/src/zig/test.zig +82 -0
  422. package/src/zig/tests/README.md +18 -0
  423. package/src/zig/tests/ansi_test.zig +18 -0
  424. package/src/zig/tests/audio_test.zig +439 -0
  425. package/src/zig/tests/buffer-methods_test.zig +1111 -0
  426. package/src/zig/tests/buffer_test.zig +2926 -0
  427. package/src/zig/tests/edit-buffer-history_test.zig +299 -0
  428. package/src/zig/tests/edit-buffer_test.zig +1688 -0
  429. package/src/zig/tests/editor-view_test.zig +3454 -0
  430. package/src/zig/tests/event-emitter_test.zig +249 -0
  431. package/src/zig/tests/grapheme_test.zig +1329 -0
  432. package/src/zig/tests/handles_test.zig +123 -0
  433. package/src/zig/tests/link_test.zig +220 -0
  434. package/src/zig/tests/mem-registry_test.zig +473 -0
  435. package/src/zig/tests/memory_leak_regression_test.zig +234 -0
  436. package/src/zig/tests/native-renderable_test.zig +16 -0
  437. package/src/zig/tests/native-span-feed_test.zig +1266 -0
  438. package/src/zig/tests/renderer_test.zig +2604 -0
  439. package/src/zig/tests/rope-nested_test.zig +712 -0
  440. package/src/zig/tests/rope_fuzz_test.zig +238 -0
  441. package/src/zig/tests/rope_test.zig +2362 -0
  442. package/src/zig/tests/segment-merge.test.zig +148 -0
  443. package/src/zig/tests/split-scrollback_test.zig +70 -0
  444. package/src/zig/tests/syntax-style_test.zig +558 -0
  445. package/src/zig/tests/terminal_test.zig +1489 -0
  446. package/src/zig/tests/test-renderer.zig +126 -0
  447. package/src/zig/tests/text-buffer-drawing_test.zig +3291 -0
  448. package/src/zig/tests/text-buffer-highlights_test.zig +706 -0
  449. package/src/zig/tests/text-buffer-iterators_test.zig +776 -0
  450. package/src/zig/tests/text-buffer-segment_test.zig +320 -0
  451. package/src/zig/tests/text-buffer-selection_test.zig +1056 -0
  452. package/src/zig/tests/text-buffer-selection_viewport_test.zig +358 -0
  453. package/src/zig/tests/text-buffer-view_test.zig +3672 -0
  454. package/src/zig/tests/text-buffer_test.zig +2191 -0
  455. package/src/zig/tests/unicode-width-map.zon +3909 -0
  456. package/src/zig/tests/utf8_no_zwj_test.zig +260 -0
  457. package/src/zig/tests/utf8_test.zig +4060 -0
  458. package/src/zig/tests/utf8_wcwidth_cursor_test.zig +267 -0
  459. package/src/zig/tests/utf8_wcwidth_test.zig +357 -0
  460. package/src/zig/tests/word-wrap-editing_test.zig +498 -0
  461. package/src/zig/tests/wrap-cache-perf_test.zig +113 -0
  462. package/src/zig/tests/yoga_test.zig +65 -0
  463. package/src/zig/text-buffer-iterators.zig +496 -0
  464. package/src/zig/text-buffer-segment.zig +403 -0
  465. package/src/zig/text-buffer-view.zig +1428 -0
  466. package/src/zig/text-buffer.zig +1272 -0
  467. package/src/zig/utf8.zig +1954 -0
  468. package/src/zig/utils.zig +12 -0
  469. package/src/zig/uucode-stub.zig +76 -0
  470. package/src/zig/vendor/miniaudio/miniaudio.h +93468 -0
  471. package/src/zig/yoga.zig +658 -0
  472. package/src/zig-structs.ts +381 -0
  473. package/src/zig.ts +5260 -0
  474. package/tsconfig.build.json +17 -0
  475. package/tsconfig.json +27 -0
  476. package/tsconfig.node-test.json +138 -0
@@ -0,0 +1,2747 @@
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<<a841bb29f095097bae9635f62b9fb16d>>
8
+ * generated by gentest/gentest-driver.ts from gentest/fixtures/YGBoxSizingTest.html
9
+ */
10
+
11
+ import { instrinsicSizeMeasureFunc } from "../tools/utils.ts"
12
+ import Yoga from "../../../yoga.js"
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.js"
30
+
31
+ test("box_sizing_content_box_simple", () => {
32
+ const config = Yoga.Config.create()
33
+ let root
34
+
35
+ try {
36
+ root = Yoga.Node.create(config)
37
+ root.setPositionType(PositionType.Absolute)
38
+ root.setPadding(Edge.Left, 5)
39
+ root.setPadding(Edge.Top, 5)
40
+ root.setPadding(Edge.Right, 5)
41
+ root.setPadding(Edge.Bottom, 5)
42
+ root.setBorder(Edge.Left, 10)
43
+ root.setBorder(Edge.Top, 10)
44
+ root.setBorder(Edge.Right, 10)
45
+ root.setBorder(Edge.Bottom, 10)
46
+ root.setWidth(100)
47
+ root.setHeight(100)
48
+ root.setBoxSizing(BoxSizing.ContentBox)
49
+ root.calculateLayout(undefined, undefined, Direction.LTR)
50
+
51
+ expect(root.getComputedLeft()).toBe(0)
52
+ expect(root.getComputedTop()).toBe(0)
53
+ expect(root.getComputedWidth()).toBe(130)
54
+ expect(root.getComputedHeight()).toBe(130)
55
+
56
+ root.calculateLayout(undefined, undefined, Direction.RTL)
57
+
58
+ expect(root.getComputedLeft()).toBe(0)
59
+ expect(root.getComputedTop()).toBe(0)
60
+ expect(root.getComputedWidth()).toBe(130)
61
+ expect(root.getComputedHeight()).toBe(130)
62
+ } finally {
63
+ if (typeof root !== "undefined") {
64
+ root.freeRecursive()
65
+ }
66
+
67
+ config.free()
68
+ }
69
+ })
70
+ test("box_sizing_border_box_simple", () => {
71
+ const config = Yoga.Config.create()
72
+ let root
73
+
74
+ try {
75
+ root = Yoga.Node.create(config)
76
+ root.setPositionType(PositionType.Absolute)
77
+ root.setPadding(Edge.Left, 5)
78
+ root.setPadding(Edge.Top, 5)
79
+ root.setPadding(Edge.Right, 5)
80
+ root.setPadding(Edge.Bottom, 5)
81
+ root.setBorder(Edge.Left, 10)
82
+ root.setBorder(Edge.Top, 10)
83
+ root.setBorder(Edge.Right, 10)
84
+ root.setBorder(Edge.Bottom, 10)
85
+ root.setWidth(100)
86
+ root.setHeight(100)
87
+ root.calculateLayout(undefined, undefined, Direction.LTR)
88
+
89
+ expect(root.getComputedLeft()).toBe(0)
90
+ expect(root.getComputedTop()).toBe(0)
91
+ expect(root.getComputedWidth()).toBe(100)
92
+ expect(root.getComputedHeight()).toBe(100)
93
+
94
+ root.calculateLayout(undefined, undefined, Direction.RTL)
95
+
96
+ expect(root.getComputedLeft()).toBe(0)
97
+ expect(root.getComputedTop()).toBe(0)
98
+ expect(root.getComputedWidth()).toBe(100)
99
+ expect(root.getComputedHeight()).toBe(100)
100
+ } finally {
101
+ if (typeof root !== "undefined") {
102
+ root.freeRecursive()
103
+ }
104
+
105
+ config.free()
106
+ }
107
+ })
108
+ test("box_sizing_content_box_percent", () => {
109
+ const config = Yoga.Config.create()
110
+ let root
111
+
112
+ try {
113
+ root = Yoga.Node.create(config)
114
+ root.setPositionType(PositionType.Absolute)
115
+ root.setWidth(100)
116
+ root.setHeight(100)
117
+
118
+ const root_child0 = Yoga.Node.create(config)
119
+ root_child0.setPadding(Edge.Left, 4)
120
+ root_child0.setPadding(Edge.Top, 4)
121
+ root_child0.setPadding(Edge.Right, 4)
122
+ root_child0.setPadding(Edge.Bottom, 4)
123
+ root_child0.setBorder(Edge.Left, 16)
124
+ root_child0.setBorder(Edge.Top, 16)
125
+ root_child0.setBorder(Edge.Right, 16)
126
+ root_child0.setBorder(Edge.Bottom, 16)
127
+ root_child0.setWidth("50%")
128
+ root_child0.setHeight("25%")
129
+ root_child0.setBoxSizing(BoxSizing.ContentBox)
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(90)
141
+ expect(root_child0.getComputedHeight()).toBe(65)
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(10)
151
+ expect(root_child0.getComputedTop()).toBe(0)
152
+ expect(root_child0.getComputedWidth()).toBe(90)
153
+ expect(root_child0.getComputedHeight()).toBe(65)
154
+ } finally {
155
+ if (typeof root !== "undefined") {
156
+ root.freeRecursive()
157
+ }
158
+
159
+ config.free()
160
+ }
161
+ })
162
+ test("box_sizing_border_box_percent", () => {
163
+ const config = Yoga.Config.create()
164
+ let root
165
+
166
+ try {
167
+ root = Yoga.Node.create(config)
168
+ root.setPositionType(PositionType.Absolute)
169
+ root.setWidth(100)
170
+ root.setHeight(100)
171
+
172
+ const root_child0 = Yoga.Node.create(config)
173
+ root_child0.setPadding(Edge.Left, 4)
174
+ root_child0.setPadding(Edge.Top, 4)
175
+ root_child0.setPadding(Edge.Right, 4)
176
+ root_child0.setPadding(Edge.Bottom, 4)
177
+ root_child0.setBorder(Edge.Left, 16)
178
+ root_child0.setBorder(Edge.Top, 16)
179
+ root_child0.setBorder(Edge.Right, 16)
180
+ root_child0.setBorder(Edge.Bottom, 16)
181
+ root_child0.setWidth("50%")
182
+ root_child0.setHeight("25%")
183
+ root.insertChild(root_child0, 0)
184
+ root.calculateLayout(undefined, undefined, Direction.LTR)
185
+
186
+ expect(root.getComputedLeft()).toBe(0)
187
+ expect(root.getComputedTop()).toBe(0)
188
+ expect(root.getComputedWidth()).toBe(100)
189
+ expect(root.getComputedHeight()).toBe(100)
190
+
191
+ expect(root_child0.getComputedLeft()).toBe(0)
192
+ expect(root_child0.getComputedTop()).toBe(0)
193
+ expect(root_child0.getComputedWidth()).toBe(50)
194
+ expect(root_child0.getComputedHeight()).toBe(40)
195
+
196
+ root.calculateLayout(undefined, undefined, Direction.RTL)
197
+
198
+ expect(root.getComputedLeft()).toBe(0)
199
+ expect(root.getComputedTop()).toBe(0)
200
+ expect(root.getComputedWidth()).toBe(100)
201
+ expect(root.getComputedHeight()).toBe(100)
202
+
203
+ expect(root_child0.getComputedLeft()).toBe(50)
204
+ expect(root_child0.getComputedTop()).toBe(0)
205
+ expect(root_child0.getComputedWidth()).toBe(50)
206
+ expect(root_child0.getComputedHeight()).toBe(40)
207
+ } finally {
208
+ if (typeof root !== "undefined") {
209
+ root.freeRecursive()
210
+ }
211
+
212
+ config.free()
213
+ }
214
+ })
215
+ test("box_sizing_content_box_absolute", () => {
216
+ const config = Yoga.Config.create()
217
+ let root
218
+
219
+ try {
220
+ root = Yoga.Node.create(config)
221
+ root.setPositionType(PositionType.Absolute)
222
+ root.setWidth(100)
223
+ root.setHeight(100)
224
+
225
+ const root_child0 = Yoga.Node.create(config)
226
+ root_child0.setPositionType(PositionType.Absolute)
227
+ root_child0.setPadding(Edge.Left, 12)
228
+ root_child0.setPadding(Edge.Top, 12)
229
+ root_child0.setPadding(Edge.Right, 12)
230
+ root_child0.setPadding(Edge.Bottom, 12)
231
+ root_child0.setBorder(Edge.Left, 8)
232
+ root_child0.setBorder(Edge.Top, 8)
233
+ root_child0.setBorder(Edge.Right, 8)
234
+ root_child0.setBorder(Edge.Bottom, 8)
235
+ root_child0.setHeight("25%")
236
+ root_child0.setBoxSizing(BoxSizing.ContentBox)
237
+ root.insertChild(root_child0, 0)
238
+ root.calculateLayout(undefined, undefined, Direction.LTR)
239
+
240
+ expect(root.getComputedLeft()).toBe(0)
241
+ expect(root.getComputedTop()).toBe(0)
242
+ expect(root.getComputedWidth()).toBe(100)
243
+ expect(root.getComputedHeight()).toBe(100)
244
+
245
+ expect(root_child0.getComputedLeft()).toBe(0)
246
+ expect(root_child0.getComputedTop()).toBe(0)
247
+ expect(root_child0.getComputedWidth()).toBe(40)
248
+ expect(root_child0.getComputedHeight()).toBe(65)
249
+
250
+ root.calculateLayout(undefined, undefined, Direction.RTL)
251
+
252
+ expect(root.getComputedLeft()).toBe(0)
253
+ expect(root.getComputedTop()).toBe(0)
254
+ expect(root.getComputedWidth()).toBe(100)
255
+ expect(root.getComputedHeight()).toBe(100)
256
+
257
+ expect(root_child0.getComputedLeft()).toBe(60)
258
+ expect(root_child0.getComputedTop()).toBe(0)
259
+ expect(root_child0.getComputedWidth()).toBe(40)
260
+ expect(root_child0.getComputedHeight()).toBe(65)
261
+ } finally {
262
+ if (typeof root !== "undefined") {
263
+ root.freeRecursive()
264
+ }
265
+
266
+ config.free()
267
+ }
268
+ })
269
+ test("box_sizing_border_box_absolute", () => {
270
+ const config = Yoga.Config.create()
271
+ let root
272
+
273
+ try {
274
+ root = Yoga.Node.create(config)
275
+ root.setPositionType(PositionType.Absolute)
276
+ root.setWidth(100)
277
+ root.setHeight(100)
278
+
279
+ const root_child0 = Yoga.Node.create(config)
280
+ root_child0.setPositionType(PositionType.Absolute)
281
+ root_child0.setPadding(Edge.Left, 12)
282
+ root_child0.setPadding(Edge.Top, 12)
283
+ root_child0.setPadding(Edge.Right, 12)
284
+ root_child0.setPadding(Edge.Bottom, 12)
285
+ root_child0.setBorder(Edge.Left, 8)
286
+ root_child0.setBorder(Edge.Top, 8)
287
+ root_child0.setBorder(Edge.Right, 8)
288
+ root_child0.setBorder(Edge.Bottom, 8)
289
+ root_child0.setHeight("25%")
290
+ root.insertChild(root_child0, 0)
291
+ root.calculateLayout(undefined, undefined, Direction.LTR)
292
+
293
+ expect(root.getComputedLeft()).toBe(0)
294
+ expect(root.getComputedTop()).toBe(0)
295
+ expect(root.getComputedWidth()).toBe(100)
296
+ expect(root.getComputedHeight()).toBe(100)
297
+
298
+ expect(root_child0.getComputedLeft()).toBe(0)
299
+ expect(root_child0.getComputedTop()).toBe(0)
300
+ expect(root_child0.getComputedWidth()).toBe(40)
301
+ expect(root_child0.getComputedHeight()).toBe(40)
302
+
303
+ root.calculateLayout(undefined, undefined, Direction.RTL)
304
+
305
+ expect(root.getComputedLeft()).toBe(0)
306
+ expect(root.getComputedTop()).toBe(0)
307
+ expect(root.getComputedWidth()).toBe(100)
308
+ expect(root.getComputedHeight()).toBe(100)
309
+
310
+ expect(root_child0.getComputedLeft()).toBe(60)
311
+ expect(root_child0.getComputedTop()).toBe(0)
312
+ expect(root_child0.getComputedWidth()).toBe(40)
313
+ expect(root_child0.getComputedHeight()).toBe(40)
314
+ } finally {
315
+ if (typeof root !== "undefined") {
316
+ root.freeRecursive()
317
+ }
318
+
319
+ config.free()
320
+ }
321
+ })
322
+ test("box_sizing_content_box_comtaining_block", () => {
323
+ const config = Yoga.Config.create()
324
+ let root
325
+
326
+ try {
327
+ root = Yoga.Node.create(config)
328
+ root.setPositionType(PositionType.Absolute)
329
+ root.setPadding(Edge.Left, 12)
330
+ root.setPadding(Edge.Top, 12)
331
+ root.setPadding(Edge.Right, 12)
332
+ root.setPadding(Edge.Bottom, 12)
333
+ root.setBorder(Edge.Left, 8)
334
+ root.setBorder(Edge.Top, 8)
335
+ root.setBorder(Edge.Right, 8)
336
+ root.setBorder(Edge.Bottom, 8)
337
+ root.setWidth(100)
338
+ root.setHeight(100)
339
+ root.setBoxSizing(BoxSizing.ContentBox)
340
+
341
+ const root_child0 = Yoga.Node.create(config)
342
+ root_child0.setPositionType(PositionType.Static)
343
+ root.insertChild(root_child0, 0)
344
+
345
+ const root_child0_child0 = Yoga.Node.create(config)
346
+ root_child0_child0.setPositionType(PositionType.Absolute)
347
+ root_child0_child0.setWidth(50)
348
+ root_child0_child0.setHeight("25%")
349
+ root_child0.insertChild(root_child0_child0, 0)
350
+ root.calculateLayout(undefined, undefined, Direction.LTR)
351
+
352
+ expect(root.getComputedLeft()).toBe(0)
353
+ expect(root.getComputedTop()).toBe(0)
354
+ expect(root.getComputedWidth()).toBe(140)
355
+ expect(root.getComputedHeight()).toBe(140)
356
+
357
+ expect(root_child0.getComputedLeft()).toBe(20)
358
+ expect(root_child0.getComputedTop()).toBe(20)
359
+ expect(root_child0.getComputedWidth()).toBe(100)
360
+ expect(root_child0.getComputedHeight()).toBe(0)
361
+
362
+ expect(root_child0_child0.getComputedLeft()).toBe(0)
363
+ expect(root_child0_child0.getComputedTop()).toBe(0)
364
+ expect(root_child0_child0.getComputedWidth()).toBe(50)
365
+ expect(root_child0_child0.getComputedHeight()).toBe(31)
366
+
367
+ root.calculateLayout(undefined, undefined, Direction.RTL)
368
+
369
+ expect(root.getComputedLeft()).toBe(0)
370
+ expect(root.getComputedTop()).toBe(0)
371
+ expect(root.getComputedWidth()).toBe(140)
372
+ expect(root.getComputedHeight()).toBe(140)
373
+
374
+ expect(root_child0.getComputedLeft()).toBe(20)
375
+ expect(root_child0.getComputedTop()).toBe(20)
376
+ expect(root_child0.getComputedWidth()).toBe(100)
377
+ expect(root_child0.getComputedHeight()).toBe(0)
378
+
379
+ expect(root_child0_child0.getComputedLeft()).toBe(50)
380
+ expect(root_child0_child0.getComputedTop()).toBe(0)
381
+ expect(root_child0_child0.getComputedWidth()).toBe(50)
382
+ expect(root_child0_child0.getComputedHeight()).toBe(31)
383
+ } finally {
384
+ if (typeof root !== "undefined") {
385
+ root.freeRecursive()
386
+ }
387
+
388
+ config.free()
389
+ }
390
+ })
391
+ test("box_sizing_border_box_comtaining_block", () => {
392
+ const config = Yoga.Config.create()
393
+ let root
394
+
395
+ try {
396
+ root = Yoga.Node.create(config)
397
+ root.setPositionType(PositionType.Absolute)
398
+ root.setPadding(Edge.Left, 12)
399
+ root.setPadding(Edge.Top, 12)
400
+ root.setPadding(Edge.Right, 12)
401
+ root.setPadding(Edge.Bottom, 12)
402
+ root.setBorder(Edge.Left, 8)
403
+ root.setBorder(Edge.Top, 8)
404
+ root.setBorder(Edge.Right, 8)
405
+ root.setBorder(Edge.Bottom, 8)
406
+ root.setWidth(100)
407
+ root.setHeight(100)
408
+
409
+ const root_child0 = Yoga.Node.create(config)
410
+ root_child0.setPositionType(PositionType.Static)
411
+ root.insertChild(root_child0, 0)
412
+
413
+ const root_child0_child0 = Yoga.Node.create(config)
414
+ root_child0_child0.setPositionType(PositionType.Absolute)
415
+ root_child0_child0.setWidth(50)
416
+ root_child0_child0.setHeight("25%")
417
+ root_child0.insertChild(root_child0_child0, 0)
418
+ root.calculateLayout(undefined, undefined, Direction.LTR)
419
+
420
+ expect(root.getComputedLeft()).toBe(0)
421
+ expect(root.getComputedTop()).toBe(0)
422
+ expect(root.getComputedWidth()).toBe(100)
423
+ expect(root.getComputedHeight()).toBe(100)
424
+
425
+ expect(root_child0.getComputedLeft()).toBe(20)
426
+ expect(root_child0.getComputedTop()).toBe(20)
427
+ expect(root_child0.getComputedWidth()).toBe(60)
428
+ expect(root_child0.getComputedHeight()).toBe(0)
429
+
430
+ expect(root_child0_child0.getComputedLeft()).toBe(0)
431
+ expect(root_child0_child0.getComputedTop()).toBe(0)
432
+ expect(root_child0_child0.getComputedWidth()).toBe(50)
433
+ expect(root_child0_child0.getComputedHeight()).toBe(21)
434
+
435
+ root.calculateLayout(undefined, undefined, Direction.RTL)
436
+
437
+ expect(root.getComputedLeft()).toBe(0)
438
+ expect(root.getComputedTop()).toBe(0)
439
+ expect(root.getComputedWidth()).toBe(100)
440
+ expect(root.getComputedHeight()).toBe(100)
441
+
442
+ expect(root_child0.getComputedLeft()).toBe(20)
443
+ expect(root_child0.getComputedTop()).toBe(20)
444
+ expect(root_child0.getComputedWidth()).toBe(60)
445
+ expect(root_child0.getComputedHeight()).toBe(0)
446
+
447
+ expect(root_child0_child0.getComputedLeft()).toBe(10)
448
+ expect(root_child0_child0.getComputedTop()).toBe(0)
449
+ expect(root_child0_child0.getComputedWidth()).toBe(50)
450
+ expect(root_child0_child0.getComputedHeight()).toBe(21)
451
+ } finally {
452
+ if (typeof root !== "undefined") {
453
+ root.freeRecursive()
454
+ }
455
+
456
+ config.free()
457
+ }
458
+ })
459
+ test("box_sizing_content_box_padding_only", () => {
460
+ const config = Yoga.Config.create()
461
+ let root
462
+
463
+ try {
464
+ root = Yoga.Node.create(config)
465
+ root.setPositionType(PositionType.Absolute)
466
+ root.setPadding(Edge.Left, 5)
467
+ root.setPadding(Edge.Top, 5)
468
+ root.setPadding(Edge.Right, 5)
469
+ root.setPadding(Edge.Bottom, 5)
470
+ root.setWidth(100)
471
+ root.setHeight(100)
472
+ root.setBoxSizing(BoxSizing.ContentBox)
473
+ root.calculateLayout(undefined, undefined, Direction.LTR)
474
+
475
+ expect(root.getComputedLeft()).toBe(0)
476
+ expect(root.getComputedTop()).toBe(0)
477
+ expect(root.getComputedWidth()).toBe(110)
478
+ expect(root.getComputedHeight()).toBe(110)
479
+
480
+ root.calculateLayout(undefined, undefined, Direction.RTL)
481
+
482
+ expect(root.getComputedLeft()).toBe(0)
483
+ expect(root.getComputedTop()).toBe(0)
484
+ expect(root.getComputedWidth()).toBe(110)
485
+ expect(root.getComputedHeight()).toBe(110)
486
+ } finally {
487
+ if (typeof root !== "undefined") {
488
+ root.freeRecursive()
489
+ }
490
+
491
+ config.free()
492
+ }
493
+ })
494
+ test("box_sizing_content_box_padding_only_percent", () => {
495
+ const config = Yoga.Config.create()
496
+ let root
497
+
498
+ try {
499
+ root = Yoga.Node.create(config)
500
+ root.setPositionType(PositionType.Absolute)
501
+ root.setWidth(100)
502
+ root.setHeight(150)
503
+
504
+ const root_child0 = Yoga.Node.create(config)
505
+ root_child0.setPadding(Edge.Left, "10%")
506
+ root_child0.setPadding(Edge.Top, "10%")
507
+ root_child0.setPadding(Edge.Right, "10%")
508
+ root_child0.setPadding(Edge.Bottom, "10%")
509
+ root_child0.setWidth(50)
510
+ root_child0.setHeight(75)
511
+ root_child0.setBoxSizing(BoxSizing.ContentBox)
512
+ root.insertChild(root_child0, 0)
513
+ root.calculateLayout(undefined, undefined, Direction.LTR)
514
+
515
+ expect(root.getComputedLeft()).toBe(0)
516
+ expect(root.getComputedTop()).toBe(0)
517
+ expect(root.getComputedWidth()).toBe(100)
518
+ expect(root.getComputedHeight()).toBe(150)
519
+
520
+ expect(root_child0.getComputedLeft()).toBe(0)
521
+ expect(root_child0.getComputedTop()).toBe(0)
522
+ expect(root_child0.getComputedWidth()).toBe(70)
523
+ expect(root_child0.getComputedHeight()).toBe(95)
524
+
525
+ root.calculateLayout(undefined, undefined, Direction.RTL)
526
+
527
+ expect(root.getComputedLeft()).toBe(0)
528
+ expect(root.getComputedTop()).toBe(0)
529
+ expect(root.getComputedWidth()).toBe(100)
530
+ expect(root.getComputedHeight()).toBe(150)
531
+
532
+ expect(root_child0.getComputedLeft()).toBe(30)
533
+ expect(root_child0.getComputedTop()).toBe(0)
534
+ expect(root_child0.getComputedWidth()).toBe(70)
535
+ expect(root_child0.getComputedHeight()).toBe(95)
536
+ } finally {
537
+ if (typeof root !== "undefined") {
538
+ root.freeRecursive()
539
+ }
540
+
541
+ config.free()
542
+ }
543
+ })
544
+ test("box_sizing_border_box_padding_only", () => {
545
+ const config = Yoga.Config.create()
546
+ let root
547
+
548
+ try {
549
+ root = Yoga.Node.create(config)
550
+ root.setPositionType(PositionType.Absolute)
551
+ root.setPadding(Edge.Left, 5)
552
+ root.setPadding(Edge.Top, 5)
553
+ root.setPadding(Edge.Right, 5)
554
+ root.setPadding(Edge.Bottom, 5)
555
+ root.setWidth(100)
556
+ root.setHeight(100)
557
+ root.calculateLayout(undefined, undefined, Direction.LTR)
558
+
559
+ expect(root.getComputedLeft()).toBe(0)
560
+ expect(root.getComputedTop()).toBe(0)
561
+ expect(root.getComputedWidth()).toBe(100)
562
+ expect(root.getComputedHeight()).toBe(100)
563
+
564
+ root.calculateLayout(undefined, undefined, Direction.RTL)
565
+
566
+ expect(root.getComputedLeft()).toBe(0)
567
+ expect(root.getComputedTop()).toBe(0)
568
+ expect(root.getComputedWidth()).toBe(100)
569
+ expect(root.getComputedHeight()).toBe(100)
570
+ } finally {
571
+ if (typeof root !== "undefined") {
572
+ root.freeRecursive()
573
+ }
574
+
575
+ config.free()
576
+ }
577
+ })
578
+ test("box_sizing_border_box_padding_only_percent", () => {
579
+ const config = Yoga.Config.create()
580
+ let root
581
+
582
+ try {
583
+ root = Yoga.Node.create(config)
584
+ root.setPositionType(PositionType.Absolute)
585
+ root.setWidth(100)
586
+ root.setHeight(150)
587
+
588
+ const root_child0 = Yoga.Node.create(config)
589
+ root_child0.setPadding(Edge.Left, "10%")
590
+ root_child0.setPadding(Edge.Top, "10%")
591
+ root_child0.setPadding(Edge.Right, "10%")
592
+ root_child0.setPadding(Edge.Bottom, "10%")
593
+ root_child0.setWidth(50)
594
+ root_child0.setHeight(75)
595
+ root.insertChild(root_child0, 0)
596
+ root.calculateLayout(undefined, undefined, Direction.LTR)
597
+
598
+ expect(root.getComputedLeft()).toBe(0)
599
+ expect(root.getComputedTop()).toBe(0)
600
+ expect(root.getComputedWidth()).toBe(100)
601
+ expect(root.getComputedHeight()).toBe(150)
602
+
603
+ expect(root_child0.getComputedLeft()).toBe(0)
604
+ expect(root_child0.getComputedTop()).toBe(0)
605
+ expect(root_child0.getComputedWidth()).toBe(50)
606
+ expect(root_child0.getComputedHeight()).toBe(75)
607
+
608
+ root.calculateLayout(undefined, undefined, Direction.RTL)
609
+
610
+ expect(root.getComputedLeft()).toBe(0)
611
+ expect(root.getComputedTop()).toBe(0)
612
+ expect(root.getComputedWidth()).toBe(100)
613
+ expect(root.getComputedHeight()).toBe(150)
614
+
615
+ expect(root_child0.getComputedLeft()).toBe(50)
616
+ expect(root_child0.getComputedTop()).toBe(0)
617
+ expect(root_child0.getComputedWidth()).toBe(50)
618
+ expect(root_child0.getComputedHeight()).toBe(75)
619
+ } finally {
620
+ if (typeof root !== "undefined") {
621
+ root.freeRecursive()
622
+ }
623
+
624
+ config.free()
625
+ }
626
+ })
627
+ test("box_sizing_content_box_border_only", () => {
628
+ const config = Yoga.Config.create()
629
+ let root
630
+
631
+ try {
632
+ root = Yoga.Node.create(config)
633
+ root.setPositionType(PositionType.Absolute)
634
+ root.setBorder(Edge.Left, 10)
635
+ root.setBorder(Edge.Top, 10)
636
+ root.setBorder(Edge.Right, 10)
637
+ root.setBorder(Edge.Bottom, 10)
638
+ root.setWidth(100)
639
+ root.setHeight(100)
640
+ root.setBoxSizing(BoxSizing.ContentBox)
641
+ root.calculateLayout(undefined, undefined, Direction.LTR)
642
+
643
+ expect(root.getComputedLeft()).toBe(0)
644
+ expect(root.getComputedTop()).toBe(0)
645
+ expect(root.getComputedWidth()).toBe(120)
646
+ expect(root.getComputedHeight()).toBe(120)
647
+
648
+ root.calculateLayout(undefined, undefined, Direction.RTL)
649
+
650
+ expect(root.getComputedLeft()).toBe(0)
651
+ expect(root.getComputedTop()).toBe(0)
652
+ expect(root.getComputedWidth()).toBe(120)
653
+ expect(root.getComputedHeight()).toBe(120)
654
+ } finally {
655
+ if (typeof root !== "undefined") {
656
+ root.freeRecursive()
657
+ }
658
+
659
+ config.free()
660
+ }
661
+ })
662
+ test("box_sizing_content_box_border_only_percent", () => {
663
+ const config = Yoga.Config.create()
664
+ let root
665
+
666
+ try {
667
+ root = Yoga.Node.create(config)
668
+ root.setPositionType(PositionType.Absolute)
669
+ root.setWidth(100)
670
+ root.setHeight(100)
671
+
672
+ const root_child0 = Yoga.Node.create(config)
673
+ root_child0.setWidth("50%")
674
+ root_child0.setBoxSizing(BoxSizing.ContentBox)
675
+ root.insertChild(root_child0, 0)
676
+ root.calculateLayout(undefined, undefined, Direction.LTR)
677
+
678
+ expect(root.getComputedLeft()).toBe(0)
679
+ expect(root.getComputedTop()).toBe(0)
680
+ expect(root.getComputedWidth()).toBe(100)
681
+ expect(root.getComputedHeight()).toBe(100)
682
+
683
+ expect(root_child0.getComputedLeft()).toBe(0)
684
+ expect(root_child0.getComputedTop()).toBe(0)
685
+ expect(root_child0.getComputedWidth()).toBe(50)
686
+ expect(root_child0.getComputedHeight()).toBe(0)
687
+
688
+ root.calculateLayout(undefined, undefined, Direction.RTL)
689
+
690
+ expect(root.getComputedLeft()).toBe(0)
691
+ expect(root.getComputedTop()).toBe(0)
692
+ expect(root.getComputedWidth()).toBe(100)
693
+ expect(root.getComputedHeight()).toBe(100)
694
+
695
+ expect(root_child0.getComputedLeft()).toBe(50)
696
+ expect(root_child0.getComputedTop()).toBe(0)
697
+ expect(root_child0.getComputedWidth()).toBe(50)
698
+ expect(root_child0.getComputedHeight()).toBe(0)
699
+ } finally {
700
+ if (typeof root !== "undefined") {
701
+ root.freeRecursive()
702
+ }
703
+
704
+ config.free()
705
+ }
706
+ })
707
+ test("box_sizing_border_box_border_only", () => {
708
+ const config = Yoga.Config.create()
709
+ let root
710
+
711
+ try {
712
+ root = Yoga.Node.create(config)
713
+ root.setPositionType(PositionType.Absolute)
714
+ root.setBorder(Edge.Left, 10)
715
+ root.setBorder(Edge.Top, 10)
716
+ root.setBorder(Edge.Right, 10)
717
+ root.setBorder(Edge.Bottom, 10)
718
+ root.setWidth(100)
719
+ root.setHeight(100)
720
+ root.calculateLayout(undefined, undefined, Direction.LTR)
721
+
722
+ expect(root.getComputedLeft()).toBe(0)
723
+ expect(root.getComputedTop()).toBe(0)
724
+ expect(root.getComputedWidth()).toBe(100)
725
+ expect(root.getComputedHeight()).toBe(100)
726
+
727
+ root.calculateLayout(undefined, undefined, Direction.RTL)
728
+
729
+ expect(root.getComputedLeft()).toBe(0)
730
+ expect(root.getComputedTop()).toBe(0)
731
+ expect(root.getComputedWidth()).toBe(100)
732
+ expect(root.getComputedHeight()).toBe(100)
733
+ } finally {
734
+ if (typeof root !== "undefined") {
735
+ root.freeRecursive()
736
+ }
737
+
738
+ config.free()
739
+ }
740
+ })
741
+ test("box_sizing_border_box_border_only_percent", () => {
742
+ const config = Yoga.Config.create()
743
+ let root
744
+
745
+ try {
746
+ root = Yoga.Node.create(config)
747
+ root.setPositionType(PositionType.Absolute)
748
+ root.setWidth(100)
749
+ root.setHeight(100)
750
+
751
+ const root_child0 = Yoga.Node.create(config)
752
+ root_child0.setWidth("50%")
753
+ root.insertChild(root_child0, 0)
754
+ root.calculateLayout(undefined, undefined, Direction.LTR)
755
+
756
+ expect(root.getComputedLeft()).toBe(0)
757
+ expect(root.getComputedTop()).toBe(0)
758
+ expect(root.getComputedWidth()).toBe(100)
759
+ expect(root.getComputedHeight()).toBe(100)
760
+
761
+ expect(root_child0.getComputedLeft()).toBe(0)
762
+ expect(root_child0.getComputedTop()).toBe(0)
763
+ expect(root_child0.getComputedWidth()).toBe(50)
764
+ expect(root_child0.getComputedHeight()).toBe(0)
765
+
766
+ root.calculateLayout(undefined, undefined, Direction.RTL)
767
+
768
+ expect(root.getComputedLeft()).toBe(0)
769
+ expect(root.getComputedTop()).toBe(0)
770
+ expect(root.getComputedWidth()).toBe(100)
771
+ expect(root.getComputedHeight()).toBe(100)
772
+
773
+ expect(root_child0.getComputedLeft()).toBe(50)
774
+ expect(root_child0.getComputedTop()).toBe(0)
775
+ expect(root_child0.getComputedWidth()).toBe(50)
776
+ expect(root_child0.getComputedHeight()).toBe(0)
777
+ } finally {
778
+ if (typeof root !== "undefined") {
779
+ root.freeRecursive()
780
+ }
781
+
782
+ config.free()
783
+ }
784
+ })
785
+ test("box_sizing_content_box_no_padding_no_border", () => {
786
+ const config = Yoga.Config.create()
787
+ let root
788
+
789
+ try {
790
+ root = Yoga.Node.create(config)
791
+ root.setPositionType(PositionType.Absolute)
792
+ root.setWidth(100)
793
+ root.setHeight(100)
794
+ root.setBoxSizing(BoxSizing.ContentBox)
795
+ root.calculateLayout(undefined, undefined, Direction.LTR)
796
+
797
+ expect(root.getComputedLeft()).toBe(0)
798
+ expect(root.getComputedTop()).toBe(0)
799
+ expect(root.getComputedWidth()).toBe(100)
800
+ expect(root.getComputedHeight()).toBe(100)
801
+
802
+ root.calculateLayout(undefined, undefined, Direction.RTL)
803
+
804
+ expect(root.getComputedLeft()).toBe(0)
805
+ expect(root.getComputedTop()).toBe(0)
806
+ expect(root.getComputedWidth()).toBe(100)
807
+ expect(root.getComputedHeight()).toBe(100)
808
+ } finally {
809
+ if (typeof root !== "undefined") {
810
+ root.freeRecursive()
811
+ }
812
+
813
+ config.free()
814
+ }
815
+ })
816
+ test("box_sizing_border_box_no_padding_no_border", () => {
817
+ const config = Yoga.Config.create()
818
+ let root
819
+
820
+ try {
821
+ root = Yoga.Node.create(config)
822
+ root.setPositionType(PositionType.Absolute)
823
+ root.setWidth(100)
824
+ root.setHeight(100)
825
+ root.calculateLayout(undefined, undefined, Direction.LTR)
826
+
827
+ expect(root.getComputedLeft()).toBe(0)
828
+ expect(root.getComputedTop()).toBe(0)
829
+ expect(root.getComputedWidth()).toBe(100)
830
+ expect(root.getComputedHeight()).toBe(100)
831
+
832
+ root.calculateLayout(undefined, undefined, Direction.RTL)
833
+
834
+ expect(root.getComputedLeft()).toBe(0)
835
+ expect(root.getComputedTop()).toBe(0)
836
+ expect(root.getComputedWidth()).toBe(100)
837
+ expect(root.getComputedHeight()).toBe(100)
838
+ } finally {
839
+ if (typeof root !== "undefined") {
840
+ root.freeRecursive()
841
+ }
842
+
843
+ config.free()
844
+ }
845
+ })
846
+ test("box_sizing_content_box_children", () => {
847
+ const config = Yoga.Config.create()
848
+ let root
849
+
850
+ try {
851
+ root = Yoga.Node.create(config)
852
+ root.setPositionType(PositionType.Absolute)
853
+ root.setPadding(Edge.Left, 5)
854
+ root.setPadding(Edge.Top, 5)
855
+ root.setPadding(Edge.Right, 5)
856
+ root.setPadding(Edge.Bottom, 5)
857
+ root.setBorder(Edge.Left, 10)
858
+ root.setBorder(Edge.Top, 10)
859
+ root.setBorder(Edge.Right, 10)
860
+ root.setBorder(Edge.Bottom, 10)
861
+ root.setWidth(100)
862
+ root.setHeight(100)
863
+ root.setBoxSizing(BoxSizing.ContentBox)
864
+
865
+ const root_child0 = Yoga.Node.create(config)
866
+ root_child0.setWidth(25)
867
+ root_child0.setHeight(25)
868
+ root.insertChild(root_child0, 0)
869
+
870
+ const root_child1 = Yoga.Node.create(config)
871
+ root_child1.setWidth(25)
872
+ root_child1.setHeight(25)
873
+ root.insertChild(root_child1, 1)
874
+
875
+ const root_child2 = Yoga.Node.create(config)
876
+ root_child2.setWidth(25)
877
+ root_child2.setHeight(25)
878
+ root.insertChild(root_child2, 2)
879
+
880
+ const root_child3 = Yoga.Node.create(config)
881
+ root_child3.setWidth(25)
882
+ root_child3.setHeight(25)
883
+ root.insertChild(root_child3, 3)
884
+ root.calculateLayout(undefined, undefined, Direction.LTR)
885
+
886
+ expect(root.getComputedLeft()).toBe(0)
887
+ expect(root.getComputedTop()).toBe(0)
888
+ expect(root.getComputedWidth()).toBe(130)
889
+ expect(root.getComputedHeight()).toBe(130)
890
+
891
+ expect(root_child0.getComputedLeft()).toBe(15)
892
+ expect(root_child0.getComputedTop()).toBe(15)
893
+ expect(root_child0.getComputedWidth()).toBe(25)
894
+ expect(root_child0.getComputedHeight()).toBe(25)
895
+
896
+ expect(root_child1.getComputedLeft()).toBe(15)
897
+ expect(root_child1.getComputedTop()).toBe(40)
898
+ expect(root_child1.getComputedWidth()).toBe(25)
899
+ expect(root_child1.getComputedHeight()).toBe(25)
900
+
901
+ expect(root_child2.getComputedLeft()).toBe(15)
902
+ expect(root_child2.getComputedTop()).toBe(65)
903
+ expect(root_child2.getComputedWidth()).toBe(25)
904
+ expect(root_child2.getComputedHeight()).toBe(25)
905
+
906
+ expect(root_child3.getComputedLeft()).toBe(15)
907
+ expect(root_child3.getComputedTop()).toBe(90)
908
+ expect(root_child3.getComputedWidth()).toBe(25)
909
+ expect(root_child3.getComputedHeight()).toBe(25)
910
+
911
+ root.calculateLayout(undefined, undefined, Direction.RTL)
912
+
913
+ expect(root.getComputedLeft()).toBe(0)
914
+ expect(root.getComputedTop()).toBe(0)
915
+ expect(root.getComputedWidth()).toBe(130)
916
+ expect(root.getComputedHeight()).toBe(130)
917
+
918
+ expect(root_child0.getComputedLeft()).toBe(90)
919
+ expect(root_child0.getComputedTop()).toBe(15)
920
+ expect(root_child0.getComputedWidth()).toBe(25)
921
+ expect(root_child0.getComputedHeight()).toBe(25)
922
+
923
+ expect(root_child1.getComputedLeft()).toBe(90)
924
+ expect(root_child1.getComputedTop()).toBe(40)
925
+ expect(root_child1.getComputedWidth()).toBe(25)
926
+ expect(root_child1.getComputedHeight()).toBe(25)
927
+
928
+ expect(root_child2.getComputedLeft()).toBe(90)
929
+ expect(root_child2.getComputedTop()).toBe(65)
930
+ expect(root_child2.getComputedWidth()).toBe(25)
931
+ expect(root_child2.getComputedHeight()).toBe(25)
932
+
933
+ expect(root_child3.getComputedLeft()).toBe(90)
934
+ expect(root_child3.getComputedTop()).toBe(90)
935
+ expect(root_child3.getComputedWidth()).toBe(25)
936
+ expect(root_child3.getComputedHeight()).toBe(25)
937
+ } finally {
938
+ if (typeof root !== "undefined") {
939
+ root.freeRecursive()
940
+ }
941
+
942
+ config.free()
943
+ }
944
+ })
945
+ test("box_sizing_border_box_children", () => {
946
+ const config = Yoga.Config.create()
947
+ let root
948
+
949
+ try {
950
+ root = Yoga.Node.create(config)
951
+ root.setPositionType(PositionType.Absolute)
952
+ root.setPadding(Edge.Left, 5)
953
+ root.setPadding(Edge.Top, 5)
954
+ root.setPadding(Edge.Right, 5)
955
+ root.setPadding(Edge.Bottom, 5)
956
+ root.setBorder(Edge.Left, 10)
957
+ root.setBorder(Edge.Top, 10)
958
+ root.setBorder(Edge.Right, 10)
959
+ root.setBorder(Edge.Bottom, 10)
960
+ root.setWidth(100)
961
+ root.setHeight(100)
962
+
963
+ const root_child0 = Yoga.Node.create(config)
964
+ root_child0.setWidth(25)
965
+ root_child0.setHeight(25)
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
+
973
+ const root_child2 = Yoga.Node.create(config)
974
+ root_child2.setWidth(25)
975
+ root_child2.setHeight(25)
976
+ root.insertChild(root_child2, 2)
977
+
978
+ const root_child3 = Yoga.Node.create(config)
979
+ root_child3.setWidth(25)
980
+ root_child3.setHeight(25)
981
+ root.insertChild(root_child3, 3)
982
+ root.calculateLayout(undefined, undefined, Direction.LTR)
983
+
984
+ expect(root.getComputedLeft()).toBe(0)
985
+ expect(root.getComputedTop()).toBe(0)
986
+ expect(root.getComputedWidth()).toBe(100)
987
+ expect(root.getComputedHeight()).toBe(100)
988
+
989
+ expect(root_child0.getComputedLeft()).toBe(15)
990
+ expect(root_child0.getComputedTop()).toBe(15)
991
+ expect(root_child0.getComputedWidth()).toBe(25)
992
+ expect(root_child0.getComputedHeight()).toBe(25)
993
+
994
+ expect(root_child1.getComputedLeft()).toBe(15)
995
+ expect(root_child1.getComputedTop()).toBe(40)
996
+ expect(root_child1.getComputedWidth()).toBe(25)
997
+ expect(root_child1.getComputedHeight()).toBe(25)
998
+
999
+ expect(root_child2.getComputedLeft()).toBe(15)
1000
+ expect(root_child2.getComputedTop()).toBe(65)
1001
+ expect(root_child2.getComputedWidth()).toBe(25)
1002
+ expect(root_child2.getComputedHeight()).toBe(25)
1003
+
1004
+ expect(root_child3.getComputedLeft()).toBe(15)
1005
+ expect(root_child3.getComputedTop()).toBe(90)
1006
+ expect(root_child3.getComputedWidth()).toBe(25)
1007
+ expect(root_child3.getComputedHeight()).toBe(25)
1008
+
1009
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1010
+
1011
+ expect(root.getComputedLeft()).toBe(0)
1012
+ expect(root.getComputedTop()).toBe(0)
1013
+ expect(root.getComputedWidth()).toBe(100)
1014
+ expect(root.getComputedHeight()).toBe(100)
1015
+
1016
+ expect(root_child0.getComputedLeft()).toBe(60)
1017
+ expect(root_child0.getComputedTop()).toBe(15)
1018
+ expect(root_child0.getComputedWidth()).toBe(25)
1019
+ expect(root_child0.getComputedHeight()).toBe(25)
1020
+
1021
+ expect(root_child1.getComputedLeft()).toBe(60)
1022
+ expect(root_child1.getComputedTop()).toBe(40)
1023
+ expect(root_child1.getComputedWidth()).toBe(25)
1024
+ expect(root_child1.getComputedHeight()).toBe(25)
1025
+
1026
+ expect(root_child2.getComputedLeft()).toBe(60)
1027
+ expect(root_child2.getComputedTop()).toBe(65)
1028
+ expect(root_child2.getComputedWidth()).toBe(25)
1029
+ expect(root_child2.getComputedHeight()).toBe(25)
1030
+
1031
+ expect(root_child3.getComputedLeft()).toBe(60)
1032
+ expect(root_child3.getComputedTop()).toBe(90)
1033
+ expect(root_child3.getComputedWidth()).toBe(25)
1034
+ expect(root_child3.getComputedHeight()).toBe(25)
1035
+ } finally {
1036
+ if (typeof root !== "undefined") {
1037
+ root.freeRecursive()
1038
+ }
1039
+
1040
+ config.free()
1041
+ }
1042
+ })
1043
+ test("box_sizing_content_box_siblings", () => {
1044
+ const config = Yoga.Config.create()
1045
+ let root
1046
+
1047
+ try {
1048
+ root = Yoga.Node.create(config)
1049
+ root.setPositionType(PositionType.Absolute)
1050
+ root.setWidth(100)
1051
+ root.setHeight(100)
1052
+
1053
+ const root_child0 = Yoga.Node.create(config)
1054
+ root_child0.setWidth(25)
1055
+ root_child0.setHeight(25)
1056
+ root.insertChild(root_child0, 0)
1057
+
1058
+ const root_child1 = Yoga.Node.create(config)
1059
+ root_child1.setPadding(Edge.Left, 10)
1060
+ root_child1.setPadding(Edge.Top, 10)
1061
+ root_child1.setPadding(Edge.Right, 10)
1062
+ root_child1.setPadding(Edge.Bottom, 10)
1063
+ root_child1.setBorder(Edge.Left, 10)
1064
+ root_child1.setBorder(Edge.Top, 10)
1065
+ root_child1.setBorder(Edge.Right, 10)
1066
+ root_child1.setBorder(Edge.Bottom, 10)
1067
+ root_child1.setWidth(25)
1068
+ root_child1.setHeight(25)
1069
+ root_child1.setBoxSizing(BoxSizing.ContentBox)
1070
+ root.insertChild(root_child1, 1)
1071
+
1072
+ const root_child2 = Yoga.Node.create(config)
1073
+ root_child2.setWidth(25)
1074
+ root_child2.setHeight(25)
1075
+ root.insertChild(root_child2, 2)
1076
+
1077
+ const root_child3 = Yoga.Node.create(config)
1078
+ root_child3.setWidth(25)
1079
+ root_child3.setHeight(25)
1080
+ root.insertChild(root_child3, 3)
1081
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1082
+
1083
+ expect(root.getComputedLeft()).toBe(0)
1084
+ expect(root.getComputedTop()).toBe(0)
1085
+ expect(root.getComputedWidth()).toBe(100)
1086
+ expect(root.getComputedHeight()).toBe(100)
1087
+
1088
+ expect(root_child0.getComputedLeft()).toBe(0)
1089
+ expect(root_child0.getComputedTop()).toBe(0)
1090
+ expect(root_child0.getComputedWidth()).toBe(25)
1091
+ expect(root_child0.getComputedHeight()).toBe(25)
1092
+
1093
+ expect(root_child1.getComputedLeft()).toBe(0)
1094
+ expect(root_child1.getComputedTop()).toBe(25)
1095
+ expect(root_child1.getComputedWidth()).toBe(65)
1096
+ expect(root_child1.getComputedHeight()).toBe(65)
1097
+
1098
+ expect(root_child2.getComputedLeft()).toBe(0)
1099
+ expect(root_child2.getComputedTop()).toBe(90)
1100
+ expect(root_child2.getComputedWidth()).toBe(25)
1101
+ expect(root_child2.getComputedHeight()).toBe(25)
1102
+
1103
+ expect(root_child3.getComputedLeft()).toBe(0)
1104
+ expect(root_child3.getComputedTop()).toBe(115)
1105
+ expect(root_child3.getComputedWidth()).toBe(25)
1106
+ expect(root_child3.getComputedHeight()).toBe(25)
1107
+
1108
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1109
+
1110
+ expect(root.getComputedLeft()).toBe(0)
1111
+ expect(root.getComputedTop()).toBe(0)
1112
+ expect(root.getComputedWidth()).toBe(100)
1113
+ expect(root.getComputedHeight()).toBe(100)
1114
+
1115
+ expect(root_child0.getComputedLeft()).toBe(75)
1116
+ expect(root_child0.getComputedTop()).toBe(0)
1117
+ expect(root_child0.getComputedWidth()).toBe(25)
1118
+ expect(root_child0.getComputedHeight()).toBe(25)
1119
+
1120
+ expect(root_child1.getComputedLeft()).toBe(35)
1121
+ expect(root_child1.getComputedTop()).toBe(25)
1122
+ expect(root_child1.getComputedWidth()).toBe(65)
1123
+ expect(root_child1.getComputedHeight()).toBe(65)
1124
+
1125
+ expect(root_child2.getComputedLeft()).toBe(75)
1126
+ expect(root_child2.getComputedTop()).toBe(90)
1127
+ expect(root_child2.getComputedWidth()).toBe(25)
1128
+ expect(root_child2.getComputedHeight()).toBe(25)
1129
+
1130
+ expect(root_child3.getComputedLeft()).toBe(75)
1131
+ expect(root_child3.getComputedTop()).toBe(115)
1132
+ expect(root_child3.getComputedWidth()).toBe(25)
1133
+ expect(root_child3.getComputedHeight()).toBe(25)
1134
+ } finally {
1135
+ if (typeof root !== "undefined") {
1136
+ root.freeRecursive()
1137
+ }
1138
+
1139
+ config.free()
1140
+ }
1141
+ })
1142
+ test("box_sizing_border_box_siblings", () => {
1143
+ const config = Yoga.Config.create()
1144
+ let root
1145
+
1146
+ try {
1147
+ root = Yoga.Node.create(config)
1148
+ root.setPositionType(PositionType.Absolute)
1149
+ root.setWidth(100)
1150
+ root.setHeight(100)
1151
+
1152
+ const root_child0 = Yoga.Node.create(config)
1153
+ root_child0.setWidth(25)
1154
+ root_child0.setHeight(25)
1155
+ root.insertChild(root_child0, 0)
1156
+
1157
+ const root_child1 = Yoga.Node.create(config)
1158
+ root_child1.setPadding(Edge.Left, 10)
1159
+ root_child1.setPadding(Edge.Top, 10)
1160
+ root_child1.setPadding(Edge.Right, 10)
1161
+ root_child1.setPadding(Edge.Bottom, 10)
1162
+ root_child1.setBorder(Edge.Left, 10)
1163
+ root_child1.setBorder(Edge.Top, 10)
1164
+ root_child1.setBorder(Edge.Right, 10)
1165
+ root_child1.setBorder(Edge.Bottom, 10)
1166
+ root_child1.setWidth(25)
1167
+ root_child1.setHeight(25)
1168
+ root.insertChild(root_child1, 1)
1169
+
1170
+ const root_child2 = Yoga.Node.create(config)
1171
+ root_child2.setWidth(25)
1172
+ root_child2.setHeight(25)
1173
+ root.insertChild(root_child2, 2)
1174
+
1175
+ const root_child3 = Yoga.Node.create(config)
1176
+ root_child3.setWidth(25)
1177
+ root_child3.setHeight(25)
1178
+ root.insertChild(root_child3, 3)
1179
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1180
+
1181
+ expect(root.getComputedLeft()).toBe(0)
1182
+ expect(root.getComputedTop()).toBe(0)
1183
+ expect(root.getComputedWidth()).toBe(100)
1184
+ expect(root.getComputedHeight()).toBe(100)
1185
+
1186
+ expect(root_child0.getComputedLeft()).toBe(0)
1187
+ expect(root_child0.getComputedTop()).toBe(0)
1188
+ expect(root_child0.getComputedWidth()).toBe(25)
1189
+ expect(root_child0.getComputedHeight()).toBe(25)
1190
+
1191
+ expect(root_child1.getComputedLeft()).toBe(0)
1192
+ expect(root_child1.getComputedTop()).toBe(25)
1193
+ expect(root_child1.getComputedWidth()).toBe(40)
1194
+ expect(root_child1.getComputedHeight()).toBe(40)
1195
+
1196
+ expect(root_child2.getComputedLeft()).toBe(0)
1197
+ expect(root_child2.getComputedTop()).toBe(65)
1198
+ expect(root_child2.getComputedWidth()).toBe(25)
1199
+ expect(root_child2.getComputedHeight()).toBe(25)
1200
+
1201
+ expect(root_child3.getComputedLeft()).toBe(0)
1202
+ expect(root_child3.getComputedTop()).toBe(90)
1203
+ expect(root_child3.getComputedWidth()).toBe(25)
1204
+ expect(root_child3.getComputedHeight()).toBe(25)
1205
+
1206
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1207
+
1208
+ expect(root.getComputedLeft()).toBe(0)
1209
+ expect(root.getComputedTop()).toBe(0)
1210
+ expect(root.getComputedWidth()).toBe(100)
1211
+ expect(root.getComputedHeight()).toBe(100)
1212
+
1213
+ expect(root_child0.getComputedLeft()).toBe(75)
1214
+ expect(root_child0.getComputedTop()).toBe(0)
1215
+ expect(root_child0.getComputedWidth()).toBe(25)
1216
+ expect(root_child0.getComputedHeight()).toBe(25)
1217
+
1218
+ expect(root_child1.getComputedLeft()).toBe(60)
1219
+ expect(root_child1.getComputedTop()).toBe(25)
1220
+ expect(root_child1.getComputedWidth()).toBe(40)
1221
+ expect(root_child1.getComputedHeight()).toBe(40)
1222
+
1223
+ expect(root_child2.getComputedLeft()).toBe(75)
1224
+ expect(root_child2.getComputedTop()).toBe(65)
1225
+ expect(root_child2.getComputedWidth()).toBe(25)
1226
+ expect(root_child2.getComputedHeight()).toBe(25)
1227
+
1228
+ expect(root_child3.getComputedLeft()).toBe(75)
1229
+ expect(root_child3.getComputedTop()).toBe(90)
1230
+ expect(root_child3.getComputedWidth()).toBe(25)
1231
+ expect(root_child3.getComputedHeight()).toBe(25)
1232
+ } finally {
1233
+ if (typeof root !== "undefined") {
1234
+ root.freeRecursive()
1235
+ }
1236
+
1237
+ config.free()
1238
+ }
1239
+ })
1240
+ test("box_sizing_content_box_max_width", () => {
1241
+ const config = Yoga.Config.create()
1242
+ let root
1243
+
1244
+ try {
1245
+ root = Yoga.Node.create(config)
1246
+ root.setPositionType(PositionType.Absolute)
1247
+ root.setWidth(100)
1248
+ root.setHeight(100)
1249
+
1250
+ const root_child0 = Yoga.Node.create(config)
1251
+ root_child0.setPadding(Edge.Left, 5)
1252
+ root_child0.setPadding(Edge.Top, 5)
1253
+ root_child0.setPadding(Edge.Right, 5)
1254
+ root_child0.setPadding(Edge.Bottom, 5)
1255
+ root_child0.setBorder(Edge.Left, 15)
1256
+ root_child0.setBorder(Edge.Top, 15)
1257
+ root_child0.setBorder(Edge.Right, 15)
1258
+ root_child0.setBorder(Edge.Bottom, 15)
1259
+ root_child0.setMaxWidth(50)
1260
+ root_child0.setHeight(25)
1261
+ root_child0.setBoxSizing(BoxSizing.ContentBox)
1262
+ root.insertChild(root_child0, 0)
1263
+
1264
+ const root_child1 = Yoga.Node.create(config)
1265
+ root_child1.setWidth(25)
1266
+ root_child1.setHeight(25)
1267
+ root.insertChild(root_child1, 1)
1268
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1269
+
1270
+ expect(root.getComputedLeft()).toBe(0)
1271
+ expect(root.getComputedTop()).toBe(0)
1272
+ expect(root.getComputedWidth()).toBe(100)
1273
+ expect(root.getComputedHeight()).toBe(100)
1274
+
1275
+ expect(root_child0.getComputedLeft()).toBe(0)
1276
+ expect(root_child0.getComputedTop()).toBe(0)
1277
+ expect(root_child0.getComputedWidth()).toBe(90)
1278
+ expect(root_child0.getComputedHeight()).toBe(65)
1279
+
1280
+ expect(root_child1.getComputedLeft()).toBe(0)
1281
+ expect(root_child1.getComputedTop()).toBe(65)
1282
+ expect(root_child1.getComputedWidth()).toBe(25)
1283
+ expect(root_child1.getComputedHeight()).toBe(25)
1284
+
1285
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1286
+
1287
+ expect(root.getComputedLeft()).toBe(0)
1288
+ expect(root.getComputedTop()).toBe(0)
1289
+ expect(root.getComputedWidth()).toBe(100)
1290
+ expect(root.getComputedHeight()).toBe(100)
1291
+
1292
+ expect(root_child0.getComputedLeft()).toBe(10)
1293
+ expect(root_child0.getComputedTop()).toBe(0)
1294
+ expect(root_child0.getComputedWidth()).toBe(90)
1295
+ expect(root_child0.getComputedHeight()).toBe(65)
1296
+
1297
+ expect(root_child1.getComputedLeft()).toBe(75)
1298
+ expect(root_child1.getComputedTop()).toBe(65)
1299
+ expect(root_child1.getComputedWidth()).toBe(25)
1300
+ expect(root_child1.getComputedHeight()).toBe(25)
1301
+ } finally {
1302
+ if (typeof root !== "undefined") {
1303
+ root.freeRecursive()
1304
+ }
1305
+
1306
+ config.free()
1307
+ }
1308
+ })
1309
+ test("box_sizing_border_box_max_width", () => {
1310
+ const config = Yoga.Config.create()
1311
+ let root
1312
+
1313
+ try {
1314
+ root = Yoga.Node.create(config)
1315
+ root.setPositionType(PositionType.Absolute)
1316
+ root.setWidth(100)
1317
+ root.setHeight(100)
1318
+
1319
+ const root_child0 = Yoga.Node.create(config)
1320
+ root_child0.setPadding(Edge.Left, 5)
1321
+ root_child0.setPadding(Edge.Top, 5)
1322
+ root_child0.setPadding(Edge.Right, 5)
1323
+ root_child0.setPadding(Edge.Bottom, 5)
1324
+ root_child0.setBorder(Edge.Left, 15)
1325
+ root_child0.setBorder(Edge.Top, 15)
1326
+ root_child0.setBorder(Edge.Right, 15)
1327
+ root_child0.setBorder(Edge.Bottom, 15)
1328
+ root_child0.setMaxWidth(50)
1329
+ root_child0.setHeight(25)
1330
+ root.insertChild(root_child0, 0)
1331
+
1332
+ const root_child1 = Yoga.Node.create(config)
1333
+ root_child1.setWidth(25)
1334
+ root_child1.setHeight(25)
1335
+ root.insertChild(root_child1, 1)
1336
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1337
+
1338
+ expect(root.getComputedLeft()).toBe(0)
1339
+ expect(root.getComputedTop()).toBe(0)
1340
+ expect(root.getComputedWidth()).toBe(100)
1341
+ expect(root.getComputedHeight()).toBe(100)
1342
+
1343
+ expect(root_child0.getComputedLeft()).toBe(0)
1344
+ expect(root_child0.getComputedTop()).toBe(0)
1345
+ expect(root_child0.getComputedWidth()).toBe(50)
1346
+ expect(root_child0.getComputedHeight()).toBe(40)
1347
+
1348
+ expect(root_child1.getComputedLeft()).toBe(0)
1349
+ expect(root_child1.getComputedTop()).toBe(40)
1350
+ expect(root_child1.getComputedWidth()).toBe(25)
1351
+ expect(root_child1.getComputedHeight()).toBe(25)
1352
+
1353
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1354
+
1355
+ expect(root.getComputedLeft()).toBe(0)
1356
+ expect(root.getComputedTop()).toBe(0)
1357
+ expect(root.getComputedWidth()).toBe(100)
1358
+ expect(root.getComputedHeight()).toBe(100)
1359
+
1360
+ expect(root_child0.getComputedLeft()).toBe(50)
1361
+ expect(root_child0.getComputedTop()).toBe(0)
1362
+ expect(root_child0.getComputedWidth()).toBe(50)
1363
+ expect(root_child0.getComputedHeight()).toBe(40)
1364
+
1365
+ expect(root_child1.getComputedLeft()).toBe(75)
1366
+ expect(root_child1.getComputedTop()).toBe(40)
1367
+ expect(root_child1.getComputedWidth()).toBe(25)
1368
+ expect(root_child1.getComputedHeight()).toBe(25)
1369
+ } finally {
1370
+ if (typeof root !== "undefined") {
1371
+ root.freeRecursive()
1372
+ }
1373
+
1374
+ config.free()
1375
+ }
1376
+ })
1377
+ test("box_sizing_content_box_max_height", () => {
1378
+ const config = Yoga.Config.create()
1379
+ let root
1380
+
1381
+ try {
1382
+ root = Yoga.Node.create(config)
1383
+ root.setPositionType(PositionType.Absolute)
1384
+ root.setWidth(100)
1385
+ root.setHeight(100)
1386
+
1387
+ const root_child0 = Yoga.Node.create(config)
1388
+ root_child0.setPadding(Edge.Left, 5)
1389
+ root_child0.setPadding(Edge.Top, 5)
1390
+ root_child0.setPadding(Edge.Right, 5)
1391
+ root_child0.setPadding(Edge.Bottom, 5)
1392
+ root_child0.setBorder(Edge.Left, 15)
1393
+ root_child0.setBorder(Edge.Top, 15)
1394
+ root_child0.setBorder(Edge.Right, 15)
1395
+ root_child0.setBorder(Edge.Bottom, 15)
1396
+ root_child0.setWidth(50)
1397
+ root_child0.setMaxHeight(50)
1398
+ root_child0.setBoxSizing(BoxSizing.ContentBox)
1399
+ root.insertChild(root_child0, 0)
1400
+
1401
+ const root_child1 = Yoga.Node.create(config)
1402
+ root_child1.setWidth(25)
1403
+ root_child1.setHeight(25)
1404
+ root.insertChild(root_child1, 1)
1405
+ root.calculateLayout(undefined, undefined, Direction.LTR)
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(90)
1415
+ expect(root_child0.getComputedHeight()).toBe(40)
1416
+
1417
+ expect(root_child1.getComputedLeft()).toBe(0)
1418
+ expect(root_child1.getComputedTop()).toBe(40)
1419
+ expect(root_child1.getComputedWidth()).toBe(25)
1420
+ expect(root_child1.getComputedHeight()).toBe(25)
1421
+
1422
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1423
+
1424
+ expect(root.getComputedLeft()).toBe(0)
1425
+ expect(root.getComputedTop()).toBe(0)
1426
+ expect(root.getComputedWidth()).toBe(100)
1427
+ expect(root.getComputedHeight()).toBe(100)
1428
+
1429
+ expect(root_child0.getComputedLeft()).toBe(10)
1430
+ expect(root_child0.getComputedTop()).toBe(0)
1431
+ expect(root_child0.getComputedWidth()).toBe(90)
1432
+ expect(root_child0.getComputedHeight()).toBe(40)
1433
+
1434
+ expect(root_child1.getComputedLeft()).toBe(75)
1435
+ expect(root_child1.getComputedTop()).toBe(40)
1436
+ expect(root_child1.getComputedWidth()).toBe(25)
1437
+ expect(root_child1.getComputedHeight()).toBe(25)
1438
+ } finally {
1439
+ if (typeof root !== "undefined") {
1440
+ root.freeRecursive()
1441
+ }
1442
+
1443
+ config.free()
1444
+ }
1445
+ })
1446
+ test("box_sizing_border_box_max_height", () => {
1447
+ const config = Yoga.Config.create()
1448
+ let root
1449
+
1450
+ try {
1451
+ root = Yoga.Node.create(config)
1452
+ root.setPositionType(PositionType.Absolute)
1453
+ root.setWidth(100)
1454
+ root.setHeight(100)
1455
+
1456
+ const root_child0 = Yoga.Node.create(config)
1457
+ root_child0.setPadding(Edge.Left, 5)
1458
+ root_child0.setPadding(Edge.Top, 5)
1459
+ root_child0.setPadding(Edge.Right, 5)
1460
+ root_child0.setPadding(Edge.Bottom, 5)
1461
+ root_child0.setBorder(Edge.Left, 15)
1462
+ root_child0.setBorder(Edge.Top, 15)
1463
+ root_child0.setBorder(Edge.Right, 15)
1464
+ root_child0.setBorder(Edge.Bottom, 15)
1465
+ root_child0.setWidth(50)
1466
+ root_child0.setMaxHeight(50)
1467
+ root.insertChild(root_child0, 0)
1468
+
1469
+ const root_child1 = Yoga.Node.create(config)
1470
+ root_child1.setWidth(25)
1471
+ root_child1.setHeight(25)
1472
+ root.insertChild(root_child1, 1)
1473
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1474
+
1475
+ expect(root.getComputedLeft()).toBe(0)
1476
+ expect(root.getComputedTop()).toBe(0)
1477
+ expect(root.getComputedWidth()).toBe(100)
1478
+ expect(root.getComputedHeight()).toBe(100)
1479
+
1480
+ expect(root_child0.getComputedLeft()).toBe(0)
1481
+ expect(root_child0.getComputedTop()).toBe(0)
1482
+ expect(root_child0.getComputedWidth()).toBe(50)
1483
+ expect(root_child0.getComputedHeight()).toBe(40)
1484
+
1485
+ expect(root_child1.getComputedLeft()).toBe(0)
1486
+ expect(root_child1.getComputedTop()).toBe(40)
1487
+ expect(root_child1.getComputedWidth()).toBe(25)
1488
+ expect(root_child1.getComputedHeight()).toBe(25)
1489
+
1490
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1491
+
1492
+ expect(root.getComputedLeft()).toBe(0)
1493
+ expect(root.getComputedTop()).toBe(0)
1494
+ expect(root.getComputedWidth()).toBe(100)
1495
+ expect(root.getComputedHeight()).toBe(100)
1496
+
1497
+ expect(root_child0.getComputedLeft()).toBe(50)
1498
+ expect(root_child0.getComputedTop()).toBe(0)
1499
+ expect(root_child0.getComputedWidth()).toBe(50)
1500
+ expect(root_child0.getComputedHeight()).toBe(40)
1501
+
1502
+ expect(root_child1.getComputedLeft()).toBe(75)
1503
+ expect(root_child1.getComputedTop()).toBe(40)
1504
+ expect(root_child1.getComputedWidth()).toBe(25)
1505
+ expect(root_child1.getComputedHeight()).toBe(25)
1506
+ } finally {
1507
+ if (typeof root !== "undefined") {
1508
+ root.freeRecursive()
1509
+ }
1510
+
1511
+ config.free()
1512
+ }
1513
+ })
1514
+ test("box_sizing_content_box_min_width", () => {
1515
+ const config = Yoga.Config.create()
1516
+ let root
1517
+
1518
+ try {
1519
+ root = Yoga.Node.create(config)
1520
+ root.setPositionType(PositionType.Absolute)
1521
+ root.setWidth(100)
1522
+ root.setHeight(100)
1523
+
1524
+ const root_child0 = Yoga.Node.create(config)
1525
+ root_child0.setPadding(Edge.Left, 5)
1526
+ root_child0.setPadding(Edge.Top, 5)
1527
+ root_child0.setPadding(Edge.Right, 5)
1528
+ root_child0.setPadding(Edge.Bottom, 5)
1529
+ root_child0.setBorder(Edge.Left, 15)
1530
+ root_child0.setBorder(Edge.Top, 15)
1531
+ root_child0.setBorder(Edge.Right, 15)
1532
+ root_child0.setBorder(Edge.Bottom, 15)
1533
+ root_child0.setMinWidth(50)
1534
+ root_child0.setHeight(25)
1535
+ root_child0.setBoxSizing(BoxSizing.ContentBox)
1536
+ root.insertChild(root_child0, 0)
1537
+
1538
+ const root_child1 = Yoga.Node.create(config)
1539
+ root_child1.setWidth(25)
1540
+ root_child1.setHeight(25)
1541
+ root.insertChild(root_child1, 1)
1542
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1543
+
1544
+ expect(root.getComputedLeft()).toBe(0)
1545
+ expect(root.getComputedTop()).toBe(0)
1546
+ expect(root.getComputedWidth()).toBe(100)
1547
+ expect(root.getComputedHeight()).toBe(100)
1548
+
1549
+ expect(root_child0.getComputedLeft()).toBe(0)
1550
+ expect(root_child0.getComputedTop()).toBe(0)
1551
+ expect(root_child0.getComputedWidth()).toBe(100)
1552
+ expect(root_child0.getComputedHeight()).toBe(65)
1553
+
1554
+ expect(root_child1.getComputedLeft()).toBe(0)
1555
+ expect(root_child1.getComputedTop()).toBe(65)
1556
+ expect(root_child1.getComputedWidth()).toBe(25)
1557
+ expect(root_child1.getComputedHeight()).toBe(25)
1558
+
1559
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1560
+
1561
+ expect(root.getComputedLeft()).toBe(0)
1562
+ expect(root.getComputedTop()).toBe(0)
1563
+ expect(root.getComputedWidth()).toBe(100)
1564
+ expect(root.getComputedHeight()).toBe(100)
1565
+
1566
+ expect(root_child0.getComputedLeft()).toBe(0)
1567
+ expect(root_child0.getComputedTop()).toBe(0)
1568
+ expect(root_child0.getComputedWidth()).toBe(100)
1569
+ expect(root_child0.getComputedHeight()).toBe(65)
1570
+
1571
+ expect(root_child1.getComputedLeft()).toBe(75)
1572
+ expect(root_child1.getComputedTop()).toBe(65)
1573
+ expect(root_child1.getComputedWidth()).toBe(25)
1574
+ expect(root_child1.getComputedHeight()).toBe(25)
1575
+ } finally {
1576
+ if (typeof root !== "undefined") {
1577
+ root.freeRecursive()
1578
+ }
1579
+
1580
+ config.free()
1581
+ }
1582
+ })
1583
+ test("box_sizing_border_box_min_width", () => {
1584
+ const config = Yoga.Config.create()
1585
+ let root
1586
+
1587
+ try {
1588
+ root = Yoga.Node.create(config)
1589
+ root.setPositionType(PositionType.Absolute)
1590
+ root.setWidth(100)
1591
+ root.setHeight(100)
1592
+
1593
+ const root_child0 = Yoga.Node.create(config)
1594
+ root_child0.setPadding(Edge.Left, 5)
1595
+ root_child0.setPadding(Edge.Top, 5)
1596
+ root_child0.setPadding(Edge.Right, 5)
1597
+ root_child0.setPadding(Edge.Bottom, 5)
1598
+ root_child0.setBorder(Edge.Left, 15)
1599
+ root_child0.setBorder(Edge.Top, 15)
1600
+ root_child0.setBorder(Edge.Right, 15)
1601
+ root_child0.setBorder(Edge.Bottom, 15)
1602
+ root_child0.setMinWidth(50)
1603
+ root_child0.setHeight(25)
1604
+ root.insertChild(root_child0, 0)
1605
+
1606
+ const root_child1 = Yoga.Node.create(config)
1607
+ root_child1.setWidth(25)
1608
+ root_child1.setHeight(25)
1609
+ root.insertChild(root_child1, 1)
1610
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1611
+
1612
+ expect(root.getComputedLeft()).toBe(0)
1613
+ expect(root.getComputedTop()).toBe(0)
1614
+ expect(root.getComputedWidth()).toBe(100)
1615
+ expect(root.getComputedHeight()).toBe(100)
1616
+
1617
+ expect(root_child0.getComputedLeft()).toBe(0)
1618
+ expect(root_child0.getComputedTop()).toBe(0)
1619
+ expect(root_child0.getComputedWidth()).toBe(100)
1620
+ expect(root_child0.getComputedHeight()).toBe(40)
1621
+
1622
+ expect(root_child1.getComputedLeft()).toBe(0)
1623
+ expect(root_child1.getComputedTop()).toBe(40)
1624
+ expect(root_child1.getComputedWidth()).toBe(25)
1625
+ expect(root_child1.getComputedHeight()).toBe(25)
1626
+
1627
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1628
+
1629
+ expect(root.getComputedLeft()).toBe(0)
1630
+ expect(root.getComputedTop()).toBe(0)
1631
+ expect(root.getComputedWidth()).toBe(100)
1632
+ expect(root.getComputedHeight()).toBe(100)
1633
+
1634
+ expect(root_child0.getComputedLeft()).toBe(0)
1635
+ expect(root_child0.getComputedTop()).toBe(0)
1636
+ expect(root_child0.getComputedWidth()).toBe(100)
1637
+ expect(root_child0.getComputedHeight()).toBe(40)
1638
+
1639
+ expect(root_child1.getComputedLeft()).toBe(75)
1640
+ expect(root_child1.getComputedTop()).toBe(40)
1641
+ expect(root_child1.getComputedWidth()).toBe(25)
1642
+ expect(root_child1.getComputedHeight()).toBe(25)
1643
+ } finally {
1644
+ if (typeof root !== "undefined") {
1645
+ root.freeRecursive()
1646
+ }
1647
+
1648
+ config.free()
1649
+ }
1650
+ })
1651
+ test("box_sizing_content_box_min_height", () => {
1652
+ const config = Yoga.Config.create()
1653
+ let root
1654
+
1655
+ try {
1656
+ root = Yoga.Node.create(config)
1657
+ root.setPositionType(PositionType.Absolute)
1658
+ root.setWidth(100)
1659
+ root.setHeight(100)
1660
+
1661
+ const root_child0 = Yoga.Node.create(config)
1662
+ root_child0.setPadding(Edge.Left, 5)
1663
+ root_child0.setPadding(Edge.Top, 5)
1664
+ root_child0.setPadding(Edge.Right, 5)
1665
+ root_child0.setPadding(Edge.Bottom, 5)
1666
+ root_child0.setBorder(Edge.Left, 15)
1667
+ root_child0.setBorder(Edge.Top, 15)
1668
+ root_child0.setBorder(Edge.Right, 15)
1669
+ root_child0.setBorder(Edge.Bottom, 15)
1670
+ root_child0.setWidth(50)
1671
+ root_child0.setMinHeight(50)
1672
+ root_child0.setBoxSizing(BoxSizing.ContentBox)
1673
+ root.insertChild(root_child0, 0)
1674
+
1675
+ const root_child1 = Yoga.Node.create(config)
1676
+ root_child1.setWidth(25)
1677
+ root_child1.setHeight(25)
1678
+ root.insertChild(root_child1, 1)
1679
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1680
+
1681
+ expect(root.getComputedLeft()).toBe(0)
1682
+ expect(root.getComputedTop()).toBe(0)
1683
+ expect(root.getComputedWidth()).toBe(100)
1684
+ expect(root.getComputedHeight()).toBe(100)
1685
+
1686
+ expect(root_child0.getComputedLeft()).toBe(0)
1687
+ expect(root_child0.getComputedTop()).toBe(0)
1688
+ expect(root_child0.getComputedWidth()).toBe(90)
1689
+ expect(root_child0.getComputedHeight()).toBe(90)
1690
+
1691
+ expect(root_child1.getComputedLeft()).toBe(0)
1692
+ expect(root_child1.getComputedTop()).toBe(90)
1693
+ expect(root_child1.getComputedWidth()).toBe(25)
1694
+ expect(root_child1.getComputedHeight()).toBe(25)
1695
+
1696
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1697
+
1698
+ expect(root.getComputedLeft()).toBe(0)
1699
+ expect(root.getComputedTop()).toBe(0)
1700
+ expect(root.getComputedWidth()).toBe(100)
1701
+ expect(root.getComputedHeight()).toBe(100)
1702
+
1703
+ expect(root_child0.getComputedLeft()).toBe(10)
1704
+ expect(root_child0.getComputedTop()).toBe(0)
1705
+ expect(root_child0.getComputedWidth()).toBe(90)
1706
+ expect(root_child0.getComputedHeight()).toBe(90)
1707
+
1708
+ expect(root_child1.getComputedLeft()).toBe(75)
1709
+ expect(root_child1.getComputedTop()).toBe(90)
1710
+ expect(root_child1.getComputedWidth()).toBe(25)
1711
+ expect(root_child1.getComputedHeight()).toBe(25)
1712
+ } finally {
1713
+ if (typeof root !== "undefined") {
1714
+ root.freeRecursive()
1715
+ }
1716
+
1717
+ config.free()
1718
+ }
1719
+ })
1720
+ test("box_sizing_border_box_min_height", () => {
1721
+ const config = Yoga.Config.create()
1722
+ let root
1723
+
1724
+ try {
1725
+ root = Yoga.Node.create(config)
1726
+ root.setPositionType(PositionType.Absolute)
1727
+ root.setWidth(100)
1728
+ root.setHeight(100)
1729
+
1730
+ const root_child0 = Yoga.Node.create(config)
1731
+ root_child0.setPadding(Edge.Left, 5)
1732
+ root_child0.setPadding(Edge.Top, 5)
1733
+ root_child0.setPadding(Edge.Right, 5)
1734
+ root_child0.setPadding(Edge.Bottom, 5)
1735
+ root_child0.setBorder(Edge.Left, 15)
1736
+ root_child0.setBorder(Edge.Top, 15)
1737
+ root_child0.setBorder(Edge.Right, 15)
1738
+ root_child0.setBorder(Edge.Bottom, 15)
1739
+ root_child0.setWidth(50)
1740
+ root_child0.setMinHeight(50)
1741
+ root.insertChild(root_child0, 0)
1742
+
1743
+ const root_child1 = Yoga.Node.create(config)
1744
+ root_child1.setWidth(25)
1745
+ root_child1.setHeight(25)
1746
+ root.insertChild(root_child1, 1)
1747
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1748
+
1749
+ expect(root.getComputedLeft()).toBe(0)
1750
+ expect(root.getComputedTop()).toBe(0)
1751
+ expect(root.getComputedWidth()).toBe(100)
1752
+ expect(root.getComputedHeight()).toBe(100)
1753
+
1754
+ expect(root_child0.getComputedLeft()).toBe(0)
1755
+ expect(root_child0.getComputedTop()).toBe(0)
1756
+ expect(root_child0.getComputedWidth()).toBe(50)
1757
+ expect(root_child0.getComputedHeight()).toBe(50)
1758
+
1759
+ expect(root_child1.getComputedLeft()).toBe(0)
1760
+ expect(root_child1.getComputedTop()).toBe(50)
1761
+ expect(root_child1.getComputedWidth()).toBe(25)
1762
+ expect(root_child1.getComputedHeight()).toBe(25)
1763
+
1764
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1765
+
1766
+ expect(root.getComputedLeft()).toBe(0)
1767
+ expect(root.getComputedTop()).toBe(0)
1768
+ expect(root.getComputedWidth()).toBe(100)
1769
+ expect(root.getComputedHeight()).toBe(100)
1770
+
1771
+ expect(root_child0.getComputedLeft()).toBe(50)
1772
+ expect(root_child0.getComputedTop()).toBe(0)
1773
+ expect(root_child0.getComputedWidth()).toBe(50)
1774
+ expect(root_child0.getComputedHeight()).toBe(50)
1775
+
1776
+ expect(root_child1.getComputedLeft()).toBe(75)
1777
+ expect(root_child1.getComputedTop()).toBe(50)
1778
+ expect(root_child1.getComputedWidth()).toBe(25)
1779
+ expect(root_child1.getComputedHeight()).toBe(25)
1780
+ } finally {
1781
+ if (typeof root !== "undefined") {
1782
+ root.freeRecursive()
1783
+ }
1784
+
1785
+ config.free()
1786
+ }
1787
+ })
1788
+ test("box_sizing_content_box_no_height_no_width", () => {
1789
+ const config = Yoga.Config.create()
1790
+ let root
1791
+
1792
+ try {
1793
+ root = Yoga.Node.create(config)
1794
+ root.setPositionType(PositionType.Absolute)
1795
+ root.setWidth(100)
1796
+ root.setHeight(100)
1797
+
1798
+ const root_child0 = Yoga.Node.create(config)
1799
+ root_child0.setPadding(Edge.Left, 2)
1800
+ root_child0.setPadding(Edge.Top, 2)
1801
+ root_child0.setPadding(Edge.Right, 2)
1802
+ root_child0.setPadding(Edge.Bottom, 2)
1803
+ root_child0.setBorder(Edge.Left, 7)
1804
+ root_child0.setBorder(Edge.Top, 7)
1805
+ root_child0.setBorder(Edge.Right, 7)
1806
+ root_child0.setBorder(Edge.Bottom, 7)
1807
+ root_child0.setBoxSizing(BoxSizing.ContentBox)
1808
+ root.insertChild(root_child0, 0)
1809
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1810
+
1811
+ expect(root.getComputedLeft()).toBe(0)
1812
+ expect(root.getComputedTop()).toBe(0)
1813
+ expect(root.getComputedWidth()).toBe(100)
1814
+ expect(root.getComputedHeight()).toBe(100)
1815
+
1816
+ expect(root_child0.getComputedLeft()).toBe(0)
1817
+ expect(root_child0.getComputedTop()).toBe(0)
1818
+ expect(root_child0.getComputedWidth()).toBe(100)
1819
+ expect(root_child0.getComputedHeight()).toBe(18)
1820
+
1821
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1822
+
1823
+ expect(root.getComputedLeft()).toBe(0)
1824
+ expect(root.getComputedTop()).toBe(0)
1825
+ expect(root.getComputedWidth()).toBe(100)
1826
+ expect(root.getComputedHeight()).toBe(100)
1827
+
1828
+ expect(root_child0.getComputedLeft()).toBe(0)
1829
+ expect(root_child0.getComputedTop()).toBe(0)
1830
+ expect(root_child0.getComputedWidth()).toBe(100)
1831
+ expect(root_child0.getComputedHeight()).toBe(18)
1832
+ } finally {
1833
+ if (typeof root !== "undefined") {
1834
+ root.freeRecursive()
1835
+ }
1836
+
1837
+ config.free()
1838
+ }
1839
+ })
1840
+ test("box_sizing_border_box_no_height_no_width", () => {
1841
+ const config = Yoga.Config.create()
1842
+ let root
1843
+
1844
+ try {
1845
+ root = Yoga.Node.create(config)
1846
+ root.setPositionType(PositionType.Absolute)
1847
+ root.setWidth(100)
1848
+ root.setHeight(100)
1849
+
1850
+ const root_child0 = Yoga.Node.create(config)
1851
+ root_child0.setPadding(Edge.Left, 2)
1852
+ root_child0.setPadding(Edge.Top, 2)
1853
+ root_child0.setPadding(Edge.Right, 2)
1854
+ root_child0.setPadding(Edge.Bottom, 2)
1855
+ root_child0.setBorder(Edge.Left, 7)
1856
+ root_child0.setBorder(Edge.Top, 7)
1857
+ root_child0.setBorder(Edge.Right, 7)
1858
+ root_child0.setBorder(Edge.Bottom, 7)
1859
+ root.insertChild(root_child0, 0)
1860
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1861
+
1862
+ expect(root.getComputedLeft()).toBe(0)
1863
+ expect(root.getComputedTop()).toBe(0)
1864
+ expect(root.getComputedWidth()).toBe(100)
1865
+ expect(root.getComputedHeight()).toBe(100)
1866
+
1867
+ expect(root_child0.getComputedLeft()).toBe(0)
1868
+ expect(root_child0.getComputedTop()).toBe(0)
1869
+ expect(root_child0.getComputedWidth()).toBe(100)
1870
+ expect(root_child0.getComputedHeight()).toBe(18)
1871
+
1872
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1873
+
1874
+ expect(root.getComputedLeft()).toBe(0)
1875
+ expect(root.getComputedTop()).toBe(0)
1876
+ expect(root.getComputedWidth()).toBe(100)
1877
+ expect(root.getComputedHeight()).toBe(100)
1878
+
1879
+ expect(root_child0.getComputedLeft()).toBe(0)
1880
+ expect(root_child0.getComputedTop()).toBe(0)
1881
+ expect(root_child0.getComputedWidth()).toBe(100)
1882
+ expect(root_child0.getComputedHeight()).toBe(18)
1883
+ } finally {
1884
+ if (typeof root !== "undefined") {
1885
+ root.freeRecursive()
1886
+ }
1887
+
1888
+ config.free()
1889
+ }
1890
+ })
1891
+ test("box_sizing_content_box_nested", () => {
1892
+ const config = Yoga.Config.create()
1893
+ let root
1894
+
1895
+ try {
1896
+ root = Yoga.Node.create(config)
1897
+ root.setPositionType(PositionType.Absolute)
1898
+ root.setPadding(Edge.Left, 15)
1899
+ root.setPadding(Edge.Top, 15)
1900
+ root.setPadding(Edge.Right, 15)
1901
+ root.setPadding(Edge.Bottom, 15)
1902
+ root.setBorder(Edge.Left, 3)
1903
+ root.setBorder(Edge.Top, 3)
1904
+ root.setBorder(Edge.Right, 3)
1905
+ root.setBorder(Edge.Bottom, 3)
1906
+ root.setWidth(100)
1907
+ root.setHeight(100)
1908
+ root.setBoxSizing(BoxSizing.ContentBox)
1909
+
1910
+ const root_child0 = Yoga.Node.create(config)
1911
+ root_child0.setPadding(Edge.Left, 2)
1912
+ root_child0.setPadding(Edge.Top, 2)
1913
+ root_child0.setPadding(Edge.Right, 2)
1914
+ root_child0.setPadding(Edge.Bottom, 2)
1915
+ root_child0.setBorder(Edge.Left, 7)
1916
+ root_child0.setBorder(Edge.Top, 7)
1917
+ root_child0.setBorder(Edge.Right, 7)
1918
+ root_child0.setBorder(Edge.Bottom, 7)
1919
+ root_child0.setWidth(20)
1920
+ root_child0.setHeight(20)
1921
+ root_child0.setBoxSizing(BoxSizing.ContentBox)
1922
+ root.insertChild(root_child0, 0)
1923
+
1924
+ const root_child0_child0 = Yoga.Node.create(config)
1925
+ root_child0_child0.setPadding(Edge.Left, 1)
1926
+ root_child0_child0.setPadding(Edge.Top, 1)
1927
+ root_child0_child0.setPadding(Edge.Right, 1)
1928
+ root_child0_child0.setPadding(Edge.Bottom, 1)
1929
+ root_child0_child0.setBorder(Edge.Left, 2)
1930
+ root_child0_child0.setBorder(Edge.Top, 2)
1931
+ root_child0_child0.setBorder(Edge.Right, 2)
1932
+ root_child0_child0.setBorder(Edge.Bottom, 2)
1933
+ root_child0_child0.setWidth(10)
1934
+ root_child0_child0.setHeight(5)
1935
+ root_child0_child0.setBoxSizing(BoxSizing.ContentBox)
1936
+ root_child0.insertChild(root_child0_child0, 0)
1937
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1938
+
1939
+ expect(root.getComputedLeft()).toBe(0)
1940
+ expect(root.getComputedTop()).toBe(0)
1941
+ expect(root.getComputedWidth()).toBe(136)
1942
+ expect(root.getComputedHeight()).toBe(136)
1943
+
1944
+ expect(root_child0.getComputedLeft()).toBe(18)
1945
+ expect(root_child0.getComputedTop()).toBe(18)
1946
+ expect(root_child0.getComputedWidth()).toBe(38)
1947
+ expect(root_child0.getComputedHeight()).toBe(38)
1948
+
1949
+ expect(root_child0_child0.getComputedLeft()).toBe(9)
1950
+ expect(root_child0_child0.getComputedTop()).toBe(9)
1951
+ expect(root_child0_child0.getComputedWidth()).toBe(16)
1952
+ expect(root_child0_child0.getComputedHeight()).toBe(11)
1953
+
1954
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1955
+
1956
+ expect(root.getComputedLeft()).toBe(0)
1957
+ expect(root.getComputedTop()).toBe(0)
1958
+ expect(root.getComputedWidth()).toBe(136)
1959
+ expect(root.getComputedHeight()).toBe(136)
1960
+
1961
+ expect(root_child0.getComputedLeft()).toBe(80)
1962
+ expect(root_child0.getComputedTop()).toBe(18)
1963
+ expect(root_child0.getComputedWidth()).toBe(38)
1964
+ expect(root_child0.getComputedHeight()).toBe(38)
1965
+
1966
+ expect(root_child0_child0.getComputedLeft()).toBe(13)
1967
+ expect(root_child0_child0.getComputedTop()).toBe(9)
1968
+ expect(root_child0_child0.getComputedWidth()).toBe(16)
1969
+ expect(root_child0_child0.getComputedHeight()).toBe(11)
1970
+ } finally {
1971
+ if (typeof root !== "undefined") {
1972
+ root.freeRecursive()
1973
+ }
1974
+
1975
+ config.free()
1976
+ }
1977
+ })
1978
+ test("box_sizing_border_box_nested", () => {
1979
+ const config = Yoga.Config.create()
1980
+ let root
1981
+
1982
+ try {
1983
+ root = Yoga.Node.create(config)
1984
+ root.setPositionType(PositionType.Absolute)
1985
+ root.setPadding(Edge.Left, 15)
1986
+ root.setPadding(Edge.Top, 15)
1987
+ root.setPadding(Edge.Right, 15)
1988
+ root.setPadding(Edge.Bottom, 15)
1989
+ root.setBorder(Edge.Left, 3)
1990
+ root.setBorder(Edge.Top, 3)
1991
+ root.setBorder(Edge.Right, 3)
1992
+ root.setBorder(Edge.Bottom, 3)
1993
+ root.setWidth(100)
1994
+ root.setHeight(100)
1995
+
1996
+ const root_child0 = Yoga.Node.create(config)
1997
+ root_child0.setPadding(Edge.Left, 2)
1998
+ root_child0.setPadding(Edge.Top, 2)
1999
+ root_child0.setPadding(Edge.Right, 2)
2000
+ root_child0.setPadding(Edge.Bottom, 2)
2001
+ root_child0.setBorder(Edge.Left, 7)
2002
+ root_child0.setBorder(Edge.Top, 7)
2003
+ root_child0.setBorder(Edge.Right, 7)
2004
+ root_child0.setBorder(Edge.Bottom, 7)
2005
+ root_child0.setWidth(20)
2006
+ root_child0.setHeight(20)
2007
+ root.insertChild(root_child0, 0)
2008
+
2009
+ const root_child0_child0 = Yoga.Node.create(config)
2010
+ root_child0_child0.setPadding(Edge.Left, 1)
2011
+ root_child0_child0.setPadding(Edge.Top, 1)
2012
+ root_child0_child0.setPadding(Edge.Right, 1)
2013
+ root_child0_child0.setPadding(Edge.Bottom, 1)
2014
+ root_child0_child0.setBorder(Edge.Left, 2)
2015
+ root_child0_child0.setBorder(Edge.Top, 2)
2016
+ root_child0_child0.setBorder(Edge.Right, 2)
2017
+ root_child0_child0.setBorder(Edge.Bottom, 2)
2018
+ root_child0_child0.setWidth(10)
2019
+ root_child0_child0.setHeight(5)
2020
+ root_child0.insertChild(root_child0_child0, 0)
2021
+ root.calculateLayout(undefined, undefined, Direction.LTR)
2022
+
2023
+ expect(root.getComputedLeft()).toBe(0)
2024
+ expect(root.getComputedTop()).toBe(0)
2025
+ expect(root.getComputedWidth()).toBe(100)
2026
+ expect(root.getComputedHeight()).toBe(100)
2027
+
2028
+ expect(root_child0.getComputedLeft()).toBe(18)
2029
+ expect(root_child0.getComputedTop()).toBe(18)
2030
+ expect(root_child0.getComputedWidth()).toBe(20)
2031
+ expect(root_child0.getComputedHeight()).toBe(20)
2032
+
2033
+ expect(root_child0_child0.getComputedLeft()).toBe(9)
2034
+ expect(root_child0_child0.getComputedTop()).toBe(9)
2035
+ expect(root_child0_child0.getComputedWidth()).toBe(10)
2036
+ expect(root_child0_child0.getComputedHeight()).toBe(6)
2037
+
2038
+ root.calculateLayout(undefined, undefined, Direction.RTL)
2039
+
2040
+ expect(root.getComputedLeft()).toBe(0)
2041
+ expect(root.getComputedTop()).toBe(0)
2042
+ expect(root.getComputedWidth()).toBe(100)
2043
+ expect(root.getComputedHeight()).toBe(100)
2044
+
2045
+ expect(root_child0.getComputedLeft()).toBe(62)
2046
+ expect(root_child0.getComputedTop()).toBe(18)
2047
+ expect(root_child0.getComputedWidth()).toBe(20)
2048
+ expect(root_child0.getComputedHeight()).toBe(20)
2049
+
2050
+ expect(root_child0_child0.getComputedLeft()).toBe(1)
2051
+ expect(root_child0_child0.getComputedTop()).toBe(9)
2052
+ expect(root_child0_child0.getComputedWidth()).toBe(10)
2053
+ expect(root_child0_child0.getComputedHeight()).toBe(6)
2054
+ } finally {
2055
+ if (typeof root !== "undefined") {
2056
+ root.freeRecursive()
2057
+ }
2058
+
2059
+ config.free()
2060
+ }
2061
+ })
2062
+ test("box_sizing_content_box_nested_alternating", () => {
2063
+ const config = Yoga.Config.create()
2064
+ let root
2065
+
2066
+ try {
2067
+ root = Yoga.Node.create(config)
2068
+ root.setPositionType(PositionType.Absolute)
2069
+ root.setPadding(Edge.Left, 3)
2070
+ root.setPadding(Edge.Top, 3)
2071
+ root.setPadding(Edge.Right, 3)
2072
+ root.setPadding(Edge.Bottom, 3)
2073
+ root.setBorder(Edge.Left, 2)
2074
+ root.setBorder(Edge.Top, 2)
2075
+ root.setBorder(Edge.Right, 2)
2076
+ root.setBorder(Edge.Bottom, 2)
2077
+ root.setWidth(100)
2078
+ root.setHeight(100)
2079
+ root.setBoxSizing(BoxSizing.ContentBox)
2080
+
2081
+ const root_child0 = Yoga.Node.create(config)
2082
+ root_child0.setPadding(Edge.Left, 8)
2083
+ root_child0.setPadding(Edge.Top, 8)
2084
+ root_child0.setPadding(Edge.Right, 8)
2085
+ root_child0.setPadding(Edge.Bottom, 8)
2086
+ root_child0.setBorder(Edge.Left, 2)
2087
+ root_child0.setBorder(Edge.Top, 2)
2088
+ root_child0.setBorder(Edge.Right, 2)
2089
+ root_child0.setBorder(Edge.Bottom, 2)
2090
+ root_child0.setWidth(40)
2091
+ root_child0.setHeight(40)
2092
+ root.insertChild(root_child0, 0)
2093
+
2094
+ const root_child0_child0 = Yoga.Node.create(config)
2095
+ root_child0_child0.setPadding(Edge.Left, 3)
2096
+ root_child0_child0.setPadding(Edge.Top, 3)
2097
+ root_child0_child0.setPadding(Edge.Right, 3)
2098
+ root_child0_child0.setPadding(Edge.Bottom, 3)
2099
+ root_child0_child0.setBorder(Edge.Left, 6)
2100
+ root_child0_child0.setBorder(Edge.Top, 6)
2101
+ root_child0_child0.setBorder(Edge.Right, 6)
2102
+ root_child0_child0.setBorder(Edge.Bottom, 6)
2103
+ root_child0_child0.setWidth(20)
2104
+ root_child0_child0.setHeight(25)
2105
+ root_child0_child0.setBoxSizing(BoxSizing.ContentBox)
2106
+ root_child0.insertChild(root_child0_child0, 0)
2107
+
2108
+ const root_child0_child0_child0 = Yoga.Node.create(config)
2109
+ root_child0_child0_child0.setPadding(Edge.Left, 1)
2110
+ root_child0_child0_child0.setPadding(Edge.Top, 1)
2111
+ root_child0_child0_child0.setPadding(Edge.Right, 1)
2112
+ root_child0_child0_child0.setPadding(Edge.Bottom, 1)
2113
+ root_child0_child0_child0.setBorder(Edge.Left, 1)
2114
+ root_child0_child0_child0.setBorder(Edge.Top, 1)
2115
+ root_child0_child0_child0.setBorder(Edge.Right, 1)
2116
+ root_child0_child0_child0.setBorder(Edge.Bottom, 1)
2117
+ root_child0_child0_child0.setWidth(10)
2118
+ root_child0_child0_child0.setHeight(5)
2119
+ root_child0_child0.insertChild(root_child0_child0_child0, 0)
2120
+ root.calculateLayout(undefined, undefined, Direction.LTR)
2121
+
2122
+ expect(root.getComputedLeft()).toBe(0)
2123
+ expect(root.getComputedTop()).toBe(0)
2124
+ expect(root.getComputedWidth()).toBe(110)
2125
+ expect(root.getComputedHeight()).toBe(110)
2126
+
2127
+ expect(root_child0.getComputedLeft()).toBe(5)
2128
+ expect(root_child0.getComputedTop()).toBe(5)
2129
+ expect(root_child0.getComputedWidth()).toBe(40)
2130
+ expect(root_child0.getComputedHeight()).toBe(40)
2131
+
2132
+ expect(root_child0_child0.getComputedLeft()).toBe(10)
2133
+ expect(root_child0_child0.getComputedTop()).toBe(10)
2134
+ expect(root_child0_child0.getComputedWidth()).toBe(38)
2135
+ expect(root_child0_child0.getComputedHeight()).toBe(43)
2136
+
2137
+ expect(root_child0_child0_child0.getComputedLeft()).toBe(9)
2138
+ expect(root_child0_child0_child0.getComputedTop()).toBe(9)
2139
+ expect(root_child0_child0_child0.getComputedWidth()).toBe(10)
2140
+ expect(root_child0_child0_child0.getComputedHeight()).toBe(5)
2141
+
2142
+ root.calculateLayout(undefined, undefined, Direction.RTL)
2143
+
2144
+ expect(root.getComputedLeft()).toBe(0)
2145
+ expect(root.getComputedTop()).toBe(0)
2146
+ expect(root.getComputedWidth()).toBe(110)
2147
+ expect(root.getComputedHeight()).toBe(110)
2148
+
2149
+ expect(root_child0.getComputedLeft()).toBe(65)
2150
+ expect(root_child0.getComputedTop()).toBe(5)
2151
+ expect(root_child0.getComputedWidth()).toBe(40)
2152
+ expect(root_child0.getComputedHeight()).toBe(40)
2153
+
2154
+ expect(root_child0_child0.getComputedLeft()).toBe(-8)
2155
+ expect(root_child0_child0.getComputedTop()).toBe(10)
2156
+ expect(root_child0_child0.getComputedWidth()).toBe(38)
2157
+ expect(root_child0_child0.getComputedHeight()).toBe(43)
2158
+
2159
+ expect(root_child0_child0_child0.getComputedLeft()).toBe(19)
2160
+ expect(root_child0_child0_child0.getComputedTop()).toBe(9)
2161
+ expect(root_child0_child0_child0.getComputedWidth()).toBe(10)
2162
+ expect(root_child0_child0_child0.getComputedHeight()).toBe(5)
2163
+ } finally {
2164
+ if (typeof root !== "undefined") {
2165
+ root.freeRecursive()
2166
+ }
2167
+
2168
+ config.free()
2169
+ }
2170
+ })
2171
+ test("box_sizing_border_box_nested_alternating", () => {
2172
+ const config = Yoga.Config.create()
2173
+ let root
2174
+
2175
+ try {
2176
+ root = Yoga.Node.create(config)
2177
+ root.setPositionType(PositionType.Absolute)
2178
+ root.setPadding(Edge.Left, 3)
2179
+ root.setPadding(Edge.Top, 3)
2180
+ root.setPadding(Edge.Right, 3)
2181
+ root.setPadding(Edge.Bottom, 3)
2182
+ root.setBorder(Edge.Left, 2)
2183
+ root.setBorder(Edge.Top, 2)
2184
+ root.setBorder(Edge.Right, 2)
2185
+ root.setBorder(Edge.Bottom, 2)
2186
+ root.setWidth(100)
2187
+ root.setHeight(100)
2188
+
2189
+ const root_child0 = Yoga.Node.create(config)
2190
+ root_child0.setPadding(Edge.Left, 8)
2191
+ root_child0.setPadding(Edge.Top, 8)
2192
+ root_child0.setPadding(Edge.Right, 8)
2193
+ root_child0.setPadding(Edge.Bottom, 8)
2194
+ root_child0.setBorder(Edge.Left, 2)
2195
+ root_child0.setBorder(Edge.Top, 2)
2196
+ root_child0.setBorder(Edge.Right, 2)
2197
+ root_child0.setBorder(Edge.Bottom, 2)
2198
+ root_child0.setWidth(40)
2199
+ root_child0.setHeight(40)
2200
+ root_child0.setBoxSizing(BoxSizing.ContentBox)
2201
+ root.insertChild(root_child0, 0)
2202
+
2203
+ const root_child0_child0 = Yoga.Node.create(config)
2204
+ root_child0_child0.setPadding(Edge.Left, 3)
2205
+ root_child0_child0.setPadding(Edge.Top, 3)
2206
+ root_child0_child0.setPadding(Edge.Right, 3)
2207
+ root_child0_child0.setPadding(Edge.Bottom, 3)
2208
+ root_child0_child0.setBorder(Edge.Left, 6)
2209
+ root_child0_child0.setBorder(Edge.Top, 6)
2210
+ root_child0_child0.setBorder(Edge.Right, 6)
2211
+ root_child0_child0.setBorder(Edge.Bottom, 6)
2212
+ root_child0_child0.setWidth(20)
2213
+ root_child0_child0.setHeight(25)
2214
+ root_child0.insertChild(root_child0_child0, 0)
2215
+
2216
+ const root_child0_child0_child0 = Yoga.Node.create(config)
2217
+ root_child0_child0_child0.setPadding(Edge.Left, 1)
2218
+ root_child0_child0_child0.setPadding(Edge.Top, 1)
2219
+ root_child0_child0_child0.setPadding(Edge.Right, 1)
2220
+ root_child0_child0_child0.setPadding(Edge.Bottom, 1)
2221
+ root_child0_child0_child0.setBorder(Edge.Left, 1)
2222
+ root_child0_child0_child0.setBorder(Edge.Top, 1)
2223
+ root_child0_child0_child0.setBorder(Edge.Right, 1)
2224
+ root_child0_child0_child0.setBorder(Edge.Bottom, 1)
2225
+ root_child0_child0_child0.setWidth(10)
2226
+ root_child0_child0_child0.setHeight(5)
2227
+ root_child0_child0_child0.setBoxSizing(BoxSizing.ContentBox)
2228
+ root_child0_child0.insertChild(root_child0_child0_child0, 0)
2229
+ root.calculateLayout(undefined, undefined, Direction.LTR)
2230
+
2231
+ expect(root.getComputedLeft()).toBe(0)
2232
+ expect(root.getComputedTop()).toBe(0)
2233
+ expect(root.getComputedWidth()).toBe(100)
2234
+ expect(root.getComputedHeight()).toBe(100)
2235
+
2236
+ expect(root_child0.getComputedLeft()).toBe(5)
2237
+ expect(root_child0.getComputedTop()).toBe(5)
2238
+ expect(root_child0.getComputedWidth()).toBe(60)
2239
+ expect(root_child0.getComputedHeight()).toBe(60)
2240
+
2241
+ expect(root_child0_child0.getComputedLeft()).toBe(10)
2242
+ expect(root_child0_child0.getComputedTop()).toBe(10)
2243
+ expect(root_child0_child0.getComputedWidth()).toBe(20)
2244
+ expect(root_child0_child0.getComputedHeight()).toBe(25)
2245
+
2246
+ expect(root_child0_child0_child0.getComputedLeft()).toBe(9)
2247
+ expect(root_child0_child0_child0.getComputedTop()).toBe(9)
2248
+ expect(root_child0_child0_child0.getComputedWidth()).toBe(14)
2249
+ expect(root_child0_child0_child0.getComputedHeight()).toBe(9)
2250
+
2251
+ root.calculateLayout(undefined, undefined, Direction.RTL)
2252
+
2253
+ expect(root.getComputedLeft()).toBe(0)
2254
+ expect(root.getComputedTop()).toBe(0)
2255
+ expect(root.getComputedWidth()).toBe(100)
2256
+ expect(root.getComputedHeight()).toBe(100)
2257
+
2258
+ expect(root_child0.getComputedLeft()).toBe(35)
2259
+ expect(root_child0.getComputedTop()).toBe(5)
2260
+ expect(root_child0.getComputedWidth()).toBe(60)
2261
+ expect(root_child0.getComputedHeight()).toBe(60)
2262
+
2263
+ expect(root_child0_child0.getComputedLeft()).toBe(30)
2264
+ expect(root_child0_child0.getComputedTop()).toBe(10)
2265
+ expect(root_child0_child0.getComputedWidth()).toBe(20)
2266
+ expect(root_child0_child0.getComputedHeight()).toBe(25)
2267
+
2268
+ expect(root_child0_child0_child0.getComputedLeft()).toBe(-3)
2269
+ expect(root_child0_child0_child0.getComputedTop()).toBe(9)
2270
+ expect(root_child0_child0_child0.getComputedWidth()).toBe(14)
2271
+ expect(root_child0_child0_child0.getComputedHeight()).toBe(9)
2272
+ } finally {
2273
+ if (typeof root !== "undefined") {
2274
+ root.freeRecursive()
2275
+ }
2276
+
2277
+ config.free()
2278
+ }
2279
+ })
2280
+ test.skip("box_sizing_content_box_flex_basis_row", () => {
2281
+ const config = Yoga.Config.create()
2282
+ let root
2283
+
2284
+ try {
2285
+ root = Yoga.Node.create(config)
2286
+ root.setFlexDirection(FlexDirection.Row)
2287
+ root.setPositionType(PositionType.Absolute)
2288
+ root.setWidth(100)
2289
+ root.setHeight(100)
2290
+
2291
+ const root_child0 = Yoga.Node.create(config)
2292
+ root_child0.setFlexBasis(50)
2293
+ root_child0.setPadding(Edge.Left, 5)
2294
+ root_child0.setPadding(Edge.Top, 5)
2295
+ root_child0.setPadding(Edge.Right, 5)
2296
+ root_child0.setPadding(Edge.Bottom, 5)
2297
+ root_child0.setBorder(Edge.Left, 10)
2298
+ root_child0.setBorder(Edge.Top, 10)
2299
+ root_child0.setBorder(Edge.Right, 10)
2300
+ root_child0.setBorder(Edge.Bottom, 10)
2301
+ root_child0.setHeight(25)
2302
+ root_child0.setBoxSizing(BoxSizing.ContentBox)
2303
+ root.insertChild(root_child0, 0)
2304
+ root.calculateLayout(undefined, undefined, Direction.LTR)
2305
+
2306
+ expect(root.getComputedLeft()).toBe(0)
2307
+ expect(root.getComputedTop()).toBe(0)
2308
+ expect(root.getComputedWidth()).toBe(100)
2309
+ expect(root.getComputedHeight()).toBe(100)
2310
+
2311
+ expect(root_child0.getComputedLeft()).toBe(0)
2312
+ expect(root_child0.getComputedTop()).toBe(0)
2313
+ expect(root_child0.getComputedWidth()).toBe(80)
2314
+ expect(root_child0.getComputedHeight()).toBe(55)
2315
+
2316
+ root.calculateLayout(undefined, undefined, Direction.RTL)
2317
+
2318
+ expect(root.getComputedLeft()).toBe(0)
2319
+ expect(root.getComputedTop()).toBe(0)
2320
+ expect(root.getComputedWidth()).toBe(100)
2321
+ expect(root.getComputedHeight()).toBe(100)
2322
+
2323
+ expect(root_child0.getComputedLeft()).toBe(20)
2324
+ expect(root_child0.getComputedTop()).toBe(0)
2325
+ expect(root_child0.getComputedWidth()).toBe(80)
2326
+ expect(root_child0.getComputedHeight()).toBe(55)
2327
+ } finally {
2328
+ if (typeof root !== "undefined") {
2329
+ root.freeRecursive()
2330
+ }
2331
+
2332
+ config.free()
2333
+ }
2334
+ })
2335
+ test("box_sizing_border_box_flex_basis_row", () => {
2336
+ const config = Yoga.Config.create()
2337
+ let root
2338
+
2339
+ try {
2340
+ root = Yoga.Node.create(config)
2341
+ root.setFlexDirection(FlexDirection.Row)
2342
+ root.setPositionType(PositionType.Absolute)
2343
+ root.setWidth(100)
2344
+ root.setHeight(100)
2345
+
2346
+ const root_child0 = Yoga.Node.create(config)
2347
+ root_child0.setFlexBasis(50)
2348
+ root_child0.setPadding(Edge.Left, 5)
2349
+ root_child0.setPadding(Edge.Top, 5)
2350
+ root_child0.setPadding(Edge.Right, 5)
2351
+ root_child0.setPadding(Edge.Bottom, 5)
2352
+ root_child0.setBorder(Edge.Left, 10)
2353
+ root_child0.setBorder(Edge.Top, 10)
2354
+ root_child0.setBorder(Edge.Right, 10)
2355
+ root_child0.setBorder(Edge.Bottom, 10)
2356
+ root_child0.setHeight(25)
2357
+ root.insertChild(root_child0, 0)
2358
+ root.calculateLayout(undefined, undefined, Direction.LTR)
2359
+
2360
+ expect(root.getComputedLeft()).toBe(0)
2361
+ expect(root.getComputedTop()).toBe(0)
2362
+ expect(root.getComputedWidth()).toBe(100)
2363
+ expect(root.getComputedHeight()).toBe(100)
2364
+
2365
+ expect(root_child0.getComputedLeft()).toBe(0)
2366
+ expect(root_child0.getComputedTop()).toBe(0)
2367
+ expect(root_child0.getComputedWidth()).toBe(50)
2368
+ expect(root_child0.getComputedHeight()).toBe(30)
2369
+
2370
+ root.calculateLayout(undefined, undefined, Direction.RTL)
2371
+
2372
+ expect(root.getComputedLeft()).toBe(0)
2373
+ expect(root.getComputedTop()).toBe(0)
2374
+ expect(root.getComputedWidth()).toBe(100)
2375
+ expect(root.getComputedHeight()).toBe(100)
2376
+
2377
+ expect(root_child0.getComputedLeft()).toBe(50)
2378
+ expect(root_child0.getComputedTop()).toBe(0)
2379
+ expect(root_child0.getComputedWidth()).toBe(50)
2380
+ expect(root_child0.getComputedHeight()).toBe(30)
2381
+ } finally {
2382
+ if (typeof root !== "undefined") {
2383
+ root.freeRecursive()
2384
+ }
2385
+
2386
+ config.free()
2387
+ }
2388
+ })
2389
+ test.skip("box_sizing_content_box_flex_basis_column", () => {
2390
+ const config = Yoga.Config.create()
2391
+ let root
2392
+
2393
+ try {
2394
+ root = Yoga.Node.create(config)
2395
+ root.setPositionType(PositionType.Absolute)
2396
+ root.setWidth(100)
2397
+ root.setHeight(100)
2398
+
2399
+ const root_child0 = Yoga.Node.create(config)
2400
+ root_child0.setFlexBasis(50)
2401
+ root_child0.setPadding(Edge.Left, 5)
2402
+ root_child0.setPadding(Edge.Top, 5)
2403
+ root_child0.setPadding(Edge.Right, 5)
2404
+ root_child0.setPadding(Edge.Bottom, 5)
2405
+ root_child0.setBorder(Edge.Left, 10)
2406
+ root_child0.setBorder(Edge.Top, 10)
2407
+ root_child0.setBorder(Edge.Right, 10)
2408
+ root_child0.setBorder(Edge.Bottom, 10)
2409
+ root_child0.setHeight(25)
2410
+ root_child0.setBoxSizing(BoxSizing.ContentBox)
2411
+ root.insertChild(root_child0, 0)
2412
+ root.calculateLayout(undefined, undefined, Direction.LTR)
2413
+
2414
+ expect(root.getComputedLeft()).toBe(0)
2415
+ expect(root.getComputedTop()).toBe(0)
2416
+ expect(root.getComputedWidth()).toBe(100)
2417
+ expect(root.getComputedHeight()).toBe(100)
2418
+
2419
+ expect(root_child0.getComputedLeft()).toBe(0)
2420
+ expect(root_child0.getComputedTop()).toBe(0)
2421
+ expect(root_child0.getComputedWidth()).toBe(100)
2422
+ expect(root_child0.getComputedHeight()).toBe(80)
2423
+
2424
+ root.calculateLayout(undefined, undefined, Direction.RTL)
2425
+
2426
+ expect(root.getComputedLeft()).toBe(0)
2427
+ expect(root.getComputedTop()).toBe(0)
2428
+ expect(root.getComputedWidth()).toBe(100)
2429
+ expect(root.getComputedHeight()).toBe(100)
2430
+
2431
+ expect(root_child0.getComputedLeft()).toBe(0)
2432
+ expect(root_child0.getComputedTop()).toBe(0)
2433
+ expect(root_child0.getComputedWidth()).toBe(100)
2434
+ expect(root_child0.getComputedHeight()).toBe(80)
2435
+ } finally {
2436
+ if (typeof root !== "undefined") {
2437
+ root.freeRecursive()
2438
+ }
2439
+
2440
+ config.free()
2441
+ }
2442
+ })
2443
+ test("box_sizing_border_box_flex_basis_column", () => {
2444
+ const config = Yoga.Config.create()
2445
+ let root
2446
+
2447
+ try {
2448
+ root = Yoga.Node.create(config)
2449
+ root.setPositionType(PositionType.Absolute)
2450
+ root.setWidth(100)
2451
+ root.setHeight(100)
2452
+
2453
+ const root_child0 = Yoga.Node.create(config)
2454
+ root_child0.setFlexBasis(50)
2455
+ root_child0.setPadding(Edge.Left, 5)
2456
+ root_child0.setPadding(Edge.Top, 5)
2457
+ root_child0.setPadding(Edge.Right, 5)
2458
+ root_child0.setPadding(Edge.Bottom, 5)
2459
+ root_child0.setBorder(Edge.Left, 10)
2460
+ root_child0.setBorder(Edge.Top, 10)
2461
+ root_child0.setBorder(Edge.Right, 10)
2462
+ root_child0.setBorder(Edge.Bottom, 10)
2463
+ root_child0.setHeight(25)
2464
+ root.insertChild(root_child0, 0)
2465
+ root.calculateLayout(undefined, undefined, Direction.LTR)
2466
+
2467
+ expect(root.getComputedLeft()).toBe(0)
2468
+ expect(root.getComputedTop()).toBe(0)
2469
+ expect(root.getComputedWidth()).toBe(100)
2470
+ expect(root.getComputedHeight()).toBe(100)
2471
+
2472
+ expect(root_child0.getComputedLeft()).toBe(0)
2473
+ expect(root_child0.getComputedTop()).toBe(0)
2474
+ expect(root_child0.getComputedWidth()).toBe(100)
2475
+ expect(root_child0.getComputedHeight()).toBe(50)
2476
+
2477
+ root.calculateLayout(undefined, undefined, Direction.RTL)
2478
+
2479
+ expect(root.getComputedLeft()).toBe(0)
2480
+ expect(root.getComputedTop()).toBe(0)
2481
+ expect(root.getComputedWidth()).toBe(100)
2482
+ expect(root.getComputedHeight()).toBe(100)
2483
+
2484
+ expect(root_child0.getComputedLeft()).toBe(0)
2485
+ expect(root_child0.getComputedTop()).toBe(0)
2486
+ expect(root_child0.getComputedWidth()).toBe(100)
2487
+ expect(root_child0.getComputedHeight()).toBe(50)
2488
+ } finally {
2489
+ if (typeof root !== "undefined") {
2490
+ root.freeRecursive()
2491
+ }
2492
+
2493
+ config.free()
2494
+ }
2495
+ })
2496
+ test("box_sizing_content_box_padding_start", () => {
2497
+ const config = Yoga.Config.create()
2498
+ let root
2499
+
2500
+ try {
2501
+ root = Yoga.Node.create(config)
2502
+ root.setPositionType(PositionType.Absolute)
2503
+ root.setPadding(Edge.Start, 5)
2504
+ root.setWidth(100)
2505
+ root.setHeight(100)
2506
+ root.setBoxSizing(BoxSizing.ContentBox)
2507
+ root.calculateLayout(undefined, undefined, Direction.LTR)
2508
+
2509
+ expect(root.getComputedLeft()).toBe(0)
2510
+ expect(root.getComputedTop()).toBe(0)
2511
+ expect(root.getComputedWidth()).toBe(105)
2512
+ expect(root.getComputedHeight()).toBe(100)
2513
+
2514
+ root.calculateLayout(undefined, undefined, Direction.RTL)
2515
+
2516
+ expect(root.getComputedLeft()).toBe(0)
2517
+ expect(root.getComputedTop()).toBe(0)
2518
+ expect(root.getComputedWidth()).toBe(105)
2519
+ expect(root.getComputedHeight()).toBe(100)
2520
+ } finally {
2521
+ if (typeof root !== "undefined") {
2522
+ root.freeRecursive()
2523
+ }
2524
+
2525
+ config.free()
2526
+ }
2527
+ })
2528
+ test("box_sizing_border_box_padding_start", () => {
2529
+ const config = Yoga.Config.create()
2530
+ let root
2531
+
2532
+ try {
2533
+ root = Yoga.Node.create(config)
2534
+ root.setPositionType(PositionType.Absolute)
2535
+ root.setPadding(Edge.Start, 5)
2536
+ root.setWidth(100)
2537
+ root.setHeight(100)
2538
+ root.calculateLayout(undefined, undefined, Direction.LTR)
2539
+
2540
+ expect(root.getComputedLeft()).toBe(0)
2541
+ expect(root.getComputedTop()).toBe(0)
2542
+ expect(root.getComputedWidth()).toBe(100)
2543
+ expect(root.getComputedHeight()).toBe(100)
2544
+
2545
+ root.calculateLayout(undefined, undefined, Direction.RTL)
2546
+
2547
+ expect(root.getComputedLeft()).toBe(0)
2548
+ expect(root.getComputedTop()).toBe(0)
2549
+ expect(root.getComputedWidth()).toBe(100)
2550
+ expect(root.getComputedHeight()).toBe(100)
2551
+ } finally {
2552
+ if (typeof root !== "undefined") {
2553
+ root.freeRecursive()
2554
+ }
2555
+
2556
+ config.free()
2557
+ }
2558
+ })
2559
+ test("box_sizing_content_box_padding_end", () => {
2560
+ const config = Yoga.Config.create()
2561
+ let root
2562
+
2563
+ try {
2564
+ root = Yoga.Node.create(config)
2565
+ root.setPositionType(PositionType.Absolute)
2566
+ root.setPadding(Edge.End, 5)
2567
+ root.setWidth(100)
2568
+ root.setHeight(100)
2569
+ root.setBoxSizing(BoxSizing.ContentBox)
2570
+ root.calculateLayout(undefined, undefined, Direction.LTR)
2571
+
2572
+ expect(root.getComputedLeft()).toBe(0)
2573
+ expect(root.getComputedTop()).toBe(0)
2574
+ expect(root.getComputedWidth()).toBe(105)
2575
+ expect(root.getComputedHeight()).toBe(100)
2576
+
2577
+ root.calculateLayout(undefined, undefined, Direction.RTL)
2578
+
2579
+ expect(root.getComputedLeft()).toBe(0)
2580
+ expect(root.getComputedTop()).toBe(0)
2581
+ expect(root.getComputedWidth()).toBe(105)
2582
+ expect(root.getComputedHeight()).toBe(100)
2583
+ } finally {
2584
+ if (typeof root !== "undefined") {
2585
+ root.freeRecursive()
2586
+ }
2587
+
2588
+ config.free()
2589
+ }
2590
+ })
2591
+ test("box_sizing_border_box_padding_end", () => {
2592
+ const config = Yoga.Config.create()
2593
+ let root
2594
+
2595
+ try {
2596
+ root = Yoga.Node.create(config)
2597
+ root.setPositionType(PositionType.Absolute)
2598
+ root.setPadding(Edge.End, 5)
2599
+ root.setWidth(100)
2600
+ root.setHeight(100)
2601
+ root.calculateLayout(undefined, undefined, Direction.LTR)
2602
+
2603
+ expect(root.getComputedLeft()).toBe(0)
2604
+ expect(root.getComputedTop()).toBe(0)
2605
+ expect(root.getComputedWidth()).toBe(100)
2606
+ expect(root.getComputedHeight()).toBe(100)
2607
+
2608
+ root.calculateLayout(undefined, undefined, Direction.RTL)
2609
+
2610
+ expect(root.getComputedLeft()).toBe(0)
2611
+ expect(root.getComputedTop()).toBe(0)
2612
+ expect(root.getComputedWidth()).toBe(100)
2613
+ expect(root.getComputedHeight()).toBe(100)
2614
+ } finally {
2615
+ if (typeof root !== "undefined") {
2616
+ root.freeRecursive()
2617
+ }
2618
+
2619
+ config.free()
2620
+ }
2621
+ })
2622
+ test("box_sizing_content_box_border_start", () => {
2623
+ const config = Yoga.Config.create()
2624
+ let root
2625
+
2626
+ try {
2627
+ root = Yoga.Node.create(config)
2628
+ root.setPositionType(PositionType.Absolute)
2629
+ root.setBorder(Edge.Start, 5)
2630
+ root.setWidth(100)
2631
+ root.setHeight(100)
2632
+ root.setBoxSizing(BoxSizing.ContentBox)
2633
+ root.calculateLayout(undefined, undefined, Direction.LTR)
2634
+
2635
+ expect(root.getComputedLeft()).toBe(0)
2636
+ expect(root.getComputedTop()).toBe(0)
2637
+ expect(root.getComputedWidth()).toBe(105)
2638
+ expect(root.getComputedHeight()).toBe(100)
2639
+
2640
+ root.calculateLayout(undefined, undefined, Direction.RTL)
2641
+
2642
+ expect(root.getComputedLeft()).toBe(0)
2643
+ expect(root.getComputedTop()).toBe(0)
2644
+ expect(root.getComputedWidth()).toBe(105)
2645
+ expect(root.getComputedHeight()).toBe(100)
2646
+ } finally {
2647
+ if (typeof root !== "undefined") {
2648
+ root.freeRecursive()
2649
+ }
2650
+
2651
+ config.free()
2652
+ }
2653
+ })
2654
+ test("box_sizing_border_box_border_start", () => {
2655
+ const config = Yoga.Config.create()
2656
+ let root
2657
+
2658
+ try {
2659
+ root = Yoga.Node.create(config)
2660
+ root.setPositionType(PositionType.Absolute)
2661
+ root.setBorder(Edge.Start, 5)
2662
+ root.setWidth(100)
2663
+ root.setHeight(100)
2664
+ root.calculateLayout(undefined, undefined, Direction.LTR)
2665
+
2666
+ expect(root.getComputedLeft()).toBe(0)
2667
+ expect(root.getComputedTop()).toBe(0)
2668
+ expect(root.getComputedWidth()).toBe(100)
2669
+ expect(root.getComputedHeight()).toBe(100)
2670
+
2671
+ root.calculateLayout(undefined, undefined, Direction.RTL)
2672
+
2673
+ expect(root.getComputedLeft()).toBe(0)
2674
+ expect(root.getComputedTop()).toBe(0)
2675
+ expect(root.getComputedWidth()).toBe(100)
2676
+ expect(root.getComputedHeight()).toBe(100)
2677
+ } finally {
2678
+ if (typeof root !== "undefined") {
2679
+ root.freeRecursive()
2680
+ }
2681
+
2682
+ config.free()
2683
+ }
2684
+ })
2685
+ test("box_sizing_content_box_border_end", () => {
2686
+ const config = Yoga.Config.create()
2687
+ let root
2688
+
2689
+ try {
2690
+ root = Yoga.Node.create(config)
2691
+ root.setPositionType(PositionType.Absolute)
2692
+ root.setBorder(Edge.End, 5)
2693
+ root.setWidth(100)
2694
+ root.setHeight(100)
2695
+ root.setBoxSizing(BoxSizing.ContentBox)
2696
+ root.calculateLayout(undefined, undefined, Direction.LTR)
2697
+
2698
+ expect(root.getComputedLeft()).toBe(0)
2699
+ expect(root.getComputedTop()).toBe(0)
2700
+ expect(root.getComputedWidth()).toBe(105)
2701
+ expect(root.getComputedHeight()).toBe(100)
2702
+
2703
+ root.calculateLayout(undefined, undefined, Direction.RTL)
2704
+
2705
+ expect(root.getComputedLeft()).toBe(0)
2706
+ expect(root.getComputedTop()).toBe(0)
2707
+ expect(root.getComputedWidth()).toBe(105)
2708
+ expect(root.getComputedHeight()).toBe(100)
2709
+ } finally {
2710
+ if (typeof root !== "undefined") {
2711
+ root.freeRecursive()
2712
+ }
2713
+
2714
+ config.free()
2715
+ }
2716
+ })
2717
+ test("box_sizing_border_box_border_end", () => {
2718
+ const config = Yoga.Config.create()
2719
+ let root
2720
+
2721
+ try {
2722
+ root = Yoga.Node.create(config)
2723
+ root.setPositionType(PositionType.Absolute)
2724
+ root.setBorder(Edge.End, 5)
2725
+ root.setWidth(100)
2726
+ root.setHeight(100)
2727
+ root.calculateLayout(undefined, undefined, Direction.LTR)
2728
+
2729
+ expect(root.getComputedLeft()).toBe(0)
2730
+ expect(root.getComputedTop()).toBe(0)
2731
+ expect(root.getComputedWidth()).toBe(100)
2732
+ expect(root.getComputedHeight()).toBe(100)
2733
+
2734
+ root.calculateLayout(undefined, undefined, Direction.RTL)
2735
+
2736
+ expect(root.getComputedLeft()).toBe(0)
2737
+ expect(root.getComputedTop()).toBe(0)
2738
+ expect(root.getComputedWidth()).toBe(100)
2739
+ expect(root.getComputedHeight()).toBe(100)
2740
+ } finally {
2741
+ if (typeof root !== "undefined") {
2742
+ root.freeRecursive()
2743
+ }
2744
+
2745
+ config.free()
2746
+ }
2747
+ })