aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/css.cc18
-rw-r--r--src/css.hh3
-rw-r--r--src/cssparser.cc12
3 files changed, 19 insertions, 14 deletions
diff --git a/src/css.cc b/src/css.cc
index f991c051..420ac6c8 100644
--- a/src/css.cc
+++ b/src/css.cc
@@ -348,14 +348,20 @@ void CssContext::apply (CssPropertyList *props, Doctree *docTree,
tagStyle->apply (props);
}
-void CssContext::addRule (CssRule *rule, CssPrimaryOrder order) {
- if (sheet[order] == NULL)
- sheet[order] = new CssStyleSheet ();
+void CssContext::addRule (CssSelector *sel, CssPropertyList *props,
+ CssPrimaryOrder order) {
- sheet[order]->addRule (rule);
+ if (props->size () > 0) {
+ CssRule *rule = new CssRule (sel, props);
-// fprintf(stderr, "Adding Rule (%d)\n", order);
-// rule->print ();
+ if (sheet[order] == NULL)
+ sheet[order] = new CssStyleSheet ();
+
+ sheet[order]->addRule (rule);
+
+// fprintf(stderr, "Adding Rule (%d)\n", order);
+// rule->print ();
+ }
}
void CssContext::buildUserAgentStyle () {
diff --git a/src/css.hh b/src/css.hh
index 18a6016f..e899816c 100644
--- a/src/css.hh
+++ b/src/css.hh
@@ -339,7 +339,8 @@ class CssContext {
CssContext ();
~CssContext ();
- void addRule (CssRule *rule, CssPrimaryOrder order);
+ void addRule (CssSelector *sel, CssPropertyList *props,
+ CssPrimaryOrder order);
void apply (CssPropertyList *props,
Doctree *docTree,
CssPropertyList *tagStyle, CssPropertyList *nonCssHints);
diff --git a/src/cssparser.cc b/src/cssparser.cc
index bd5949bd..60fa1ce9 100644
--- a/src/cssparser.cc
+++ b/src/cssparser.cc
@@ -1139,16 +1139,14 @@ static void Css_parse_ruleset(CssParser * parser)
CssSelector *s = list->get(i);
if (parser->origin == CSS_ORIGIN_USER_AGENT) {
- parser->context->addRule(new CssRule(s, props),
- CSS_PRIMARY_USER_AGENT);
+ parser->context->addRule(s, props, CSS_PRIMARY_USER_AGENT);
} else if (parser->origin == CSS_ORIGIN_USER) {
- parser->context->addRule(new CssRule(s, props), CSS_PRIMARY_USER);
- parser->context->addRule(new CssRule(s, importantProps),
+ parser->context->addRule(s, props, CSS_PRIMARY_USER);
+ parser->context->addRule(s, importantProps,
CSS_PRIMARY_USER_IMPORTANT);
} else if (parser->origin == CSS_ORIGIN_AUTHOR) {
- parser->context->addRule(new CssRule(s, props),
- CSS_PRIMARY_AUTHOR);
- parser->context->addRule(new CssRule(s, importantProps),
+ parser->context->addRule(s, props, CSS_PRIMARY_AUTHOR);
+ parser->context->addRule(s, importantProps,
CSS_PRIMARY_AUTHOR_IMPORTANT);
}