1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

document/dom: Move stylesheet parsing out of style loop

...for better clarity of the document initialization functions.
This commit is contained in:
Petr Baudis 2007-08-28 21:31:25 +02:00 committed by Petr Baudis
parent a9619bce80
commit baeb0cb0d5
2 changed files with 24 additions and 19 deletions

View File

@ -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,

View File

@ -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))