summaryrefslogtreecommitdiff
path: root/source/html
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2017-12-07 15:15:26 +0100
committerTor Andersson <tor.andersson@artifex.com>2017-12-13 15:01:05 +0100
commiteacd070190d0c7a7fbc905a2a292f38e282b5a82 (patch)
tree57971ec5acec6b5867cc313c3d2f6f6f619e35fe /source/html
parentfa9cd085533f68367c299e058ab3fbb7ad8a2dc6 (diff)
downloadmupdf-eacd070190d0c7a7fbc905a2a292f38e282b5a82.tar.xz
Parse XML using pool allocator.
This needs adding a fz_xml_doc type to hold the pool.
Diffstat (limited to 'source/html')
-rw-r--r--source/html/epub-doc.c12
-rw-r--r--source/html/html-layout.c14
2 files changed, 14 insertions, 12 deletions
diff --git a/source/html/epub-doc.c b/source/html/epub-doc.c
index 41b21361..91d6e6b5 100644
--- a/source/html/epub-doc.c
+++ b/source/html/epub-doc.c
@@ -358,7 +358,7 @@ epub_parse_ncx(fz_context *ctx, epub_document *doc, const char *path)
{
fz_archive *zip = doc->zip;
fz_buffer *buf;
- fz_xml *ncx;
+ fz_xml_doc *ncx;
char base_uri[2048];
fz_dirname(base_uri, path, sizeof base_uri);
@@ -367,7 +367,7 @@ epub_parse_ncx(fz_context *ctx, epub_document *doc, const char *path)
ncx = fz_parse_xml(ctx, buf, 0);
fz_drop_buffer(ctx, buf);
- doc->outline = epub_parse_ncx_imp(ctx, doc, fz_xml_find_down(ncx, "navMap"), base_uri);
+ doc->outline = epub_parse_ncx_imp(ctx, doc, fz_xml_find_down(fz_xml_root(ncx), "navMap"), base_uri);
fz_drop_xml(ctx, ncx);
}
@@ -386,8 +386,8 @@ epub_parse_header(fz_context *ctx, epub_document *doc)
{
fz_archive *zip = doc->zip;
fz_buffer *buf = NULL;
- fz_xml *container_xml = NULL;
- fz_xml *content_opf = NULL;
+ fz_xml_doc *container_xml = NULL;
+ fz_xml_doc *content_opf = NULL;
fz_xml *container, *rootfiles, *rootfile;
fz_xml *package, *manifest, *spine, *itemref, *metadata;
char base_uri[2048];
@@ -414,7 +414,7 @@ epub_parse_header(fz_context *ctx, epub_document *doc)
fz_drop_buffer(ctx, buf);
buf = NULL;
- container = fz_xml_find(container_xml, "container");
+ container = fz_xml_find(fz_xml_root(container_xml), "container");
rootfiles = fz_xml_find_down(container, "rootfiles");
rootfile = fz_xml_find_down(rootfiles, "rootfile");
full_path = fz_xml_att(rootfile, "full-path");
@@ -430,7 +430,7 @@ epub_parse_header(fz_context *ctx, epub_document *doc)
fz_drop_buffer(ctx, buf);
buf = NULL;
- package = fz_xml_find(content_opf, "package");
+ package = fz_xml_find(fz_xml_root(content_opf), "package");
version = fz_xml_att(package, "version");
if (!version || strcmp(version, "2.0"))
fz_warn(ctx, "unknown epub version: %s", version ? version : "<none>");
diff --git a/source/html/html-layout.c b/source/html/html-layout.c
index e5e4f597..d6f63975 100644
--- a/source/html/html-layout.c
+++ b/source/html/html-layout.c
@@ -2672,7 +2672,8 @@ detect_directionality(fz_context *ctx, fz_pool *pool, fz_html_box *box)
fz_html *
fz_parse_html(fz_context *ctx, fz_html_font_set *set, fz_archive *zip, const char *base_uri, fz_buffer *buf, const char *user_css)
{
- fz_xml *xml;
+ fz_xml_doc *xml;
+ fz_xml *root;
fz_html *html = NULL;
fz_css_match match;
@@ -2689,6 +2690,7 @@ fz_parse_html(fz_context *ctx, fz_html_font_set *set, fz_archive *zip, const cha
g.last_brk_cls = UCDN_LINEBREAK_CLASS_OP;
xml = fz_parse_xml(ctx, buf, 1);
+ root = fz_xml_root(xml);
fz_try(ctx)
g.css = fz_new_css(ctx);
@@ -2700,20 +2702,20 @@ fz_parse_html(fz_context *ctx, fz_html_font_set *set, fz_archive *zip, const cha
fz_try(ctx)
{
- if (fz_xml_find(xml, "FictionBook"))
+ if (fz_xml_find(root, "FictionBook"))
{
g.is_fb2 = 1;
fz_parse_css(ctx, g.css, fb2_default_css, "<default:fb2>");
if (fz_use_document_css(ctx))
- fb2_load_css(ctx, g.zip, g.base_uri, g.css, xml);
- g.images = load_fb2_images(ctx, xml);
+ fb2_load_css(ctx, g.zip, g.base_uri, g.css, root);
+ g.images = load_fb2_images(ctx, root);
}
else
{
g.is_fb2 = 0;
fz_parse_css(ctx, g.css, html_default_css, "<default:html>");
if (fz_use_document_css(ctx))
- html_load_css(ctx, g.zip, g.base_uri, g.css, xml);
+ html_load_css(ctx, g.zip, g.base_uri, g.css, root);
g.images = NULL;
}
@@ -2743,7 +2745,7 @@ fz_parse_html(fz_context *ctx, fz_html_font_set *set, fz_archive *zip, const cha
fz_apply_css_style(ctx, g.set, &html->root->style, &match);
// TODO: transfer page margins out of this hacky box
- generate_boxes(ctx, xml, html->root, &match, 0, DEFAULT_DIR, FZ_LANG_UNSET, &g);
+ generate_boxes(ctx, root, html->root, &match, 0, DEFAULT_DIR, FZ_LANG_UNSET, &g);
detect_directionality(ctx, g.pool, html->root);
}