summaryrefslogtreecommitdiff
path: root/src/stylesheet.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2008-10-25 01:24:03 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2008-10-25 01:24:03 +0000
commit5caf9a56956f55b70d937cea7e135417bada7b25 (patch)
tree1fec329c7b8133c3ef4b76b18ae48fb161f94c71 /src/stylesheet.c
parentc8e73871f9006987983fd1010d97b6168c13f6a3 (diff)
downloadlibcss-5caf9a56956f55b70d937cea7e135417bada7b25.tar.gz
libcss-5caf9a56956f55b70d937cea7e135417bada7b25.tar.bz2
A bunch of property parsers.
Split out !important parsing into a separate function. Support for dumping bytecode to a file handle in some kind of human-readable format. Strings can be represented in the bytecode as a pointer, length pair rather than embedding the string data into the bytecode -- all strings are interned by the core syntax parser. Add todo relating to early destruction of parser object (it shouldn't be needed once parsing is complete). Note documented issue surrounding interned string dictionary, however. In general, it seems wasteful to create a new dictionary containing string representations of keywords for every single parser instance. It would be better to have one central (statically allocated?) dictionary for this and then each parser instance can have a smaller dictionary containing any unknown strings contained within the stylesheet being parsed (e.g. string constants or URLs). svn path=/trunk/libcss/; revision=5627
Diffstat (limited to 'src/stylesheet.c')
-rw-r--r--src/stylesheet.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/stylesheet.c b/src/stylesheet.c
index 7a093f9..7608b16 100644
--- a/src/stylesheet.c
+++ b/src/stylesheet.c
@@ -8,6 +8,7 @@
#include <string.h>
#include "stylesheet.h"
+#include "bytecode/bytecode.h"
#include "parse/css21.h"
#include "utils/utils.h"
@@ -158,6 +159,13 @@ css_error css_stylesheet_data_done(css_stylesheet *sheet)
return CSS_BADPARM;
return css_parser_completed(sheet->parser);
+
+ /** \todo We can destroy the parser here as it won't be needed
+ * Note, however, that, if we do so, then the dictionary of
+ * strings created by the parser *must* be preserved (and, ideally,
+ * created by us in the first place) because our stylesheet
+ * datastructures contain pointers to strings stored in this
+ * dictionary. */
}
/**
@@ -531,6 +539,9 @@ css_error css_stylesheet_rule_append_style(css_stylesheet *sheet,
if (temp == NULL)
return CSS_NOMEM;
+ /* Ensure bytecode pointer is correct */
+ temp->bytecode = ((uint8_t *) temp + sizeof(css_style));
+
/** \todo Can we optimise the bytecode here? */
memcpy((uint8_t *) temp->bytecode + temp->length,
style->bytecode, style->length);
@@ -666,6 +677,12 @@ void css_stylesheet_dump_rule(css_rule *rule, FILE *target)
if (i != rule->data.selector.selector_count - 1)
fprintf(target, ", ");
}
+ fprintf(target, " { ");
+ if (rule->data.selector.style != NULL) {
+ css_bytecode_dump(rule->data.selector.style->bytecode,
+ rule->data.selector.style->length, target);
+ }
+ fprintf(target, "}");
break;
case CSS_RULE_CHARSET:
case CSS_RULE_IMPORT: