summaryrefslogtreecommitdiff
path: root/include/dom
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2011-12-21 22:18:10 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2011-12-21 22:18:10 +0000
commit83f3338663c4969eebefd8c2c43bd3fc43587fdd (patch)
treee48ba69628c5ba793533094e308c1fce9acb21aa /include/dom
parent4ade8ad1c7b23e6eeeee6681acbdb43fb10cab43 (diff)
downloadlibdom-83f3338663c4969eebefd8c2c43bd3fc43587fdd.tar.gz
libdom-83f3338663c4969eebefd8c2c43bd3fc43587fdd.tar.bz2
Merge branches/jmb/dom-alloc-purge back to trunk
svn path=/trunk/libdom/; revision=13316
Diffstat (limited to 'include/dom')
-rw-r--r--include/dom/core/implementation.h2
-rw-r--r--include/dom/core/node.h2
-rw-r--r--include/dom/core/string.h22
-rw-r--r--include/dom/dom.h3
-rw-r--r--include/dom/events/document_event.h3
-rw-r--r--include/dom/events/event_target.h87
-rw-r--r--include/dom/functypes.h5
-rw-r--r--include/dom/html/html_document.h3
8 files changed, 79 insertions, 48 deletions
diff --git a/include/dom/core/implementation.h b/include/dom/core/implementation.h
index 0094217..2577829 100644
--- a/include/dom/core/implementation.h
+++ b/include/dom/core/implementation.h
@@ -36,14 +36,12 @@ dom_exception dom_implementation_has_feature(
dom_exception dom_implementation_create_document_type(
const char *qname,
const char *public_id, const char *system_id,
- dom_alloc alloc, void *pw,
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,
dom_events_default_action_fetcher daf,
struct dom_document **doc);
diff --git a/include/dom/core/node.h b/include/dom/core/node.h
index ee1f057..fbc3ee3 100644
--- a/include/dom/core/node.h
+++ b/include/dom/core/node.h
@@ -13,6 +13,7 @@
#include <dom/core/exceptions.h>
#include <dom/core/string.h>
+#include <dom/events/event_target.h>
struct dom_document;
struct dom_nodelist;
@@ -81,6 +82,7 @@ typedef struct dom_node {
/* DOM node vtable */
typedef struct dom_node_vtable {
+ dom_event_target_vtable base;
/* The DOM level 3 node's oprations */
dom_exception (*dom_node_get_node_name)(dom_node_internal *node,
diff --git a/include/dom/core/string.h b/include/dom/core/string.h
index b671cb7..1ff4f75 100644
--- a/include/dom/core/string.h
+++ b/include/dom/core/string.h
@@ -19,26 +19,22 @@
typedef struct dom_string dom_string;
/* Claim a reference on a DOM string */
-void dom_string_ref(dom_string *str);
+dom_string *dom_string_ref(dom_string *str);
/* Release a reference on a DOM string */
void dom_string_unref(dom_string *str);
/* Create a DOM string from a string of characters */
-dom_exception dom_string_create(dom_alloc alloc, void *pw,
- const uint8_t *ptr, size_t len, dom_string **str);
+dom_exception dom_string_create(const uint8_t *ptr, size_t len,
+ dom_string **str);
-/* Clone a dom_string */
-dom_exception dom_string_clone(dom_alloc alloc, void *pw,
- dom_string *str, dom_string **ret);
-
-/* Get the internal lwc_string */
-dom_exception dom_string_get_intern(dom_string *str,
+/* Obtain an interned representation of a dom string */
+dom_exception dom_string_intern(dom_string *str,
struct lwc_string_s **lwcstr);
/* Case sensitively compare two DOM strings */
-int dom_string_cmp(dom_string *s1, dom_string *s2);
+bool dom_string_isequal(const dom_string *s1, const dom_string *s2);
/* Case insensitively compare two DOM strings */
-int dom_string_icmp(dom_string *s1, dom_string *s2);
+bool dom_string_caseless_isequal(const dom_string *s1, const dom_string *s2);
/* Get the index of the first occurrence of a character in a dom string */
uint32_t dom_string_index(dom_string *str, uint32_t chr);
@@ -72,10 +68,6 @@ dom_exception dom_string_replace(dom_string *target,
dom_string *source, uint32_t i1, uint32_t i2,
dom_string **result);
-/* Duplicate a dom string */
-dom_exception dom_string_dup(dom_string *str,
- dom_string **result);
-
/* Calculate a hash value from a dom string */
uint32_t dom_string_hash(dom_string *str);
diff --git a/include/dom/dom.h b/include/dom/dom.h
index 371c773..c99a044 100644
--- a/include/dom/dom.h
+++ b/include/dom/dom.h
@@ -54,7 +54,4 @@ typedef enum dom_namespace {
extern dom_string *dom_namespaces[DOM_NAMESPACE_COUNT];
-dom_exception dom_initialise(dom_alloc alloc, void *pw);
-dom_exception dom_finalise(void);
-
#endif
diff --git a/include/dom/events/document_event.h b/include/dom/events/document_event.h
index bbb9f83..7f61df7 100644
--- a/include/dom/events/document_event.h
+++ b/include/dom/events/document_event.h
@@ -15,7 +15,6 @@
struct dom_event;
struct dom_document;
-struct lwc_string_s;
typedef struct dom_document dom_document_event;
@@ -80,7 +79,7 @@ typedef enum {
* \return a callback function, NULL if there is none.
*/
typedef dom_default_action_callback (*dom_events_default_action_fetcher)
- (struct lwc_string_s *type, dom_default_action_phase phase,
+ (dom_string *type, dom_default_action_phase phase,
void **pw);
dom_exception _dom_document_event_create_event(dom_document_event *de,
diff --git a/include/dom/events/event_target.h b/include/dom/events/event_target.h
index 51226ed..e55b6cb 100644
--- a/include/dom/events/event_target.h
+++ b/include/dom/events/event_target.h
@@ -14,46 +14,95 @@
struct dom_event_listener;
struct dom_event;
-struct dom_node_internal;
-typedef struct dom_node_internal dom_event_target;
+/* Event target is a mixin interface, thus has no concrete implementation.
+ * Subclasses must provide implementations of the event target methods. */
+typedef struct dom_event_target {
+ void *vtable;
+} dom_event_target;
-dom_exception _dom_event_target_add_event_listener(dom_event_target *et,
- dom_string *type, struct dom_event_listener *listener,
- bool capture);
+typedef struct dom_event_target_vtable {
+ dom_exception (*add_event_listener)(
+ dom_event_target *et, dom_string *type,
+ struct dom_event_listener *listener,
+ bool capture);
+ dom_exception (*remove_event_listener)(
+ dom_event_target *et, dom_string *type,
+ struct dom_event_listener *listener,
+ bool capture);
+ dom_exception (*dispatch_event)(
+ dom_event_target *et,
+ struct dom_event *evt, bool *success);
+ dom_exception (*add_event_listener_ns)(
+ dom_event_target *et,
+ dom_string *namespace, dom_string *type,
+ struct dom_event_listener *listener,
+ bool capture);
+ dom_exception (*remove_event_listener_ns)(
+ dom_event_target *et,
+ dom_string *namespace, dom_string *type,
+ struct dom_event_listener *listener,
+ bool capture);
+} dom_event_target_vtable;
+
+static inline dom_exception dom_event_target_add_event_listener(
+ dom_event_target *et, dom_string *type,
+ struct dom_event_listener *listener, bool capture)
+{
+ return ((dom_event_target_vtable *) et->vtable)->add_event_listener(
+ et, type, listener, capture);
+}
#define dom_event_target_add_event_listener(et, t, l, c) \
- _dom_event_target_add_event_listener((dom_event_target *) (et),\
+ dom_event_target_add_event_listener((dom_event_target *) (et),\
(dom_string *) (t), (struct dom_event_listener *) (l), \
(bool) (c))
-dom_exception _dom_event_target_remove_event_listener(dom_event_target *et,
- dom_string *type, struct dom_event_listener *listener,
- bool capture);
+static inline dom_exception dom_event_target_remove_event_listener(
+ dom_event_target *et, dom_string *type,
+ struct dom_event_listener *listener, bool capture)
+{
+ return ((dom_event_target_vtable *) et->vtable)->remove_event_listener(
+ et, type, listener, capture);
+}
#define dom_event_target_remove_event_listener(et, t, l, c) \
- _dom_event_target_remove_event_listener(\
+ dom_event_target_remove_event_listener(\
(dom_event_target *) (et), (dom_string *) (t),\
(struct dom_event_listener *) (l), (bool) (c))
-dom_exception _dom_event_target_dispatch_event(dom_event_target *et,
- struct dom_event *evt, bool *success);
+static inline dom_exception dom_event_target_dispatch_event(
+ dom_event_target *et, struct dom_event *evt, bool *success)
+{
+ return ((dom_event_target_vtable *) et->vtable)->dispatch_event(
+ et, evt, success);
+}
#define dom_event_target_dispatch_event(et, e, s) \
- _dom_event_target_dispatch_event((dom_event_target *) (et),\
+ dom_event_target_dispatch_event((dom_event_target *) (et),\
(struct dom_event *) (e), (bool *) (s))
-dom_exception _dom_event_target_add_event_listener_ns(dom_event_target *et,
+static inline dom_exception dom_event_target_add_event_listener_ns(
+ dom_event_target *et,
dom_string *namespace, dom_string *type,
- struct dom_event_listener *listener, bool capture);
+ struct dom_event_listener *listener, bool capture)
+{
+ return ((dom_event_target_vtable *) et->vtable)->add_event_listener_ns(
+ et, namespace, type, listener, capture);
+}
#define dom_event_target_add_event_listener_ns(et, n, t, l, c) \
- _dom_event_target_add_event_listener_ns(\
+ dom_event_target_add_event_listener_ns(\
(dom_event_target *) (et), (dom_string *) (n),\
(dom_string *) (t), (struct dom_event_listener *) (l),\
(bool) (c))
-dom_exception _dom_event_target_remove_event_listener_ns(dom_event_target *et,
+static inline dom_exception dom_event_target_remove_event_listener_ns(
+ dom_event_target *et,
dom_string *namespace, dom_string *type,
- struct dom_event_listener *listener, bool capture);
+ struct dom_event_listener *listener, bool capture)
+{
+ return ((dom_event_target_vtable *) et->vtable)->remove_event_listener_ns(
+ et, namespace, type, listener, capture);
+}
#define dom_event_target_remove_event_listener_ns(et, n, t, l, c) \
- _dom_event_target_remove_event_listener_ns(\
+ dom_event_target_remove_event_listener_ns(\
(dom_event_target *) (et), (dom_string *) (n),\
(dom_string *) (t), (struct dom_event_listener *) (l),\
(bool) (c))
diff --git a/include/dom/functypes.h b/include/dom/functypes.h
index 18b644a..31a7ee8 100644
--- a/include/dom/functypes.h
+++ b/include/dom/functypes.h
@@ -12,11 +12,6 @@
#include <inttypes.h>
/**
- * Type of allocation function for DOM implementation
- */
-typedef void *(*dom_alloc)(void *ptr, size_t size, void *pw);
-
-/**
* Severity levels for dom_msg function, based on syslog(3)
*/
enum {
diff --git a/include/dom/html/html_document.h b/include/dom/html/html_document.h
index 55bc12b..d03c117 100644
--- a/include/dom/html/html_document.h
+++ b/include/dom/html/html_document.h
@@ -41,8 +41,7 @@ struct dom_ui_handler {
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_exception dom_html_document_create(dom_msg msg, void *msg_pw,
dom_events_default_action_fetcher daf, dom_ui_handler *ui,
dom_parser_type pt, dom_html_document **doc);