ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
reflow_css.h
Go to the documentation of this file.
1
47
48#pragma once
49
50#ifdef __cplusplus
51extern "C" {
52#endif
53
54#include <stdint.h>
55
56#include "ra8_err.h"
57
73
78typedef enum : int16_t {
81
90typedef enum : uint8_t {
91 k_ra8_css_set_bold = 1U << 0U,
100
108typedef enum : uint8_t {
112
122typedef struct {
123 uint8_t set;
124 uint8_t style;
125 uint8_t align;
126 uint8_t font_unit;
127 uint32_t color;
128 uint16_t font_val;
129 uint8_t display;
130 uint8_t pad;
131 uint16_t family_off;
132 uint16_t family_len;
134
145typedef struct {
146 uint8_t tag;
147 uint8_t pad8;
148 uint16_t class_off;
149 uint16_t class_len;
150 uint16_t id_off;
151 uint16_t id_len;
153
173typedef struct {
174 uint8_t sel_tag;
175 uint8_t anc_count;
176 uint16_t class_off;
177 uint16_t class_len;
178 uint16_t id_off;
179 uint16_t id_len;
180 uint16_t order;
184
195typedef struct {
196 uint16_t family_off;
197 uint16_t family_len;
198 uint16_t src_off;
199 uint16_t src_len;
200 uint8_t weight_bold;
201 uint8_t style_italic;
202 uint16_t pad;
204
221
230typedef struct {
231 uint8_t tag;
232 const char* id;
233 uint16_t id_len;
234 const char* class_str;
235 uint16_t class_len;
237
255[[nodiscard]] ra8_err_t ra8_css_sheet_reset(ra8_css_sheet_t* sheet);
256
281[[nodiscard]] ra8_err_t ra8_css_parse(ra8_css_sheet_t* sheet, const char* css, uint32_t len);
282
306[[nodiscard]] ra8_err_t ra8_css_parse_inline(const char* decls, uint32_t len, ra8_css_style_t* out);
307
325[[nodiscard]] bool ra8_css_rule_matches(const ra8_css_rule_t* rule,
326 const ra8_css_element_t* el,
327 const ra8_css_sheet_t* sheet);
328
351[[nodiscard]] ra8_css_style_t ra8_css_cascade(const ra8_css_sheet_t* sheet,
352 const ra8_css_element_t* el,
353 ra8_css_style_t inherited,
354 ra8_css_style_t inline_decl);
355
383[[nodiscard]] ra8_css_style_t ra8_css_cascade_ctx(const ra8_css_sheet_t* sheet,
384 const ra8_css_element_t* el,
385 ra8_css_style_t inherited,
386 ra8_css_style_t inline_decl,
387 const ra8_css_element_t* ancestors,
388 uint8_t n_anc);
389
417[[nodiscard]] int16_t ra8_css_match_face(const ra8_css_sheet_t* sheet,
418 const char* family,
419 uint16_t family_len,
420 bool want_bold,
421 bool want_italic);
422
446[[nodiscard]] bool ra8_css_face_src(const ra8_css_sheet_t* sheet,
447 uint16_t idx,
448 const char** out_src,
449 uint16_t* out_len);
450
451#ifdef __cplusplus
452}
453#endif
Error Code Definitions for ra8-firmware.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
bool ra8_css_rule_matches(const ra8_css_rule_t *rule, const ra8_css_element_t *el, const ra8_css_sheet_t *sheet)
Test whether rule rule's selector matches element el.
ra8_err_t ra8_css_parse_inline(const char *decls, uint32_t len, ra8_css_style_t *out)
Parse an inline style="..." declaration body into one style.
Definition reflow_css.c:805
ra8_css_style_t ra8_css_cascade_ctx(const ra8_css_sheet_t *sheet, const ra8_css_element_t *el, ra8_css_style_t inherited, ra8_css_style_t inline_decl, const ra8_css_element_t *ancestors, uint8_t n_anc)
Compute an element's cascaded style with descendant-selector context.
ra8_css_set_t
Which properties a declaration block actually set (presence bits).
Definition reflow_css.h:90
@ k_ra8_css_set_fontsize
font-size was declared.
Definition reflow_css.h:96
@ k_ra8_css_set_underline
text-decoration was declared.
Definition reflow_css.h:93
@ k_ra8_css_set_align
text-align was declared.
Definition reflow_css.h:94
@ k_ra8_css_set_display
display was declared.
Definition reflow_css.h:97
@ k_ra8_css_set_bold
font-weight was declared.
Definition reflow_css.h:91
@ k_ra8_css_set_italic
font-style was declared.
Definition reflow_css.h:92
@ k_ra8_css_set_color
color was declared.
Definition reflow_css.h:95
@ k_ra8_css_set_family
font-family was declared.
Definition reflow_css.h:98
ra8_err_t ra8_css_sheet_reset(ra8_css_sheet_t *sheet)
Reset a stylesheet to empty (no rules, no names, order 0).
ra8_css_face_match_t
Sentinel for ra8_css_match_face when no @font-face entry matches.
Definition reflow_css.h:78
@ k_ra8_css_no_face
No @font-face matched the requested family.
Definition reflow_css.h:79
ra8_css_limits_t
Static-allocation caps for one parsed stylesheet.
Definition reflow_css.h:65
@ k_ra8_css_name_pool
Bytes of class / id / font name storage.
Definition reflow_css.h:67
@ k_ra8_css_name_max
Max bytes of one class / id / font name.
Definition reflow_css.h:69
@ k_ra8_css_max_anc
Max descendant-ancestor parts per selector.
Definition reflow_css.h:71
@ k_ra8_css_max_faces
Max @font-face rules kept per sheet.
Definition reflow_css.h:70
@ k_ra8_css_max_classes
Max classes matched per element.
Definition reflow_css.h:68
@ k_ra8_css_max_rules
Max rules kept across all <style> blocks.
Definition reflow_css.h:66
bool ra8_css_face_src(const ra8_css_sheet_t *sheet, uint16_t idx, const char **out_src, uint16_t *out_len)
Read a parsed @font-face entry's src href bytes.
ra8_err_t ra8_css_parse(ra8_css_sheet_t *sheet, const char *css, uint32_t len)
Parse one <style> block's CSS text, appending rules to sheet.
int16_t ra8_css_match_face(const ra8_css_sheet_t *sheet, const char *family, uint16_t family_len, bool want_bold, bool want_italic)
Pick the @font-face whose family + emphasis best fits a run.
ra8_css_style_t ra8_css_cascade(const ra8_css_sheet_t *sheet, const ra8_css_element_t *el, ra8_css_style_t inherited, ra8_css_style_t inline_decl)
Compute an element's cascaded style.
ra8_css_font_unit_t
How a declared font-size value is interpreted.
Definition reflow_css.h:108
@ k_ra8_css_font_px
Value is an absolute pixel size.
Definition reflow_css.h:109
@ k_ra8_css_font_pct
Value is a percentage of inherited px.
Definition reflow_css.h:110
One ancestor part of a descendant selector (e.g.
Definition reflow_css.h:145
uint16_t id_off
Id name slice offset (id_len 0 = none).
Definition reflow_css.h:150
uint16_t class_len
Class name slice length, bytes.
Definition reflow_css.h:149
uint16_t id_len
Id name slice length, bytes.
Definition reflow_css.h:151
uint16_t class_off
Class name slice offset (class_len 0 = none).
Definition reflow_css.h:148
uint8_t pad8
Padding.
Definition reflow_css.h:147
uint8_t tag
Type tag, or k_reflow_tag_unknown = no type.
Definition reflow_css.h:146
The identity of one element, used to match selectors.
Definition reflow_css.h:230
uint16_t class_len
Length of class_str, bytes.
Definition reflow_css.h:235
const char * id
id attribute bytes (NULL = none).
Definition reflow_css.h:232
const char * class_str
class attribute bytes (NULL = none).
Definition reflow_css.h:234
uint16_t id_len
Length of id, bytes.
Definition reflow_css.h:233
uint8_t tag
reflow_html_tag_t of the element.
Definition reflow_css.h:231
One parsed @font-face rule: family + weight/style + src href.
Definition reflow_css.h:195
uint16_t src_len
src href slice length.
Definition reflow_css.h:199
uint8_t weight_bold
1 = this face is the bold weight.
Definition reflow_css.h:200
uint16_t family_len
font-family name slice length.
Definition reflow_css.h:197
uint8_t style_italic
1 = this face is italic / oblique.
Definition reflow_css.h:201
uint16_t pad
Padding.
Definition reflow_css.h:202
uint16_t src_off
src href slice offset.
Definition reflow_css.h:198
uint16_t family_off
font-family name slice offset.
Definition reflow_css.h:196
One selector { ... } rule: a (possibly descendant) selector plus its declarations.
Definition reflow_css.h:173
uint16_t class_off
Class name slice offset (class_len 0 = none).
Definition reflow_css.h:176
uint16_t id_off
Id name slice offset (id_len 0 = none).
Definition reflow_css.h:178
ra8_css_style_t decl
Declared properties.
Definition reflow_css.h:182
ra8_css_anc_t anc[k_ra8_css_max_anc]
Descendant ancestor parts.
Definition reflow_css.h:181
uint16_t class_len
Class name slice length, bytes.
Definition reflow_css.h:177
uint16_t order
Source order (lower = earlier; ties to later).
Definition reflow_css.h:180
uint8_t anc_count
Ancestor parts in anc (0 = simple).
Definition reflow_css.h:175
uint16_t id_len
Id name slice length, bytes.
Definition reflow_css.h:179
uint8_t sel_tag
Type tag, or k_reflow_tag_unknown = no type.
Definition reflow_css.h:174
A parsed stylesheet: rule + @font-face arrays and a name byte pool.
Definition reflow_css.h:212
uint16_t face_count
@font-face rules in use.
Definition reflow_css.h:216
uint16_t rule_count
Rules in use.
Definition reflow_css.h:215
ra8_css_rule_t rules[k_ra8_css_max_rules]
Parsed rules.
Definition reflow_css.h:213
uint16_t next_order
Running source-order ctr.
Definition reflow_css.h:217
uint16_t names_used
Bytes used in names.
Definition reflow_css.h:218
ra8_css_fontface_t faces[k_ra8_css_max_faces]
Parsed @font-face rules.
Definition reflow_css.h:214
uint8_t names[k_ra8_css_name_pool]
class/id/font name bytes.
Definition reflow_css.h:219
A declared or computed style: a presence mask plus property values.
Definition reflow_css.h:122
uint16_t font_val
font-size number: px or % (valid iff set & fontsize).
Definition reflow_css.h:128
uint16_t family_len
font-family name slice length (0 = none).
Definition reflow_css.h:132
uint8_t font_unit
ra8_css_font_unit_t (valid iff set & fontsize).
Definition reflow_css.h:126
uint8_t pad
Padding.
Definition reflow_css.h:130
uint8_t display
1 = display:none (valid iff set & display).
Definition reflow_css.h:129
uint8_t style
reflow_font_style_t bit VALUES (bold/italic/ul).
Definition reflow_css.h:124
uint8_t set
ra8_css_set_t bitmask: which properties are present.
Definition reflow_css.h:123
uint16_t family_off
font-family name slice offset (valid iff set&family).
Definition reflow_css.h:131
uint32_t color
0xRRGGBB text colour (valid iff set & color).
Definition reflow_css.h:127
uint8_t align
reflow_align_t (valid iff set & align).
Definition reflow_css.h:125