示例#1
0
文件: css-apply.c 项目: Enzime/mupdf
void
fz_match_css(fz_context *ctx, fz_css_match *match, fz_css_rule *css, fz_xml *node)
{
	fz_css_rule *rule;
	fz_css_selector *sel;
	fz_css_property *prop, *head, *tail;
	const char *s;

	for (rule = css; rule; rule = rule->next)
	{
		sel = rule->selector;
		while (sel)
		{
			if (match_selector(sel, node))
			{
				for (prop = rule->declaration; prop; prop = prop->next)
					add_property(match, prop->name, prop->value, selector_specificity(sel, prop->important));
				break;
			}
			sel = sel->next;
		}
	}

	s = fz_xml_att(node, "style");
	if (s)
	{
		fz_try(ctx)
		{
			head = tail = prop = fz_parse_css_properties(ctx, s);
			while (prop)
			{
				add_property(match, prop->name, prop->value, INLINE_SPECIFICITY);
				tail = prop;
				prop = prop->next;
			}
			if (tail)
				tail->next = css->garbage;
			css->garbage = head;
		}
		fz_catch(ctx)
		{
			fz_warn(ctx, "ignoring style attribute");
		}
	}

	sort_properties(match); /* speed up subsequent value_from_raw_property lookups */
}
示例#2
0
文件: css-apply.c 项目: Enzime/mupdf
void
print_rule(fz_css_rule *rule)
{
	fz_css_selector *sel;
	fz_css_property *prop;

	for (sel = rule->selector; sel; sel = sel->next)
	{
		print_selector(sel);
		printf(" /* %d */", selector_specificity(sel, 0));
		if (sel->next)
			printf(", ");
	}

	printf("\n{\n");
	for (prop = rule->declaration; prop; prop = prop->next)
	{
		print_property(prop);
	}
	printf("}\n");
}
示例#3
0
void
fz_match_css(fz_context *ctx, fz_css_match *match, fz_css_rule *css, fz_xml *node)
{
	fz_css_rule *rule;
	fz_css_selector *sel;
	fz_css_property *prop, *head, *tail;
	const char *s;

	for (rule = css; rule; rule = rule->next)
	{
		sel = rule->selector;
		while (sel)
		{
			if (match_selector(sel, node))
			{
				for (prop = rule->declaration; prop; prop = prop->next)
					add_property(match, prop->name, prop->value, selector_specificity(sel));
				break;
			}
			sel = sel->next;
		}
	}

	s = fz_xml_att(node, "style");
	if (s)
	{
		head = tail = prop = fz_parse_css_properties(ctx, s);
		while (prop)
		{
			add_property(match, prop->name, prop->value, INLINE_SPECIFICITY);
			tail = prop;
			prop = prop->next;
		}
		if (tail)
			tail->next = css->garbage;
		css->garbage = head;
	}
}
示例#4
0
文件: css-apply.c 项目: Enzime/mupdf
void
fz_match_css_at_page(fz_context *ctx, fz_css_match *match, fz_css_rule *css)
{
	fz_css_rule *rule;
	fz_css_selector *sel;
	fz_css_property *prop;

	for (rule = css; rule; rule = rule->next)
	{
		sel = rule->selector;
		while (sel)
		{
			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, prop->important));
				break;
			}
			sel = sel->next;
		}
	}

	sort_properties(match); /* speed up subsequent value_from_raw_property lookups */
}