summaryrefslogtreecommitdiff
path: root/source/html/layout.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2014-11-14 11:15:58 +0100
committerTor Andersson <tor.andersson@artifex.com>2014-12-03 12:25:52 +0100
commitb3a9f7e5d838e095a5cf4f6d73a73316089190ec (patch)
tree96b8677b4d7d39037d007f2a1aa9e43972e32488 /source/html/layout.c
parent8758df6c290525eb2246977d84816d171e95309b (diff)
downloadmupdf-b3a9f7e5d838e095a5cf4f6d73a73316089190ec.tar.xz
html: Only draw the boxes and lines if they're on the current page.
Diffstat (limited to 'source/html/layout.c')
-rw-r--r--source/html/layout.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/source/html/layout.c b/source/html/layout.c
index 00ad79f6..9533e634 100644
--- a/source/html/layout.c
+++ b/source/html/layout.c
@@ -495,7 +495,7 @@ static void print_box(fz_context *ctx, struct box *box, int level)
}
static void
-draw_flow_box(fz_context *ctx, struct box *box, fz_device *dev, const fz_matrix *ctm)
+draw_flow_box(fz_context *ctx, struct box *box, float page_top, float page_bot, fz_device *dev, const fz_matrix *ctm)
{
struct flow *node;
fz_text *text;
@@ -509,6 +509,9 @@ draw_flow_box(fz_context *ctx, struct box *box, fz_device *dev, const fz_matrix
for (node = box->flow_head; node; node = node->next)
{
+ if (node->y > page_bot || node->y + node->h < page_top)
+ continue;
+
if (node->type == FLOW_WORD)
{
fz_scale(&trm, node->em, -node->em);
@@ -533,7 +536,7 @@ draw_flow_box(fz_context *ctx, struct box *box, fz_device *dev, const fz_matrix
}
static void
-draw_block_box(fz_context *ctx, struct box *box, fz_device *dev, const fz_matrix *ctm)
+draw_block_box(fz_context *ctx, struct box *box, float page_top, float page_bot, fz_device *dev, const fz_matrix *ctm)
{
fz_path *path;
float black[1];
@@ -549,6 +552,9 @@ draw_block_box(fz_context *ctx, struct box *box, fz_device *dev, const fz_matrix
x1 = box->x + box->w + box->padding[RIGHT];
y1 = box->y + box->h + box->padding[BOTTOM];
+ if (y0 > page_bot || y1 < page_top)
+ return;
+
path = fz_new_path(ctx);
fz_moveto(ctx, path, x0, y0);
fz_lineto(ctx, path, x1, y0);
@@ -564,18 +570,18 @@ draw_block_box(fz_context *ctx, struct box *box, fz_device *dev, const fz_matrix
{
switch (box->type)
{
- case BOX_BLOCK: draw_block_box(ctx, box, dev, ctm); break;
- case BOX_FLOW: draw_flow_box(ctx, box, dev, ctm); break;
+ case BOX_BLOCK: draw_block_box(ctx, box, page_top, page_bot, dev, ctm); break;
+ case BOX_FLOW: draw_flow_box(ctx, box, page_top, page_bot, dev, ctm); break;
}
}
}
void
-html_run_box(fz_context *ctx, struct box *box, float offset, fz_device *dev, const fz_matrix *inctm)
+html_run_box(fz_context *ctx, struct box *box, float page_top, float page_bot, fz_device *dev, const fz_matrix *inctm)
{
fz_matrix ctm = *inctm;
- fz_pre_translate(&ctm, 0, -offset);
- draw_block_box(ctx, box, dev, &ctm);
+ fz_pre_translate(&ctm, 0, -page_top);
+ draw_block_box(ctx, box, page_top, page_bot, dev, &ctm);
}
static char *concat_text(fz_context *ctx, fz_xml *root)