From 705cd7f113ec7537baf12960c7f6a01f114a0479 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk <witekfl@poczta.onet.pl> Date: Wed, 23 Jun 2021 20:42:58 +0200 Subject: [PATCH] [test] align.html is displayable --- src/document/html/renderer.c | 36 ----------------------------- src/document/html/renderer.h | 38 ++++++++++++++++++++++++++++++ src/document/xml/renderer2.c | 45 +++++++++++++++++++++++++----------- 3 files changed, 69 insertions(+), 50 deletions(-) diff --git a/src/document/html/renderer.c b/src/document/html/renderer.c index 20fa58c77..e5a536607 100644 --- a/src/document/html/renderer.c +++ b/src/document/html/renderer.c @@ -62,13 +62,6 @@ enum link_state { LINK_STATE_SAME, }; -struct link_state_info { - char *link; - char *target; - char *image; - struct el_form_control *form; -}; - struct table_cache_entry_key { char *start; char *end; @@ -93,35 +86,6 @@ struct table_cache_entry { static int table_cache_entries; static struct hash *table_cache; -struct renderer_context { - int last_link_to_move; - struct tag *last_tag_to_move; - /* All tags between document->tags and this tag (inclusive) should - * be aligned to the next line break, unless some real content follows - * the tag. Therefore, this virtual tags list accumulates new tags as - * they arrive and empties when some real content is written; if a line - * break is inserted in the meanwhile, the tags follow it (ie. imagine - * <a name="x"> <p>, then the "x" tag follows the line breaks inserted - * by the <p> tag). */ - struct tag *last_tag_for_newline; - - struct link_state_info link_state_info; - - struct conv_table *convert_table; - - /* Used for setting cache info from HTTP-EQUIV meta tags. */ - struct cache_entry *cached; - - int g_ctrl_num; - int subscript; /* Count stacked subscripts */ - int supscript; /* Count stacked supscripts */ - - unsigned int empty_format:1; - unsigned int nobreak:1; - unsigned int nosearchable:1; - unsigned int nowrap:1; /* Activated/deactivated by SP_NOWRAP. */ -}; - struct renderer_context renderer_context; /* Prototypes */ diff --git a/src/document/html/renderer.h b/src/document/html/renderer.h index 7e4e6bbd1..49a93336d 100644 --- a/src/document/html/renderer.h +++ b/src/document/html/renderer.h @@ -62,6 +62,44 @@ struct part { unsigned int begin:1; }; +struct link_state_info { + char *link; + char *target; + char *image; + struct el_form_control *form; +}; + +struct renderer_context { + int last_link_to_move; + struct tag *last_tag_to_move; + /* All tags between document->tags and this tag (inclusive) should + * be aligned to the next line break, unless some real content follows + * the tag. Therefore, this virtual tags list accumulates new tags as + * they arrive and empties when some real content is written; if a line + * break is inserted in the meanwhile, the tags follow it (ie. imagine + * <a name="x"> <p>, then the "x" tag follows the line breaks inserted + * by the <p> tag). */ + struct tag *last_tag_for_newline; + + struct link_state_info link_state_info; + + struct conv_table *convert_table; + + /* Used for setting cache info from HTTP-EQUIV meta tags. */ + struct cache_entry *cached; + + int g_ctrl_num; + int subscript; /* Count stacked subscripts */ + int supscript; /* Count stacked supscripts */ + + unsigned int empty_format:1; + unsigned int nobreak:1; + unsigned int nosearchable:1; + unsigned int nowrap:1; /* Activated/deactivated by SP_NOWRAP. */ +}; + +extern struct renderer_context renderer_context; + void expand_lines(struct html_context *html_context, struct part *part, int x, int y, int lines, color_T bgcolor); void check_html_form_hierarchy(struct part *part); diff --git a/src/document/xml/renderer2.c b/src/document/xml/renderer2.c index fc7f23ebe..b4ac10814 100644 --- a/src/document/xml/renderer2.c +++ b/src/document/xml/renderer2.c @@ -296,6 +296,13 @@ render_xhtml_document(struct cache_entry *cached, struct document *document, str if (!document->dom) { document->dom = document_parse(document); } + + struct tag *saved_last_tag_to_move = renderer_context.last_tag_to_move; + int saved_empty_format = renderer_context.empty_format; + int saved_margin = html_context->margin; + int saved_last_link_to_move = renderer_context.last_link_to_move; + + xmlpp::Document *doc = document->dom; if (!buffer) { @@ -313,23 +320,33 @@ render_xhtml_document(struct cache_entry *cached, struct document *document, str html_special); if (!html_context) return; -/// renderer_context.g_ctrl_num = 0; -/// renderer_context.cached = cached; -/// renderer_context.convert_table = get_convert_table(head.source, -/// document->options.cp, -/// document->options.assume_cp, -/// &document->cp, -/// &document->cp_status, -/// document->options.hard_assume); + if (document) { + struct node *node = mem_alloc(sizeof(*node)); - struct conv_table *convert_table = get_convert_table(head.source, + if (node) { + int node_width = INT_MAX ;///!html_context->table_level ? INT_MAX : width; + + set_box(&node->box, 0 /*x*/, 0 /*y*/, node_width, 1); + add_to_list(document->nodes, node); + } + + renderer_context.last_link_to_move = document->nlinks; + renderer_context.last_tag_to_move = (struct tag *) &document->tags; + renderer_context.last_tag_for_newline = (struct tag *) &document->tags; + } else { + renderer_context.last_link_to_move = 0; + renderer_context.last_tag_to_move = (struct tag *) NULL; + renderer_context.last_tag_for_newline = (struct tag *) NULL; + } + + renderer_context.g_ctrl_num = 0; + renderer_context.cached = cached; + renderer_context.convert_table = get_convert_table(head.source, document->options.cp, - document->options.assume_cp, + document->options.assume_cp, &document->cp, &document->cp_status, - document->options.hard_assume);; - - + document->options.hard_assume); #ifdef CONFIG_UTF8 html_context->options->utf8 = is_cp_utf8(document->options.cp); @@ -339,7 +356,7 @@ render_xhtml_document(struct cache_entry *cached, struct document *document, str if (title.length) { /* CSM_DEFAULT because init_html_parser() did not * decode entities in the title. */ - document->title = convert_string(convert_table, + document->title = convert_string(renderer_context.convert_table, title.source, title.length, document->options.cp, CSM_DEFAULT, NULL, NULL, NULL);