summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2015-05-13 18:01:50 +0200
committerTor Andersson <tor.andersson@artifex.com>2015-05-15 16:12:23 +0200
commit8bd1881b799489a42cef76da033be157d0ff609d (patch)
treec17cffcb8bc4d9b19305da87c4cdfdc3cb607dd1
parent397b654e3ba443f8a1fe34295f966cb63c4c0306 (diff)
downloadmupdf-8bd1881b799489a42cef76da033be157d0ff609d.tar.xz
epub: Move collapsed parent/child top margins to outside the parent.
-rw-r--r--source/html/html-layout.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/source/html/html-layout.c b/source/html/html-layout.c
index 88bc23c7..5fd3937b 100644
--- a/source/html/html-layout.c
+++ b/source/html/html-layout.c
@@ -665,6 +665,7 @@ static void layout_flow(fz_context *ctx, fz_html *box, fz_html *top, float em, f
static float layout_block(fz_context *ctx, fz_html *box, fz_html *top, float em, float page_h, float vertical)
{
fz_html *child;
+ int first;
fz_css_style *style = &box->style;
float *margin = box->margin;
@@ -704,11 +705,20 @@ static float layout_block(fz_context *ctx, fz_html *box, fz_html *top, float em,
box->y = top->y + top->h + margin[T] + border[T] + padding[T];
box->h = 0;
+ first = 1;
for (child = box->down; child; child = child->next)
{
if (child->type == BOX_BLOCK)
{
vertical = layout_block(ctx, child, box, em, page_h, vertical);
+ if (first)
+ {
+ /* move collapsed parent/child top margins to parent */
+ margin[T] += child->margin[T];
+ box->y += child->margin[T];
+ child->margin[T] = 0;
+ first = 0;
+ }
box->h += child->h +
child->padding[T] + child->padding[B] +
child->border[T] + child->border[B] +
@@ -718,6 +728,7 @@ static float layout_block(fz_context *ctx, fz_html *box, fz_html *top, float em,
{
box->h += fz_from_css_number_scale(style->line_height, em, em, em);
vertical = 0;
+ first = 0;
}
else if (child->type == BOX_FLOW)
{
@@ -726,6 +737,7 @@ static float layout_block(fz_context *ctx, fz_html *box, fz_html *top, float em,
{
box->h += child->h;
vertical = 0;
+ first = 0;
}
}
}