summaryrefslogtreecommitdiff
path: root/src/stylesheet.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-01-26 15:42:12 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-01-26 15:42:12 +0000
commit63ad55e97d14e96bf21aaf3b3371748787d32181 (patch)
tree564d26897fc78cf2a1e1851ee5ee630e497b6b91 /src/stylesheet.c
parent52e94c5b081b14a490074ef81037d028aa5b0e29 (diff)
downloadlibcss-63ad55e97d14e96bf21aaf3b3371748787d32181.tar.gz
Use a chaining hash for selectors -- permits easy sorting of hash entries by specificity/rule index.
svn path=/trunk/libcss/; revision=6280
Diffstat (limited to 'src/stylesheet.c')
-rw-r--r--src/stylesheet.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/stylesheet.c b/src/stylesheet.c
index ac7dcd5..7c055e1 100644
--- a/src/stylesheet.c
+++ b/src/stylesheet.c
@@ -898,17 +898,19 @@ css_error css_stylesheet_add_rule(css_stylesheet *sheet, css_rule *rule)
if (sheet == NULL || rule == NULL)
return CSS_BADPARM;
+ /* Need to fill in rule's index field before adding selectors
+ * because selector chains consider the rule index for sort order
+ */
+ rule->index = sheet->rule_count;
+
/* Add any selectors to the hash */
error = _add_selectors(sheet, rule);
if (error != CSS_OK)
return error;
- /* Fill in rule's index and parent fields */
- rule->index = sheet->rule_count;
+ /* Add rule to sheet */
rule->ptype = CSS_RULE_PARENT_STYLESHEET;
rule->parent = sheet;
-
- /* Add rule to sheet */
sheet->rule_count++;
if (sheet->last_rule == NULL) {