Skip to main content

Module values

Module values 

Source
Expand description

Shared value parsers used by both the HTML and CSS parsers.

Each returns Result<T, ParseError>; on failure ParseError::BadAttribute carries the calling context (tag-name in HTML, selector text in CSS), the property name, and the raw value, so error messages are useful either side of the parser boundary.

Structs§

BorderShorthand
Parsed result of a border:-family shorthand.

Functions§

bad
Construct a BadAttribute error.
parse_bg
Parse a bg= value: a hex color, a gradient function, or an image named with url(...). Gradient stops accept the CSS forms <color> (auto-distributed) or <color> <offset%> (explicit). Parsed stops are sorted by offset ascending so the renderer can hand them straight to peniko.
parse_border_shorthand
CSS border shorthand: <width> || <style> || <color> in any order (e.g. 1px solid #444). border: none clears the border.
parse_border_style
border-style keyword: none | solid (v1 subset). Other CSS styles (dashed, dotted, …) are rejected so the declaration is skipped with a warning instead of silently misrendering.
parse_border_width_edges
CSS border-width shorthand - 1-4 keyword/length terms in the standard top-right-bottom-left rotation.
parse_border_width_term
CSS border-width keyword / length term: thin (1px), medium (3px), thick (5px), or a px length. Percent is not valid CSS for border widths and is rejected.
parse_color
#rrggbb or #rrggbbaa.
parse_corner_radii
CSS border-radius multi-value shorthand -> per-corner radii [top-left, top-right, bottom-right, bottom-left]:
parse_edges
Parse a CSS-style spacing shorthand, top-right-bottom-left.
parse_f32
Parse a plain f32.
parse_font_weight
CSS font-weight: normal (400), bold (700), or a number in 1..=1000 (CSS Fonts 4). The relative keywords lighter / bolder need the parent’s computed weight and are rejected.
parse_i32
Parse a plain i32.
parse_image_fit
An image fit: fill, cover, contain, none, or scale-down. The fit of an <image> and the bg-fit of a background image take the same values.
parse_inset_edges
parse_edges for inset, where a term may also be auto (stored as NaN, the sentinel the layout backend reads as auto).
parse_inset_term
One inset longhand term: a px number, or auto (NaN).
parse_length
Length: auto | <n> | <n>px | <n>%.
parse_url
The path inside a CSS url(...), or None when value is not a url() at all. The path may be double-quoted, single-quoted, or bare; an empty one is an error.