|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Content-CSS selector + @font-face rule parsing (#111). More...
#include <stddef.h>#include <string.h>#include "ra8_attributes.h"#include "reflow.h"#include "reflow_css.h"#include "reflow_css_internal.h"#include "reflow_tokenize_internal.h"Go to the source code of this file.
Data Structures | |
| struct | priv_face_ctx_t |
| Context threading a sheet + the face being built through the loop. More... | |
| struct | priv_family_ctx_t |
| Context threading a sheet + the rule declaration through the loop. More... | |
Typedefs | |
| typedef void(* | priv_decl_fn) (void *ctx, const char *prop, size_t plen, const char *val, size_t vlen) |
| Callback invoked by internal_for_each_decl on each prop:value pair. | |
Enumerations | |
| enum | priv_css_face_t : uint8_t { k_priv_url_len = 4U } |
| @font-face parsing constants. More... | |
Functions | |
| static bool | internal_is_name_char (char c) |
True if c can appear inside a bare type / class / id name. | |
| static bool | internal_intern_name (ra8_css_sheet_t *sheet, const char *s, size_t len, uint16_t *off) |
| Intern a class/id name into the sheet pool; false if it does not fit. | |
| static bool | internal_parse_sel_type (const char *s, size_t len, size_t *i, ra8_css_rule_t *rule) |
| Parse the optional leading type / * of a compound selector. | |
| static bool | internal_parse_sel_part (ra8_css_sheet_t *sheet, const char *s, size_t len, size_t *i, ra8_css_rule_t *rule) |
Parse one .class / #id part at s[*i] into rule; advance i. | |
| static bool | internal_parse_selector (ra8_css_sheet_t *sheet, const char *s, size_t len, ra8_css_rule_t *rule) |
Parse ONE trimmed compound selector into rule; false if unsupported. | |
| static int32_t | internal_split_compounds (const char *s, size_t len, const char **part_p, size_t *part_n) |
Split s into whitespace-separated compound spans. | |
| static bool | internal_parse_complex_selector (ra8_css_sheet_t *sheet, const char *s, size_t len, ra8_css_rule_t *rule) |
Parse a (possibly descendant) selector string into rule. | |
| static void | internal_push_rule (ra8_css_sheet_t *sheet, const ra8_css_rule_t *rule) |
| Append one fully-built rule to the sheet; drop silently if full. | |
| static void | internal_parse_selector_list (ra8_css_sheet_t *sheet, const char *sel, size_t sel_len, ra8_css_style_t decl) |
Parse a comma-grouped selector list sharing declaration decl. | |
| static const char * | internal_strip_quotes (const char *s, size_t *len) |
Strip one layer of matching '/" quotes from span s[0..*len). | |
| static bool | internal_extract_url (const char *val, size_t vlen, const char **url, size_t *ulen) |
| Extract the path inside the first url(...) of a src value. | |
| static bool | internal_is_bold_kw (const char *val, size_t vlen) |
| True for a font-weight keyword that selects the bold face. | |
| static bool | internal_is_italic_kw (const char *val, size_t vlen) |
| True for a font-style keyword that selects the italic face. | |
| static void | internal_face_apply (ra8_css_sheet_t *sheet, const char *prop, size_t plen, const char *val, size_t vlen, ra8_css_fontface_t *face) |
| Apply one @font-face declaration to the face being built. | |
| static void | internal_for_each_decl (const char *s, size_t len, priv_decl_fn cb, void *ctx) |
| Iterate prop:value; pairs in a declaration block (no braces). | |
| static void | internal_face_cb (void *ctx, const char *prop, size_t plen, const char *val, size_t vlen) |
| priv_decl_fn adapter that routes one descriptor to internal_face_apply(). | |
| static void | internal_parse_fontface (ra8_css_sheet_t *sheet, const char *block, size_t len) |
| Parse one @font-face { ... } block; append it if family + src set. | |
| static void | internal_family_cb (void *ctx, const char *prop, size_t plen, const char *val, size_t vlen) |
| priv_decl_fn adapter that interns a rule's font-family value. | |
| static void | internal_extract_family (ra8_css_sheet_t *sheet, const char *block, size_t len, ra8_css_style_t *decl) |
| Scan a rule's declaration block for font-family, interning it. | |
| static void | internal_parse_at_rule (ra8_css_sheet_t *sheet, const char *sel, size_t sel_len, const char *block, size_t block_len) |
| Route an at-rule: parse @font-face; skip every other @-rule. | |
| 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. | |
Content-CSS selector + @font-face rule parsing (#111).
The selector grammar (type / class / id / descendant compounds) and the @font-face descriptor parser for the v1 CSS subset documented in reflow_css.h. Parsed selectors and faces are interned into the caller-owned ra8_css_sheet_t name pool and rule / face tables. The top-level block dispatcher priv_reflow_css_parse_one_block lives here because it drives the selector and @font-face parsers; it is invoked by the stylesheet scanner ra8_css_parse in a sibling translation unit. No MMIO, no heap.
[Ring 4 / Reflow] {World: NS}
Definition in file reflow_css_rules.c.
| typedef void( * priv_decl_fn) (void *ctx, const char *prop, size_t plen, const char *val, size_t vlen) |
Callback invoked by internal_for_each_decl on each prop:value pair.
Definition at line 680 of file reflow_css_rules.c.
| enum priv_css_face_t : uint8_t |
@font-face parsing constants.
| Enumerator | |
|---|---|
| k_priv_url_len | Length of the url( token prefix. |
Definition at line 41 of file reflow_css_rules.c.
|
static |
Scan a rule's declaration block for font-family, interning it.
Calls internal_for_each_decl() with internal_family_cb() to find and intern the "font-family" property from block into sheet->names and record it in decl. This is a thin convenience wrapper that sets up a priv_family_ctx_t and delegates all logic to the callback.
| [in,out] | sheet | Sheet whose name pool may receive the interned family name. |
| [in] | block | Declaration block text (no surrounding braces). |
| [in] | len | Number of bytes in block. |
| [in,out] | decl | Declaration to update with the font-family slice. |
sheet and decl are non-NULL. block points to at least len readable bytes (may be NULL when len == 0). block and intern succeeds, decl has k_ra8_css_set_family set and family_off/family_len populated. block is not modified.sheet and decl instances. Definition at line 887 of file reflow_css_rules.c.
References internal_family_cb(), and internal_for_each_decl().
Referenced by priv_reflow_css_parse_one_block().
|
static |
Extract the path inside the first url(...) of a src value.
Scans val[0..vlen) for the first case-insensitive "url(" prefix, then locates the matching closing ')' and trims whitespace and one layer of matching single or double quotes from the content via internal_strip_quotes(). On success, *url and *ulen receive the path span (pointing into val) and the function returns true. Returns false when no "url(" is found or the extracted path is empty after trimming.
| [in] | val | CSS src value span (e.g. url('foo.ttf') format('truetype')). |
| [in] | vlen | Number of bytes in val. |
| [out] | url | Receives a pointer into val at the start of the path (valid only on true). |
| [out] | ulen | Receives the length of the path in bytes (valid only on true). |
| true | *url and *ulen point to the unquoted path inside "url(...)". |
| false | No "url(" was found, or the extracted path was empty. |
val points to at least vlen readable bytes. url and ulen are non-NULL. *url points into val and *ulen > 0. val is not modified.Definition at line 533 of file reflow_css_rules.c.
References internal_strip_quotes(), k_priv_url_len, priv_reflow_css_ci_eq(), and priv_reflow_css_trim().
Referenced by internal_face_apply().
|
static |
Apply one @font-face declaration to the face being built.
Handles the four recognised @font-face descriptors:
sheet; stores (off, len) in face->family_off / family_len.face->weight_bold via internal_is_bold_kw().face->style_italic via internal_is_italic_kw().face->src_off / src_len. All other descriptors (e.g., unicode-range) are silently ignored.| [in,out] | sheet | Sheet whose name pool receives interned strings. |
| [in] | prop | Descriptor property name span (not NUL-terminated). |
| [in] | plen | Length of prop in bytes. |
| [in] | val | Descriptor value span (not NUL-terminated). |
| [in] | vlen | Length of val in bytes. |
| [in,out] | face | Font-face record being accumulated. |
sheet and face are non-NULL. prop points to at least plen readable bytes. face is updated. prop and val are not modified.sheet and face instances. Definition at line 646 of file reflow_css_rules.c.
References ra8_css_fontface_t::family_len, ra8_css_fontface_t::family_off, internal_extract_url(), internal_intern_name(), internal_is_bold_kw(), internal_is_italic_kw(), internal_strip_quotes(), priv_reflow_css_ci_eq(), ra8_css_fontface_t::src_len, ra8_css_fontface_t::src_off, ra8_css_fontface_t::style_italic, and ra8_css_fontface_t::weight_bold.
Referenced by internal_face_cb().
|
static |
priv_decl_fn adapter that routes one descriptor to internal_face_apply().
Casts ctx to a priv_face_ctx_t pointer and forwards the property and value spans to internal_face_apply() with the sheet and face from the context. This function is designed to be passed as the cb argument of internal_for_each_decl() when parsing an @font-face block.
| [in] | ctx | Pointer to a priv_face_ctx_t (sheet + face); must not be NULL. |
| [in] | prop | Property name span (not NUL-terminated). |
| [in] | plen | Length of prop in bytes. |
| [in] | val | Property value span (not NUL-terminated). |
| [in] | vlen | Length of val in bytes. |
ctx is a non-NULL priv_face_ctx_t pointer with valid sheet and face fields. prop points to at least plen readable bytes. prop and val are not modified.Definition at line 765 of file reflow_css_rules.c.
References priv_face_ctx_t::face, internal_face_apply(), and priv_face_ctx_t::sheet.
Referenced by internal_parse_fontface().
|
static |
priv_decl_fn adapter that interns a rule's font-family value.
Casts ctx to a priv_family_ctx_t pointer. Ignores the callback unless prop matches "font-family". When it does, strips quotes from val via internal_strip_quotes() and interns the result into the sheet's name pool. On success, sets the k_ra8_css_set_family bit in decl->set and stores (off, len) in decl->family_off / family_len. This function is designed to be used as the cb argument of internal_for_each_decl().
| [in] | ctx | Pointer to a priv_family_ctx_t (sheet + decl); must not be NULL. |
| [in] | prop | Property name span (not NUL-terminated). |
| [in] | plen | Length of prop in bytes. |
| [in] | val | Property value span (not NUL-terminated). |
| [in] | vlen | Length of val in bytes. |
ctx is a non-NULL priv_family_ctx_t with valid sheet and decl fields. prop points to at least plen readable bytes. prop is "font-family" and intern succeeds, ctx->decl has the family fields set and k_ra8_css_set_family OR'd into ctx->decl->set. prop and val are not modified.Definition at line 846 of file reflow_css_rules.c.
References priv_family_ctx_t::decl, ra8_css_style_t::family_len, ra8_css_style_t::family_off, internal_intern_name(), internal_strip_quotes(), k_ra8_css_set_family, priv_reflow_css_ci_eq(), ra8_css_style_t::set, and priv_family_ctx_t::sheet.
Referenced by internal_extract_family().
|
static |
Iterate prop:value; pairs in a declaration block (no braces).
Scans s[0..len) for semicolon-delimited declarations and invokes cb(ctx, prop, plen, val, vlen) for each pair that has a non-empty property and value after whitespace trimming. The outer loop advances past each semicolon and is bounded by len; the inner colon search is bounded by the semicolon position. Pairs missing a colon are skipped silently.
| [in] | s | Declaration block text (no surrounding braces). |
| [in] | len | Number of bytes in s. |
| [in] | cb | Callback invoked once per valid prop:value pair; must not be NULL. |
| [in] | ctx | Opaque context pointer forwarded to cb unchanged. |
s points to at least len readable bytes (may be NULL when len == 0). cb is non-NULL. cb has been called for each valid declaration found in s. s is not modified.cb and ctx; the scanner itself is stateless. Definition at line 708 of file reflow_css_rules.c.
References priv_reflow_css_trim().
Referenced by internal_extract_family(), and internal_parse_fontface().
|
static |
Intern a class/id name into the sheet pool; false if it does not fit.
Copies len bytes of s into sheet->names at offset sheet->names_used, then advances names_used by len. On success, *off receives the offset at which the name was stored so that a rule or face can reference it by (off, len) rather than by pointer. Returns false without mutation when len is 0, exceeds k_ra8_css_name_max, or would cause names_used to overflow k_ra8_css_name_pool.
| [in,out] | sheet | Sheet whose name pool receives the interned bytes. |
| [in] | s | Byte span to intern (need not be NUL-terminated). |
| [in] | len | Number of bytes to copy. |
| [out] | off | Receives the pool offset of the interned name on success. |
| true | *off holds the start offset; sheet->names_used increased by len. |
| false | len is 0 or too large, or the pool has insufficient space. |
sheet and off are non-NULL. s points to at least len readable bytes. sheet->names[*off .. *off + len) contains the copied name. sheet is not modified.sheet instances. Definition at line 107 of file reflow_css_rules.c.
References k_ra8_css_name_max, k_ra8_css_name_pool, memcpy(), ra8_css_sheet_t::names, and ra8_css_sheet_t::names_used.
Referenced by internal_face_apply(), internal_family_cb(), and internal_parse_sel_part().
|
static |
True for a font-weight keyword that selects the bold face.
Returns true when val[0..vlen) matches (case-insensitively) any of the CSS bold-weight keywords: "bold", "bolder", "600", "700", "800", or "900". All comparisons are delegated to priv_reflow_css_ci_eq().
| [in] | val | CSS font-weight value span (not NUL-terminated). |
| [in] | vlen | Number of bytes in val. |
| true | val is a bold-selecting keyword or numeric weight. |
| false | val is a non-bold weight (e.g., "normal", "400"). |
val points to at least vlen readable bytes. vlen accurately reflects the span length. val is not modified.Definition at line 581 of file reflow_css_rules.c.
References priv_reflow_css_ci_eq().
Referenced by internal_face_apply().
|
static |
True for a font-style keyword that selects the italic face.
Returns true when val[0..vlen) matches (case-insensitively) either "italic" or "oblique" via priv_reflow_css_ci_eq(). All other values (e.g., "normal") return false.
| [in] | val | CSS font-style value span (not NUL-terminated). |
| [in] | vlen | Number of bytes in val. |
| true | val is "italic" or "oblique". |
| false | val is any other font-style value. |
val points to at least vlen readable bytes. vlen accurately reflects the span length. val is not modified.Definition at line 611 of file reflow_css_rules.c.
References priv_reflow_css_ci_eq().
Referenced by internal_face_apply().
|
static |
True if c can appear inside a bare type / class / id name.
Accepts ASCII letters ('a'-'z', 'A'-'Z'), decimal digits ('0'-'9'), the hyphen ('-'), and the underscore ('_'), which are the characters allowed in CSS identifiers per the CSS specification. Used by internal_parse_sel_type() and internal_parse_sel_part() to delimit token boundaries in selector text.
| [in] | c | Byte to classify. |
| true | c is a valid CSS identifier character. |
| false | c is not a valid CSS identifier character. |
c; all byte values are valid inputs. c is not modified.Definition at line 73 of file reflow_css_rules.c.
Referenced by internal_parse_sel_part(), internal_parse_sel_type(), and internal_parse_selector().
|
static |
Route an at-rule: parse @font-face; skip every other @-rule.
Compares the trimmed at-keyword sel against "@font-face" (case-insensitive). When it matches, delegates parsing of the block to internal_parse_fontface(). All other at-rules (@media, @import, @page, etc.) are out of the v1 scope and are silently discarded.
| [in,out] | sheet | Sheet that may receive the parsed font face. |
| [in] | sel | At-keyword span (e.g. "@font-face"), trimmed. |
| [in] | sel_len | Length of sel in bytes. |
| [in] | block | Block body text (no surrounding braces). |
| [in] | block_len | Number of bytes in block. |
sheet is non-NULL. sel points to at least sel_len readable bytes. sel is "@font-face", internal_parse_fontface() has been called. sel and block are not modified.sheet instances. Definition at line 921 of file reflow_css_rules.c.
References internal_parse_fontface(), and priv_reflow_css_ci_eq().
Referenced by priv_reflow_css_parse_one_block().
|
static |
Parse a (possibly descendant) selector string into rule.
Splits s on whitespace via internal_split_compounds() to isolate the subject compound (last token) and ancestor compounds (preceding tokens). The subject is parsed into rule's sel_tag, class, and id fields via internal_parse_selector(). Each ancestor is parsed into a temporary rule and its constraints are stored in rule->anc[] in selector order (outermost first), with rule->anc_count set to the number of ancestor parts. Returns false when internal_split_compounds() returns <= 0, or any compound fails to parse.
| [in,out] | sheet | Sheet whose name pool receives interned class/id names. |
| [in] | s | Selector text (may include whitespace for descendants). |
| [in] | len | Number of bytes in s. |
| [in,out] | rule | Rule record to populate; must be zero-initialised on entry. |
| true | All compounds parsed; rule holds the complete selector. |
| false | s is empty, has too many parts, or any compound is unsupported. |
sheet and rule are non-NULL. s points to at least len readable bytes. rule->anc_count and rule->anc[] reflect the ancestor chain. rule is in a partial state and must be discarded.sheet and rule instances. Definition at line 373 of file reflow_css_rules.c.
References ra8_css_rule_t::anc, ra8_css_rule_t::anc_count, ra8_css_anc_t::class_len, ra8_css_rule_t::class_len, ra8_css_anc_t::class_off, ra8_css_rule_t::class_off, ra8_css_anc_t::id_len, ra8_css_rule_t::id_len, ra8_css_anc_t::id_off, ra8_css_rule_t::id_off, internal_parse_selector(), internal_split_compounds(), k_ra8_css_max_anc, ra8_css_rule_t::sel_tag, and ra8_css_anc_t::tag.
Referenced by internal_parse_selector_list().
|
static |
Parse one @font-face { ... } block; append it if family + src set.
Iterates over the declaration block via internal_for_each_decl() with internal_face_cb() as the callback to accumulate font-family, font-weight, font-style, and src into a local ra8_css_fontface_t. The face is appended to sheet->faces[] only when both family_len and src_len are non-zero. If the sheet is already at k_ra8_css_max_faces capacity, the function returns without parsing.
| [in,out] | sheet | Sheet that may receive the parsed font face. |
| [in] | block | Declaration block text (no surrounding braces). |
| [in] | len | Number of bytes in block. |
sheet is non-NULL. block points to at least len readable bytes (may be NULL when len == 0). sheet->face_count is incremented by 1 and the face is stored in sheet->faces[]. block is not modified.sheet instances. Definition at line 797 of file reflow_css_rules.c.
References ra8_css_sheet_t::face_count, ra8_css_sheet_t::faces, ra8_css_fontface_t::family_len, internal_face_cb(), internal_for_each_decl(), k_ra8_css_max_faces, and ra8_css_fontface_t::src_len.
Referenced by internal_parse_at_rule().
|
static |
Parse one .class / #id part at s[*i] into rule; advance i.
Reads the '.' or '#' prefix at s[*i], then consumes a run of internal_is_name_char() bytes as the name. Interns the name via internal_intern_name() and stores the resulting (off, len) pair in the appropriate field of rule:
rule->class_off / rule->class_len (only one class supported in v1)rule->id_off / rule->id_len (only one id supported in v1) Returns false when the name is empty, fails to intern, or is a duplicate of an already-stored class/id on the same rule.| [in,out] | sheet | Sheet whose name pool may receive the interned name. |
| [in] | s | Selector text span. |
| [in] | len | Length of s in bytes. |
| [in,out] | i | Cursor into s; advanced past '.' or '#' and the name. |
| [in,out] | rule | Rule record to update with the class or id constraint. |
| true | A class or id constraint was interned and stored in rule. |
| false | The name was empty, overflowed the pool, or was a duplicate. |
sheet, i, and rule are non-NULL. s[*i] is '.' or '#' on entry. *i is advanced past the name; the matching rule field is set. rule and sheet state are left in an undefined partial state (the rule is discarded by the caller).sheet and rule instances. Definition at line 201 of file reflow_css_rules.c.
References ra8_css_rule_t::class_len, ra8_css_rule_t::class_off, ra8_css_rule_t::id_len, ra8_css_rule_t::id_off, internal_intern_name(), and internal_is_name_char().
Referenced by internal_parse_selector().
|
static |
Parse the optional leading type / * of a compound selector.
Reads the element type or universal selector at s[*i]:
*i by 1 and returns true without recording a type constraint (universal selector).rule->sel_tag and returns true. Returns false if the name is not a recognised HTML tag (caller drops the rule).| [in] | s | Selector text span. |
| [in] | len | Length of s in bytes. |
| [in,out] | i | Cursor into s; advanced past the consumed type token. |
| [in,out] | rule | Rule record to update with the parsed tag. |
| true | A recognised type or universal selector was consumed. |
| false | The name at s[*i] is not a recognised HTML element tag. |
s points to at least len readable bytes. i and rule are non-NULL; *i < len on entry. *i is advanced past the consumed token. rule->sel_tag holds the classified tag (or remains unknown for '*').rule instances. Definition at line 151 of file reflow_css_rules.c.
References internal_is_name_char(), k_reflow_tag_unknown, priv_reflow_tok_classify(), and ra8_css_rule_t::sel_tag.
Referenced by internal_parse_selector().
|
static |
Parse ONE trimmed compound selector into rule; false if unsupported.
Accepts one type + one class + one id in CSS order, e.g. *, p, .note, #x, p.note, p#x, .note#x. Two classes (.a.b), descendant combinators (div p) and pseudo selectors fail (the caller drops the rule). Delegates to internal_parse_sel_type() and internal_parse_sel_part() for each token.
| [in,out] | sheet | Sheet whose name pool may receive interned names. |
| [in] | s | Trimmed compound selector span (no surrounding whitespace). |
| [in] | len | Length of s in bytes. |
| [in,out] | rule | Rule record to populate with selector constraints. |
| true | The entire span was consumed as a supported compound selector. |
| false | len is 0, an unsupported combinator or pseudo was encountered, or an inner parse helper returned false. |
sheet and rule are non-NULL. s points to at least len readable bytes (may be NULL when len == 0). rule contains all parsed constraints; sheet->names_used may have grown. rule is left in a partial state and must be discarded.sheet and rule instances. Definition at line 263 of file reflow_css_rules.c.
References internal_is_name_char(), internal_parse_sel_part(), and internal_parse_sel_type().
Referenced by internal_parse_complex_selector().
|
static |
Parse a comma-grouped selector list sharing declaration decl.
Iterates over comma-delimited selectors in sel[0..sel_len), trims each individual selector, constructs a fresh ra8_css_rule_t carrying decl, and attempts to parse the selector via internal_parse_complex_selector(). Rules that parse successfully are appended to sheet via internal_push_rule(); those that fail to parse are silently discarded. The loop is bounded by sel_len; each iteration advances past the next comma.
| [in,out] | sheet | Sheet that receives the generated rules. |
| [in] | sel | Comma-separated selector list span. |
| [in] | sel_len | Number of bytes in sel. |
| [in] | decl | Shared declaration applied to every generated rule. |
sheet is non-NULL. sel points to at least sel_len readable bytes (may be NULL when 0). sel and decl have been appended to sheet (subject to k_ra8_css_max_rules capacity). sel is not modified.sheet instances. Definition at line 467 of file reflow_css_rules.c.
References ra8_css_rule_t::decl, internal_parse_complex_selector(), internal_push_rule(), and priv_reflow_css_trim().
Referenced by priv_reflow_css_parse_one_block().
|
static |
Append one fully-built rule to the sheet; drop silently if full.
Copies *rule into sheet->rules[sheet->rule_count], stamps the stored rule's order field with sheet->next_order, then increments both sheet->rule_count and sheet->next_order. When the sheet has already reached k_ra8_css_max_rules, the function returns immediately without modifying any field, silently discarding the rule.
| [in,out] | sheet | Sheet that receives the appended rule. |
| [in] | rule | Fully-parsed rule to append; must not be NULL. |
sheet and rule are non-NULL. rule is fully populated (selector and declaration fields valid). sheet->rule_count < k_ra8_css_max_rules, rule_count and next_order are each incremented by 1 and the rule is stored. sheet->rule_count == k_ra8_css_max_rules, no field is modified.sheet instances. Definition at line 429 of file reflow_css_rules.c.
References k_ra8_css_max_rules, ra8_css_sheet_t::next_order, ra8_css_rule_t::order, ra8_css_sheet_t::rule_count, and ra8_css_sheet_t::rules.
Referenced by internal_parse_selector_list().
|
static |
Split s into whitespace-separated compound spans.
Iterates over s[0..len), skipping runs of priv_reflow_css_is_ws() characters and recording the start and length of each non-whitespace token in the parallel part_p / part_n arrays. Returns -1 early when the part count would exceed (k_ra8_css_max_anc + 1), enforcing the maximum ancestor depth. Both output arrays must have capacity for at least (k_ra8_css_max_anc + 1) entries.
| [in] | s | Selector text span (need not be NUL-terminated). |
| [in] | len | Number of bytes in s. |
| [out] | part_p | Array of pointers; each entry points into s at the start of the corresponding compound token. |
| [out] | part_n | Array of sizes; each entry is the byte length of the corresponding compound token. |
| 0 | The span is empty or contains only whitespace. |
| >0 | The number of whitespace-separated compound tokens found. |
| -1 | More than (k_ra8_css_max_anc + 1) tokens were encountered. |
s points to at least len readable bytes. part_p and part_n are non-NULL with capacity >= (k_ra8_css_max_anc + 1). part_p[0..ret) and part_n[0..ret) are set. s is not modified; entries beyond the return count are unspecified.Definition at line 317 of file reflow_css_rules.c.
References k_ra8_css_max_anc, and priv_reflow_css_is_ws().
Referenced by internal_parse_complex_selector().
|
static |
Strip one layer of matching '/" quotes from span s[0..*len).
Definition at line 496 of file reflow_css_rules.c.
Referenced by internal_extract_url(), internal_face_apply(), and internal_family_cb().
| 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 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().
| [in,out] | sheet | Sheet receiving parsed rules or font faces. |
| [in] | sel | Selector or at-keyword text. |
| [in] | sel_len | Number of bytes in sel. |
| [in] | block | Declaration block body (no surrounding braces). |
| [in] | block_len | Number of bytes in block. |
sheet is non-NULL. sel points to at least sel_len readable bytes. sheet has been updated with all rules or faces derived from this block. sel and block are not modified.sheet instances. 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().