mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
document/dom: Simplify init_template_by_style() usage
It doesn't take the useless styling information but just uses options->default_style.
This commit is contained in:
parent
55495ab655
commit
dc0cf23631
@ -214,8 +214,6 @@ dom_rss_push_document(struct dom_stack *stack, struct dom_node *root, void *xxx)
|
||||
|
||||
for (type = 0; type < RSS_STYLES; type++) {
|
||||
struct screen_char *template = &data->styles[type];
|
||||
color_T background = document->options.default_style.bg;
|
||||
color_T foreground = document->options.default_style.fg;
|
||||
static int i_want_struct_module_for_dom;
|
||||
|
||||
static unsigned char *names[RSS_STYLES] = { "title", "aux" };
|
||||
@ -237,7 +235,7 @@ dom_rss_push_document(struct dom_stack *stack, struct dom_node *root, void *xxx)
|
||||
selector = find_css_selector(&css->selectors,
|
||||
CST_ELEMENT, CSR_ROOT,
|
||||
names[type], strlen(names[type]));
|
||||
init_template_by_style(template, &document->options, 0, foreground, background,
|
||||
init_template_by_style(template, &document->options,
|
||||
selector ? &selector->properties : NULL);
|
||||
}
|
||||
|
||||
|
@ -342,10 +342,7 @@ render_dom_document_start(struct dom_stack *stack, struct dom_node *node, void *
|
||||
|
||||
for (type = 0; type < DOM_NODES; type++) {
|
||||
struct screen_char *template = &data->styles[type];
|
||||
color_T background = document->options.default_style.bg;
|
||||
color_T foreground = document->options.default_style.fg;
|
||||
static int i_want_struct_module_for_dom;
|
||||
|
||||
struct dom_string *name = get_dom_node_type_name(type);
|
||||
struct css_selector *selector = NULL;
|
||||
|
||||
@ -372,7 +369,7 @@ render_dom_document_start(struct dom_stack *stack, struct dom_node *node, void *
|
||||
selector = find_css_selector(&css->selectors,
|
||||
CST_ELEMENT, CSR_ROOT,
|
||||
name->string, name->length);
|
||||
init_template_by_style(template, &document->options, 0, foreground, background,
|
||||
init_template_by_style(template, &document->options,
|
||||
selector ? &selector->properties : NULL);
|
||||
}
|
||||
|
||||
|
@ -38,9 +38,9 @@ init_template(struct screen_char *template, struct document_options *options,
|
||||
|
||||
void
|
||||
init_template_by_style(struct screen_char *template, struct document_options *options,
|
||||
color_T background, color_T foreground, enum screen_char_attr attr,
|
||||
LIST_OF(struct css_property) *properties)
|
||||
LIST_OF(struct css_property) *properties)
|
||||
{
|
||||
struct text_style style = options->default_style;
|
||||
struct css_property *property;
|
||||
|
||||
if (properties) {
|
||||
@ -50,19 +50,19 @@ init_template_by_style(struct screen_char *template, struct document_options *op
|
||||
case CSS_PT_BACKGROUND_COLOR:
|
||||
case CSS_PT_BACKGROUND:
|
||||
if (property->value_type == CSS_VT_COLOR)
|
||||
background = property->value.color;
|
||||
style.bg = property->value.color;
|
||||
break;
|
||||
case CSS_PT_COLOR:
|
||||
foreground = property->value.color;
|
||||
style.fg = property->value.color;
|
||||
break;
|
||||
case CSS_PT_FONT_WEIGHT:
|
||||
attr |= property->value.font_attribute.add;
|
||||
style.attr |= property->value.font_attribute.add;
|
||||
break;
|
||||
case CSS_PT_FONT_STYLE:
|
||||
attr |= property->value.font_attribute.add;
|
||||
style.attr |= property->value.font_attribute.add;
|
||||
break;
|
||||
case CSS_PT_TEXT_DECORATION:
|
||||
attr |= property->value.font_attribute.add;
|
||||
style.attr |= property->value.font_attribute.add;
|
||||
break;
|
||||
case CSS_PT_DISPLAY:
|
||||
case CSS_PT_NONE:
|
||||
@ -74,7 +74,7 @@ init_template_by_style(struct screen_char *template, struct document_options *op
|
||||
}
|
||||
}
|
||||
|
||||
init_template(template, options, attr, foreground, background);
|
||||
get_screen_char_template(template, options, style);
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,8 +44,6 @@ struct dom_renderer {
|
||||
|
||||
void init_template_by_style(struct screen_char *template,
|
||||
struct document_options *options,
|
||||
color_T background, color_T foreground,
|
||||
enum screen_char_attr attr,
|
||||
LIST_OF(struct css_property) *properties);
|
||||
|
||||
void render_dom_text(struct dom_renderer *renderer, struct screen_char *template,
|
||||
|
Loading…
Reference in New Issue
Block a user