libcss
Loading...
Searching...
No Matches
Enumerations | Functions
utils.h File Reference
#include "parse/language.h"

Go to the source code of this file.

Enumerations

enum  border_side_e { BORDER_SIDE_TOP = 0 , BORDER_SIDE_RIGHT = 1 , BORDER_SIDE_BOTTOM = 2 , BORDER_SIDE_LEFT = 3 }
 

Functions

css_error css__parse_border_side (css_language *c, const parserutils_vector *vector, int32_t *ctx, css_style *result, enum border_side_e side)
 
css_error css__parse_border_side_color (css_language *c, const parserutils_vector *vector, int32_t *ctx, css_style *result, enum css_properties_e op)
 
css_error css__parse_border_side_style (css_language *c, const parserutils_vector *vector, int32_t *ctx, css_style *result, enum css_properties_e op)
 
css_error css__parse_border_side_width (css_language *c, const parserutils_vector *vector, int32_t *ctx, css_style *result, enum css_properties_e op)
 
css_error css__parse_side (css_language *c, const parserutils_vector *vector, int32_t *ctx, css_style *result, enum css_properties_e op)
 
css_error css__parse_margin_side (css_language *c, const parserutils_vector *vector, int32_t *ctx, css_style *result, enum css_properties_e op)
 
css_error css__parse_padding_side (css_language *c, const parserutils_vector *vector, int32_t *ctx, css_style *result, enum css_properties_e op)
 
css_error css__parse_list_style_type_value (css_language *c, const css_token *token, uint16_t *value)
 
css_error css__parse_colour_specifier (css_language *c, const parserutils_vector *vector, int32_t *ctx, uint16_t *value, uint32_t *result)
 
css_error css__parse_named_colour (css_language *c, lwc_string *data, uint32_t *result)
 
css_error css__parse_hash_colour (lwc_string *data, uint32_t *result)
 
css_error css__parse_unit_specifier (css_language *c, const parserutils_vector *vector, int32_t *ctx, uint32_t default_unit, css_fixed *length, uint32_t *unit)
 
css_error css__parse_unit_keyword (const char *ptr, size_t len, uint32_t *unit)
 
css_error css__ident_list_or_string_to_string (css_language *c, const parserutils_vector *vector, int32_t *ctx, bool(*reserved)(css_language *c, const css_token *ident), lwc_string **result)
 
css_error css__ident_list_to_string (css_language *c, const parserutils_vector *vector, int32_t *ctx, bool(*reserved)(css_language *c, const css_token *ident), lwc_string **result)
 
css_error css__comma_list_to_style (css_language *c, const parserutils_vector *vector, int32_t *ctx, bool(*reserved)(css_language *c, const css_token *ident), css_code_t(*get_value)(css_language *c, const css_token *token, bool first), css_style *result)
 
css_error css__parse_calc (css_language *c, const parserutils_vector *vector, int *ctx, css_style *result, css_code_t OPV, uint32_t unit)
 

Enumeration Type Documentation

◆ border_side_e

Enumerator
BORDER_SIDE_TOP 
BORDER_SIDE_RIGHT 
BORDER_SIDE_BOTTOM 
BORDER_SIDE_LEFT 

Function Documentation

◆ css__comma_list_to_style()

css_error css__comma_list_to_style ( css_language c,
const parserutils_vector *  vector,
int32_t *  ctx,
bool(*)(css_language *c, const css_token *ident)  reserved,
css_code_t(*)(css_language *c, const css_token *token, bool first)  get_value,
css_style result 
)

Parse a comma separated list, converting to bytecode

Parameters
cParsing context
vectorVector of tokens to process
ctxPointer to vector iteration context
reservedCallback to determine if an identifier is reserved
get_valueCallback to retrieve bytecode value for a token
stylePointer to output style
Returns
CSS_OK on success, CSS_INVALID if the input is invalid

Post condition: *ctx is updated with the next token to process If the input is invalid, then *ctx remains unchanged.

◆ css__ident_list_or_string_to_string()

css_error css__ident_list_or_string_to_string ( css_language c,
const parserutils_vector *  vector,
int32_t *  ctx,
bool(*)(css_language *c, const css_token *ident)  reserved,
lwc_string **  result 
)

Create a string from a list of IDENT/S tokens if the next token is IDENT or references the next token's string if it is a STRING

Parameters
cParsing context
vectorVector containing tokens
ctxVector iteration context
reservedCallback to determine if an identifier is reserved
resultPointer to location to receive resulting string
Returns
CSS_OK on success, appropriate error otherwise.

Post condition: *ctx is updated with the next token to process If the input is invalid, then *ctx remains unchanged.

The resulting string's reference is passed to the caller

◆ css__ident_list_to_string()

css_error css__ident_list_to_string ( css_language c,
const parserutils_vector *  vector,
int32_t *  ctx,
bool(*)(css_language *c, const css_token *ident)  reserved,
lwc_string **  result 
)

Create a string from a list of IDENT/S tokens

Parameters
cParsing context
vectorVector containing tokens
ctxVector iteration context
reservedCallback to determine if an identifier is reserved
resultPointer to location to receive resulting string
Returns
CSS_OK on success, appropriate error otherwise.

Post condition: *ctx is updated with the next token to process If the input is invalid, then *ctx remains unchanged.

The resulting string's reference is passed to the caller

◆ css__parse_border_side()

css_error css__parse_border_side ( css_language c,
const parserutils_vector *  vector,
int32_t *  ctx,
css_style result,
enum border_side_e  side 
)

Parse border-{top,right,bottom,left} shorthand

Parameters
cParsing context.
vectorVector of tokens to process.
ctxPointer to vector iteration context.
resultResult style.
sideThe side we're parsing for.
Returns
CSS_OK on success, CSS_NOMEM on memory exhaustion, CSS_INVALID if the input is not valid

Post condition: *ctx is updated with the next token to process If the input is invalid, then *ctx remains unchanged.

Parse border-{top,right,bottom,left} shorthand

Parameters
cParsing context
vectorVector of tokens to process
ctxPointer to vector iteration context
sideThe side we're parsing for
resultPointer to location to receive resulting style
Returns
CSS_OK on success, CSS_NOMEM on memory exhaustion, CSS_INVALID if the input is not valid

Post condition: *ctx is updated with the next token to process If the input is invalid, then *ctx remains unchanged.

◆ css__parse_border_side_color()

css_error css__parse_border_side_color ( css_language c,
const parserutils_vector *  vector,
int32_t *  ctx,
css_style result,
enum css_properties_e  op 
)

Parse border-{top,right,bottom,left}-color

Parameters
cParsing context
vectorVector of tokens to process
ctxPointer to vector iteration context
resultPointer to location to receive resulting style
opOpcode to parse for (encodes side)
Returns
CSS_OK on success, CSS_NOMEM on memory exhaustion, CSS_INVALID if the input is not valid

Post condition: *ctx is updated with the next token to process If the input is invalid, then *ctx remains unchanged.

Parse border_side_color

Parameters
cParsing context
vectorVector of tokens to process
ctxPointer to vector iteration context
resultresulting style
opBytecode OpCode for CSS property to encode
Returns
CSS_OK on success, CSS_NOMEM on memory exhaustion, CSS_INVALID if the input is not valid

Post condition: *ctx is updated with the next token to process If the input is invalid, then *ctx remains unchanged.

◆ css__parse_border_side_style()

css_error css__parse_border_side_style ( css_language c,
const parserutils_vector *  vector,
int32_t *  ctx,
css_style result,
enum css_properties_e  op 
)

Parse border-{top,right,bottom,left}-style

Parameters
cParsing context
vectorVector of tokens to process
ctxPointer to vector iteration context
resultPointer to location to receive resulting style
opOpcode to parse for (encodes side)
Returns
CSS_OK on success, CSS_NOMEM on memory exhaustion, CSS_INVALID if the input is not valid

Post condition: *ctx is updated with the next token to process If the input is invalid, then *ctx remains unchanged.

Parse border_side_style

Parameters
cParsing context
vectorVector of tokens to process
ctxPointer to vector iteration context
resultresulting style
opBytecode OpCode for CSS property to encode
Returns
CSS_OK on success, CSS_NOMEM on memory exhaustion, CSS_INVALID if the input is not valid

Post condition: *ctx is updated with the next token to process If the input is invalid, then *ctx remains unchanged.

◆ css__parse_border_side_width()

css_error css__parse_border_side_width ( css_language c,
const parserutils_vector *  vector,
int32_t *  ctx,
css_style result,
enum css_properties_e  op 
)

Parse border-{top,right,bottom,left}-width

Parameters
cParsing context
vectorVector of tokens to process
ctxPointer to vector iteration context
resultPointer to location to receive resulting style
opOpcode to parse for (encodes side)
Returns
CSS_OK on success, CSS_NOMEM on memory exhaustion, CSS_INVALID if the input is not valid

Post condition: *ctx is updated with the next token to process If the input is invalid, then *ctx remains unchanged.

Parse border_side_width

Parameters
cParsing context
vectorVector of tokens to process
ctxPointer to vector iteration context
resultresulting style
opBytecode OpCode for CSS property to encode
Returns
CSS_OK on success, CSS_NOMEM on memory exhaustion, CSS_INVALID if the input is not valid

Post condition: *ctx is updated with the next token to process If the input is invalid, then *ctx remains unchanged.

◆ css__parse_calc()

css_error css__parse_calc ( css_language c,
const parserutils_vector *  vector,
int *  ctx,
css_style result,
css_code_t  OPV,
uint32_t  unit 
)

Parse a CSS calc() invocation

Calc can generate a number of kinds of units, so we have to tell the parser the kind of unit we're aiming for (e.g. UNIT_PX, UNIT_ANGLE, etc.)

Parameters
[in]cParsing context
[in]vectorVector of tokens to process
[in]ctxPointer to vector iteration context
[in]resultPointer to location to receive resulting style
[in]OPVThe CSS property we are calculating for
[in]unitThe kind of unit which we want to come out of this calc()
Returns
CSS_OK on success, CSS_NOMEM on memory exhaustion, CSS_INVALID if the input is not valid

Post condition: *ctx is updated with the next token to process If the input is invalid, then *ctx remains unchanged.

◆ css__parse_colour_specifier()

css_error css__parse_colour_specifier ( css_language c,
const parserutils_vector *  vector,
int32_t *  ctx,
uint16_t *  value,
uint32_t *  result 
)

Parse a colour specifier

Parameters
cParsing context
vectorVector of tokens to process
ctxPointer to vector iteration context
valuePointer to location to receive value
resultPointer to location to receive result (AARRGGBB)
Returns
CSS_OK on success, CSS_INVALID if the input is invalid

Post condition: *ctx is updated with the next token to process If the input is invalid, then *ctx remains unchanged.

◆ css__parse_hash_colour()

css_error css__parse_hash_colour ( lwc_string *  data,
uint32_t *  result 
)

Parse a hash colour (#rgb, #rgba, #rrggbb or #rrggbbaa)

Parameters
dataPointer to colour string
resultPointer to location to receive result (AARRGGBB)
Returns
CSS_OK on success, CSS_INVALID if the input is invalid

◆ css__parse_list_style_type_value()

css_error css__parse_list_style_type_value ( css_language c,
const css_token ident,
uint16_t *  value 
)

Parse list-style-type value

Parameters
cParsing context
identIdentifier to consider
valuePointer to location to receive value
Returns
CSS_OK on success, CSS_INVALID if the input is not valid

◆ css__parse_margin_side()

css_error css__parse_margin_side ( css_language c,
const parserutils_vector *  vector,
int32_t *  ctx,
css_style result,
enum css_properties_e  op 
)

Parse margin-{top,right,bottom,left}

Parameters
cParsing context
vectorVector of tokens to process
ctxPointer to vector iteration context
resultPointer to location to receive resulting style
Returns
CSS_OK on success, CSS_NOMEM on memory exhaustion, CSS_INVALID if the input is not valid

Post condition: *ctx is updated with the next token to process If the input is invalid, then *ctx remains unchanged.

Parse margin_side

Parameters
cParsing context
vectorVector of tokens to process
ctxPointer to vector iteration context
resultresulting style
opBytecode OpCode for CSS property to encode
Returns
CSS_OK on success, CSS_NOMEM on memory exhaustion, CSS_INVALID if the input is not valid

Post condition: *ctx is updated with the next token to process If the input is invalid, then *ctx remains unchanged.

◆ css__parse_named_colour()

css_error css__parse_named_colour ( css_language c,
lwc_string *  data,
uint32_t *  result 
)

Parse a named colour

Parameters
cParsing context
dataColour name string
resultPointer to location to receive result
Returns
CSS_OK on success, CSS_INVALID if the colour name is unknown

Legacy system colour mapping

◆ css__parse_padding_side()

css_error css__parse_padding_side ( css_language c,
const parserutils_vector *  vector,
int32_t *  ctx,
css_style result,
enum css_properties_e  op 
)

Parse padding-{top,right,bottom,left}

Parameters
cParsing context
vectorVector of tokens to process
ctxPointer to vector iteration context
resultPointer to location to receive resulting style
Returns
CSS_OK on success, CSS_NOMEM on memory exhaustion, CSS_INVALID if the input is not valid

Post condition: *ctx is updated with the next token to process If the input is invalid, then *ctx remains unchanged.

Parse padding_side

Parameters
cParsing context
vectorVector of tokens to process
ctxPointer to vector iteration context
resultresulting style
opBytecode OpCode for CSS property to encode
Returns
CSS_OK on success, CSS_NOMEM on memory exhaustion, CSS_INVALID if the input is not valid

Post condition: *ctx is updated with the next token to process If the input is invalid, then *ctx remains unchanged.

◆ css__parse_side()

css_error css__parse_side ( css_language c,
const parserutils_vector *  vector,
int32_t *  ctx,
css_style result,
enum css_properties_e  op 
)

Parse {top,right,bottom,left}

Parameters
cParsing context
vectorVector of tokens to process
ctxPointer to vector iteration context
opOpcode to parse for
resultPointer to location to receive resulting style
Returns
CSS_OK on success, CSS_NOMEM on memory exhaustion, CSS_INVALID if the input is not valid

Post condition: *ctx is updated with the next token to process If the input is invalid, then *ctx remains unchanged.

Parse side

Parameters
cParsing context
vectorVector of tokens to process
ctxPointer to vector iteration context
resultresulting style
opBytecode OpCode for CSS property to encode
Returns
CSS_OK on success, CSS_NOMEM on memory exhaustion, CSS_INVALID if the input is not valid

Post condition: *ctx is updated with the next token to process If the input is invalid, then *ctx remains unchanged.

◆ css__parse_unit_keyword()

css_error css__parse_unit_keyword ( const char *  ptr,
size_t  len,
uint32_t *  unit 
)

Parse a unit keyword

Parameters
ptrPointer to keyword string
lenLength, in bytes, of string
unitPointer to location to receive computed unit
Returns
CSS_OK on success, CSS_INVALID on encountering an unknown keyword

◆ css__parse_unit_specifier()

css_error css__parse_unit_specifier ( css_language c,
const parserutils_vector *  vector,
int32_t *  ctx,
uint32_t  default_unit,
css_fixed length,
uint32_t *  unit 
)

Parse a unit specifier

Parameters
cParsing context
vectorVector of tokens to process
ctxPointer to current vector iteration context
default_unitThe default unit to use if none specified
lengthPointer to location to receive length
unitPointer to location to receive unit
Returns
CSS_OK on success, CSS_INVALID if the tokens do not form a valid unit

Post condition: *ctx is updated with the next token to process If the input is invalid, then *ctx remains unchanged.