diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2014-11-26 02:23:54 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2014-12-03 12:25:52 +0100 |
commit | a3b0ce19561c42cc165a0c459286100af50ba615 (patch) | |
tree | 56d88d3674a91ce5a4e157898498c2ce7f11a8c3 | |
parent | 08a4d6d49f91e295fa6265a91ce030fc9c585922 (diff) | |
download | mupdf-a3b0ce19561c42cc165a0c459286100af50ba615.tar.xz |
html: Some cleaning.
-rw-r--r-- | include/mupdf/html.h | 56 | ||||
-rw-r--r-- | source/html/css-parse.c | 21 |
2 files changed, 29 insertions, 48 deletions
diff --git a/include/mupdf/html.h b/include/mupdf/html.h index 16036144..eeb713a9 100644 --- a/include/mupdf/html.h +++ b/include/mupdf/html.h @@ -4,19 +4,15 @@ #include "mupdf/fitz.h" typedef struct fz_html_font_set_s fz_html_font_set; +typedef struct rule fz_css; +typedef struct property fz_css_property; +typedef struct box fz_html; struct fz_html_font_set_s { fz_font *fonts[16]; }; -fz_html_font_set *fz_new_html_font_set(fz_context *ctx); -void fz_free_html_font_set(fz_context *ctx, fz_html_font_set *htx); - -struct box *fz_generate_html(fz_context *ctx, fz_html_font_set *htx, fz_archive *zip, const char *base_uri, fz_buffer *buf); -void fz_layout_html(fz_context *ctx, struct box *box, float w, float h, float em); -void fz_draw_html(fz_context *ctx, struct box *box, float page_top, float page_bot, fz_device *dev, const fz_matrix *ctm); - enum { CSS_KEYWORD = 256, @@ -80,17 +76,6 @@ struct value struct value *next; }; -struct rule *new_rule(struct selector *selector, struct property *declaration); -struct selector *new_selector(const char *name); -struct condition *new_condition(int type, const char *key, const char *val); -struct property *new_property(const char *name, struct value *value, int spec); -struct value *new_value(int type, const char *value); - -int get_style_property_display(struct style *node); -struct rule *fz_parse_css(fz_context *ctx, struct rule *old, const char *source); -struct rule *fz_parse_css_file(fz_context *ctx, struct rule *chain, const char *filename); -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 { WS_NORMAL, WS_PRE, WS_NOWRAP, WS_PRE_WRAP, WS_PRE_LINE }; @@ -129,15 +114,6 @@ struct computed_style fz_font *font; }; -void apply_styles(fz_context *ctx, struct style *style, struct rule *rule, fz_xml *node); -void default_computed_style(struct computed_style *cstyle); -void compute_style(fz_context *ctx, fz_html_font_set *set, struct computed_style *cstyle, struct style *style); -float from_number(struct number, float em, float width); -float from_number_scale(struct number number, float scale, float em, float width); - -fz_font *fz_html_load_font(fz_context *ctx, fz_html_font_set *set, - const char *family, const char *variant, const char *style, const char *weight); - enum { BOX_BLOCK, /* block-level: contains block, break, and flow boxes */ @@ -177,4 +153,30 @@ struct flow struct flow *next; }; +struct rule *fz_parse_css(fz_context *ctx, struct rule *old, const char *source); +struct property *fz_parse_css_properties(fz_context *ctx, const char *source); + +struct rule *new_rule(struct selector *selector, struct property *declaration); +struct selector *new_selector(const char *name); +struct condition *new_condition(int type, const char *key, const char *val); +struct property *new_property(const char *name, struct value *value, int spec); +struct value *new_value(int type, const char *value); + +int get_style_property_display(struct style *node); + +void apply_styles(fz_context *ctx, struct style *style, struct rule *rule, fz_xml *node); +void default_computed_style(struct computed_style *cstyle); +void compute_style(fz_context *ctx, fz_html_font_set *set, struct computed_style *cstyle, struct style *style); +float from_number(struct number, float em, float width); +float from_number_scale(struct number number, float scale, float em, float width); + +fz_html_font_set *fz_new_html_font_set(fz_context *ctx); +fz_font *fz_html_load_font(fz_context *ctx, fz_html_font_set *set, + const char *family, const char *variant, const char *style, const char *weight); +void fz_free_html_font_set(fz_context *ctx, fz_html_font_set *htx); + +struct box *fz_generate_html(fz_context *ctx, fz_html_font_set *htx, fz_archive *zip, const char *base_uri, fz_buffer *buf); +void fz_layout_html(fz_context *ctx, struct box *box, float w, float h, float em); +void fz_draw_html(fz_context *ctx, struct box *box, float page_top, float page_bot, fz_device *dev, const fz_matrix *ctm); + #endif diff --git a/source/html/css-parse.c b/source/html/css-parse.c index d454dbf1..d4aa39ec 100644 --- a/source/html/css-parse.c +++ b/source/html/css-parse.c @@ -746,24 +746,3 @@ struct rule *fz_parse_css(fz_context *ctx, struct rule *chain, const char *sourc next(&buf); return parse_stylesheet(&buf, chain); } - -struct rule *fz_parse_css_file(fz_context *ctx, struct rule *chain, const char *filename) -{ - fz_buffer *buf = fz_read_file(ctx, filename); - - fz_try(ctx) - { - fz_write_buffer_byte(ctx, buf, 0); - chain = fz_parse_css(ctx, chain, (char*)buf->data); - } - fz_always(ctx) - { - fz_drop_buffer(ctx, buf); - } - fz_catch(ctx) - { - fz_rethrow(ctx); - } - - return chain; -} |