From dc761c227e004f3dcbd8fa3bd8d58201762ac602 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Thu, 7 Aug 2008 08:11:51 +0000 Subject: Sketch out the internal representation of a stylesheet svn path=/trunk/libcss/; revision=4942 --- docs/Representation | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 docs/Representation (limited to 'docs') diff --git a/docs/Representation b/docs/Representation new file mode 100644 index 0000000..b4e4a89 --- /dev/null +++ b/docs/Representation @@ -0,0 +1,96 @@ +LibCSS internal stylesheet representation +========================================= + +Selector: + +struct selector { + selector_type type; /**< Type of selector */ + + struct { + const uint8_t *name; + size_t name_len; + + const uint8_t *value; + size_t value_len; + } data; /**< Selector data */ + + combinator combinator_type; /**< Type of combinator */ + struct selector *combinator; /**< Combining selector */ + + struct rule *rule; /**< Owning rule */ + + struct style *style; /**< Applicable style */ + + struct selector *chain_next; /**< Next in hash chain */ + struct selector *chain_prev; /**< Previous in hash chain */ +}; + +Rule: + +struct rule { + rule_type type; /**< Type of rule */ + + union { + struct { + uint32_t selector_count; + struct selector **selectors; + } selector; + struct { + uint32_t media; + uint32_t rule_count; + struct rule **rules; + } media; + struct { + struct style *style; + } font_face; + struct { + uint32_t selector_count; + struct selector **selectors; + struct style *style; + } page; + struct { + struct stylesheet *sheet; + } import; + struct { + char *encoding; + } charset; + } data; /**< Rule data */ + + uint32_t index; /**< Index of rule in sheet */ + + struct stylesheet *owner; /**< Owning sheet */ + + struct rule *parent; /**< Parent rule */ + struct rule *first_child; /**< First in child list */ + struct rule *last_child; /**< Last in child list */ + struct rule *next; /**< Next rule */ + struct rule *prev; /**< Previous rule */ +}; + +Stylesheet: + +struct stylesheet { +#define HASH_SIZE (37) + struct selector *selectors[HASH_SIZE]; /**< Hashtable of selectors */ + + uint32_t rule_count; /**< Number of rules in sheet */ + struct rule *rule_list; /**< List of rules in sheet */ + + bool disabled; /**< Whether this sheet is + * disabled */ + + char *url; /**< URL of this sheet */ + char *title; /**< Title of this sheet */ + + uint32_t media; /**< Bitfield of media types */ + + void *ownerNode; /**< Owning node in document */ + struct rule *ownerRule; /**< Owning rule in parent */ + + struct stylesheet *parent; /**< Parent sheet */ + struct stylesheet *first_child; /**< First in child list */ + struct stylesheet *last_child; /**< Last in child list */ + struct stylesheet *next; /**< Next in sibling list */ + struct stylesheet *prev; /**< Previous in sibling list */ +}; + -- cgit v1.2.3