diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2014-11-04 17:01:19 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2014-12-03 12:25:51 +0100 |
commit | b8f932bba1ca5003700a8c6465e6b67bffb5ea38 (patch) | |
tree | 9318071f04cface48dddae738b87eb8d1e233458 | |
parent | 59a3ca3072abebde69c11d5070c0bc42773f0f44 (diff) | |
download | mupdf-b8f932bba1ca5003700a8c6465e6b67bffb5ea38.tar.xz |
html: Parse white-space property.
-rw-r--r-- | include/mupdf/html.h | 2 | ||||
-rw-r--r-- | source/html/css-apply.c | 55 | ||||
-rw-r--r-- | source/html/css-parse.c | 1 |
3 files changed, 39 insertions, 19 deletions
diff --git a/include/mupdf/html.h b/include/mupdf/html.h index 9a42043d..07f35553 100644 --- a/include/mupdf/html.h +++ b/include/mupdf/html.h @@ -96,6 +96,7 @@ struct property *fz_parse_css_properties(fz_context *ctx, const char *source); enum { DIS_NONE, DIS_BLOCK, DIS_INLINE, DIS_LIST_ITEM }; enum { POS_STATIC, POS_RELATIVE, POS_ABSOLUTE, POS_FIXED }; enum { TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY }; +enum { WS_NORMAL, WS_PRE, WS_NOWRAP, WS_PRE_WRAP, WS_PRE_LINE }; enum { TOP, RIGHT, BOTTOM, LEFT }; @@ -118,6 +119,7 @@ struct computed_style struct number margin[4]; struct number padding[4]; struct number text_indent; + int white_space; int text_align; int vertical_align; struct number line_height; diff --git a/source/html/css-apply.c b/source/html/css-apply.c index 4f58154a..0e451ce0 100644 --- a/source/html/css-apply.c +++ b/source/html/css-apply.c @@ -699,24 +699,6 @@ get_style_property_string(struct style *node, const char *name, const char *init return value->data; } -int -get_style_property_display(struct style *node) -{ - struct value *value = get_style_property(node, "display"); - if (value) - { - if (!strcmp(value->data, "none")) - return DIS_NONE; - if (!strcmp(value->data, "inline")) - return DIS_INLINE; - if (!strcmp(value->data, "block")) - return DIS_BLOCK; - if (!strcmp(value->data, "list-item")) - return DIS_LIST_ITEM; - } - return DIS_INLINE; -} - static struct number make_number(float v, int u) { @@ -785,6 +767,39 @@ from_number(struct number number, float em, float width) } } +int +get_style_property_display(struct style *node) +{ + struct value *value = get_style_property(node, "display"); + if (value) + { + if (!strcmp(value->data, "none")) + return DIS_NONE; + if (!strcmp(value->data, "inline")) + return DIS_INLINE; + if (!strcmp(value->data, "block")) + return DIS_BLOCK; + if (!strcmp(value->data, "list-item")) + return DIS_LIST_ITEM; + } + return DIS_INLINE; +} + +int +get_style_property_white_space(struct style *node) +{ + struct value *value = get_style_property(node, "white-space"); + if (value) + { + if (!strcmp(value->data, "normal")) return WS_NORMAL; + if (!strcmp(value->data, "pre")) return WS_PRE; + if (!strcmp(value->data, "nowrap")) return WS_NOWRAP; + if (!strcmp(value->data, "pre-wrap")) return WS_PRE_WRAP; + if (!strcmp(value->data, "pre-line")) return WS_PRE_LINE; + } + return WS_NORMAL; +} + void compute_style(struct computed_style *style, struct style *node) { @@ -793,8 +808,12 @@ compute_style(struct computed_style *style, struct style *node) memset(style, 0, sizeof *style); style->text_align = TA_LEFT; + style->vertical_align = 0; + style->white_space = WS_NORMAL; style->font_size = make_number(1, N_SCALE); + style->white_space = get_style_property_white_space(node); + value = get_style_property(node, "text-align"); if (value) { diff --git a/source/html/css-parse.c b/source/html/css-parse.c index 066eb0f7..28176d14 100644 --- a/source/html/css-parse.c +++ b/source/html/css-parse.c @@ -1,4 +1,3 @@ -#include "mupdf/fitz.h" #include "mupdf/html.h" struct lexbuf |