summaryrefslogtreecommitdiff
path: root/src/stylesheet.h
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2008-11-27 12:14:07 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2008-11-27 12:14:07 +0000
commit7adaf92154adc7f3455769ca197f906e3d4cddaa (patch)
treeae172720c8e44a35b87b5506602768db19ec538f /src/stylesheet.h
parent79c0f3bc5c1581a6f2f6568a50e3b4f64b452541 (diff)
downloadlibcss-7adaf92154adc7f3455769ca197f906e3d4cddaa.tar.gz
libcss-7adaf92154adc7f3455769ca197f906e3d4cddaa.tar.bz2
css_string is now the same as a parserutils_dict_entry. This allows us to use dict entries directly as strings.
iChange the way in which selectors are represented. This significantly reduces memory requirements -- reducing the approximate usage count (excludes the string dictionary, which is about 360k) of allzengarden.css from 4,535,400 bytes to 2,414,312 bytes on a 64bit platform. The string dictionary is now created and owned by the stylesheet object. The parser is just given access to this so that it can store strings in it. svn path=/trunk/libcss/; revision=5809
Diffstat (limited to 'src/stylesheet.h')
-rw-r--r--src/stylesheet.h36
1 files changed, 23 insertions, 13 deletions
diff --git a/src/stylesheet.h b/src/stylesheet.h
index cedc3de..c5c2812 100644
--- a/src/stylesheet.h
+++ b/src/stylesheet.h
@@ -11,6 +11,8 @@
#include <inttypes.h>
#include <stdio.h>
+#include <parserutils/utils/dict.h>
+
#include <libcss/errors.h>
#include <libcss/functypes.h>
#include <libcss/stylesheet.h>
@@ -45,24 +47,24 @@ typedef enum css_combinator {
CSS_COMBINATOR_SIBLING
} css_combinator;
-struct css_selector {
- css_selector_type type; /**< Type of selector */
+typedef struct css_selector_detail {
+ const css_string *name; /**< Interned name */
+ const css_string *value; /**< Interned value, or NULL */
- struct {
- css_string name;
- css_string value;
- } data; /**< Selector data */
+ uint32_t type : 4, /**< Type of selector */
+ comb : 2, /**< Type of combinator */
+ next : 1; /**< Another selector detail
+ * follows */
+} css_selector_detail;
- uint32_t specificity; /**< Specificity of selector */
- css_selector *specifics; /**< Selector specifics */
-
- css_combinator combinator_type; /**< Type of combinator */
+struct css_selector {
css_selector *combinator; /**< Combining selector */
css_rule *rule; /**< Owning rule */
- css_selector *next; /**< Next selector in list */
- css_selector *prev; /**< Previous selector */
+ uint32_t specificity; /**< Specificity of selector */
+
+ css_selector_detail data; /**< Selector data */
};
typedef enum css_rule_type {
@@ -149,6 +151,8 @@ struct css_stylesheet {
css_parser *parser; /**< Core parser for sheet */
void *parser_frontend; /**< Frontend parser */
+ parserutils_dict *dictionary; /**< String dictionary */
+
css_alloc alloc; /**< Allocation function */
void *pw; /**< Private word */
};
@@ -163,8 +167,14 @@ css_error css_stylesheet_selector_create(css_stylesheet *sheet,
css_error css_stylesheet_selector_destroy(css_stylesheet *sheet,
css_selector *selector);
+css_error css_stylesheet_selector_detail_create(css_stylesheet *sheet,
+ css_selector_type type, const css_string *name,
+ const css_string *value, css_selector_detail **detail);
+css_error css_stylesheet_selector_detail_destroy(css_stylesheet *sheet,
+ css_selector_detail *detail);
+
css_error css_stylesheet_selector_append_specific(css_stylesheet *sheet,
- css_selector *parent, css_selector *specific);
+ css_selector **parent, css_selector_detail *specific);
css_error css_stylesheet_selector_combine(css_stylesheet *sheet,
css_combinator type, css_selector *a, css_selector *b);