ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
reflow_css_internal.h File Reference

Cross-TU surface for the split content-CSS cascade (#111). More...

#include <stddef.h>
#include "ra8_attributes.h"
#include "reflow_css.h"
Include dependency graph for reflow_css_internal.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool priv_reflow_css_is_ws (char c)
 True for CSS whitespace (space / tab / newline / CR / FF).
char priv_reflow_css_lower (char c)
 ASCII-fold one byte to lower case.
bool priv_reflow_css_ci_eq (const char *s, size_t len, const char *lit)
 Case-insensitive compare of span s[0..len) against NUL literal lit.
const char * priv_reflow_css_trim (const char *s, size_t *len)
 Trim leading + trailing whitespace from s[0..*len); returns start.
void priv_reflow_css_parse_decls (const char *s, size_t len, ra8_css_style_t *out)
 Parse a prop:value; ... declaration body (no braces) into out.
void priv_reflow_css_parse_one_block (ra8_css_sheet_t *sheet, const char *sel, size_t sel_len, const char *block, size_t block_len)
 Dispatch one selector|@rule { block }: at-rule vs.

Detailed Description

Cross-TU surface for the split content-CSS cascade (#111).

The content-CSS implementation is split across three translation units that share a small set of pure, leaf-level helpers:

  • reflow_css.c – parser entry, selector + @font-face parsing.
  • reflow_css_decl.c – declaration-body parsing (colour / font-size / emphasis / align / prop:value; block).
  • reflow_css_cascade.c – selector matching, the cascade, and the public cascade / face-lookup API. Only the symbols referenced by more than one of those TUs are declared here; every TU-private helper stays static in its defining file. There is no MMIO and no heap: all state lives in the caller-owned ra8_css_sheet_t.

[Ring 4 / Reflow] {World: NS}

Since
0.1.0

Definition in file reflow_css_internal.h.

Function Documentation

◆ priv_reflow_css_ci_eq()

bool priv_reflow_css_ci_eq ( const char * s,
size_t len,
const char * lit )

Case-insensitive compare of span s[0..len) against NUL literal lit.

Compares exactly len bytes of s against the NUL-terminated string lit using ASCII case folding via priv_reflow_css_lower(). Returns true only when the span and the literal have equal length and all bytes fold equal. Either null pointer causes an immediate false return without dereferencing.

Parameters
[in]sPointer to the byte span (need not be NUL-terminated).
[in]lenNumber of bytes in s to compare.
[in]litNUL-terminated reference string; must not be NULL for a true result.
Returns
bool Comparison result.
Return values
trues[0..len) equals lit case-insensitively and lengths match.
falseLengths differ, any byte differs, or a null pointer was passed.
Precondition
len is the exact byte count of the span to compare (may be 0).
lit is a valid NUL-terminated string pointer or NULL.
Postcondition
No state is mutated; the function is pure.
s and lit are not modified.
Note
Thread-safe; no shared mutable state.
Since
0.1.0

Definition at line 162 of file reflow_css.c.

References priv_reflow_css_lower().

Referenced by internal_apply_align(), internal_apply_decl(), internal_apply_emphasis(), internal_extract_url(), internal_face_apply(), internal_family_cb(), internal_is_bold_kw(), internal_is_italic_kw(), internal_parse_at_rule(), internal_parse_color(), and internal_parse_fontsize().

◆ priv_reflow_css_is_ws()

bool priv_reflow_css_is_ws ( char c)

True for CSS whitespace (space / tab / newline / CR / FF).

Classifies a single byte as a CSS white-space character per the CSS specification: space (0x20), horizontal tab (0x09), newline (0x0A), carriage return (0x0D), and form feed (0x0C). Used throughout the parser to skip or trim tokens.

Parameters
[in]cByte to classify (any value).
Returns
bool Classification result.
Return values
truec is a CSS whitespace byte.
falsec is not a CSS whitespace byte.
Precondition
No precondition on c; all byte values are valid inputs.
Caller must be in a context where character classification is meaningful.
Postcondition
Return value is determined solely by c; no state is mutated.
The function has no side effects.
Note
Thread-safe; pure function with no shared state.
Since
0.1.0

Definition at line 106 of file reflow_css.c.

Referenced by internal_class_list_has(), internal_split_compounds(), priv_reflow_css_trim(), and ra8_css_parse().

◆ priv_reflow_css_lower()

char priv_reflow_css_lower ( char c)

ASCII-fold one byte to lower case.

Converts an ASCII upper-case letter ('A'-'Z') to its lower-case equivalent by adding the fixed offset between 'A' and 'a'. All other byte values are returned unchanged. This is used for case-insensitive CSS keyword and identifier comparisons throughout the parser.

Parameters
[in]cByte to fold; may be any value.
Returns
char The lower-cased byte.
Return values
c+ ('a' - 'A') When c is in the range 'A'..'Z'.
cFor all other byte values.
Precondition
No precondition on c; all byte values are valid inputs.
Caller must be performing a case-insensitive comparison or scan.
Postcondition
Return value differs from c only when c is an ASCII upper-case letter.
No state is mutated; the function is pure.
Note
Thread-safe; pure function with no shared state.
Since
0.1.0

Definition at line 133 of file reflow_css.c.

Referenced by internal_ci_contains(), internal_ci_eq_span(), internal_hex_val(), and priv_reflow_css_ci_eq().

◆ priv_reflow_css_parse_decls()

void priv_reflow_css_parse_decls ( const char * s,
size_t len,
ra8_css_style_t * out )

Parse a prop:value; ... declaration body (no braces) into out.

Iterates over semicolon-delimited declarations in s[0..len). For each declaration, it locates the colon separator, trims whitespace from both property name and value, and applies the recognised property to out. Declarations with an empty property or value after trimming are skipped silently. The loop is bounded by len; each iteration advances past the next semicolon.

Parameters
[in]sByte span of the declaration block (no surrounding braces).
[in]lenNumber of bytes in s.
[in,out]outStyle record to accumulate parsed declarations into.
Returns
Nothing.
Precondition
s points to at least len readable bytes (may be NULL only when len == 0).
out is non-NULL and zero-initialised or partially filled by the caller.
Postcondition
out reflects all successfully parsed declarations from s.
s is not modified.
Note
Thread-safe with respect to distinct out instances.
Since
0.1.0

Iterates over semicolon-delimited declarations in s[0..len). For each declaration, it locates the colon separator, trims whitespace from both property name and value, and delegates to internal_apply_decl(). Declarations with an empty property or value after trimming are skipped silently. The loop is bounded by len; each iteration advances past the next semicolon.

Parameters
[in]sByte span of the declaration block (no surrounding braces).
[in]lenNumber of bytes in s.
[in,out]outStyle record to accumulate parsed declarations into.
Returns
Nothing.
Precondition
s points to at least len readable bytes (may be NULL only when len == 0).
out is non-NULL and zero-initialised or partially filled by the caller.
Postcondition
out reflects all successfully parsed declarations from s.
s is not modified.
Note
Thread-safe with respect to distinct out instances.
Since
0.1.0

Definition at line 774 of file reflow_css.c.

References internal_apply_decl(), and priv_reflow_css_trim().

Referenced by priv_reflow_css_parse_one_block(), and ra8_css_parse_inline().

◆ priv_reflow_css_parse_one_block()

void priv_reflow_css_parse_one_block ( ra8_css_sheet_t * sheet,
const char * sel,
size_t sel_len,
const char * block,
size_t block_len )

Dispatch one selector|@rule { block }: at-rule vs.

style rule.

Trims sel to obtain the effective keyword. When the first byte is '@', routes to the @font-face handler. Otherwise, parses the declaration block and distributes the resulting style to every comma-separated selector in sel. This is the per-block worker called by the top-level stylesheet scanner ra8_css_parse() (which lives in a different translation unit).

Parameters
[in,out]sheetSheet receiving parsed rules or font faces.
[in]selSelector or at-keyword text.
[in]sel_lenNumber of bytes in sel.
[in]blockDeclaration block body (no surrounding braces).
[in]block_lenNumber of bytes in block.
Returns
Nothing.
Precondition
sheet is non-NULL.
sel points to at least sel_len readable bytes.
Postcondition
sheet has been updated with all rules or faces derived from this block.
sel and block are not modified.
Note
Thread-safe with respect to distinct sheet instances.
Since
0.1.0

style rule.

Trims sel to obtain the effective keyword. When the first byte is '@', routes to internal_parse_at_rule(). Otherwise, parses the declaration block via priv_reflow_css_parse_decls() and internal_extract_family(), then distributes the resulting style to every comma-separated selector in sel via internal_parse_selector_list().

Parameters
[in,out]sheetSheet receiving parsed rules or font faces.
[in]selSelector or at-keyword text.
[in]sel_lenNumber of bytes in sel.
[in]blockDeclaration block body (no surrounding braces).
[in]block_lenNumber of bytes in block.
Returns
Nothing.
Precondition
sheet is non-NULL.
sel points to at least sel_len readable bytes.
Postcondition
sheet has been updated with all rules or faces derived from this block.
sel and block are not modified.
Note
Thread-safe with respect to distinct sheet instances.
Since
0.1.0

Definition at line 958 of file reflow_css_rules.c.

References internal_extract_family(), internal_parse_at_rule(), internal_parse_selector_list(), priv_reflow_css_parse_decls(), and priv_reflow_css_trim().

Referenced by ra8_css_parse().

◆ priv_reflow_css_trim()

const char * priv_reflow_css_trim ( const char * s,
size_t * len )

Trim leading + trailing whitespace from s[0..*len); returns start.

Advances past leading priv_reflow_css_is_ws() bytes and shrinks past trailing ones, writing the trimmed length back through len and returning a pointer to the first retained byte. Used to normalise property names, values, and selector spans before classification.

Parameters
[in]sByte span to trim (need not be NUL-terminated).
[in,out]lenOn entry, the span length; on return, the trimmed length.
Returns
const char* Pointer to the first non-whitespace byte of s.
Return values
&s[a]Pointer to the trimmed start; *len holds the trimmed length.
Precondition
s points to at least *len readable bytes.
len is non-NULL.
Postcondition
*len is in [0, *len_entry]; s contents are not modified.
The returned pointer lies within [s, s + *len_entry].
Note
Thread-safe; operates only on caller-owned memory.
Since
0.1.0

Definition at line 228 of file reflow_css.c.

References priv_reflow_css_is_ws().

Referenced by internal_extract_url(), internal_for_each_decl(), internal_parse_selector_list(), priv_reflow_css_parse_decls(), and priv_reflow_css_parse_one_block().