summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/dom/core/node.h10
-rw-r--r--include/dom/core/tokenlist.h43
-rw-r--r--include/dom/dom.h2
-rw-r--r--include/dom/events/keyboard_event.h4
-rw-r--r--include/dom/html/html_canvas_element.h31
-rw-r--r--include/dom/html/html_elements.h9
-rw-r--r--include/dom/walk.h65
7 files changed, 157 insertions, 7 deletions
diff --git a/include/dom/core/node.h b/include/dom/core/node.h
index 9600e6d..90026a1 100644
--- a/include/dom/core/node.h
+++ b/include/dom/core/node.h
@@ -77,7 +77,7 @@ typedef struct dom_node_internal dom_node_internal;
* DOM node type
*/
typedef struct dom_node {
- void *vtable;
+ const void *vtable;
uint32_t refcnt;
} dom_node;
@@ -169,8 +169,8 @@ typedef struct dom_node_vtable {
dom_exception (*dom_node_set_user_data)(dom_node_internal *node,
dom_string *key, void *data,
dom_user_data_handler handler, void **result);
- dom_exception (*dom_node_get_user_data)(dom_node_internal *node,
- dom_string *key, void **result);
+ dom_exception (*dom_node_get_user_data)(const dom_node_internal *node,
+ const dom_string *key, void **result);
} dom_node_vtable;
/* The ref/unref methods define */
@@ -567,8 +567,8 @@ static inline dom_exception dom_node_set_user_data(struct dom_node *node,
(dom_node *) (n), (k), (void *) (d), \
(dom_user_data_handler) h, (void **) (r))
-static inline dom_exception dom_node_get_user_data(struct dom_node *node,
- dom_string *key, void **result)
+static inline dom_exception dom_node_get_user_data(const struct dom_node *node,
+ const dom_string *key, void **result)
{
return ((dom_node_vtable *) node->vtable)->dom_node_get_user_data(
(dom_node_internal *) node, key, result);
diff --git a/include/dom/core/tokenlist.h b/include/dom/core/tokenlist.h
new file mode 100644
index 0000000..718d3a5
--- /dev/null
+++ b/include/dom/core/tokenlist.h
@@ -0,0 +1,43 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2022 Daniel Silverstone <dsilvers@netsurf-browser.org>
+ */
+
+#ifndef dom_core_tokenlist_h_
+#define dom_core_tokenlist_h_
+
+#include <dom/core/exceptions.h>
+
+struct dom_element;
+struct dom_string;
+
+typedef struct dom_tokenlist dom_tokenlist;
+
+void dom_tokenlist_ref(struct dom_tokenlist *list);
+void dom_tokenlist_unref(struct dom_tokenlist *list);
+
+dom_exception dom_tokenlist_create(struct dom_element *ele, struct dom_string *attr, dom_tokenlist **list);
+
+dom_exception dom_tokenlist_get_length(struct dom_tokenlist *list,
+ uint32_t *length);
+dom_exception _dom_tokenlist_item(struct dom_tokenlist *list,
+ uint32_t index, struct dom_string **value);
+
+#define dom_tokenlist_item(l, i, n) _dom_tokenlist_item((dom_tokenlist *) (l), \
+ (uint32_t) (i), (struct dom_string **) (n))
+
+dom_exception dom_tokenlist_get_value(struct dom_tokenlist *list,
+ struct dom_string **value);
+
+dom_exception dom_tokenlist_set_value(struct dom_tokenlist *list,
+ struct dom_string *value);
+
+dom_exception dom_tokenlist_contains(struct dom_tokenlist *list, struct dom_string *value, bool *contains);
+
+dom_exception dom_tokenlist_add(struct dom_tokenlist *list, struct dom_string *value);
+
+dom_exception dom_tokenlist_remove(struct dom_tokenlist *list, struct dom_string *value);
+
+#endif
diff --git a/include/dom/dom.h b/include/dom/dom.h
index 1737f29..00bf3d9 100644
--- a/include/dom/dom.h
+++ b/include/dom/dom.h
@@ -32,6 +32,7 @@
#include <dom/core/doc_fragment.h>
#include <dom/core/entity_ref.h>
#include <dom/core/nodelist.h>
+#include <dom/core/tokenlist.h>
#include <dom/core/string.h>
#include <dom/core/text.h>
#include <dom/core/pi.h>
@@ -51,6 +52,7 @@
#include <dom/html/html_form_element.h>
#include <dom/html/html_input_element.h>
#include <dom/html/html_button_element.h>
+#include <dom/html/html_canvas_element.h>
#include <dom/html/html_text_area_element.h>
#include <dom/html/html_opt_group_element.h>
#include <dom/html/html_option_element.h>
diff --git a/include/dom/events/keyboard_event.h b/include/dom/events/keyboard_event.h
index 03cab4b..e3b7d50 100644
--- a/include/dom/events/keyboard_event.h
+++ b/include/dom/events/keyboard_event.h
@@ -41,8 +41,8 @@ dom_exception _dom_keyboard_event_get_code(dom_keyboard_event *evt,
dom_exception _dom_keyboard_event_get_location(dom_keyboard_event *evt,
dom_key_location *location);
-#define dom_keyboard_event_get_key_location(e, l) \
- _dom_keyboard_event_get_key_location( \
+#define dom_keyboard_event_get_location(e, l) \
+ _dom_keyboard_event_get_location( \
(dom_keyboard_event *) (e), (dom_key_location *) (l))
dom_exception _dom_keyboard_event_get_ctrl_key(dom_keyboard_event *evt,
diff --git a/include/dom/html/html_canvas_element.h b/include/dom/html/html_canvas_element.h
new file mode 100644
index 0000000..29c7668
--- /dev/null
+++ b/include/dom/html/html_canvas_element.h
@@ -0,0 +1,31 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2020 Vincent Sanders <vince@netsurf-browser.org>
+ */
+
+#ifndef dom_html_canvas_element_h_
+#define dom_html_canvas_element_h_
+
+#include <dom/inttypes.h>
+#include <dom/core/exceptions.h>
+
+#include <dom/html/html_document.h>
+
+typedef struct dom_html_canvas_element dom_html_canvas_element;
+
+dom_exception dom_html_canvas_element_get_width(
+ dom_html_canvas_element *object, dom_ulong *width);
+
+dom_exception dom_html_canvas_element_set_width(
+ dom_html_canvas_element *object, dom_ulong width);
+
+dom_exception dom_html_canvas_element_get_height(
+ dom_html_canvas_element *object, dom_ulong *height);
+
+dom_exception dom_html_canvas_element_set_height(
+ dom_html_canvas_element *object, dom_ulong height);
+
+
+#endif
diff --git a/include/dom/html/html_elements.h b/include/dom/html/html_elements.h
index 5b54bbe..6e954c5 100644
--- a/include/dom/html/html_elements.h
+++ b/include/dom/html/html_elements.h
@@ -12,6 +12,7 @@
DOM_HTML_ELEMENT_STRINGS_ENTRY(_UNKNOWN) \
DOM_HTML_ELEMENT_STRINGS_ENTRY(A) \
DOM_HTML_ELEMENT_STRINGS_ENTRY(ABBR) \
+ DOM_HTML_ELEMENT_STRINGS_ENTRY(ACRONYM) \
DOM_HTML_ELEMENT_STRINGS_ENTRY(ADDRESS) \
DOM_HTML_ELEMENT_STRINGS_ENTRY(APPLET) \
DOM_HTML_ELEMENT_STRINGS_ENTRY(AREA) \
@@ -23,6 +24,8 @@
DOM_HTML_ELEMENT_STRINGS_ENTRY(BASEFONT) \
DOM_HTML_ELEMENT_STRINGS_ENTRY(BDI) \
DOM_HTML_ELEMENT_STRINGS_ENTRY(BDO) \
+ DOM_HTML_ELEMENT_STRINGS_ENTRY(BGSOUND) \
+ DOM_HTML_ELEMENT_STRINGS_ENTRY(BIG) \
DOM_HTML_ELEMENT_STRINGS_ENTRY(BLOCKQUOTE) \
DOM_HTML_ELEMENT_STRINGS_ENTRY(BODY) \
DOM_HTML_ELEMENT_STRINGS_ENTRY(BR) \
@@ -81,11 +84,14 @@
DOM_HTML_ELEMENT_STRINGS_ENTRY(MAIN) \
DOM_HTML_ELEMENT_STRINGS_ENTRY(MAP) \
DOM_HTML_ELEMENT_STRINGS_ENTRY(MARK) \
+ DOM_HTML_ELEMENT_STRINGS_ENTRY(MARQUEE) \
DOM_HTML_ELEMENT_STRINGS_ENTRY(MENU) \
DOM_HTML_ELEMENT_STRINGS_ENTRY(MENUITEM) \
DOM_HTML_ELEMENT_STRINGS_ENTRY(META) \
DOM_HTML_ELEMENT_STRINGS_ENTRY(METER) \
DOM_HTML_ELEMENT_STRINGS_ENTRY(NAV) \
+ DOM_HTML_ELEMENT_STRINGS_ENTRY(NOBR) \
+ DOM_HTML_ELEMENT_STRINGS_ENTRY(NOFRAMES) \
DOM_HTML_ELEMENT_STRINGS_ENTRY(NOSCRIPT) \
DOM_HTML_ELEMENT_STRINGS_ENTRY(OBJECT) \
DOM_HTML_ELEMENT_STRINGS_ENTRY(OL) \
@@ -108,7 +114,9 @@
DOM_HTML_ELEMENT_STRINGS_ENTRY(SELECT) \
DOM_HTML_ELEMENT_STRINGS_ENTRY(SMALL) \
DOM_HTML_ELEMENT_STRINGS_ENTRY(SOURCE) \
+ DOM_HTML_ELEMENT_STRINGS_ENTRY(SPACER) \
DOM_HTML_ELEMENT_STRINGS_ENTRY(SPAN) \
+ DOM_HTML_ELEMENT_STRINGS_ENTRY(STRIKE) \
DOM_HTML_ELEMENT_STRINGS_ENTRY(STRONG) \
DOM_HTML_ELEMENT_STRINGS_ENTRY(STYLE) \
DOM_HTML_ELEMENT_STRINGS_ENTRY(SUB) \
@@ -126,6 +134,7 @@
DOM_HTML_ELEMENT_STRINGS_ENTRY(TITLE) \
DOM_HTML_ELEMENT_STRINGS_ENTRY(TR) \
DOM_HTML_ELEMENT_STRINGS_ENTRY(TRACK) \
+ DOM_HTML_ELEMENT_STRINGS_ENTRY(TT) \
DOM_HTML_ELEMENT_STRINGS_ENTRY(U) \
DOM_HTML_ELEMENT_STRINGS_ENTRY(UL) \
DOM_HTML_ELEMENT_STRINGS_ENTRY(VAR) \
diff --git a/include/dom/walk.h b/include/dom/walk.h
new file mode 100644
index 0000000..5de3546
--- /dev/null
+++ b/include/dom/walk.h
@@ -0,0 +1,65 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2021 Michael Drake <tlsa@netsurf-browser.org>
+ */
+
+/** \file
+ * This is an API for walking a loaded DOM.
+ */
+
+#ifndef dom_walk_h_
+#define dom_walk_h_
+
+enum dom_walk_stage {
+ DOM_WALK_STAGE_ENTER,
+ DOM_WALK_STAGE_LEAVE,
+};
+
+enum dom_walk_enable {
+ DOM_WALK_ENABLE_ENTER = (1 << DOM_WALK_STAGE_ENTER),
+ DOM_WALK_ENABLE_LEAVE = (1 << DOM_WALK_STAGE_LEAVE),
+ DOM_WALK_ENABLE_ALL = DOM_WALK_ENABLE_ENTER | DOM_WALK_ENABLE_LEAVE,
+};
+
+enum dom_walk_cmd {
+ DOM_WALK_CMD_CONTINUE, /**< Continue the tree walk. */
+ DOM_WALK_CMD_ABORT, /**< Early termination of the tree walk. */
+ DOM_WALK_CMD_SKIP, /**< Skip children (only for \ref DOM_WALK_ENABLE_ENTER). */
+};
+
+/**
+ * DOM walking callback.
+ *
+ * Client callback for DOM walk.
+ *
+ * \param[in] stage Whether the \ref node is being entered or left.
+ * \param[in] node The node being walked. Client must take ref itself.
+ * \param[in] type The node type.
+ * \param[in] pw Client private data.
+ * \return Tree walking client command.
+ */
+typedef enum dom_walk_cmd (*dom_walk_cb)(
+ enum dom_walk_stage stage,
+ dom_node_type type,
+ dom_node *node,
+ void *pw);
+
+
+/**
+ * Walk a DOM subtree.
+ *
+ * \param[in] mask Mask of stages to enable callback for.
+ * \param[in] cb The client callback function.
+ * \param[in] root Node to start walk from.
+ * \param[in] pw The client's private data.
+ * \return false for early termination of walk, true otherwise.
+ */
+dom_exception libdom_treewalk(
+ enum dom_walk_enable mask,
+ dom_walk_cb cb,
+ dom_node *root,
+ void *pw);
+
+#endif