code wiki / _hdl_build / nx_css_vars.nx

nx_css_vars.nx

buildroot/runtime/_hdl_build/nx_css_vars.nx

12590 B242 linesdepth 2pulls 2 transitivereach 79 importersview sourcekind librarytopic css
docsdependenciesstructsconstsfunctions

about

nx_css_vars.nx -- CSS custom-property (var()) resolution for the SOVEREIGN render engine, so Nishi Browser + the reader + NishiOS render the fleet-standard --nx-color-* design tokens NATIVELY (operator 2026-07-10: "build nishi os and nishi browser first, not into javascript until last-mile on 3rd-party"). The native engine parsed only #hex/rgb(); every fleet-bar page is built on var(--token), so without this our own browser renders them colorless while Waterfox looks perfect -- the exact inversion to kill. PURE LIB (no main). One entry: cx_expand(inp,n,out,outcap) -> a byte copy of the CSS with every var(--x) substituted by its :root definition (FIRST-wins, so base/light tokens beat later dark overrides; recursive so a token defined as var() of another resolves; var(--x,fallback) supported; nested rgb() parens balanced). GUARANTEED no-op when the CSS has no var() -> existing pages/gates stay byte-identical. Wired as the final pass of rh_filter_media (nx_render_html) so all three native surfaces get it from one point. Consumers: nx_render_html (via rh_filter_media) + gate nx_css_vars_gate. license_tier: ORIGINAL

dependencies 1 imports · 2 importers

nx_syscalls.nx nx_css_vars.nx nx_css_vars_gate.nx nx_render_html.nx

imports: nx_syscalls.nx

imported by: nx_css_vars_gate.nxnx_render_html.nx

structs

none

consts

13const K_MAGIC_1024: i64 = 1024

functions

15func cx_ch(s: *u8, i: i64) -> i64 { return s[i] as i64 }
16func cx_is_ws(c: i64) -> i64 { if c == 32 { return 1 } if c == 9 { return 1 } if c == 10 { return 1 } if c == 13 { return 1 } return 0 }
17func cx_name_eq(s: *u8, o1: i64, l1: i64, o2: i64, l2: i64) -> i64
called by 1: cx_find calls 1: cx_ch
24func cx_find(s: *u8, noff: *i64, nlen: *i64, cnt: i64, no: i64, nl: i64) -> i64
called by 2: cx_collectcx_emit_name calls 1: cx_name_eq
30func cx_collect(s: *u8, n: i64, noff: *i64, nlen: *i64, voff: *i64, vlen: *i64, cap: i64) -> i64
called by 1: cx_expand calls 3: cx_chcx_is_wscx_find
76func cx_emit_name(s: *u8, noff: *i64, nlen: *i64, voff: *i64, vlen: *i64, cnt: i64, no: i64, nl: i64, out: *u8, op: *i64, outcap: i64, depth: i64) -> i64
called by 1: cx_emit_span calls 2: cx_findcx_emit_span
83func cx_emit_span(s: *u8, noff: *i64, nlen: *i64, voff: *i64, vlen: *i64, cnt: i64, so: i64, sl: i64, out: *u8, op: *i64, outcap: i64, depth: i64) -> i64
122func cx_isdig(c: i64) -> i64 { if c >= 48 { if c <= 57 { return 1 } } return 0 }
called by 1: clamp_term
125func clamp_term(s: *u8, i: i64, b: i64, vw: i64, ni: *i64) -> i64
called by 1: clamp_eval calls 2: cx_isdigcx_ch
151func clamp_eval(s: *u8, a: i64, b: i64, vw: i64) -> i64
170func cl_emit_int(out: *u8, op: i64, cap: i64, v: i64) -> i64
called by 1: clamp_resolve calls 1: sys_mmap
183func clamp_resolve(inp: *u8, n: i64, out: *u8, outcap: i64, vw: i64) -> i64
231func cx_expand(inp: *u8, n: i64, out: *u8, outcap: i64) -> i64