libcss
Loading...
Searching...
No Matches
Classes | Typedefs | Enumerations | Functions
stylesheet.h File Reference
#include <libcss/errors.h>
#include <libcss/types.h>
#include <libcss/properties.h>

Go to the source code of this file.

Classes

struct  css_system_font
 
struct  css_stylesheet_params
 

Typedefs

typedef css_error(* css_url_resolution_fn) (void *pw, const char *base, lwc_string *rel, lwc_string **abs)
 
typedef css_error(* css_import_notification_fn) (void *pw, css_stylesheet *parent, lwc_string *url)
 
typedef css_error(* css_color_resolution_fn) (void *pw, lwc_string *name, css_color *color)
 
typedef struct css_system_font css_system_font
 
typedef css_error(* css_font_resolution_fn) (void *pw, lwc_string *name, css_system_font *system_font)
 
typedef enum css_stylesheet_params_version css_stylesheet_params_version
 
typedef struct css_stylesheet_params css_stylesheet_params
 

Enumerations

enum  css_stylesheet_params_version { CSS_STYLESHEET_PARAMS_VERSION_1 = 1 }
 

Functions

css_error css_stylesheet_create (const css_stylesheet_params *params, css_stylesheet **stylesheet)
 
css_error css_stylesheet_destroy (css_stylesheet *sheet)
 
css_error css_stylesheet_append_data (css_stylesheet *sheet, const uint8_t *data, size_t len)
 
css_error css_stylesheet_data_done (css_stylesheet *sheet)
 
css_error css_stylesheet_next_pending_import (css_stylesheet *parent, lwc_string **url)
 
css_error css_stylesheet_register_import (css_stylesheet *parent, css_stylesheet *child)
 
css_error css_stylesheet_get_language_level (css_stylesheet *sheet, css_language_level *level)
 
css_error css_stylesheet_get_url (css_stylesheet *sheet, const char **url)
 
css_error css_stylesheet_get_title (css_stylesheet *sheet, const char **title)
 
css_error css_stylesheet_quirks_allowed (css_stylesheet *sheet, bool *allowed)
 
css_error css_stylesheet_used_quirks (css_stylesheet *sheet, bool *quirks)
 
css_error css_stylesheet_get_disabled (css_stylesheet *sheet, bool *disabled)
 
css_error css_stylesheet_set_disabled (css_stylesheet *sheet, bool disabled)
 
css_error css_stylesheet_size (css_stylesheet *sheet, size_t *size)
 

Typedef Documentation

◆ css_color_resolution_fn

typedef css_error(* css_color_resolution_fn) (void *pw, lwc_string *name, css_color *color)

Callback use to resolve system colour names to RGB values

Parameters
pwClient data
nameSystem colour name
colorPointer to location to receive color value
Returns
CSS_OK on success, CSS_INVALID if the name is unknown.

◆ css_font_resolution_fn

typedef css_error(* css_font_resolution_fn) (void *pw, lwc_string *name, css_system_font *system_font)

Callback use to resolve system font names to font values

Parameters
pwClient data
nameSystem font identifier
system_fontPointer to system font descriptor to be filled
Returns
CSS_OK on success, CSS_INVALID if the name is unknown.

◆ css_import_notification_fn

typedef css_error(* css_import_notification_fn) (void *pw, css_stylesheet *parent, lwc_string *url)

Callback to be notified of the need for an imported stylesheet

Parameters
pwClient data
parentStylesheet requesting the import
urlURL of the imported sheet
Returns
CSS_OK on success, appropriate error otherwise
Note
This function will be invoked for notification purposes only. The client may use this to trigger a parallel fetch of the imported stylesheet. The imported sheet must be registered with its parent using the post-parse import registration API.

◆ css_stylesheet_params

Parameter block for css_stylesheet_create()

◆ css_stylesheet_params_version

◆ css_system_font

System font callback result data.

◆ css_url_resolution_fn

typedef css_error(* css_url_resolution_fn) (void *pw, const char *base, lwc_string *rel, lwc_string **abs)

Callback to resolve an URL

Parameters
pwClient data
dictString internment context
baseBase URI (absolute)
relURL to resolve, either absolute or relative to base
absPointer to location to receive result
Returns
CSS_OK on success, appropriate error otherwise.

Enumeration Type Documentation

◆ css_stylesheet_params_version

Enumerator
CSS_STYLESHEET_PARAMS_VERSION_1 

Function Documentation

◆ css_stylesheet_append_data()

css_error css_stylesheet_append_data ( css_stylesheet sheet,
const uint8_t *  data,
size_t  len 
)

Append source data to a stylesheet

Parameters
sheetThe stylesheet to append data to
dataPointer to data to append
lenLength, in bytes, of data to append
Returns
CSS_OK on success, appropriate error otherwise

◆ css_stylesheet_create()

css_error css_stylesheet_create ( const css_stylesheet_params params,
css_stylesheet **  stylesheet 
)

Create a stylesheet

Parameters
paramsStylesheet parameters
stylesheetPointer to location to receive stylesheet
Returns
CSS_OK on success, CSS_BADPARM on bad parameters, CSS_NOMEM on memory exhaustion

◆ css_stylesheet_data_done()

css_error css_stylesheet_data_done ( css_stylesheet sheet)

Flag that the last of a stylesheet's data has been seen

Parameters
sheetThe stylesheet in question
Returns
CSS_OK on success, CSS_IMPORTS_PENDING if there are imports pending, appropriate error otherwise

◆ css_stylesheet_destroy()

css_error css_stylesheet_destroy ( css_stylesheet sheet)

Destroy a stylesheet

Parameters
sheetThe stylesheet to destroy
Returns
CSS_OK on success, appropriate error otherwise

◆ css_stylesheet_get_disabled()

css_error css_stylesheet_get_disabled ( css_stylesheet sheet,
bool *  disabled 
)

Get disabled status of a stylesheet

Parameters
sheetThe stylesheet to consider
disabledPointer to location to receive disabled state
Returns
CSS_OK on success, appropriate error otherwise

◆ css_stylesheet_get_language_level()

css_error css_stylesheet_get_language_level ( css_stylesheet sheet,
css_language_level level 
)

Retrieve the language level of a stylesheet

Parameters
sheetThe stylesheet to retrieve the language level of
levelPointer to location to receive language level
Returns
CSS_OK on success, appropriate error otherwise

◆ css_stylesheet_get_title()

css_error css_stylesheet_get_title ( css_stylesheet sheet,
const char **  title 
)

Retrieve the title associated with a stylesheet

Parameters
sheetThe stylesheet to retrieve the title from
titlePointer to location to receive pointer to title
Returns
CSS_Ok on success, appropriate error otherwise

◆ css_stylesheet_get_url()

css_error css_stylesheet_get_url ( css_stylesheet sheet,
const char **  url 
)

Retrieve the URL associated with a stylesheet

Parameters
sheetThe stylesheet to retrieve the URL from
urlPointer to location to receive pointer to URL
Returns
CSS_OK on success, appropriate error otherwise

◆ css_stylesheet_next_pending_import()

css_error css_stylesheet_next_pending_import ( css_stylesheet parent,
lwc_string **  url 
)

Retrieve the next pending import for the parent stylesheet

Parameters
parentParent stylesheet
urlPointer to object to be populated with details of URL of imported stylesheet (potentially relative)
Returns
CSS_OK on success, CSS_INVALID if there are no pending imports remaining

The client must resolve the absolute URL of the imported stylesheet, using the parent's URL as the base. It must then fetch the imported stylesheet, and parse it to completion, including fetching any stylesheets it may import. The resultant sheet must then be registered with the parent using css_stylesheet_register_import().

The client must then call this function again, to determine if there are any further imports for the parent stylesheet, and, if so, process them as described above.

If the client is unable to fetch an imported stylesheet, it must register an empty stylesheet with the parent in its place.

◆ css_stylesheet_quirks_allowed()

css_error css_stylesheet_quirks_allowed ( css_stylesheet sheet,
bool *  allowed 
)

Determine whether quirky parsing was permitted on a stylesheet

Parameters
sheetThe stylesheet to consider
quirksPointer to location to receive quirkyness
Returns
CSS_OK on success, appropriate error otherwise

◆ css_stylesheet_register_import()

css_error css_stylesheet_register_import ( css_stylesheet parent,
css_stylesheet import 
)

Register an imported stylesheet with its parent

Parameters
parentParent stylesheet
importImported sheet
Returns
CSS_OK on success, CSS_INVALID if there are no outstanding imports, appropriate error otherwise.

Ownership of the imported stylesheet is retained by the client.

◆ css_stylesheet_set_disabled()

css_error css_stylesheet_set_disabled ( css_stylesheet sheet,
bool  disabled 
)

Set a stylesheet's disabled state

Parameters
sheetThe stylesheet to modify
disabledThe new disabled state
Returns
CSS_OK on success, appropriate error otherwise
Todo:
needs to trigger some event announcing styles have changed

◆ css_stylesheet_size()

css_error css_stylesheet_size ( css_stylesheet sheet,
size_t *  size 
)

Determine the memory-resident size of a stylesheet

Parameters
sheetSheet to consider
sizePointer to location to receive byte count
Returns
CSS_OK on success.
Note
The returned size will not include the size of interned strings or imported stylesheets.

◆ css_stylesheet_used_quirks()

css_error css_stylesheet_used_quirks ( css_stylesheet sheet,
bool *  quirks 
)

Determine whether quirky parsing was used on a stylesheet

Parameters
sheetThe stylesheet to consider
quirksPointer to location to receive quirkyness
Returns
CSS_OK on success, appropriate error otherwise