|
libwebsockets
Lightweight C library for HTML5 websockets
|
#include <lws-html.h>
Go to the source code of this file.
Data Structures | |
| struct | lhp_atr |
| struct | lhp_sib |
| struct | lhp_table_row_t |
| struct | lhp_table_col_t |
| struct | lhp_pstack |
| struct | lcsp_atr |
| struct | lcsp_defs |
| struct | lcsp_names |
| struct | lcsp_stanza |
| struct | lhp_selidx |
| struct | lcsp_stanza_ptr |
| struct | lcsp_atr_ptr |
| struct | lcsp_match |
| struct | lhp_css_var |
| struct | lhp_css_layer |
| struct | lhp_block_rule |
| struct | lhp_ctx |
| struct | lws_lhp_filter |
Macros | |
| #define | LHP_MAX_ELEMS_NEST 128 |
| #define | LHP_MAX_DEPTH 64 |
| #define | LHP_STRING_CHUNK 2048 |
| #define | LHP_SIBLING_HISTORY 8 |
| #define | CCPAS_TOP 0 |
| #define | CCPAS_RIGHT 1 |
| #define | CCPAS_BOTTOM 2 |
| #define | CCPAS_LEFT 3 |
| #define | LHP_SELIDX_BUCKETS 64 |
| #define | LHP_CSS_LAYER_NONE 63 |
| #define | LHP_FLAG_DOCUMENT_END (1 << 0) |
| #define | LHP_CSS_PROPVAL_INT_WHOLE 1 |
| #define | LHP_CSS_PROPVAL_INT_FRAC 2 |
| #define | LHP_CSS_PROPVAL_INT_UNIT 3 |
| #define | LWS_LHPREF_WIDTH 0 |
| #define | LWS_LHPREF_HEIGHT 1 |
| #define | LWS_LHPREF_NONE 2 |
Typedefs | |
| typedef enum lcsp_props | lcsp_props_t |
| typedef lws_stateful_ret_t(* | lhp_callback) (struct lhp_ctx *ctx, char reason) |
| typedef struct lhp_atr | lhp_atr_t |
| typedef struct lhp_sib | lhp_sib_t |
| typedef struct lhp_pstack | lhp_pstack_t |
| typedef enum lcsp_css_units | lcsp_css_units_t |
| typedef struct lcsp_atr | lcsp_atr_t |
| typedef struct lcsp_defs | lcsp_defs_t |
| typedef struct lcsp_names | lcsp_names_t |
| typedef struct lcsp_stanza | lcsp_stanza_t |
| typedef struct lhp_selidx | lhp_selidx_t |
| typedef struct lcsp_stanza_ptr | lcsp_stanza_ptr_t |
| typedef struct lcsp_atr_ptr | lcsp_atr_ptr_t |
| typedef struct lcsp_match | lcsp_match_t |
| typedef struct lhp_css_var | lhp_css_var_t |
| typedef struct lhp_css_layer | lhp_css_layer_t |
| typedef struct lhp_block_rule | lhp_block_rule_t |
| typedef struct lhp_ctx | lhp_ctx_t |
| typedef struct lws_lhp_filter | lws_lhp_filter_t |
| struct lhp_atr |
Definition at line 402 of file lws-html.h.
| Data Fields | ||
|---|---|---|
| lws_dll2_t | list | |
| size_t | name_len | |
| size_t | value_len | |
| struct lhp_sib |
Definition at line 412 of file lws-html.h.
| Data Fields | ||
|---|---|---|
| lws_dll2_t | list | |
| lws_dll2_owner_t | atr | |
| struct lhp_table_row_t |
Definition at line 423 of file lws-html.h.
| Data Fields | ||
|---|---|---|
| lws_dll2_t | list | |
| lws_dll2_owner_t | row_dlos | |
| lws_fx_t | height | |
| struct lhp_table_col_t |
Definition at line 431 of file lws-html.h.
| Data Fields | ||
|---|---|---|
| lws_dll2_t | list | |
| lws_dll2_owner_t | col_dlos | |
| lws_fx_t | width | |
| lws_fx_t | min_w | |
| lws_fx_t | max_w | |
| struct lhp_pstack |
Definition at line 449 of file lws-html.h.
| Data Fields | ||
|---|---|---|
| lws_dll2_t | list | |
| void * | user | |
| lhp_callback | cb | |
| lws_box_t | drt | |
| lws_fx_t | ox | |
| lws_fx_t | oy | |
| lws_fx_t | cw | |
| lws_fx_t | abs_h | |
| lws_fx_t | abs_bot | |
| lws_fx_t | curx | |
| lws_fx_t | cury | |
| lws_fx_t | line_h | |
| lws_dlo_t * | line_first | |
| int16_t | line_asc | |
| int16_t | line_desc | |
| int16_t | last_base | |
| lws_fx_t | maxc | |
| lws_fx_t | minc | |
| lws_fx_t | nowrap | |
| lws_fx_t | rfloat_w | |
| lws_fx_t | pend_mb | |
| int32_t | abs_y | |
| uint16_t | idx | |
| lws_dll2_owner_t | atr | |
| lws_dll2_owner_t | sibs | |
| const lws_display_font_t * | f | |
| const struct lcsp_atr * | css_background_color | |
| const struct lcsp_atr * | css_color | |
| const struct lcsp_atr * | css_position | |
| const struct lcsp_atr * | css_display | |
| const struct lcsp_atr * | css_width | |
| const struct lcsp_atr * | css_height | |
| const struct lcsp_atr * | css_text_indent | |
| const struct lcsp_atr * | css_box_sizing | |
| struct lcsp_stanza * | pseudo_before | |
| struct lcsp_stanza * | pseudo_after | |
| const struct lcsp_atr * | css_border_radius[4] | |
| const struct lcsp_atr * | css_pos[4] | |
| const struct lcsp_atr * | css_margin[4] | |
| const struct lcsp_atr * | css_padding[4] | |
| struct lcsp_match * | matched | |
| struct lwsac * | styleac | |
| lws_fx_t | font_size | |
| uint16_t | nmatched | |
| uint8_t | is_block:1 | |
| uint8_t | is_table:1 | |
| uint8_t | is_row:1 | |
| uint8_t | is_cell:1 | |
| uint8_t | is_inline:1 | |
| uint8_t | is_ilevel:1 | |
| uint8_t | is_abs:1 | |
| uint8_t | is_float:1 | |
| uint8_t | is_float_right:1 | |
| uint8_t | is_flex:1 | |
| uint8_t | is_flex_item:1 | |
| uint8_t | flex_wrap:1 | |
| uint8_t | shrink:1 | |
| uint8_t | in_shrink:1 | |
| uint8_t | has_line:1 | |
| uint8_t | has_base:1 | |
| uint8_t | last_space:1 | |
| uint8_t | explicit_w:1 | |
| uint8_t | explicit_h:1 | |
| uint8_t | abs_h_set:1 | |
| uint8_t | abs_minh_set:1 | |
| uint8_t | abs_bot_set:1 | |
| uint8_t | abs_stretch_set:1 | |
| uint8_t | css_resolved:1 | |
| uint8_t | in_body:1 | |
| uint8_t | hidden:1 | |
| uint8_t | ti_done:1 | |
| lws_dlo_t * | dlo | |
| const lws_display_font_t * | font | |
| lws_dlo_t * | bg_dlo | |
| lws_fx_t | bg_ox | |
| lws_fx_t | bg_oy | |
| struct lcsp_defs |
Definition at line 641 of file lws-html.h.
| Data Fields | ||
|---|---|---|
| lws_dll2_t | list | |
| lws_dll2_owner_t | atrs | |
| struct lhp_css_var * | var | |
| uint16_t | prop | |
| uint8_t | important | |
| struct lcsp_names |
Definition at line 656 of file lws-html.h.
| Data Fields | ||
|---|---|---|
| lws_dll2_t | list | |
| uint32_t | specificity | |
| uint16_t | name_len | |
| uint16_t | key_ofs | |
| uint16_t | key_len | |
| uint8_t | key_kind | |
| struct lcsp_stanza |
Definition at line 670 of file lws-html.h.
| Data Fields | ||
|---|---|---|
| lws_dll2_t | list | |
| lws_dll2_owner_t | names | |
| lws_dll2_owner_t | defs | |
| uint32_t | seq | |
| struct lhp_selidx |
Definition at line 693 of file lws-html.h.
| Data Fields | ||
|---|---|---|
| struct lhp_selidx * | next | |
| lcsp_names_t * | nm | |
| lcsp_stanza_t * | stz | |
| struct lcsp_stanza_ptr |
Definition at line 710 of file lws-html.h.
| Data Fields | ||
|---|---|---|
| lws_dll2_t | list | |
| lcsp_stanza_t * | stz | |
| struct lcsp_atr_ptr |
Definition at line 716 of file lws-html.h.
| Data Fields | ||
|---|---|---|
| lws_dll2_t | list | |
| lcsp_atr_t * | atr | |
| struct lcsp_match |
Definition at line 728 of file lws-html.h.
| Data Fields | ||
|---|---|---|
| lcsp_stanza_t * | stz | |
| uint32_t | specificity | |
| struct lhp_css_var |
Definition at line 733 of file lws-html.h.
| Data Fields | ||
|---|---|---|
| lws_dll2_t | list | |
| size_t | name_len | |
| lcsp_defs_t * | def | |
| struct lhp_css_layer |
Definition at line 746 of file lws-html.h.
| Data Fields | ||
|---|---|---|
| lws_dll2_t | list | |
| size_t | len | |
| struct lhp_block_rule |
Definition at line 769 of file lws-html.h.
| Data Fields | ||
|---|---|---|
| lws_dll2_t | list | |
| size_t | len | |
| uint8_t | host_anchor:1 | |
| struct lws_lhp_filter |
struct lws_lhp_filter - ad / junk filtering policy for lws_lhp_set_filter()
cosmetic_css: css text hiding junk elements, or NULL for none. It is applied with higher precedence than any document css, so plain ".junk { display: none; }" rules are already authoritative; "!important" is also available for grouping with other declarations. Any selector the css engine understands can be used (classes, ids, [attr^=...] and so on).
block_rules: newline-separated URL block rules, or NULL for none. Lines starting with '#' and empty lines are ignored; other lines are either "||host.tld" (matches any subdomain of host.tld) or a plain substring that matches anywhere in the resolved asset URL. Matching is case-insensitive. A blocked asset is never fetched; the element is laid out without it.
Definition at line 966 of file lws-html.h.
| Data Fields | ||
|---|---|---|
| const char * | cosmetic_css | |
| const char * | block_rules | |
| #define LHP_MAX_ELEMS_NEST 128 |
Definition at line 29 of file lws-html.h.
| #define LHP_MAX_DEPTH 64 |
Definition at line 32 of file lws-html.h.
| #define LHP_STRING_CHUNK 2048 |
Definition at line 35 of file lws-html.h.
| #define LHP_SIBLING_HISTORY 8 |
Definition at line 47 of file lws-html.h.
| #define CCPAS_TOP 0 |
Definition at line 444 of file lws-html.h.
| #define CCPAS_RIGHT 1 |
Definition at line 445 of file lws-html.h.
| #define CCPAS_BOTTOM 2 |
Definition at line 446 of file lws-html.h.
| #define CCPAS_LEFT 3 |
Definition at line 447 of file lws-html.h.
| #define LHP_SELIDX_BUCKETS 64 |
Definition at line 699 of file lws-html.h.
| #define LHP_CSS_LAYER_NONE 63 |
Definition at line 760 of file lws-html.h.
| #define LHP_FLAG_DOCUMENT_END (1 << 0) |
Definition at line 762 of file lws-html.h.
| #define LHP_CSS_PROPVAL_INT_WHOLE 1 |
Definition at line 873 of file lws-html.h.
| #define LHP_CSS_PROPVAL_INT_FRAC 2 |
Definition at line 874 of file lws-html.h.
| #define LHP_CSS_PROPVAL_INT_UNIT 3 |
Definition at line 875 of file lws-html.h.
| #define LWS_LHPREF_WIDTH 0 |
Definition at line 1158 of file lws-html.h.
| #define LWS_LHPREF_HEIGHT 1 |
Definition at line 1159 of file lws-html.h.
| #define LWS_LHPREF_NONE 2 |
Definition at line 1160 of file lws-html.h.
| typedef enum lcsp_props lcsp_props_t |
| typedef lws_stateful_ret_t(* lhp_callback) (struct lhp_ctx *ctx, char reason) |
Definition at line 398 of file lws-html.h.
| typedef struct lhp_pstack lhp_pstack_t |
| typedef enum lcsp_css_units lcsp_css_units_t |
| typedef struct lcsp_atr lcsp_atr_t |
| typedef struct lcsp_defs lcsp_defs_t |
| typedef struct lcsp_names lcsp_names_t |
| typedef struct lcsp_stanza lcsp_stanza_t |
| typedef struct lhp_selidx lhp_selidx_t |
| typedef struct lcsp_stanza_ptr lcsp_stanza_ptr_t |
| typedef struct lcsp_atr_ptr lcsp_atr_ptr_t |
| typedef struct lcsp_match lcsp_match_t |
| typedef struct lhp_css_var lhp_css_var_t |
| typedef struct lhp_css_layer lhp_css_layer_t |
| typedef struct lhp_block_rule lhp_block_rule_t |
| typedef struct lws_lhp_filter lws_lhp_filter_t |
struct lws_lhp_filter - ad / junk filtering policy for lws_lhp_set_filter()
cosmetic_css: css text hiding junk elements, or NULL for none. It is applied with higher precedence than any document css, so plain ".junk { display: none; }" rules are already authoritative; "!important" is also available for grouping with other declarations. Any selector the css engine understands can be used (classes, ids, [attr^=...] and so on).
block_rules: newline-separated URL block rules, or NULL for none. Lines starting with '#' and empty lines are ignored; other lines are either "||host.tld" (matches any subdomain of host.tld) or a plain substring that matches anywhere in the resolved asset URL. Matching is case-insensitive. A blocked asset is never fetched; the element is laid out without it.
| enum lhp_callbacks |
Definition at line 51 of file lws-html.h.
| enum lcsp_props |
Definition at line 79 of file lws-html.h.
| enum lcsp_propvals_t |
Definition at line 246 of file lws-html.h.
| enum lcsp_css_units |
Definition at line 582 of file lws-html.h.
| anonymous enum |
| Enumerator | |
|---|---|
| LHP_SELKEY_NONE | |
| LHP_SELKEY_TAG | |
| LHP_SELKEY_CLASS | |
| LHP_SELKEY_ID | |
Definition at line 752 of file lws-html.h.
| LWS_VISIBLE LWS_EXTERN int lws_lhp_construct | ( | lhp_ctx_t * | ctx, |
| lhp_callback | cb, | ||
| void * | user, | ||
| const lws_surface_info_t * | ic ) |
References LWS_EXTERN, and LWS_VISIBLE.
| LWS_VISIBLE LWS_EXTERN void lws_lhp_destruct | ( | lhp_ctx_t * | ctx | ) |
| LWS_VISIBLE LWS_EXTERN int lws_lhp_set_filter | ( | lhp_ctx_t * | ctx, |
| const lws_lhp_filter_t * | filter ) |
lws_lhp_set_filter() - install an ad / junk filter on a prepared context
| ctx | the lhp context |
| filter | the filtering policy, or NULL to remove any existing one |
Installs the filter described in filter. The strings are copied, so the caller's storage only needs to stay valid for the call. Must be called after lws_lhp_construct() and before the first lws_lhp_parse() on ctx; returns nonzero if called too late or on OOM, else 0.
References LWS_EXTERN, and LWS_VISIBLE.
| LWS_VISIBLE LWS_EXTERN int lws_lhp_ss_browse | ( | struct lws_context * | cx, |
| lws_display_render_state_t * | rs, | ||
| const char * | url, | ||
| sul_cb_t | render ) |
lws_lhp_ss_browse() - browse url using SS and parse via lhp to DLOs
| cx | the lws_context |
| rs | the user's render state object |
| url | the https://x.com/y.xyz URL to browse |
| render | the user's linewise render callback (called from rs.sul) |
High level network fetch via SS and render html via lhp / DLO
rs->ic must be prepared before calling.
Returns nonzero if an early, fatal problem, else returns 0 and continues asynchronously.
If rs->box is (0,0,0,0) on entry, it is set to represent the whole display surface. Otherwise if not representing the whole display surface, it indicates partial mode should be used.
References LWS_EXTERN, and LWS_VISIBLE.
| LWS_VISIBLE LWS_EXTERN int lws_lhp_ss_browse_filter | ( | struct lws_context * | cx, |
| lws_display_render_state_t * | rs, | ||
| const char * | url, | ||
| sul_cb_t | render, | ||
| const lws_lhp_filter_t * | filter ) |
lws_lhp_ss_browse_filter() - as lws_lhp_ss_browse(), with content filtering
| cx | the lws_context |
| rs | the user's render state object |
| url | the https://x.com/y.xyz URL to browse |
| render | the user's linewise render callback (called from rs.sul) |
| filter | ad / junk filter to apply, see lws_lhp_set_filter() |
Identical to lws_lhp_ss_browse() but applies filter (which may be NULL, giving the same result as lws_lhp_ss_browse()).
References LWS_EXTERN, and LWS_VISIBLE.
| LWS_VISIBLE LWS_EXTERN void lws_lhp_ss_cancel | ( | lws_display_render_state_t * | rs | ) |
lws_lhp_ss_cancel() - cancel and tear down the browse on a render state
| rs | the render state the document was browsed onto |
Stops the document bound to rs completely: destroys its html stream (including its lhp parse state), and stops any of its assets that are still fetching or queued. Nothing further runs on rs for the old document; rs can be browsed again immediately afterwards. It is meant for navigating away, or laying a document out again at a new size.
Note it stops any assets active on the lws_context, so it suits the single-document-at-a-time render state usage.
References LWS_EXTERN, and LWS_VISIBLE.
| LWS_VISIBLE LWS_EXTERN lws_stateful_ret_t lws_lhp_parse | ( | lhp_ctx_t * | ctx, |
| const uint8_t ** | buf, | ||
| size_t * | len ) |
lws_lhp_parse() - parses a chunk of input HTML
ctx: the parsing context buf: pointer to the start of the chunk of html len: pointer the number of bytes of html available at *\pbuf
Parses up to *len bytes at *buf. On exit, *buf and *len are adjusted according to how much data was used. May return before processing all the input.
Returns LWS_SRET_WANT_INPUT if the parsing is stalled on some other async event (eg, fetch of image to find out the dimensions).
The lws_lhp_ss_browse() api wraps this.
References LWS_EXTERN, and LWS_VISIBLE.
| LWS_VISIBLE LWS_EXTERN const lcsp_atr_t * lws_css_cascade_get_prop_atr | ( | lhp_ctx_t * | ctx, |
| lcsp_props_t | prop ) |
lws_css_cascade_get_prop_atr() - find the css declaration in effect for a property
ctx: the parsing context prop: the LCSP_PROP_ property to look up
Looks up prop for the element currently at the top of the parse stack. The winning declaration is the one from the highest-precedence stanza that matched the element (style="" attribute, then !important, then selector specificity, then source order). If no matched stanza declares it, an inherited property (color, font-*, text-align, white-space...) is looked up on the ancestors in turn; a non-inherited one returns NULL, meaning "use
the initial value". A declared value of "inherit" also defers to the parent.
Returns NULL if nothing applies or OOM. Otherwise the values of the winning declaration are listed in ctx->active_atr (so shorthands like margin: 1px 2px can be walked) and the last value is returned.
References LWS_EXTERN, and LWS_VISIBLE.
| LWS_VISIBLE LWS_EXTERN const lcsp_atr_t * lws_css_get_prop_atr_ps | ( | lhp_ctx_t * | ctx, |
| lhp_pstack_t * | ps, | ||
| lcsp_props_t | prop ) |
lws_css_get_prop_atr_ps() - as lws_css_cascade_get_prop_atr() for any open element
ctx: the parsing context ps: the open element (any level of the parse stack) prop: the LCSP_PROP_ property to look up
References LWS_EXTERN, and LWS_VISIBLE.
| LWS_VISIBLE LWS_EXTERN int lws_http_rel_to_url | ( | char * | dest, |
| size_t | len, | ||
| const char * | base, | ||
| const char * | rel ) |
lws_http_rel_to_url() - make absolute url from base and relative
| dest | place to store the result |
| len | max length of result including NUL |
| base | a reference url including a file part |
| rel | the absolute or relative url or path to apply to base |
Copy the url formof rel into dest, using base to fill in missing context
If base is https://x.com/y/z.html
a.html -> https://x.com/y/a/html ../b.html -> https://x.com/b.html /c.html -> https://x.com/c.html https://y.com/a.html -> https://y.com/a.html
References LWS_EXTERN, and LWS_VISIBLE.
| LWS_VISIBLE LWS_EXTERN lhp_pstack_t * lws_css_get_parent_block | ( | lhp_ctx_t * | ctx, |
| lhp_pstack_t * | ps ) |
References LWS_EXTERN, and LWS_VISIBLE.
| LWS_VISIBLE LWS_EXTERN const char * lws_css_pstack_name | ( | lhp_pstack_t * | ps | ) |
References LWS_EXTERN, and LWS_VISIBLE.
| LWS_VISIBLE LWS_EXTERN const char * lws_html_get_atr | ( | lhp_pstack_t * | ps, |
| const char * | aname, | ||
| size_t | aname_len ) |
References LWS_EXTERN, and LWS_VISIBLE.
| LWS_VISIBLE LWS_EXTERN const lws_fx_t * lws_csp_px | ( | const lcsp_atr_t * | a, |
| lhp_pstack_t * | ps ) |
References LWS_EXTERN, and LWS_VISIBLE.
| LWS_VISIBLE LWS_EXTERN const lcsp_atr_t * lws_css_get_side_atr_ps | ( | lhp_pstack_t * | ps, |
| int | longhand, | ||
| int | shorthand, | ||
| int | idx, | ||
| int | radii ) |
References LWS_EXTERN, and LWS_VISIBLE.
| LWS_VISIBLE LWS_EXTERN lws_fx_t lws_csp_calc | ( | const lcsp_atr_t * | a, |
| lhp_pstack_t * | ps, | ||
| const lws_fx_t * | base, | ||
| int * | unitless ) |
lws_csp_calc() - evaluate a calc() attribute value
| a | the LCSP_UNIT_CALC atr |
| ps | the element it is for |
| base | the containing block length for %, or NULL |
| unitless | NULL, or set nonzero if the result is a bare number |
References LWS_EXTERN, and LWS_VISIBLE.
| LWS_VISIBLE LWS_EXTERN const lws_fx_t * lws_csp_px_base | ( | const lcsp_atr_t * | a, |
| lhp_pstack_t * | ps, | ||
| const lws_fx_t * | base ) |
References LWS_EXTERN, and LWS_VISIBLE.
| LWS_VISIBLE LWS_EXTERN void lws_lhp_tag_dlo_id | ( | lhp_ctx_t * | ctx, |
| lhp_pstack_t * | ps, | ||
| lws_dlo_t * | dlo ) |
| void lhp_set_dlo_padding_margin | ( | lhp_pstack_t * | ps, |
| lws_dlo_t * | dlo ) |
| LWS_VISIBLE LWS_EXTERN int lhp_prop_axis | ( | const lcsp_atr_t * | a | ) |
References LWS_EXTERN, and LWS_VISIBLE.
| LWS_VISIBLE LWS_EXTERN const lcsp_atr_t * lhp_resolve_var_color | ( | lhp_ctx_t * | ctx, |
| const lcsp_atr_t * | a ) |
References LWS_EXTERN, and LWS_VISIBLE.
| LWS_VISIBLE LWS_EXTERN const lcsp_atr_t * lhp_resolve_var | ( | lhp_ctx_t * | ctx, |
| const lcsp_atr_t * | a ) |