From bceb717f5d088f440a8046acf2e1d8f0169fdab3 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 17 Nov 2014 13:51:41 +0100 Subject: html: Don't create boxes for invisible elements. --- source/html/layout.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/source/html/layout.c b/source/html/layout.c index 4f778cc5..c948e02b 100644 --- a/source/html/layout.c +++ b/source/html/layout.c @@ -187,6 +187,7 @@ static void generate_boxes(html_document *doc, fz_xml *node, struct box *top, st fz_context *ctx = doc->ctx; struct style style; struct box *box; + const char *tag; int display; while (node) @@ -194,9 +195,8 @@ static void generate_boxes(html_document *doc, fz_xml *node, struct box *top, st style.up = up_style; style.count = 0; - box = new_box(ctx, node); - - if (fz_xml_tag(node)) + tag = fz_xml_tag(node); + if (tag) { apply_styles(ctx, &style, rule, node); @@ -207,6 +207,8 @@ static void generate_boxes(html_document *doc, fz_xml *node, struct box *top, st if (display != DIS_NONE) { + box = new_box(ctx, node); + if (display == DIS_BLOCK) { top = insert_block_box(ctx, box, top); @@ -224,17 +226,18 @@ static void generate_boxes(html_document *doc, fz_xml *node, struct box *top, st if (fz_xml_down(node)) generate_boxes(doc, fz_xml_down(node), box, rule, &style); + compute_style(doc, &box->style, &style); // TODO: remove empty flow boxes } } else { + box = new_box(ctx, node); insert_inline_box(ctx, box, top); generate_text(ctx, box, fz_xml_text(node)); + compute_style(doc, &box->style, &style); } - compute_style(doc, &box->style, &style); - node = fz_xml_next(node); } } -- cgit v1.2.3