[gs-commits] mupdf 1.16.1.epub-prerelease-5 html: Cope with documents
[email protected] (Robin Watts) Fri, 25 Oct 2019 14:53:20 +0000 (UTC)
| Newsgroups | gmane.comp.printing.ghostscript.cvs |
|---|---|
| Message-ID | <[email protected]> |
commit 4d401b9c8119222295a6a0049278d0a6ee2d5aa3 Author: Tor Andersson <[email protected]> Date: Thu Oct 24 12:57:10 2019 +0200 html: Cope with documents that don't start with a block box. Documents that start with a flow box would trigger an assert or crash in the layout/drawing top level functions that assumed the root node is always the <html> block box. diff --git a/source/html/html-layout.c b/source/html/html-layout.c index 9dc55c9..54c17ef 100644 --- a/source/html/html-layout.c +++ b/source/html/html-layout.c @@ -850,7 +850,15 @@ fz_layout_html(fz_context *ctx, fz_html *html, float w, float h, float em) if (box->down) { - layout_block(ctx, box->down, box->em, box->x, &box->b, box->w, html->page_h, 0, hb_buf); + switch (box->down->type) + { + case BOX_BLOCK: + layout_block(ctx, box->down, box->em, box->x, &box->b, box->w, html->page_h, 0, hb_buf); + break; + case BOX_FLOW: + layout_flow(ctx, box->down, box, html->page_h, hb_buf); + break; + } box->b = box->down->b; } } @@ -1225,6 +1233,24 @@ static void draw_list_mark(fz_context *ctx, fz_html_box *box, float page_top, fl fz_rethrow(ctx); } +static void draw_block_box(fz_context *ctx, fz_html_box *box, float page_top, float page_bot, fz_device *dev, fz_matrix ctm, hb_buffer_t *hb_buf); + +static void draw_box(fz_context *ctx, fz_html_box *box, float page_top, float page_bot, fz_device *dev, fz_matrix ctm, hb_buffer_t *hb_buf) +{ + switch (box->type) + { + case BOX_TABLE: + case BOX_TABLE_ROW: + case BOX_TABLE_CELL: + case BOX_BLOCK: + draw_block_box(ctx, box, page_top, page_bot, dev, ctm, hb_buf); + break; + case BOX_FLOW: + draw_flow_box(ctx, box, page_top, page_bot, dev, ctm, hb_buf); + break; + } +} + static void draw_block_box(fz_context *ctx, fz_html_box *box, float page_top, float page_bot, fz_device *dev, fz_matrix ctm, hb_buffer_t *hb_buf) { float x0, y0, x1, y1; @@ -1259,16 +1285,7 @@ static void draw_block_box(fz_context *ctx, fz_html_box *box, float page_top, fl } for (box = box->down; box; box = box->next) - { - switch (box->type) - { - case BOX_TABLE: - case BOX_TABLE_ROW: - case BOX_TABLE_CELL: - case BOX_BLOCK: draw_block_box(ctx, box, page_top, page_bot, dev, ctm, hb_buf); break; - case BOX_FLOW: draw_flow_box(ctx, box, page_top, page_bot, dev, ctm, hb_buf); break; - } - } + draw_box(ctx, box, page_top, page_bot, dev, ctm, hb_buf); } void @@ -1298,7 +1315,7 @@ fz_draw_html(fz_context *ctx, fz_device *dev, fz_matrix ctm, fz_html *html, int unlocked = 1; for (box = html->root->down; box; box = box->next) - draw_block_box(ctx, box, page_top, page_bot, dev, ctm, hb_buf); + draw_box(ctx, html->root, page_top, page_bot, dev, ctm, hb_buf); } fz_always(ctx) { http://git.ghostscript.com/?p=mupdf.git;a=commit;h=4d401b9c8119222295a6a0049278d0a6ee2d5aa3 -- MuPDF library Artifex Software, Inc.