diff --git a/src/document/dom/rss.c b/src/document/dom/rss.c index c75fccb9b..98d3bc100 100644 --- a/src/document/dom/rss.c +++ b/src/document/dom/rss.c @@ -203,22 +203,14 @@ static enum dom_code dom_rss_push_document(struct dom_stack *stack, struct dom_node *root, void *xxx) { struct dom_renderer *renderer = stack->current->data; - struct css_stylesheet *css = &default_stylesheet; struct document *document = renderer->document; struct rss_renderer *data; enum rss_style type; - data = renderer->data = mem_calloc(1, sizeof(*data)); - - /* Initialize styles. */ - - for (type = 0; type < RSS_STYLES; type++) { - struct screen_char *template = &data->styles[type]; + struct css_stylesheet *css = &default_stylesheet; + { static int i_want_struct_module_for_dom; - static unsigned char *names[RSS_STYLES] = { "title", "aux" }; - struct css_selector *selector = NULL; - if (!i_want_struct_module_for_dom) { static const unsigned char default_colors[] = "title { color: lightgreen } " @@ -231,6 +223,16 @@ dom_rss_push_document(struct dom_stack *stack, struct dom_node *root, void *xxx) * not overriding the user's default stylesheet. */ css_parse_stylesheet(css, NULL, styles, styles + sizeof(default_colors)); } + } + + data = renderer->data = mem_calloc(1, sizeof(*data)); + + /* Initialize styles. */ + + for (type = 0; type < RSS_STYLES; type++) { + struct screen_char *template = &data->styles[type]; + static const unsigned char *names[RSS_STYLES] = { "title", "aux" }; + struct css_selector *selector = NULL; selector = find_css_selector(&css->selectors, CST_ELEMENT, CSR_ROOT, diff --git a/src/document/dom/source.c b/src/document/dom/source.c index c54fc4d95..3fb957ff6 100644 --- a/src/document/dom/source.c +++ b/src/document/dom/source.c @@ -331,20 +331,13 @@ static enum dom_code render_dom_document_start(struct dom_stack *stack, struct dom_node *node, void *xxx) { struct dom_renderer *renderer = stack->current->data; - struct css_stylesheet *css = &default_stylesheet; struct document *document = renderer->document; struct source_renderer *data; enum dom_node_type type; - data = renderer->data = mem_calloc(1, sizeof(*data)); - - /* Initialize styles for all the DOM node types. */ - - for (type = 0; type < DOM_NODES; type++) { - struct screen_char *template = &data->styles[type]; + struct css_stylesheet *css = &default_stylesheet; + { static int i_want_struct_module_for_dom; - struct dom_string *name = get_dom_node_type_name(type); - struct css_selector *selector = NULL; if (!i_want_struct_module_for_dom) { static const unsigned char default_colors[] = @@ -363,6 +356,16 @@ render_dom_document_start(struct dom_stack *stack, struct dom_node *node, void * * not overriding the user's default stylesheet. */ css_parse_stylesheet(css, NULL, styles, styles + sizeof(default_colors)); } + } + + data = renderer->data = mem_calloc(1, sizeof(*data)); + + /* Initialize styles for all the DOM node types. */ + + for (type = 0; type < DOM_NODES; type++) { + struct screen_char *template = &data->styles[type]; + struct dom_string *name = get_dom_node_type_name(type); + struct css_selector *selector = NULL; if (name) if (is_dom_string_set(name))