#include <inttypes.h>
#include <stdio.h>
#include <libwapcaplet/libwapcaplet.h>
#include <libcss/errors.h>
#include <libcss/functypes.h>
#include <libcss/stylesheet.h>
#include <libcss/types.h>
#include "bytecode/bytecode.h"
#include "parse/parse.h"
#include "parse/mq.h"
#include "select/hash.h"
Go to the source code of this file.
|
| enum | css_selector_type {
CSS_SELECTOR_ELEMENT
, CSS_SELECTOR_CLASS
, CSS_SELECTOR_ID
, CSS_SELECTOR_PSEUDO_CLASS
,
CSS_SELECTOR_PSEUDO_ELEMENT
, CSS_SELECTOR_ATTRIBUTE
, CSS_SELECTOR_ATTRIBUTE_EQUAL
, CSS_SELECTOR_ATTRIBUTE_DASHMATCH
,
CSS_SELECTOR_ATTRIBUTE_INCLUDES
, CSS_SELECTOR_ATTRIBUTE_PREFIX
, CSS_SELECTOR_ATTRIBUTE_SUFFIX
, CSS_SELECTOR_ATTRIBUTE_SUBSTRING
} |
| |
| enum | css_combinator {
CSS_COMBINATOR_NONE
, CSS_COMBINATOR_ANCESTOR
, CSS_COMBINATOR_PARENT
, CSS_COMBINATOR_SIBLING
,
CSS_COMBINATOR_GENERIC_SIBLING
} |
| |
| enum | css_selector_detail_value_type { CSS_SELECTOR_DETAIL_VALUE_STRING
, CSS_SELECTOR_DETAIL_VALUE_NTH
} |
| |
| enum | css_rule_type {
CSS_RULE_UNKNOWN
, CSS_RULE_SELECTOR
, CSS_RULE_CHARSET
, CSS_RULE_IMPORT
,
CSS_RULE_MEDIA
, CSS_RULE_FONT_FACE
, CSS_RULE_PAGE
} |
| |
| enum | css_rule_parent_type { CSS_RULE_PARENT_STYLESHEET
, CSS_RULE_PARENT_RULE
} |
| |
|
| css_error | css__stylesheet_style_create (css_stylesheet *sheet, css_style **style) |
| |
| css_error | css__stylesheet_style_append (css_style *style, css_code_t code) |
| |
| css_error | css__stylesheet_style_vappend (css_style *style, uint32_t style_count,...) |
| |
| css_error | css__stylesheet_style_destroy (css_style *style) |
| |
| css_error | css__stylesheet_merge_style (css_style *target, css_style *style) |
| |
| css_error | css__stylesheet_selector_create (css_stylesheet *sheet, css_qname *qname, css_selector **selector) |
| |
| css_error | css__stylesheet_selector_destroy (css_stylesheet *sheet, css_selector *selector) |
| |
| 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) |
| |
| css_error | css__stylesheet_selector_append_specific (css_stylesheet *sheet, css_selector **parent, const css_selector_detail *specific) |
| |
| css_error | css__stylesheet_selector_combine (css_stylesheet *sheet, css_combinator type, css_selector *a, css_selector *b) |
| |
| css_error | css__stylesheet_rule_create (css_stylesheet *sheet, css_rule_type type, css_rule **rule) |
| |
| css_error | css__stylesheet_rule_destroy (css_stylesheet *sheet, css_rule *rule) |
| |
| css_error | css__stylesheet_rule_add_selector (css_stylesheet *sheet, css_rule *rule, css_selector *selector) |
| |
| css_error | css__stylesheet_rule_append_style (css_stylesheet *sheet, css_rule *rule, css_style *style) |
| |
| css_error | css__stylesheet_rule_set_charset (css_stylesheet *sheet, css_rule *rule, lwc_string *charset) |
| |
| css_error | css__stylesheet_rule_set_nascent_import (css_stylesheet *sheet, css_rule *rule, lwc_string *url, css_mq_query *media) |
| |
| css_error | css__stylesheet_rule_set_media (css_stylesheet *sheet, css_rule *rule, css_mq_query *media) |
| |
| css_error | css__stylesheet_rule_set_page_selector (css_stylesheet *sheet, css_rule *rule, css_selector *sel) |
| |
| css_error | css__stylesheet_add_rule (css_stylesheet *sheet, css_rule *rule, css_rule *parent) |
| |
| css_error | css__stylesheet_remove_rule (css_stylesheet *sheet, css_rule *rule) |
| |
| css_error | css__stylesheet_string_get (css_stylesheet *sheet, uint32_t string_number, lwc_string **string) |
| |
| css_error | css__stylesheet_string_add (css_stylesheet *sheet, lwc_string *string, uint32_t *string_number) |
| |
◆ CSS_SPECIFICITY_A
| #define CSS_SPECIFICITY_A 0x01000000 |
◆ CSS_SPECIFICITY_B
| #define CSS_SPECIFICITY_B 0x00010000 |
◆ CSS_SPECIFICITY_C
| #define CSS_SPECIFICITY_C 0x00000100 |
◆ CSS_SPECIFICITY_D
| #define CSS_SPECIFICITY_D 0x00000001 |
◆ css_combinator
◆ css_rule
◆ css_rule_charset
◆ css_rule_font_face
◆ css_rule_import
◆ css_rule_media
◆ css_rule_page
◆ css_rule_parent_type
◆ css_rule_selector
◆ css_rule_type
◆ css_selector
◆ css_selector_detail
◆ css_selector_detail_value
◆ css_selector_detail_value_type
◆ css_selector_type
◆ css_style
◆ css_combinator
| Enumerator |
|---|
| CSS_COMBINATOR_NONE | |
| CSS_COMBINATOR_ANCESTOR | |
| CSS_COMBINATOR_PARENT | |
| CSS_COMBINATOR_SIBLING | |
| CSS_COMBINATOR_GENERIC_SIBLING | |
◆ css_rule_parent_type
| Enumerator |
|---|
| CSS_RULE_PARENT_STYLESHEET | |
| CSS_RULE_PARENT_RULE | |
◆ css_rule_type
| Enumerator |
|---|
| CSS_RULE_UNKNOWN | |
| CSS_RULE_SELECTOR | |
| CSS_RULE_CHARSET | |
| CSS_RULE_IMPORT | |
| CSS_RULE_MEDIA | |
| CSS_RULE_FONT_FACE | |
| CSS_RULE_PAGE | |
◆ css_selector_detail_value_type
| Enumerator |
|---|
| CSS_SELECTOR_DETAIL_VALUE_STRING | |
| CSS_SELECTOR_DETAIL_VALUE_NTH | |
◆ css_selector_type
| Enumerator |
|---|
| CSS_SELECTOR_ELEMENT | |
| CSS_SELECTOR_CLASS | |
| CSS_SELECTOR_ID | |
| CSS_SELECTOR_PSEUDO_CLASS | |
| CSS_SELECTOR_PSEUDO_ELEMENT | |
| CSS_SELECTOR_ATTRIBUTE | |
| CSS_SELECTOR_ATTRIBUTE_EQUAL | |
| CSS_SELECTOR_ATTRIBUTE_DASHMATCH | |
| CSS_SELECTOR_ATTRIBUTE_INCLUDES | |
| CSS_SELECTOR_ATTRIBUTE_PREFIX | |
| CSS_SELECTOR_ATTRIBUTE_SUFFIX | |
| CSS_SELECTOR_ATTRIBUTE_SUBSTRING | |
◆ css__stylesheet_add_rule()
Add a rule to a stylesheet
- Parameters
-
| sheet | The stylesheet to add to |
| rule | The rule to add |
| parent | The parent rule, or NULL for a top-level rule |
- Returns
- CSS_OK on success, appropriate error otherwise
- Todo:
- needs to trigger some event announcing styles have changed
◆ css__stylesheet_merge_style()
◆ css__stylesheet_remove_rule()
Remove a rule from a stylesheet
- Parameters
-
| sheet | The sheet to remove from |
| rule | The rule to remove |
- Returns
- CSS_OK on success, appropriate error otherwise
\ 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.
- Todo:
- needs to trigger some event announcing styles have changed
◆ css__stylesheet_rule_add_selector()
Add a selector to a CSS rule
- Parameters
-
| sheet | The stylesheet context |
| rule | The rule to add to (must be of type CSS_RULE_SELECTOR) |
| selector | The selector to add |
- Returns
- CSS_OK on success, appropriate error otherwise
◆ css__stylesheet_rule_append_style()
Append a style to a CSS rule
- Parameters
-
| sheet | The stylesheet context |
| rule | The rule to add to (must be CSS_RULE_SELECTOR or CSS_RULE_PAGE) |
| style | The style to add |
- Returns
- CSS_OK on success, appropriate error otherwise
◆ css__stylesheet_rule_create()
Create a CSS rule
- Parameters
-
| sheet | The stylesheet context |
| type | The rule type |
| rule | Pointer to location to receive rule object |
- Returns
- CSS_OK on success, CSS_BADPARM on bad parameters, CSS_NOMEM on memory exhaustion
◆ css__stylesheet_rule_destroy()
Destroy a CSS rule
- Parameters
-
| sheet | The stylesheet context |
| rule | The rule to destroy |
- Returns
- CSS_OK on success, appropriate error otherwise
◆ css__stylesheet_rule_set_charset()
Set the charset of a CSS rule
- Parameters
-
| sheet | The stylesheet context |
| rule | The rule to add to (must be of type CSS_RULE_CHARSET) |
| charset | The charset |
- Returns
- CSS_OK on success, appropriate error otherwise
◆ css__stylesheet_rule_set_media()
Set the media of an @media rule
- Parameters
-
| 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 |
- Returns
- CSS_OK on success, appropriate error otherwise
◆ css__stylesheet_rule_set_nascent_import()
Set the necessary data to import a stylesheet associated with a rule
- Parameters
-
| 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 |
- Returns
- CSS_OK on success, appropriate error otherwise
◆ css__stylesheet_rule_set_page_selector()
◆ css__stylesheet_selector_append_specific()
Append a selector to the specifics chain of another selector
- Parameters
-
| sheet | The stylesheet context |
| parent | Pointer to pointer to the parent selector (updated on exit) |
| specific | The selector to append (copied) |
- Returns
- CSS_OK on success, appropriate error otherwise.
- Todo:
- this may want optimising – counting blocks is O(n) In practice, however, n isn't likely to be large, so may be fine
◆ css__stylesheet_selector_combine()
Combine a pair of selectors
- Parameters
-
| sheet | The stylesheet context |
| type | The combinator type |
| a | The first operand |
| b | The second operand |
- Returns
- CSS_OK on success, appropriate error otherwise.
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__stylesheet_selector_create()
Create an element selector
- Parameters
-
| sheet | The stylesheet context |
| qname | Qualified name of selector |
| selector | Pointer to location to receive selector object |
- Returns
- CSS_OK on success, CSS_BADPARM on bad parameters, CSS_NOMEM on memory exhaustion
◆ css__stylesheet_selector_destroy()
Destroy a selector object
- Parameters
-
| sheet | The stylesheet context |
| selector | The selector to destroy |
- Returns
- CSS_OK on success, appropriate error otherwise
◆ css__stylesheet_selector_detail_init()
Initialise a selector detail
- Parameters
-
| 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 |
- Returns
- CSS_OK on success, CSS_BADPARM on bad parameters
- Note
- No strings are referenced at this point: they will be referenced when appending the detail to a selector.
◆ css__stylesheet_string_add()
Add a string to a stylesheet's string vector.
- Parameters
-
| sheet | The stylesheet to add string to. |
| string | The string to add. |
| string_number | Pointer to location to receive string number. |
- Returns
- CSS_OK on success, CSS_BADPARM on bad parameters, CSS_NOMEM on memory exhaustion
- Postcondition
- Ownership of string reference is passed to the stylesheet (even on failure)
- Note
- The returned string number is guaranteed to be non-zero
◆ css__stylesheet_string_get()
Get a string from a stylesheet's string vector.
- Parameters
-
| sheet | The stylesheet to retrive string from. |
| string_number | The string number to retrive. |
| string | Pointer to location to receive string. |
- Returns
- CSS_OK on success, CSS_BADPARM on bad parameters,
◆ css__stylesheet_style_append()
append a css code entry to a style
◆ css__stylesheet_style_create()
Create a style
- Parameters
-
| sheet | The stylesheet context |
| len | The required length of the style |
| style | Pointer to location to receive style |
- Returns
- CSS_OK on success, CSS_BADPARM on bad parameters, CSS_NOMEM on memory exhaustion
◆ css__stylesheet_style_destroy()
Destroy a style
- Parameters
-
| sheet | The stylesheet context |
| style | The style to destroy |
- Returns
- CSS_OK on success, appropriate error otherwise
◆ css__stylesheet_style_vappend()
append one or more css code entries to a style
◆ _ALIGNED