diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2015-05-15 16:36:00 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2015-05-15 16:36:00 +0200 |
commit | fed5c6bde9ae32bddfdce2f235e5adc484effad0 (patch) | |
tree | 0511000e339c53b68a12a0a75e6a46f5fd8c8539 | |
parent | afa0a2b4b0508fb6b095c30a6e27afd0c5c21c64 (diff) | |
download | mupdf-fed5c6bde9ae32bddfdce2f235e5adc484effad0.tar.xz |
epub: Use flag bits for white-space enum.
-rw-r--r-- | include/mupdf/html.h | 12 | ||||
-rw-r--r-- | source/html/html-layout.c | 36 |
2 files changed, 14 insertions, 34 deletions
diff --git a/include/mupdf/html.h b/include/mupdf/html.h index 6a5cdc90..3f48af22 100644 --- a/include/mupdf/html.h +++ b/include/mupdf/html.h @@ -89,12 +89,22 @@ 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 { WS_NORMAL, WS_PRE, WS_NOWRAP, WS_PRE_WRAP, WS_PRE_LINE }; enum { TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY }; enum { VA_BASELINE, VA_SUB, VA_SUPER, VA_TOP, VA_BOTTOM }; enum { BS_NONE, BS_SOLID }; enum { + WS_COLLAPSE = 1, + WS_ALLOW_BREAK_SPACE = 2, + WS_FORCE_BREAK_NEWLINE = 4, + WS_NORMAL = WS_COLLAPSE | WS_ALLOW_BREAK_SPACE, + WS_PRE = WS_FORCE_BREAK_NEWLINE, + WS_NOWRAP = WS_COLLAPSE, + WS_PRE_WRAP = WS_ALLOW_BREAK_SPACE | WS_FORCE_BREAK_NEWLINE, + WS_PRE_LINE = WS_COLLAPSE | WS_ALLOW_BREAK_SPACE | WS_FORCE_BREAK_NEWLINE +}; + +enum { LST_NONE, LST_DISC, LST_CIRCLE, LST_SQUARE, LST_DECIMAL, LST_DECIMAL_ZERO, diff --git a/source/html/html-layout.c b/source/html/html-layout.c index 52171ef8..cfc5da4f 100644 --- a/source/html/html-layout.c +++ b/source/html/html-layout.c @@ -99,44 +99,14 @@ static void generate_text(fz_context *ctx, fz_html *box, const char *text) { fz_html *flow; - int collapse; /* collapse sequences of white space */ - int bsp; /* allow breaks at white space */ - int bnl; /* force breaks at newline characters */ + int collapse = box->style.white_space & WS_COLLAPSE; + int bsp = box->style.white_space & WS_ALLOW_BREAK_SPACE; + int bnl = box->style.white_space & WS_FORCE_BREAK_NEWLINE; flow = box; while (flow->type != BOX_FLOW) flow = flow->up; - switch (box->style.white_space) - { - default: - case WS_NORMAL: - collapse = 1; - bsp = 1; - bnl = 0; - break; - case WS_PRE: - collapse = 0; - bsp = 0; - bnl = 1; - break; - case WS_NOWRAP: - collapse = 1; - bsp = 0; - bnl = 0; - break; - case WS_PRE_WRAP: - collapse = 0; - bsp = 1; - bnl = 1; - break; - case WS_PRE_LINE: - collapse = 1; - bsp = 1; - bnl = 1; - break; - } - while (*text) { if (bnl && (*text == '\n' || *text == '\r')) |