code wiki / _hdl_build / nx_css_vars.nx
nx_css_vars.nx
buildroot/runtime/_hdl_build/nx_css_vars.nx
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
imports: nx_syscalls.nx
imported by: nx_css_vars_gate.nxnx_render_html.nx
structs
| none |
consts
| 13 | const K_MAGIC_1024: i64 = 1024 |
functions
| 15 | func cx_ch(s: *u8, i: i64) -> i64 { return s[i] as i64 } |
| 16 | func 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 } |
| 17 | func cx_name_eq(s: *u8, o1: i64, l1: i64, o2: i64, l2: i64) -> i64 |
| 24 | func cx_find(s: *u8, noff: *i64, nlen: *i64, cnt: i64, no: i64, nl: i64) -> i64 |
| 30 | func cx_collect(s: *u8, n: i64, noff: *i64, nlen: *i64, voff: *i64, vlen: *i64, cap: i64) -> i64 |
| 76 | func 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 |
| 83 | func 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 |
| 122 | func cx_isdig(c: i64) -> i64 { if c >= 48 { if c <= 57 { return 1 } } return 0 } called by 1: clamp_term |
| 125 | func clamp_term(s: *u8, i: i64, b: i64, vw: i64, ni: *i64) -> i64 |
| 151 | func clamp_eval(s: *u8, a: i64, b: i64, vw: i64) -> i64 |
| 170 | func cl_emit_int(out: *u8, op: i64, cap: i64, v: i64) -> i64 |
| 183 | func clamp_resolve(inp: *u8, n: i64, out: *u8, outcap: i64, vw: i64) -> i64 |
| 231 | func cx_expand(inp: *u8, n: i64, out: *u8, outcap: i64) -> i64 |