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
diagram shows first 10 each side; +0 more imports, +24 more importers in the complete lists below.