code wiki / (root) / nx_css_dimension_to_px.nx

nx_css_dimension_to_px.nx

buildroot/runtime/nx_css_dimension_to_px.nx

6167 B164 linesdepth 3pulls 3 transitivereach 89 importersview sourcekind librarytopic css
docsdependenciesstructsconstsfunctions

about

nx_css_dimension_to_px.nx -- convert a CSS dimension (NUMBER body + UNIT body) into absolute integer pixels. Phase 2.5 bridge primitive completing the value-decoder layer between Phase 2 (CSS apply emits VAL_DIMENSION as byte ranges) and Phase 3 layout. Supports the 4 most-common CSS length units (per W3C CSS Values Module Level 4 table of distance units): px absolute device pixels (direct) em relative to parent font-size in px rem relative to root font-size in px % percentage of parent dimension (caller-supplied) Math is integer-only Q3 (thousandths) per the nx_css_number_parse contract; this primitive ROUNDS toward zero to get whole pixels for the layout pipeline (sub-pixel positioning is Phase 4b queued). What it does NOT handle (Phase 2b improvements): - pt / pc / in / cm / mm / Q absolute length units - vw / vh / vmin / vmax viewport-relative units - ex / ch font-relative units (require font metrics from nx_text_render) - fr fractional flex units (require flexbox; Phase 3b) - calc() / clamp() / min() / max() functional values - negative dimensions (margin: -10px) -- caller computes sign Per cardinal feedback-honest-perf-verdict-no-aspirational-claims: gap list is EXACT. genealogy_id: w3c_css_values_module_level_4_distance_units lineage_id: nishi_browser_css_dimension_to_px_v1 nx_safety_envelope: intended_use: "CSS dimension -> integer px -- layout input" sil_target: SIL1 evidence: [W3C_CSS_Values_canonical_basis, bounded_4_supported_units, integer_Q3_arithmetic_no_FP] verdict: NOT_YET_EVALUATED

dependencies 2 imports · 19 importers

nx_syscalls.nx nx_css_number_parse.nx nx_css_dimension_to_px.nx nx_align_gate.nx nx_css_dimension_to_px_test.nx nx_flexgrow_gate.nx nx_flexgrow_probe.nx nx_float_gate.nx nx_float_test.nx nx_grid_gate.nx nx_grid_test.nx nx_grid_track_gate.nx nx_justify_gate.nx

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

imports: nx_syscalls.nxnx_css_number_parse.nx

imported by: nx_align_gate.nxnx_css_dimension_to_px_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_negmargin_gate.nxnx_paint_box_borders.nxnx_paint_box_borders_test.nxnx_real_page_gate.nxnx_table_cell_gate.nxnx_wiki_boxdump.nx

structs

59struct CssResolveCtx

consts

43const NX_MAGIC_100000: i64 = 100000
46const NX_CSS_UNIT_UNKNOWN: i64 = 0
47const NX_CSS_UNIT_PX: i64 = 1
48const NX_CSS_UNIT_EM: i64 = 2
49const NX_CSS_UNIT_REM: i64 = 3
50const NX_CSS_UNIT_PERCENT: i64 = 4
51const NX_CSS_UNIT_N: i64 = 5
65const NX_CSS_RESOLVE_CTX_BYTES: i64 = 24
67const NX_CSS_DIMENSION_PARSE_ERROR: i64 = 9223372036854775807 // sentinel matches nx_css_number_parse

functions

74func _css_unit_match2(src: *u8, off: i64, len: i64,
92func _css_unit_match3(src: *u8, off: i64, len: i64,
114func nx_css_unit_classify(src: *u8, off: i64, len: i64) -> i64
134func nx_css_dimension_to_px(src: *u8,