diff options
-rw-r--r-- | bindings/hubbub/parser.c | 3 | ||||
-rw-r--r-- | bindings/xml/xmlparser.c | 1 | ||||
-rw-r--r-- | include/dom/core/implementation.h | 11 | ||||
-rw-r--r-- | include/dom/html/html_document.h | 2 | ||||
-rw-r--r-- | src/core/implementation.c | 27 | ||||
-rw-r--r-- | src/html/html_document.c | 4 | ||||
-rw-r--r-- | src/html/html_document.h | 2 |
7 files changed, 43 insertions, 7 deletions
diff --git a/bindings/hubbub/parser.c b/bindings/hubbub/parser.c index 97d3e24..350d7ac 100644 --- a/bindings/hubbub/parser.c +++ b/bindings/hubbub/parser.c @@ -145,7 +145,8 @@ dom_hubbub_parser *dom_hubbub_parser_create( /* TODO: Just pass the dom_events_default_action_fetcher a NULL, * we should pass the real function when we integrate libDOM with * Netsurf */ - err = dom_implementation_create_document(NULL, NULL, NULL, + err = dom_implementation_create_document(DOM_IMPLEMENTATION_HTML, + NULL, NULL, NULL, alloc, pw, NULL, &parser->doc); if (err != DOM_NO_ERR) { hubbub_parser_destroy(parser->parser); diff --git a/bindings/xml/xmlparser.c b/bindings/xml/xmlparser.c index ff1f9d6..7f15b83 100644 --- a/bindings/xml/xmlparser.c +++ b/bindings/xml/xmlparser.c @@ -315,6 +315,7 @@ void xml_parser_start_document(void *ctx) * we should pass the real function when we integrate libDOM with * Netsurf */ err = dom_implementation_create_document( + DOM_IMPLEMENTATION_XML, /* namespace */ NULL, /* qname */ NULL, /* doctype */ NULL, diff --git a/include/dom/core/implementation.h b/include/dom/core/implementation.h index 6b3f143..0094217 100644 --- a/include/dom/core/implementation.h +++ b/include/dom/core/implementation.h @@ -19,6 +19,16 @@ struct dom_document_type; typedef const char *dom_implementation; +typedef enum dom_implementation_type { + DOM_IMPLEMENTATION_CORE = 0, + DOM_IMPLEMENTATION_XML = (1 << 0), /* not implemented */ + DOM_IMPLEMENTATION_HTML = (1 << 1), + + DOM_IMPLEMENTATION_ALL = DOM_IMPLEMENTATION_CORE | + DOM_IMPLEMENTATION_XML | + DOM_IMPLEMENTATION_HTML +} dom_implementation_type; + dom_exception dom_implementation_has_feature( const char *feature, const char *version, bool *result); @@ -30,6 +40,7 @@ dom_exception dom_implementation_create_document_type( struct dom_document_type **doctype); 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, diff --git a/include/dom/html/html_document.h b/include/dom/html/html_document.h index 00a355e..230024a 100644 --- a/include/dom/html/html_document.h +++ b/include/dom/html/html_document.h @@ -43,7 +43,7 @@ typedef struct dom_ui_handler dom_ui_handler; /* 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); /* Parse a data chunk into the HTMLDocument */ 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); |