summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2016-02-02 00:26:01 +0100
committerSebastian Rasmussen <sebras@gmail.com>2016-02-10 01:12:32 +0100
commit93699403812c87a8d96d0029f37134cf86e86205 (patch)
tree21a541ccca78da25e8620eec0500315db392de73
parentf17c1a2a06eb04daabd381e7e9f374c3f76e77fa (diff)
downloadmupdf-93699403812c87a8d96d0029f37134cf86e86205.tar.xz
html: Support vertical alignment to top/bottom of parent box
Fixes http://bugs.ghostscript.com/show_bug.cgi?id=696004
-rw-r--r--include/mupdf/html.h2
-rw-r--r--source/html/css-apply.c2
-rw-r--r--source/html/html-layout.c11
3 files changed, 12 insertions, 3 deletions
diff --git a/include/mupdf/html.h b/include/mupdf/html.h
index c734ea0d..33ee84c8 100644
--- a/include/mupdf/html.h
+++ b/include/mupdf/html.h
@@ -107,7 +107,7 @@ struct fz_css_match_s
enum { DIS_NONE, DIS_BLOCK, DIS_INLINE, DIS_LIST_ITEM, DIS_INLINE_BLOCK };
enum { POS_STATIC, POS_RELATIVE, POS_ABSOLUTE, POS_FIXED };
enum { TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY };
-enum { VA_BASELINE, VA_SUB, VA_SUPER, VA_TOP, VA_BOTTOM };
+enum { VA_BASELINE, VA_SUB, VA_SUPER, VA_TOP, VA_BOTTOM, VA_TEXT_TOP, VA_TEXT_BOTTOM };
enum { BS_NONE, BS_SOLID };
enum { V_VISIBLE, V_HIDDEN, V_COLLAPSE };
diff --git a/source/html/css-apply.c b/source/html/css-apply.c
index db588bf7..a6c531b0 100644
--- a/source/html/css-apply.c
+++ b/source/html/css-apply.c
@@ -1177,6 +1177,8 @@ fz_apply_css_style(fz_context *ctx, fz_html_font_set *set, fz_css_style *style,
else if (!strcmp(value->data, "super")) style->vertical_align = VA_SUPER;
else if (!strcmp(value->data, "top")) style->vertical_align = VA_TOP;
else if (!strcmp(value->data, "bottom")) style->vertical_align = VA_BOTTOM;
+ else if (!strcmp(value->data, "text-top")) style->vertical_align = VA_TEXT_TOP;
+ else if (!strcmp(value->data, "text-bottom")) style->vertical_align = VA_TEXT_BOTTOM;
}
value = value_from_property(match, "font-size");
diff --git a/source/html/html-layout.c b/source/html/html-layout.c
index 259dcbc5..30b6e334 100644
--- a/source/html/html-layout.c
+++ b/source/html/html-layout.c
@@ -667,7 +667,7 @@ static float measure_line(fz_html_flow *node, fz_html_flow *end, float *baseline
return h;
}
-static void layout_line(fz_context *ctx, float indent, float page_w, float line_w, int align, fz_html_flow *start, fz_html_flow *end, fz_html *box, float baseline)
+static void layout_line(fz_context *ctx, float indent, float page_w, float line_w, int align, fz_html_flow *start, fz_html_flow *end, fz_html *box, float baseline, float line_h)
{
float x = box->x + indent;
float y = box->y + box->h;
@@ -737,7 +737,14 @@ static void layout_line(fz_context *ctx, float indent, float page_w, float line_
case VA_SUPER:
va = node->em * -0.3f;
break;
+ case VA_TEXT_TOP:
+ va = -baseline + node->h;
+ break;
+ case VA_TEXT_BOTTOM:
+ va = -baseline + line_h;
+ break;
}
+
if (node->type == FLOW_IMAGE)
node->y = y + baseline - node->h;
else
@@ -768,7 +775,7 @@ static void flush_line(fz_context *ctx, fz_html *box, float page_h, float page_w
line_h = measure_line(a, b, &baseline, &line_w);
if (line_h > avail)
box->h += avail;
- layout_line(ctx, indent, page_w, line_w, align, a, b, box, baseline);
+ layout_line(ctx, indent, page_w, line_w, align, a, b, box, baseline, line_h);
box->h += line_h;
}