libcss
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Enumerations | Functions
select.c File Reference
#include <assert.h>
#include <string.h>
#include <libwapcaplet/libwapcaplet.h>
#include <libcss/select.h>
#include "bytecode/bytecode.h"
#include "bytecode/opcodes.h"
#include "stylesheet.h"
#include "select/arena.h"
#include "select/calc.h"
#include "select/computed.h"
#include "select/dispatch.h"
#include "select/hash.h"
#include "select/mq.h"
#include "select/propset.h"
#include "select/font_face.h"
#include "select/select.h"
#include "select/strings.h"
#include "select/unit.h"
#include "utils/parserutilserror.h"
#include "utils/utils.h"

Classes

struct  css_select_sheet
 
struct  css_select_ctx
 
struct  css_select_font_faces_list
 
struct  css_select_font_faces_state
 
struct  css_select_rule_source
 

Macros

#define IMPORT_STACK_SIZE   256
 

Typedefs

typedef struct css_select_sheet css_select_sheet
 
typedef struct css_select_font_faces_list css_select_font_faces_list
 
typedef struct css_select_font_faces_state css_select_font_faces_state
 
typedef struct css_select_rule_source css_select_rule_source
 

Enumerations

enum  share_candidate_type { CANDIDATE_SIBLING , CANDIDATE_COUSIN }
 

Functions

css_error css_libcss_node_data_handler (css_select_handler *handler, css_node_data_action action, void *pw, void *node, void *clone_node, void *libcss_node_data)
 
css_error css_select_ctx_create (css_select_ctx **result)
 
css_error css_select_ctx_destroy (css_select_ctx *ctx)
 
css_error css_select_ctx_append_sheet (css_select_ctx *ctx, const css_stylesheet *sheet, css_origin origin, const char *media)
 
css_error css_select_ctx_insert_sheet (css_select_ctx *ctx, const css_stylesheet *sheet, uint32_t index, css_origin origin, const char *media)
 
css_error css_select_ctx_remove_sheet (css_select_ctx *ctx, const css_stylesheet *sheet)
 
css_error css_select_ctx_count_sheets (css_select_ctx *ctx, uint32_t *count)
 
css_error css_select_ctx_get_sheet (css_select_ctx *ctx, uint32_t index, const css_stylesheet **sheet)
 
css_error css_select_default_style (css_select_ctx *ctx, css_select_handler *handler, void *pw, css_computed_style **style)
 
css_error css_select_style (css_select_ctx *ctx, void *node, const css_unit_ctx *unit_ctx, const css_media *media, const css_stylesheet *inline_style, css_select_handler *handler, void *pw, css_select_results **result)
 
css_error css_select_results_destroy (css_select_results *results)
 
css_error css_select_font_faces (css_select_ctx *ctx, const css_media *media, const css_unit_ctx *unit_ctx, lwc_string *font_family, css_select_font_faces_results **result)
 
css_error css_select_font_faces_results_destroy (css_select_font_faces_results *results)
 
bool css__outranks_existing (uint16_t op, bool important, css_select_state *state, enum flag_value explicit_default)
 

Macro Definition Documentation

◆ IMPORT_STACK_SIZE

#define IMPORT_STACK_SIZE   256

Typedef Documentation

◆ css_select_font_faces_list

Container for selected font faces

◆ css_select_font_faces_state

Font face selection state

◆ css_select_rule_source

CSS rule source

◆ css_select_sheet

Container for stylesheet selection info

Enumeration Type Documentation

◆ share_candidate_type

The releationship of a share candidate node to the selection node.

Enumerator
CANDIDATE_SIBLING 
CANDIDATE_COUSIN 

Function Documentation

◆ css__outranks_existing()

bool css__outranks_existing ( uint16_t  op,
bool  important,
css_select_state state,
enum flag_value  explicit_default 
)

◆ css_libcss_node_data_handler()

css_error css_libcss_node_data_handler ( css_select_handler handler,
css_node_data_action  action,
void *  pw,
void *  node,
void *  clone_node,
void *  libcss_node_data 
)

Handle libcss_node_data on DOM changes/deletion.

When a DOM node is deleted, if it has libcss_node_data, call with action CSS_NODE_DELETED, to ensure the libcss_node_data is not leaked. Does not call handler->set_libcss_node_data.

When a DOM node is modified, if the node has libcss_node_data, call with CSS_NODE_MODIFIED. This will result in a call to handler->set_libcss_node_data for the node.

When a DOM node's ancestors are modified, if the node has libcss_node_data, call with CSS_NODE_ANCESTORS_MODIFIED. This will result in a call to handler->set_libcss_node_data for the node.

When a DOM node with libcss_node_data is cloned, and its ancestors are also clones, call with CSS_NODE_CLONED. This will result in a call to handler->set_libcss_node_data for the clone node.

Parameters
handlerSelection handler vtable
actionType of node action.
pwClient data
nodeDOM node to get data from
clone_nodeClone node, or NULL
libcss_node_dataNode data (non-NULL)
Returns
CSS_OK on success, or appropriate error otherwise

◆ css_select_ctx_append_sheet()

css_error css_select_ctx_append_sheet ( css_select_ctx ctx,
const css_stylesheet sheet,
css_origin  origin,
const char *  media 
)

Append a stylesheet to a selection context

Parameters
ctxThe context to append to
sheetThe sheet to append
originOrigin of the sheet
mediaMedia string for the stylesheet
Returns
CSS_OK on success, appropriate error otherwise

◆ css_select_ctx_count_sheets()

css_error css_select_ctx_count_sheets ( css_select_ctx ctx,
uint32_t *  count 
)

Count the number of top-level sheets in a selection context

Parameters
ctxContext to consider
countPointer to location to receive count of sheets
Returns
CSS_OK on success, appropriate error otherwise

◆ css_select_ctx_create()

css_error css_select_ctx_create ( css_select_ctx **  result)

Create a selection context

Parameters
resultPointer to location to receive created context
Returns
CSS_OK on success, appropriate error otherwise.

◆ css_select_ctx_destroy()

css_error css_select_ctx_destroy ( css_select_ctx ctx)

Destroy a selection context

Parameters
ctxThe context to destroy
Returns
CSS_OK on success, appropriate error otherwise

◆ css_select_ctx_get_sheet()

css_error css_select_ctx_get_sheet ( css_select_ctx ctx,
uint32_t  index,
const css_stylesheet **  sheet 
)

Retrieve a sheet from a selection context

Parameters
ctxContext to look in
indexIndex in context to look
sheetPointer to location to receive sheet
Returns
CSS_OK on success, appropriate error otherwise

◆ css_select_ctx_insert_sheet()

css_error css_select_ctx_insert_sheet ( css_select_ctx ctx,
const css_stylesheet sheet,
uint32_t  index,
css_origin  origin,
const char *  media 
)

Insert a stylesheet into a selection context

Parameters
ctxThe context to insert into
sheetSheet to insert
indexIndex in context to insert sheet
originOrigin of the sheet
mediaMedia string for the stylesheet
Returns
CSS_OK on success, appropriate error otherwise

◆ css_select_ctx_remove_sheet()

css_error css_select_ctx_remove_sheet ( css_select_ctx ctx,
const css_stylesheet sheet 
)

Remove a sheet from a selection context

Parameters
ctxThe context to remove from
sheetSheet to remove
Returns
CSS_OK on success, appropriate error otherwise

◆ css_select_default_style()

css_error css_select_default_style ( css_select_ctx ctx,
css_select_handler handler,
void *  pw,
css_computed_style **  style 
)

Get a default style, e.g. for an implied element's anonymous box

Parameters
ctxSelection context (used to avoid recreating default)
handlerDispatch table of handler functions
pwClient-specific private data for handler functions
stylePointer to location to receive default style
Returns
CSS_OK on success, appropriate error otherwise.

◆ css_select_font_faces()

css_error css_select_font_faces ( css_select_ctx ctx,
const css_media media,
const css_unit_ctx unit_ctx,
lwc_string *  font_family,
css_select_font_faces_results **  result 
)

Search a selection context for defined font faces

Parameters
ctxSelection context
mediaCurrently active media spec
unit_ctxCurrent unit conversion context.
font_familyFont family to search for
resultPointer to location to receive result
Returns
CSS_OK on success, appropriate error otherwise.

◆ css_select_font_faces_results_destroy()

css_error css_select_font_faces_results_destroy ( css_select_font_faces_results results)

Destroy a font-face result set

Parameters
resultsResult set to destroy
Returns
CSS_OK on success, appropriate error otherwise

◆ css_select_results_destroy()

css_error css_select_results_destroy ( css_select_results results)

Destroy a selection result set

Parameters
resultsResult set to destroy
Returns
CSS_OK on success, appropriate error otherwise

◆ css_select_style()

css_error css_select_style ( css_select_ctx ctx,
void *  node,
const css_unit_ctx unit_ctx,
const css_media media,
const css_stylesheet inline_style,
css_select_handler handler,
void *  pw,
css_select_results **  result 
)

Select a style for the given node

Parameters
ctxSelection context to use
nodeNode to select style for
unit_ctxContext for length unit conversions.
mediaCurrently active media specification
inline_styleCorresponding inline style for node, or NULL
handlerDispatch table of handler functions
pwClient-specific private data for handler functions
resultPointer to location to receive result set
Returns
CSS_OK on success, appropriate error otherwise.

In computing the style, no reference is made to the parent node's style. Therefore, the resultant computed style is not ready for immediate use, as some properties may be marked as inherited. Use css_computed_style_compose() to obtain a fully computed style.

This two-step approach to style computation is designed to allow the client to store the partially computed style and efficiently update the fully computed style for a node when layout changes.