|
libcss
|
#include <assert.h>#include <string.h>#include <stdarg.h>#include "stylesheet.h"#include "bytecode/bytecode.h"#include "parse/language.h"#include "parse/mq.h"#include "utils/parserutilserror.h"#include "utils/utils.h"#include "select/dispatch.h"#include "select/font_face.h"Macros | |
| #define | CSS_STYLE_DEFAULT_SIZE 16 |
| #define CSS_STYLE_DEFAULT_SIZE 16 |
| css_error css__stylesheet_add_rule | ( | css_stylesheet * | sheet, |
| css_rule * | rule, | ||
| css_rule * | parent | ||
| ) |
Add a rule to a stylesheet
| sheet | The stylesheet to add to |
| rule | The rule to add |
| parent | The parent rule, or NULL for a top-level rule |
| css_error css__stylesheet_remove_rule | ( | css_stylesheet * | sheet, |
| css_rule * | rule | ||
| ) |
Remove a rule from a stylesheet
| sheet | The sheet to remove from |
| rule | The rule to remove |
\ todo renumber subsequent rules? may not be necessary, as there's only an expectation that rules which occur later in the stylesheet have a higher index than those that appear earlier. There's no guarantee that the number space is continuous.
| css_error css__stylesheet_rule_add_selector | ( | css_stylesheet * | sheet, |
| css_rule * | rule, | ||
| css_selector * | selector | ||
| ) |
Add a selector to a CSS rule
| sheet | The stylesheet context |
| rule | The rule to add to (must be of type CSS_RULE_SELECTOR) |
| selector | The selector to add |
| css_error css__stylesheet_rule_append_style | ( | css_stylesheet * | sheet, |
| css_rule * | rule, | ||
| css_style * | style | ||
| ) |
Append a style to a CSS rule
| sheet | The stylesheet context |
| rule | The rule to add to (must be CSS_RULE_SELECTOR or CSS_RULE_PAGE) |
| style | The style to add |
| css_error css__stylesheet_rule_create | ( | css_stylesheet * | sheet, |
| css_rule_type | type, | ||
| css_rule ** | rule | ||
| ) |
Create a CSS rule
| sheet | The stylesheet context |
| type | The rule type |
| rule | Pointer to location to receive rule object |
| css_error css__stylesheet_rule_destroy | ( | css_stylesheet * | sheet, |
| css_rule * | rule | ||
| ) |
Destroy a CSS rule
| sheet | The stylesheet context |
| rule | The rule to destroy |
| css_error css__stylesheet_rule_set_charset | ( | css_stylesheet * | sheet, |
| css_rule * | rule, | ||
| lwc_string * | charset | ||
| ) |
Set the charset of a CSS rule
| sheet | The stylesheet context |
| rule | The rule to add to (must be of type CSS_RULE_CHARSET) |
| charset | The charset |
| css_error css__stylesheet_rule_set_media | ( | css_stylesheet * | sheet, |
| css_rule * | rule, | ||
| css_mq_query * | media | ||
| ) |
Set the media of an @media rule
| sheet | The stylesheet context |
| rule | The rule to add to (must be of type CSS_RULE_MEDIA) |
| media | The applicable media types for the rule |
| css_error css__stylesheet_rule_set_nascent_import | ( | css_stylesheet * | sheet, |
| css_rule * | rule, | ||
| lwc_string * | url, | ||
| css_mq_query * | media | ||
| ) |
Set the necessary data to import a stylesheet associated with a rule
| sheet | The stylesheet context |
| rule | The rule to add to (must be of type CSS_RULE_IMPORT) |
| url | The URL of the imported stylesheet |
| media | The applicable media types for the imported stylesheet |
| css_error css__stylesheet_rule_set_page_selector | ( | css_stylesheet * | sheet, |
| css_rule * | rule, | ||
| css_selector * | selector | ||
| ) |
| css_error css__stylesheet_selector_append_specific | ( | css_stylesheet * | sheet, |
| css_selector ** | parent, | ||
| const css_selector_detail * | detail | ||
| ) |
Append a selector to the specifics chain of another selector
| sheet | The stylesheet context |
| parent | Pointer to pointer to the parent selector (updated on exit) |
| specific | The selector to append (copied) |
| css_error css__stylesheet_selector_combine | ( | css_stylesheet * | sheet, |
| css_combinator | type, | ||
| css_selector * | a, | ||
| css_selector * | b | ||
| ) |
Combine a pair of selectors
| sheet | The stylesheet context |
| type | The combinator type |
| a | The first operand |
| b | The second operand |
For example, given A + B, the combinator field of B would point at A, with a combinator type of CSS_COMBINATOR_SIBLING. Thus, given B, we can find its combinator. It is not possible to find B given A.
| css_error css__stylesheet_selector_create | ( | css_stylesheet * | sheet, |
| css_qname * | qname, | ||
| css_selector ** | selector | ||
| ) |
Create an element selector
| sheet | The stylesheet context |
| qname | Qualified name of selector |
| selector | Pointer to location to receive selector object |
| css_error css__stylesheet_selector_destroy | ( | css_stylesheet * | sheet, |
| css_selector * | selector | ||
| ) |
Destroy a selector object
| sheet | The stylesheet context |
| selector | The selector to destroy |
| css_error css__stylesheet_selector_detail_init | ( | css_stylesheet * | sheet, |
| css_selector_type | type, | ||
| css_qname * | qname, | ||
| css_selector_detail_value | value, | ||
| css_selector_detail_value_type | value_type, | ||
| bool | negate, | ||
| css_selector_detail * | detail | ||
| ) |
Initialise a selector detail
| sheet | The stylesheet context |
| type | The type of selector to create |
| qname | Qualified name of selector |
| value | Value of selector |
| value_type | Type of value |
| negate | Whether the detail match should be negated |
| detail | Pointer to detail object to initialise |
| css_error css__stylesheet_string_add | ( | css_stylesheet * | sheet, |
| lwc_string * | string, | ||
| uint32_t * | string_number | ||
| ) |
Add a string to a stylesheet's string vector.
| sheet | The stylesheet to add string to. |
| string | The string to add. |
| string_number | Pointer to location to receive string number. |
| css_error css__stylesheet_string_get | ( | css_stylesheet * | sheet, |
| uint32_t | string_number, | ||
| lwc_string ** | string | ||
| ) |
Get a string from a stylesheet's string vector.
| sheet | The stylesheet to retrive string from. |
| string_number | The string number to retrive. |
| string | Pointer to location to receive string. |
| css_error css__stylesheet_style_append | ( | css_style * | style, |
| css_code_t | css_code | ||
| ) |
append a css code entry to a style
| css_error css__stylesheet_style_create | ( | css_stylesheet * | sheet, |
| css_style ** | style | ||
| ) |
Create a style
| sheet | The stylesheet context |
| len | The required length of the style |
| style | Pointer to location to receive style |
Destroy a style
| sheet | The stylesheet context |
| style | The style to destroy |
append one or more css code entries to a style
| css_error css_stylesheet_append_data | ( | css_stylesheet * | sheet, |
| const uint8_t * | data, | ||
| size_t | len | ||
| ) |
Append source data to a stylesheet
| sheet | The stylesheet to append data to |
| data | Pointer to data to append |
| len | Length, in bytes, of data to append |
| css_error css_stylesheet_create | ( | const css_stylesheet_params * | params, |
| css_stylesheet ** | stylesheet | ||
| ) |
Create a stylesheet
| params | Stylesheet parameters |
| stylesheet | Pointer to location to receive stylesheet |
| css_error css_stylesheet_data_done | ( | css_stylesheet * | sheet | ) |
Flag that the last of a stylesheet's data has been seen
| sheet | The stylesheet in question |
| css_error css_stylesheet_destroy | ( | css_stylesheet * | sheet | ) |
Destroy a stylesheet
| sheet | The stylesheet to destroy |
| css_error css_stylesheet_get_disabled | ( | css_stylesheet * | sheet, |
| bool * | disabled | ||
| ) |
Get disabled status of a stylesheet
| sheet | The stylesheet to consider |
| disabled | Pointer to location to receive disabled state |
| css_error css_stylesheet_get_language_level | ( | css_stylesheet * | sheet, |
| css_language_level * | level | ||
| ) |
Retrieve the language level of a stylesheet
| sheet | The stylesheet to retrieve the language level of |
| level | Pointer to location to receive language level |
| css_error css_stylesheet_get_title | ( | css_stylesheet * | sheet, |
| const char ** | title | ||
| ) |
Retrieve the title associated with a stylesheet
| sheet | The stylesheet to retrieve the title from |
| title | Pointer to location to receive pointer to title |
| css_error css_stylesheet_get_url | ( | css_stylesheet * | sheet, |
| const char ** | url | ||
| ) |
Retrieve the URL associated with a stylesheet
| sheet | The stylesheet to retrieve the URL from |
| url | Pointer to location to receive pointer to URL |
| css_error css_stylesheet_next_pending_import | ( | css_stylesheet * | parent, |
| lwc_string ** | url | ||
| ) |
Retrieve the next pending import for the parent stylesheet
| parent | Parent stylesheet |
| url | Pointer to object to be populated with details of URL of imported stylesheet (potentially relative) |
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_error css_stylesheet_quirks_allowed | ( | css_stylesheet * | sheet, |
| bool * | allowed | ||
| ) |
Determine whether quirky parsing was permitted on a stylesheet
| sheet | The stylesheet to consider |
| quirks | Pointer to location to receive quirkyness |
| css_error css_stylesheet_register_import | ( | css_stylesheet * | parent, |
| css_stylesheet * | import | ||
| ) |
Register an imported stylesheet with its parent
| parent | Parent stylesheet |
| import | Imported sheet |
Ownership of the imported stylesheet is retained by the client.
| css_error css_stylesheet_set_disabled | ( | css_stylesheet * | sheet, |
| bool | disabled | ||
| ) |
Set a stylesheet's disabled state
| sheet | The stylesheet to modify |
| disabled | The new disabled state |
| css_error css_stylesheet_size | ( | css_stylesheet * | sheet, |
| size_t * | size | ||
| ) |
Determine the memory-resident size of a stylesheet
| sheet | Sheet to consider |
| size | Pointer to location to receive byte count |
| css_error css_stylesheet_used_quirks | ( | css_stylesheet * | sheet, |
| bool * | quirks | ||
| ) |
Determine whether quirky parsing was used on a stylesheet
| sheet | The stylesheet to consider |
| quirks | Pointer to location to receive quirkyness |