summaryrefslogtreecommitdiff
path: root/source/html/css-apply.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2015-05-18 17:31:57 +0200
committerTor Andersson <tor.andersson@artifex.com>2015-05-19 16:22:57 +0200
commitc59e315a56d5f463ac329cb893082f06126d8660 (patch)
tree1af3d16532d7f7d295b8059c73af423f6b74e98f /source/html/css-apply.c
parent5fbb1782eeb9a423799e4f4d98daf50fc25580a2 (diff)
downloadmupdf-c59e315a56d5f463ac329cb893082f06126d8660.tar.xz
epub: Support !important property declarations.
Diffstat (limited to 'source/html/css-apply.c')
-rw-r--r--source/html/css-apply.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/source/html/css-apply.c b/source/html/css-apply.c
index a4fe01d7..2333ef5d 100644
--- a/source/html/css-apply.c
+++ b/source/html/css-apply.c
@@ -189,15 +189,15 @@ count_selector_names(fz_css_selector *sel)
return n;
}
-#define INLINE_SPECIFICITY 1000
+#define INLINE_SPECIFICITY 10000
static int
-selector_specificity(fz_css_selector *sel)
+selector_specificity(fz_css_selector *sel, int important)
{
int b = count_selector_ids(sel);
int c = count_selector_atts(sel);
int d = count_selector_names(sel);
- return b * 100 + c * 10 + d;
+ return important * 1000 + b * 100 + c * 10 + d;
}
/*
@@ -592,7 +592,7 @@ fz_match_css(fz_context *ctx, fz_css_match *match, fz_css_rule *css, fz_xml *nod
if (match_selector(sel, node))
{
for (prop = rule->declaration; prop; prop = prop->next)
- add_property(match, prop->name, prop->value, selector_specificity(sel));
+ add_property(match, prop->name, prop->value, selector_specificity(sel, prop->important));
break;
}
sel = sel->next;
@@ -637,7 +637,7 @@ fz_match_css_at_page(fz_context *ctx, fz_css_match *match, fz_css_rule *css)
if (sel->name && !strcmp(sel->name, "@page"))
{
for (prop = rule->declaration; prop; prop = prop->next)
- add_property(match, prop->name, prop->value, selector_specificity(sel));
+ add_property(match, prop->name, prop->value, selector_specificity(sel, prop->important));
break;
}
sel = sel->next;
@@ -1098,7 +1098,9 @@ print_property(fz_css_property *prop)
{
printf("\t%s: ", prop->name);
print_value(prop->value);
- printf(" !%d;\n", prop->spec);
+ if (prop->important)
+ printf(" !important");
+ printf(";\n");
}
void
@@ -1147,7 +1149,7 @@ print_rule(fz_css_rule *rule)
for (sel = rule->selector; sel; sel = sel->next)
{
print_selector(sel);
- printf(" !%d", selector_specificity(sel));
+ printf(" /* %d */", selector_specificity(sel, 0));
if (sel->next)
printf(", ");
}