code wiki / (root) / nx_css_apply.nx

nx_css_apply.nx

buildroot/runtime/nx_css_apply.nx

7523 B181 linesdepth 5pulls 5 transitivereach 97 importersview sourcekind librarytopic css
docsdependenciesstructsconstsfunctions

about

nx_css_apply.nx -- CSS cascade for the Nishi browser. Phase 2 fourth primitive after nx_css_tokenize, nx_css_parse, nx_css_selector_match. Walks a caller-supplied element array, matches every parsed CssRule against every element, and emits a flat `CssComputedDecl[]` of (element_idx, declaration) pairs in SOURCE ORDER. Cascade-by-source-order means downstream queries pick the LAST matching entry for "winner" semantics. What it does: - O(R × E) match loop -- fine at andelinwest.com scale (~50 rules × ~100 elements = 5k pairs). Bigger sites get a reverse selector index in Phase 2c (queued). - Per matched rule, the rule's decl_count declarations are copied into the output array, each tagged with element_idx. - Within an element_idx group, declarations appear in source order (stylesheet position, then rule position, then decl position). - Lookup helper `nx_css_lookup_property` scans the flat array and returns the LAST entry whose property name byte-equals the query for the given element. This is the value the layout / render layers consume. What it does NOT handle yet (named Phase 2b/2c improvements): - specificity (per CSS spec: id > class > tag; ties broken by source order). Phase 2 ships SOURCE-ORDER-ONLY cascade -- adequate for hand-written stylesheets where specificity is implicit. - !important - inherited properties (color, font-* propagate to children; needs DOM tree walk + parent computed_style lookup) - initial / inherit / unset / revert keyword values - reverse selector index for large sheets Per cardinal feedback-honest-perf-verdict-no-aspirational-claims: gap list is EXACT and tested. genealogy_id: w3c_css_cascade_module_level_4 + substrate_browser_phase_2_apply lineage_id: nishi_browser_css_apply_v1

dependencies 4 imports · 34 importers

nx_syscalls.nx nx_css_tokenize.nx nx_css_parse.nx nx_css_selector_match.nx nx_css_apply.nx nx_align_gate.nx nx_browser_demo_html.nx nx_browser_demo_html_nishi.nx nx_browser_demo_styled.nx nx_css_apply_test.nx nx_css_boxmap_test.nx nx_css_cascade_test.nx nx_flexgrow_gate.nx nx_flexgrow_probe.nx nx_float_gate.nx

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

imports: nx_syscalls.nxnx_css_tokenize.nxnx_css_parse.nxnx_css_selector_match.nx

imported by: nx_align_gate.nxnx_browser_demo_html.nxnx_browser_demo_html_nishi.nxnx_browser_demo_styled.nxnx_css_apply_test.nxnx_css_boxmap_test.nxnx_css_cascade_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_debug.nxnx_layout_example_com_real_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

56struct CssComputedDecl

consts

67const NX_CSS_COMPUTED_DECL_BYTES: i64 = 64

functions

75func _css_apply_bytes_equal(src: *u8, a_off: i64, a_len: i64,
100func nx_css_apply(src: *u8,
163func nx_css_lookup_property(src: *u8,
called by 1: main calls 1: _css_apply_bytes_equal