code wiki / (root) / nx_layout_box.nx

nx_layout_box.nx

buildroot/runtime/nx_layout_box.nx

8448 B241 linesdepth 2pulls 2 transitivereach 100 importersview sourcekind librarytopic layout
docsdependenciesstructsconstsfunctions

about

nx_layout_box.nx -- LayoutBox tree foundation for the Nishi browser. Phase 3 first primitive of docs/NISHI_BROWSER_ROADMAP.md, composes the Phase 2 CSS pipeline (nx_css_apply + value decoders) with the Phase 1 DOM tree (nx_html_tokenizer + nx_dom). This primitive owns ONLY the box-tree data structure -- no layout math here. nx_layout_block (next primitive, queued) walks this tree top-down in normal-flow order to assign concrete (x, y, w, h) pixels. nx_layout_inline (queued after that) handles line wrapping for inline boxes. LayoutBox kinds (sealed enum): BLOCK block-level box: <div>, <p>, <h1>...<h6>, <header>, etc. INLINE inline box: <span>, <a>, <em>, etc. INLINE_BLOCK inline-block: like inline externally, block internally TEXT terminal text run -- no children; content is bytes ANONYMOUS anonymous block wrapper inserted by spec when a block contains both block and inline children Tree layout (caller-owns-memory contract): The caller passes a `boxes: *LayoutBox` array + `max_boxes`. Boxes are appended in document order; parent/child/sibling links are indices into this array (-1 = none). Document root is at index 0 by convention. What this primitive does NOT do (queued for nx_layout_block): - assign x, y, w, h pixels (left as 0 until layout pass) - compute margin / padding / border from computed_style - resolve `width: auto` / `height: auto` - line-box generation for inline children - positioned-box layout (relative / absolute / fixed) - float / clear Per cardinal feedback-honest-perf-verdict-no-aspirational-claims: gap list is EXACT in this header. genealogy_id: w3c_css_box_model_module_level_3 + substrate_browser_phase_3_box_tree lineage_id: nishi_browser_layout_box_v1

dependencies 1 imports · 40 importers

nx_syscalls.nx nx_layout_box.nx nx_align_gate.nx nx_browser.nx nx_browser_demo_html.nx nx_browser_demo_html_nishi.nx nx_browser_demo_styled.nx nx_browser_render.nx nx_cdata_probe.nx nx_css_boxmap_test.nx nx_flexgrow_gate.nx nx_flexgrow_probe.nx

diagram shows first 10 each side; +0 more imports, +30 more importers in the complete lists below.

imports: nx_syscalls.nx

imported by: nx_align_gate.nxnx_browser.nxnx_browser_demo_html.nxnx_browser_demo_html_nishi.nxnx_browser_demo_styled.nxnx_browser_render.nxnx_cdata_probe.nxnx_css_boxmap_test.nxnx_flexgrow_gate.nxnx_flexgrow_probe.nxnx_float_gate.nxnx_float_test.nxnx_grid_gate.nxnx_grid_test.nxnx_grid_track_gate.nxnx_justify_gate.nxnx_layout_block.nxnx_layout_block_horizontal_test.nxnx_layout_block_test.nxnx_layout_box_test.nxnx_layout_debug.nxnx_layout_default_display.nxnx_layout_default_display_test.nxnx_layout_example_com_real_test.nxnx_layout_from_dom.nxnx_layout_from_dom_test.nxnx_negmargin_gate.nxnx_paint_box_borders.nxnx_paint_box_borders_test.nxnx_paint_walk_layout.nxnx_paint_walk_layout_test.nxnx_paint_walk_layout_text_test.nxnx_real_page_gate.nxnx_render_ascii.nxnx_render_html.nxnx_render_wiki_bmp.nxnx_render_wiki_styled_window.nxnx_render_wiki_window.nxnx_table_cell_gate.nxnx_wiki_boxdump.nx

structs

77struct LayoutBox
96struct LayoutTree

consts

51const NX_MAGIC_65536: i64 = 65536
54const NX_LAYOUT_BOX_UNKNOWN: i64 = 0
55const NX_LAYOUT_BOX_BLOCK: i64 = 1
56const NX_LAYOUT_BOX_INLINE: i64 = 2
57const NX_LAYOUT_BOX_INLINE_BLOCK: i64 = 3
58const NX_LAYOUT_BOX_TEXT: i64 = 4
59const NX_LAYOUT_BOX_ANONYMOUS: i64 = 5
60const NX_LAYOUT_BOX_N: i64 = 6
93const NX_LAYOUT_BOX_BYTES: i64 = 104
102const NX_LAYOUT_TREE_BYTES: i64 = 24

functions

107func _layout_box_at(tree: *LayoutTree, idx: i64) -> *LayoutBox
115func nx_layout_tree_init(tree: *LayoutTree, boxes: *LayoutBox,
130func nx_layout_box_append(tree: *LayoutTree, kind: i64,
156func nx_layout_box_attach_child(tree: *LayoutTree,
196func nx_layout_box_set_style(tree: *LayoutTree, idx: i64,
called by 1: main calls 1: _layout_box_at
207func nx_layout_box_set_text(tree: *LayoutTree, idx: i64,
219func nx_layout_box_child_count(tree: *LayoutTree, parent_idx: i64) -> i64
called by 2: mainmain calls 1: _layout_box_at