diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2014-11-12 02:24:39 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2014-12-03 12:25:51 +0100 |
commit | a5f282cac059b279823520ae3e3dfd2138a1fe23 (patch) | |
tree | 7b25f5d51bd738c6b8d5c830a81759b0164a774d | |
parent | d8699f7f7a5ee7192e1e437eaffa75f415204073 (diff) | |
download | mupdf-a5f282cac059b279823520ae3e3dfd2138a1fe23.tar.xz |
html: Collapse top/top and bottom/bottom margins.
-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) |