diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/html/layout.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/source/html/layout.c b/source/html/layout.c index 84c02e3d..6d9753ba 100644 --- a/source/html/layout.c +++ b/source/html/layout.c @@ -335,9 +335,10 @@ static void layout_block(fz_context *ctx, struct box *box, struct box *top, floa box->padding[2] = from_number(box->style.padding[2], em, top->w); box->padding[3] = from_number(box->style.padding[3], em, top->w); - // TODO: collapse top/top and bottom/bottom margins - - box_collapse_margin = 0; + if (box->padding[TOP] == 0) + box_collapse_margin = box->margin[TOP]; + else + box_collapse_margin = 0; if (box->margin[TOP] > top_collapse_margin) box->margin[TOP] -= top_collapse_margin; @@ -367,6 +368,16 @@ static void layout_block(fz_context *ctx, struct box *box, struct box *top, floa } } } + + if (box->padding[BOTTOM] == 0) + { + if (box->margin[BOTTOM] > 0) + { + box->h -= box_collapse_margin; + if (box->margin[BOTTOM] < box_collapse_margin) + box->margin[BOTTOM] = box_collapse_margin; + } + } } static void indent(int level) |