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:
parent
a9619bce80
commit
baeb0cb0d5
@ -203,22 +203,14 @@ static enum dom_code
|
|||||||
dom_rss_push_document(struct dom_stack *stack, struct dom_node *root, void *xxx)
|
dom_rss_push_document(struct dom_stack *stack, struct dom_node *root, void *xxx)
|
||||||
{
|
{
|
||||||
struct dom_renderer *renderer = stack->current->data;
|
struct dom_renderer *renderer = stack->current->data;
|
||||||
struct css_stylesheet *css = &default_stylesheet;
|
|
||||||
struct document *document = renderer->document;
|
struct document *document = renderer->document;
|
||||||
struct rss_renderer *data;
|
struct rss_renderer *data;
|
||||||
enum rss_style type;
|
enum rss_style type;
|
||||||
|
|
||||||
data = renderer->data = mem_calloc(1, sizeof(*data));
|
struct css_stylesheet *css = &default_stylesheet;
|
||||||
|
{
|
||||||
/* Initialize styles. */
|
|
||||||
|
|
||||||
for (type = 0; type < RSS_STYLES; type++) {
|
|
||||||
struct screen_char *template = &data->styles[type];
|
|
||||||
static int i_want_struct_module_for_dom;
|
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) {
|
if (!i_want_struct_module_for_dom) {
|
||||||
static const unsigned char default_colors[] =
|
static const unsigned char default_colors[] =
|
||||||
"title { color: lightgreen } "
|
"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. */
|
* not overriding the user's default stylesheet. */
|
||||||
css_parse_stylesheet(css, NULL, styles, styles + sizeof(default_colors));
|
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,
|
selector = find_css_selector(&css->selectors,
|
||||||
CST_ELEMENT, CSR_ROOT,
|
CST_ELEMENT, CSR_ROOT,
|
||||||
|
@ -331,20 +331,13 @@ static enum dom_code
|
|||||||
render_dom_document_start(struct dom_stack *stack, struct dom_node *node, void *xxx)
|
render_dom_document_start(struct dom_stack *stack, struct dom_node *node, void *xxx)
|
||||||
{
|
{
|
||||||
struct dom_renderer *renderer = stack->current->data;
|
struct dom_renderer *renderer = stack->current->data;
|
||||||
struct css_stylesheet *css = &default_stylesheet;
|
|
||||||
struct document *document = renderer->document;
|
struct document *document = renderer->document;
|
||||||
struct source_renderer *data;
|
struct source_renderer *data;
|
||||||
enum dom_node_type type;
|
enum dom_node_type type;
|
||||||
|
|
||||||
data = renderer->data = mem_calloc(1, sizeof(*data));
|
struct css_stylesheet *css = &default_stylesheet;
|
||||||
|
{
|
||||||
/* Initialize styles for all the DOM node types. */
|
|
||||||
|
|
||||||
for (type = 0; type < DOM_NODES; type++) {
|
|
||||||
struct screen_char *template = &data->styles[type];
|
|
||||||
static int i_want_struct_module_for_dom;
|
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) {
|
if (!i_want_struct_module_for_dom) {
|
||||||
static const unsigned char default_colors[] =
|
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. */
|
* not overriding the user's default stylesheet. */
|
||||||
css_parse_stylesheet(css, NULL, styles, styles + sizeof(default_colors));
|
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 (name)
|
||||||
if (is_dom_string_set(name))
|
if (is_dom_string_set(name))
|
||||||
|
Loading…
Reference in New Issue
Block a user