From 8be72ca243ee902c2bc5b34ae28c6c3c1a837961 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Sun, 13 Jun 2021 16:41:54 +0200 Subject: [PATCH] [source] Show source files after libxml++ parsing. --- config2.h.in | 6 +++--- src/document/meson.build | 3 +++ src/document/renderer.c | 12 +++++++++++- src/ecmascript/spidermonkey/document.c | 3 +-- src/ecmascript/spidermonkey/document.h | 1 + 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/config2.h.in b/config2.h.in index 091ad2cf..e9943b95 100644 --- a/config2.h.in +++ b/config2.h.in @@ -100,9 +100,6 @@ /* Define if you want: zlib support */ #mesondefine CONFIG_GZIP -/* Define if you want: htmlcxx support */ -#mesondefine CONFIG_HTMLCXX - /* Define if you want: HTML highlighting support */ #mesondefine CONFIG_HTML_HIGHLIGHT @@ -245,6 +242,9 @@ /* Define if you want: XBEL bookmarks support */ #mesondefine CONFIG_XBEL_BOOKMARKS +/* Define if you want: libxml++ support */ +#mesondefine CONFIG_XML + /* Define if you want: XmlTo support */ #mesondefine CONFIG_XMLTO diff --git a/src/document/meson.build b/src/document/meson.build index 4857fcff..ad949ad2 100644 --- a/src/document/meson.build +++ b/src/document/meson.build @@ -6,4 +6,7 @@ if conf_data.get('CONFIG_DOM') endif subdir('html') subdir('plain') +if conf_data.get('CONFIG_XML') + subdir('xml') +endif srcs += files('docdata.c', 'document.c', 'format.c', 'forms.c', 'options.c', 'refresh.c', 'renderer.c') diff --git a/src/document/renderer.c b/src/document/renderer.c index f9751cbe..7fb012e0 100644 --- a/src/document/renderer.c +++ b/src/document/renderer.c @@ -19,6 +19,9 @@ #include "document/html/frames.h" #include "document/html/renderer.h" #include "document/plain/renderer.h" +#ifdef CONFIG_XML +#include "document/xml/renderer.h" +#endif #include "document/renderer.h" #include "document/view.h" #include "ecmascript/ecmascript.h" @@ -247,7 +250,14 @@ render_encoded_document(struct cache_entry *cached, struct document *document) } } } - +#ifdef CONFIG_XML + if (document->options.plain && cached->content_type + && (!c_strcasecmp("text/html", cached->content_type) + || !c_strcasecmp("application/xhtml+xml", cached->content_type))) { + render_source_document_cxx(cached, document, &buffer); + } + else +#endif if (document->options.plain) { #ifdef CONFIG_DOM if (cached->content_type diff --git a/src/ecmascript/spidermonkey/document.c b/src/ecmascript/spidermonkey/document.c index 990f7e7d..15421a33 100644 --- a/src/ecmascript/spidermonkey/document.c +++ b/src/ecmascript/spidermonkey/document.c @@ -60,7 +60,6 @@ static xmlpp::Document emptyDoc; static JSObject *getDoctype(JSContext *ctx, void *node); static bool document_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS::MutableHandleValue hvp); -static void *document_parse(struct document *document); JSClassOps document_ops = { JS_PropertyStub, nullptr, @@ -1263,7 +1262,7 @@ document_replace(JSContext *ctx, unsigned int argc, JS::Value *vp) return(true); } -static void * +void * document_parse(struct document *document) { struct cache_entry *cached = document->cached; diff --git a/src/ecmascript/spidermonkey/document.h b/src/ecmascript/spidermonkey/document.h index d5d52f70..6f3c5032 100644 --- a/src/ecmascript/spidermonkey/document.h +++ b/src/ecmascript/spidermonkey/document.h @@ -7,5 +7,6 @@ extern JSClass document_class; extern const spidermonkeyFunctionSpec document_funcs[]; extern JSPropertySpec document_props[]; +void *document_parse(struct document *document); #endif