summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2010-12-06 23:38:53 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2010-12-06 23:38:53 +0000
commitb79bcc3fef8a90c96b3db8dcb34ceea0f778e876 (patch)
treeb75a2f2c4609ccbc0fd4193dab4e861a44e3cd61 /src
parent6b110bebb8930b171145597cfa37ff1c1ac753f7 (diff)
downloadlibdom-b79bcc3fef8a90c96b3db8dcb34ceea0f778e876.tar.gz
libdom-b79bcc3fef8a90c96b3db8dcb34ceea0f778e876.tar.bz2
Provide mechanism for binding/client to define the features a document object should support.
Utilise this to decide whether to create a raw Document or an HTMLDocument instance. Disable the above decision, as the HTMLDocument implementation is garbage svn path=/trunk/libdom/; revision=11025
Diffstat (limited to 'src')
-rw-r--r--src/core/implementation.c27
-rw-r--r--src/html/html_document.c4
-rw-r--r--src/html/html_document.h2
3 files changed, 28 insertions, 5 deletions
diff --git a/src/core/implementation.c b/src/core/implementation.c
index 58adaf3..848457e 100644
--- a/src/core/implementation.c
+++ b/src/core/implementation.c
@@ -12,6 +12,8 @@
#include "core/document.h"
#include "core/document_type.h"
+#include "html/html_document.h"
+
#include "utils/namespace.h"
#include "utils/utils.h"
#include "utils/validate.h"
@@ -138,6 +140,7 @@ dom_exception dom_implementation_create_document_type(
/**
* Create a document node
*
+ * \param impl_type The type of document object to create
* \param namespace The namespace URI of the document element
* \param qname The qualified name of the document element
* \param doctype The type of document to create
@@ -168,6 +171,7 @@ dom_exception dom_implementation_create_document_type(
* finished with it.
*/
dom_exception dom_implementation_create_document(
+ uint32_t impl_type,
const char *namespace, const char *qname,
struct dom_document_type *doctype,
dom_alloc alloc, void *pw,
@@ -213,8 +217,27 @@ dom_exception dom_implementation_create_document(
return DOM_WRONG_DOCUMENT_ERR;
}
- /* Create document object */
- err = _dom_document_create(alloc, pw, daf, &d);
+ /* Create document object that reflects the required APIs */
+ /** \todo Why do these have different APIs?
+ * Why is the html document constructor public? */
+ /** \todo Of course, none of the HTML stuff actually works,
+ * so enabling it results in total breakage of the testsuite */
+#ifdef WITH_NON_BROKEN_HTML_IMPLEMENTATION
+ if (impl_type == DOM_IMPLEMENTATION_HTML) {
+ dom_html_document *html_doc;
+
+ err = dom_html_document_create(alloc, pw, NULL, NULL,
+ daf, NULL, DOM_HTML_PARSER, &html_doc);
+
+ d = (dom_document *) html_doc;
+ } else
+#else
+ UNUSED(impl_type);
+#endif
+ {
+ err = _dom_document_create(alloc, pw, daf, &d);
+ }
+
if (err != DOM_NO_ERR) {
dom_string_unref(qname_s);
dom_string_unref(namespace_s);
diff --git a/src/html/html_document.c b/src/html/html_document.c
index d62714e..a2845aa 100644
--- a/src/html/html_document.c
+++ b/src/html/html_document.c
@@ -15,7 +15,7 @@
/* Create a HTMLDocument */
dom_exception dom_html_document_create(dom_alloc alloc, void *pw, dom_msg msg,
void *msg_pw,
- dom_events_default_action_fetcher daf, dom_ui_handler ui,
+ dom_events_default_action_fetcher daf, dom_ui_handler *ui,
dom_parser_type pt, dom_html_document **doc)
{
assert(alloc != NULL);
@@ -30,7 +30,7 @@ dom_exception dom_html_document_create(dom_alloc alloc, void *pw, dom_msg msg,
/* Initialise a HTMLDocument */
dom_exception _dom_html_document_initialise(dom_html_document *doc,
dom_alloc alloc, void *pw, dom_msg msg, void *msg_pw,
- dom_events_default_action_fetcher daf, dom_ui_handler ui,
+ dom_events_default_action_fetcher daf, dom_ui_handler *ui,
dom_parser_type pt)
{
UNUSED(doc);
diff --git a/src/html/html_document.h b/src/html/html_document.h
index 4abab09..31770ef 100644
--- a/src/html/html_document.h
+++ b/src/html/html_document.h
@@ -36,7 +36,7 @@ struct dom_html_document {
/* Initialise a HTMLDocument */
dom_exception _dom_html_document_initialise(dom_html_document *doc,
dom_alloc alloc, void *pw, dom_msg msg, void *msg_pw,
- dom_events_default_action_fetcher daf, dom_ui_handler ui,
+ dom_events_default_action_fetcher daf, dom_ui_handler *ui,
dom_parser_type pt);
/* Finalise a HTMLDocument */
void _dom_html_document_finalise(dom_html_document *doc);