Author: jmb
Date: Mon Aug 30 08:06:19 2010
New Revision: 10724
URL:
http://source.netsurf-browser.org?rev=10724&view=rev
Log:
Merge branches/struggleyb/libdom-html to trunk.
A few additional fixes to reduce the number of regressions to single figures.
Added:
trunk/dom/include/dom/html/
- copied from r10721, branches/struggleyb/libdom-html/include/dom/html/
trunk/dom/src/html/
- copied from r10721, branches/struggleyb/libdom-html/src/html/
Modified:
trunk/dom/Makefile
trunk/dom/include/dom/bootstrap/implpriv.h
trunk/dom/include/dom/core/attr.h
trunk/dom/include/dom/core/exceptions.h
trunk/dom/include/dom/events/document_event.h
trunk/dom/include/dom/html/html_document.h
trunk/dom/src/bootstrap/implementation.c
trunk/dom/src/core/attr.c
trunk/dom/src/core/attr.h
trunk/dom/src/core/document.c
trunk/dom/src/core/document.h
trunk/dom/src/core/document_type.c
trunk/dom/src/core/document_type.h
trunk/dom/src/core/element.c
trunk/dom/src/core/element.h
trunk/dom/src/core/node.c
trunk/dom/src/core/node.h
trunk/dom/src/events/event_target.c
trunk/dom/src/events/event_target.h
trunk/dom/src/html/Makefile
trunk/dom/src/html/html_document.c
trunk/dom/src/html/html_document.h
trunk/dom/src/html/html_element.c
Modified: trunk/dom/Makefile
URL:
http://source.netsurf-browser.org/trunk/dom/Makefile?rev=10724&r1=107...
==============================================================================
--- trunk/dom/Makefile (original)
+++ trunk/dom/Makefile Mon Aug 30 08:06:19 2010
@@ -14,7 +14,7 @@
-Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes \
-Wmissing-declarations -Wnested-externs -Werror -pedantic
CFLAGS := -std=c99 -D_BSD_SOURCE -I$(CURDIR)/include/ \
- -I$(CURDIR)/src $(WARNFLAGS) $(CFLAGS)
+ -I$(CURDIR)/src -I$(CURDIR)/binding $(WARNFLAGS) $(CFLAGS)
# Parserutils & wapcaplet
ifneq ($(findstring clean,$(MAKECMDGOALS)),clean)
Modified: trunk/dom/include/dom/bootstrap/implpriv.h
URL:
http://source.netsurf-browser.org/trunk/dom/include/dom/bootstrap/implpri...
==============================================================================
--- trunk/dom/include/dom/bootstrap/implpriv.h (original)
+++ trunk/dom/include/dom/bootstrap/implpriv.h Mon Aug 30 08:06:19 2010
@@ -243,21 +243,4 @@
/* Register a source with the DOM library */
dom_exception dom_register_source(struct dom_implementation_source *source);
-/* Create a DOM document */
-dom_exception dom_document_create(struct dom_implementation *impl,
- dom_alloc alloc, void *pw,
- dom_events_default_action_fetcher daf,
- struct dom_document **doc);
-
-/* Set a document's buffer */
-void dom_document_set_buffer(struct dom_document *doc, uint8_t *buffer,
- size_t buffer_len);
-
-/* Create a DOM document type */
-dom_exception dom_document_type_create(struct dom_string *qname,
- struct dom_string *public_id,
- struct dom_string *system_id,
- dom_alloc alloc, void *pw,
- struct dom_document_type **doctype);
-
#endif
Modified: trunk/dom/include/dom/core/attr.h
URL:
http://source.netsurf-browser.org/trunk/dom/include/dom/core/attr.h?rev=1...
==============================================================================
--- trunk/dom/include/dom/core/attr.h (original)
+++ trunk/dom/include/dom/core/attr.h Mon Aug 30 08:06:19 2010
@@ -20,6 +20,17 @@
struct dom_string;
typedef struct dom_attr dom_attr;
+
+/**
+ * The attribute type
+ */
+typedef enum {
+ DOM_ATTR_UNSET = 0,
+ DOM_ATTR_STRING,
+ DOM_ATTR_BOOL,
+ DOM_ATTR_SHORT,
+ DOM_ATTR_INTEGER
+} dom_attr_type;
/* DOM Attr vtable */
typedef struct dom_attr_vtable {
@@ -102,4 +113,39 @@
#define dom_attr_is_id(a, r) dom_attr_is_id((struct dom_attr *) (a), \
(bool *) (r))
+/*-----------------------------------------------------------------------*/
+/**
+ * Following are our implementation specific APIs.
+ *
+ * These APIs are defined for the purpose that there are some attributes in
+ * HTML and other DOM module whose type is not DOMString, but unsigned long or
+ * boolean, for those types of attributes, clients should call one of the
+ * following APIs to set it.
+ *
+ * When an Attr node is created, its type is unset and it can be turned into
+ * any of the four types. Once the type is fixed by calling any of the four
+ * APIs:
+ * dom_attr_set_value
+ * dom_attr_set_integer
+ * dom_attr_set_short
+ * dom_attr_set_bool
+ * it can't be modified in future.
+ *
+ * For integer/short/bool type of attributes, we provide no string
+ * repensentation of them, so when you call dom_attr_get_value on these
+ * three type of attribute nodes, you will always get a empty dom_string.
+ * If you want to do something with Attr node, you must know its type
+ * firstly by calling dom_attr_get_type before you decide to call other
+ * dom_attr_get_* functions.
+ */
+dom_attr_type dom_attr_get_type(dom_attr *a);
+dom_exception dom_attr_get_integer(dom_attr *a, unsigned long *value);
+dom_exception dom_attr_set_integer(dom_attr *a, unsigned long value);
+dom_exception dom_attr_get_short(dom_attr *a, unsigned short *value);
+dom_exception dom_attr_set_short(dom_attr *a, unsigned short value);
+dom_exception dom_attr_get_bool(dom_attr *a, bool *value);
+dom_exception dom_attr_set_bool(dom_attr *a, bool value);
+/* Make a attribute node readonly */
+void dom_attr_mark_readonly(dom_attr *a);
+
#endif
Modified: trunk/dom/include/dom/core/exceptions.h
URL:
http://source.netsurf-browser.org/trunk/dom/include/dom/core/exceptions.h...
==============================================================================
--- trunk/dom/include/dom/core/exceptions.h (original)
+++ trunk/dom/include/dom/core/exceptions.h Mon Aug 30 08:06:19 2010
@@ -44,7 +44,8 @@
DOM_UNSPECIFIED_EVENT_TYPE_ERR = DOM_EXCEPTION_CLASS_EVENT + 0,
DOM_DISPATCH_REQUEST_ERR = DOM_EXCEPTION_CLASS_EVENT + 1,
- DOM_NO_MEM_ERR = DOM_EXCEPTION_CLASS_INTERNAL + 0
+ DOM_NO_MEM_ERR = DOM_EXCEPTION_CLASS_INTERNAL + 0,
+ DOM_ATTR_WRONG_TYPE_ERR = DOM_EXCEPTION_CLASS_INTERNAL + 1
/* our own internal error */
} dom_exception;
Modified: trunk/dom/include/dom/events/document_event.h
URL:
http://source.netsurf-browser.org/trunk/dom/include/dom/events/document_e...
==============================================================================
--- trunk/dom/include/dom/events/document_event.h (original)
+++ trunk/dom/include/dom/events/document_event.h Mon Aug 30 08:06:19 2010
@@ -7,6 +7,8 @@
#ifndef dom_events_document_event_h_
#define dom_events_document_event_h_
+
+#include <stdbool.h>
#include <dom/core/exceptions.h>
@@ -18,15 +20,68 @@
typedef struct dom_document dom_document_event;
/**
+ * The callback function which is used to process the default action of any
+ * event.
+ *
+ * As ::dom_default_action_phase defines, we have three points in our
+ * implementation where these kinds of callbacks get invoked.
+ *
+ * When the implementation start to dispatch certain event, it firstly invoke
+ * the following callback, which should process the event before the normal
+ * event flow.
+ *
+ * Take a MousePressed event on a check box object as example:
+ * 1. The 'pressed' event is generated by OS and catched by our UI code;
+ * 2. The UI code dispatch the event to DOM;
+ * 3. DOM trys to dispatch the event as what the spec said;
+ * 4. Before the real event flow happens, DOM get the
+ * dom_default_action_callback function from the
+ * dom_events_default_action_fetcher with param
+ * DOM_DEFAULT_ACTION_STARTED, and then call it;
+ * 5. The callback function invoke some System-denpendent API to make the
+ * checkbox checked and then return;
+ * 6. Normal event flow goes on.
+ * 7. When the implementation reach the end of the event flow, it check whether
+ * the event's default action is prevented, if it is, then go to step 8,
+ * else go to step 9.
+ * 8. The event's default action get prevented, DOM get the
+ * dom_default_action_callback function from the
+ * dom_events_default_action_fetcher with param
+ * DOM_DEFAULT_ACTION_PREVENTED, and then call it.
+ * 8. The event's default action does not get prevented, DOM get the
+ * dom_default_action_callback function from the
+ * dom_events_default_action_fetcher with param
+ * DOM_DEFAULT_ACTION_END, and then call it.
+ *
+ * @note: the point here is that we want the UI related stuff to be done
+ * within the default action code. The DOM only take care of the content tree
+ * and the event flow itself.
+ */
+typedef void (*dom_default_action_callback)(struct dom_event *evt, void *pw);
+
+/**
+ * The default action phase
+ *
+ * @note: we define the following three values to fetch three different types
+ * of dom_default_action_callback function and their private data.
+ */
+typedef enum {
+ DOM_DEFAULT_ACTION_STARTED = 0,
+ DOM_DEFAULT_ACTION_PREVENTED,
+ DOM_DEFAULT_ACTION_END
+} dom_default_action_phase;
+
+/**
* The default action fetcher
*
- * @note: When the implementation reach the end of the event flow, it will call
- * this function to get the default action handler. If it does not return a
- * NULL, the returned dom_event_listener will be invoked as the event is not
- * canceled.
+ * \param type The type of the event
+ * \param phase The phase of the default action callback
+ * \param pw The return privat data of the callback function
+ * \return a callback function, NULL if there is none.
*/
-typedef struct dom_event_listener *(*dom_events_default_action_fetcher)
- (struct lwc_string_s *name, struct lwc_string_s *type);
+typedef dom_default_action_callback (*dom_events_default_action_fetcher)
+ (struct lwc_string_s *type, dom_default_action_phase phase,
+ void **pw);
dom_exception _dom_document_event_create_event(dom_document_event *de,
struct dom_string *type, struct dom_event **evt);
Modified: trunk/dom/include/dom/html/html_document.h
URL:
http://source.netsurf-browser.org/trunk/dom/include/dom/html/html_documen...
==============================================================================
--- trunk/dom/include/dom/html/html_document.h (original)
+++ trunk/dom/include/dom/html/html_document.h Mon Aug 30 08:06:19 2010
@@ -12,8 +12,8 @@
#include <dom/functypes.h>
#include <dom/events/document_event.h>
-struct lwc_context_s;
struct dom_element;
+struct dom_html_collection;
struct dom_html_element;
struct dom_nodelist;
@@ -42,7 +42,7 @@
/* Create a HTMLDocument */
dom_exception dom_html_document_create(dom_alloc alloc, void *pw, dom_msg msg,
- void *msg_pw, struct lwc_context_s *ctx,
+ void *msg_pw,
dom_events_default_action_fetcher daf, dom_ui_handler ui,
dom_parser_type pt, dom_html_document **doc);
@@ -70,15 +70,15 @@
dom_exception dom_html_document_set_body(dom_html_document *doc,
struct dom_html_element *body);
dom_exception dom_html_document_get_images(dom_html_document *doc,
- struct dom_html_collectoin **col);
+ struct dom_html_collection **col);
dom_exception dom_html_document_get_applets(dom_html_document *doc,
- struct dom_html_collectoin **col);
+ struct dom_html_collection **col);
dom_exception dom_html_document_get_links(dom_html_document *doc,
- struct dom_html_collectoin **col);
+ struct dom_html_collection **col);
dom_exception dom_html_document_get_forms(dom_html_document *doc,
- struct dom_html_collectoin **col);
+ struct dom_html_collection **col);
dom_exception dom_html_document_get_anchors(dom_html_document *doc,
- struct dom_html_collectoin **col);
+ struct dom_html_collection **col);
dom_exception dom_html_document_get_cookie(dom_html_document *doc,
struct dom_string **cookie);
dom_exception dom_html_document_set_cookie(dom_html_document *doc,
Modified: trunk/dom/src/bootstrap/implementation.c
URL:
http://source.netsurf-browser.org/trunk/dom/src/bootstrap/implementation....
==============================================================================
--- trunk/dom/src/bootstrap/implementation.c (original)
+++ trunk/dom/src/bootstrap/implementation.c Mon Aug 30 08:06:19 2010
@@ -23,6 +23,7 @@
#include <libwapcaplet/libwapcaplet.h>
#include "core/node.h"
+#include "core/document.h"
#include "core/document_type.h"
#include "utils/utils.h"
@@ -231,7 +232,7 @@
return DOM_NAMESPACE_ERR;
/* Create the doctype */
- err = dom_document_type_create(qname, public_id, system_id,
+ err = _dom_document_type_create(qname, public_id, system_id,
alloc, pw, &d);
if (err != DOM_NO_ERR)
return err;
@@ -308,7 +309,7 @@
}
/* Create document object */
- err = dom_document_create(impl, alloc, pw, daf, &d);
+ err = _dom_document_create(impl, alloc, pw, daf, &d);
if (err != DOM_NO_ERR)
return err;
Modified: trunk/dom/src/core/attr.c
URL:
http://source.netsurf-browser.org/trunk/dom/src/core/attr.c?rev=10724&...
==============================================================================
--- trunk/dom/src/core/attr.c (original)
+++ trunk/dom/src/core/attr.c Mon Aug 30 08:06:19 2010
@@ -19,12 +19,13 @@
#include "core/document.h"
#include "core/entity_ref.h"
#include "core/node.h"
+#include "core/element.h"
#include "utils/utils.h"
struct dom_element;
/**
- * DOM node attribute
+ * DOM attribute node
*/
struct dom_attr {
struct dom_node_internal base; /**< Base node */
@@ -35,6 +36,16 @@
struct dom_type_info *schema_type_info; /**< Type information */
bool is_id; /**< Whether this attribute is a ID attribute */
+
+ dom_attr_type type; /**< The type of this attribute */
+
+ union {
+ unsigned long lvalue;
+ unsigned short svalue;
+ bool bvalue;
+ } value; /**< The special type value of this attribute */
+
+ bool read_only; /**< Whether this attribute is readonly */
};
/* The vtable for dom_attr node */
@@ -62,7 +73,7 @@
* \param name The (local) name of the node to create
* \param namespace The namespace URI of the attribute, or NULL
* \param prefix The namespace prefix of the attribute, or NULL
- * \param specified Whtether this attribute is specified
+ * \param specified Whether this attribute is specified
* \param result Pointer to location to receive created attribute
* \return DOM_NO_ERR on success,
* DOM_NO_MEM_ERR on memory exhaustion.
@@ -127,6 +138,9 @@
a->specified = specified;
a->schema_type_info = NULL;
a->is_id = false;
+ /* The attribute type is unset when it is created */
+ a->type = DOM_ATTR_UNSET;
+ a->read_only = false;
*result = a;
@@ -165,6 +179,206 @@
_dom_document_alloc(doc, attr, 0);
}
+/*-----------------------------------------------------------------------*/
+/* Following are our implementation specific APIs */
+
+/**
+ * Get the Attr Node type
+ *
+ * \param a The attribute node
+ * \return the type
+ */
+dom_attr_type dom_attr_get_type(dom_attr *a)
+{
+ return a->type;
+}
+
+/**
+ * Get the integer value of this attribute
+ *
+ * \param a The attribute object
+ * \param value The returned value
+ * \return DOM_NO_ERR on success,
+ * DOM_ATTR_WRONG_TYPE_ERR if the attribute node is not a integer
+ * attribute
+ */
+dom_exception dom_attr_get_integer(dom_attr *a, unsigned long *value)
+{
+ if (a->type != DOM_ATTR_INTEGER)
+ return DOM_ATTR_WRONG_TYPE_ERR;
+
+ *value = a->value.lvalue;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Set the integer value of this attribute
+ *
+ * \param a The attribute object
+ * \param value The new value
+ * \return DOM_NO_ERR on success,
+ * DOM_ATTR_WRONG_TYPE_ERR if the attribute node is not a integer
+ * attribute
+ */
+dom_exception dom_attr_set_integer(dom_attr *a, unsigned long value)
+{
+ /* If this is the first set method, we should fix this attribute
+ * type */
+ if (a->type == DOM_ATTR_UNSET)
+ a->type = DOM_ATTR_INTEGER;
+
+ if (a->type != DOM_ATTR_INTEGER)
+ return DOM_ATTR_WRONG_TYPE_ERR;
+
+ if (a->value.lvalue == value)
+ return DOM_NO_ERR;
+
+ a->value.lvalue = value;
+
+ struct dom_document *doc = dom_node_get_owner(a);
+ struct dom_node_internal *ele = dom_node_get_parent(a);
+ bool success = true;
+ dom_exception err;
+ err = _dom_dispatch_attr_modified_event(doc, ele, NULL, NULL,
+ (dom_event_target *) a, NULL,
+ DOM_MUTATION_MODIFICATION, &success);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ success = true;
+ err = _dom_dispatch_subtree_modified_event(doc,
+ (dom_event_target *) a, &success);
+ return err;
+}
+
+/**
+ * Get the short value of this attribute
+ *
+ * \param a The attribute object
+ * \param value The returned value
+ * \return DOM_NO_ERR on success,
+ * DOM_ATTR_WRONG_TYPE_ERR if the attribute node is not a short
+ * attribute
+ */
+dom_exception dom_attr_get_short(dom_attr *a, unsigned short *value)
+{
+ if (a->type != DOM_ATTR_SHORT)
+ return DOM_ATTR_WRONG_TYPE_ERR;
+
+ *value = a->value.svalue;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Set the short value of this attribute
+ *
+ * \param a The attribute object
+ * \param value The new value
+ * \return DOM_NO_ERR on success,
+ * DOM_ATTR_WRONG_TYPE_ERR if the attribute node is not a short
+ * attribute
+ */
+dom_exception dom_attr_set_short(dom_attr *a, unsigned short value)
+{
+ /* If this is the first set method, we should fix this attribute
+ * type */
+ if (a->type == DOM_ATTR_UNSET)
+ a->type = DOM_ATTR_SHORT;
+
+ if (a->type != DOM_ATTR_SHORT)
+ return DOM_ATTR_WRONG_TYPE_ERR;
+
+ if (a->value.svalue == value)
+ return DOM_NO_ERR;
+
+ a->value.svalue = value;
+
+ struct dom_document *doc = dom_node_get_owner(a);
+ struct dom_node_internal *ele = dom_node_get_parent(a);
+ bool success = true;
+ dom_exception err;
+ err = _dom_dispatch_attr_modified_event(doc, ele, NULL, NULL,
+ (dom_event_target *) a, NULL,
+ DOM_MUTATION_MODIFICATION, &success);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ success = true;
+ err = _dom_dispatch_subtree_modified_event(doc,
+ (dom_event_target *) a, &success);
+ return err;
+}
+
+/**
+ * Get the bool value of this attribute
+ *
+ * \param a The attribute object
+ * \param value The returned value
+ * \return DOM_NO_ERR on success,
+ * DOM_ATTR_WRONG_TYPE_ERR if the attribute node is not a bool
+ * attribute
+ */
+dom_exception dom_attr_get_bool(dom_attr *a, bool *value)
+{
+ if (a->type != DOM_ATTR_BOOL)
+ return DOM_ATTR_WRONG_TYPE_ERR;
+
+ *value = a->value.bvalue;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Set the bool value of this attribute
+ *
+ * \param a The attribute object
+ * \param value The new value
+ * \return DOM_NO_ERR on success,
+ * DOM_ATTR_WRONG_TYPE_ERR if the attribute node is not a bool
+ * attribute
+ */
+dom_exception dom_attr_set_bool(dom_attr *a, bool value)
+{
+ /* If this is the first set method, we should fix this attribute
+ * type */
+ if (a->type == DOM_ATTR_UNSET)
+ a->type = DOM_ATTR_BOOL;
+
+ if (a->type != DOM_ATTR_BOOL)
+ return DOM_ATTR_WRONG_TYPE_ERR;
+
+ if (a->value.bvalue == value)
+ return DOM_NO_ERR;
+
+ a->value.bvalue = value;
+
+ struct dom_document *doc = dom_node_get_owner(a);
+ struct dom_node_internal *ele = dom_node_get_parent(a);
+ bool success = true;
+ dom_exception err;
+ err = _dom_dispatch_attr_modified_event(doc, ele, NULL, NULL,
+ (dom_event_target *) a, NULL,
+ DOM_MUTATION_MODIFICATION, &success);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ success = true;
+ err = _dom_dispatch_subtree_modified_event(doc,
+ (dom_event_target *) a, &success);
+ return err;
+}
+
+/**
+ * Set the node as a readonly attribute
+ *
+ * \param a The attribute
+ */
+void dom_attr_mark_readonly(dom_attr *a)
+{
+ a->read_only = true;
+}
/* -------------------------------------------------------------------- */
@@ -225,6 +439,18 @@
NULL, 0, &value);
if (err != DOM_NO_ERR) {
return err;
+ }
+
+ /* Force unknown types to strings, if necessary */
+ if (attr->type == DOM_ATTR_UNSET && a->first_child != NULL) {
+ attr->type = DOM_ATTR_STRING;
+ }
+
+ /* If this attribute node is not a string one, we just return an empty
+ * string */
+ if (attr->type != DOM_ATTR_STRING) {
+ *result = value;
+ return DOM_NO_ERR;
}
/* Traverse children, building a string representation as we go */
@@ -298,10 +524,33 @@
if (_dom_node_readonly(a))
return DOM_NO_MODIFICATION_ALLOWED_ERR;
+ /* If this is the first set method, we should fix this attribute
+ * type */
+ if (attr->type == DOM_ATTR_UNSET)
+ attr->type = DOM_ATTR_STRING;
+
+ if (attr->type != DOM_ATTR_STRING)
+ return DOM_ATTR_WRONG_TYPE_ERR;
+
+ dom_string *name = NULL;
+
+ err = _dom_attr_get_name(attr, &name);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ dom_string *parsed = NULL;
+ err = dom_element_parse_attribute(a->parent, name, value, &parsed);
+ if (err != DOM_NO_ERR) {
+ dom_string_unref(name);
+ return err;
+ }
+
/* Create text node containing new value */
- err = dom_document_create_text_node(a->owner, value, &text);
+ err = dom_document_create_text_node(a->owner, parsed, &text);
if (err != DOM_NO_ERR)
return err;
+
+ dom_string_unref(parsed);
/* Destroy children of this node */
for (c = a->first_child; c != NULL; c = d) {
@@ -561,3 +810,14 @@
attr->specified = specified;
}
+/**
+ * Whether this attribute node is readonly
+ *
+ * \param a The node
+ * \return true if this Attr is readonly, false otherwise
+ */
+bool _dom_attr_readonly(const dom_attr *a)
+{
+ return a->read_only;
+}
+
Modified: trunk/dom/src/core/attr.h
URL:
http://source.netsurf-browser.org/trunk/dom/src/core/attr.h?rev=10724&...
==============================================================================
--- trunk/dom/src/core/attr.h (original)
+++ trunk/dom/src/core/attr.h Mon Aug 30 08:06:19 2010
@@ -8,7 +8,7 @@
#ifndef dom_internal_core_attr_h_
#define dom_internal_core_attr_h_
-#include <dom/core/exceptions.h>
+#include <dom/core/attr.h>
struct dom_document;
struct dom_string;
@@ -24,7 +24,7 @@
struct dom_document *doc, struct lwc_string_s *name,
struct lwc_string_s *namespace, struct lwc_string_s *prefix,
bool specified, struct dom_attr **result);
-void _dom_attr_finalise(dom_document *doc, struct dom_attr *attr);
+void _dom_attr_finalise(struct dom_document *doc, struct dom_attr *attr);
/* Virtual functions for dom_attr */
dom_exception _dom_attr_get_name(struct dom_attr *attr,
@@ -117,5 +117,6 @@
void _dom_attr_set_isid(struct dom_attr *attr, bool is_id);
void _dom_attr_set_specified(struct dom_attr *attr, bool specified);
+bool _dom_attr_readonly(const dom_attr *a);
#endif
Modified: trunk/dom/src/core/document.c
URL:
http://source.netsurf-browser.org/trunk/dom/src/core/document.c?rev=10724...
==============================================================================
--- trunk/dom/src/core/document.c (original)
+++ trunk/dom/src/core/document.c Mon Aug 30 08:06:19 2010
@@ -76,13 +76,14 @@
* \param pw Pointer to client-specific private data
* \param doc Pointer to location to receive created document
* \param daf The default action fetcher
+ * \param daf The default action fetcher
* \return DOM_NO_ERR on success, DOM_NO_MEM_ERR on memory exhaustion.
*
* ::impl will have its reference count increased.
*
* The returned document will already be referenced.
*/
-dom_exception dom_document_create(struct dom_implementation *impl,
+dom_exception _dom_document_create(struct dom_implementation *impl,
dom_alloc alloc, void *pw,
dom_events_default_action_fetcher daf,
struct dom_document **doc)
@@ -184,6 +185,8 @@
if (doc->id_name != NULL)
lwc_string_unref(doc->id_name);
+
+ _dom_document_event_internal_finalise(doc, &doc->dei);
_dom_document_event_internal_finalise(doc, &doc->dei);
Modified: trunk/dom/src/core/document.h
URL:
http://source.netsurf-browser.org/trunk/dom/src/core/document.h?rev=10724...
==============================================================================
--- trunk/dom/src/core/document.h (original)
+++ trunk/dom/src/core/document.h Mon Aug 30 08:06:19 2010
@@ -12,6 +12,7 @@
#include <stddef.h>
#include <dom/core/node.h>
+#include <dom/core/document.h>
#include "core/string.h"
#include "core/node.h"
@@ -65,6 +66,12 @@
dom_document_event_internal dei;
/**< The DocumentEVent interface */
};
+
+/* Create a DOM document */
+dom_exception _dom_document_create(struct dom_implementation *impl,
+ dom_alloc alloc, void *pw,
+ dom_events_default_action_fetcher daf,
+ struct dom_document **doc);
/* Initialise the document */
dom_exception _dom_document_initialise(struct dom_document *doc,
@@ -194,6 +201,28 @@
_dom_document_rename_node
/* End of vtable */
+/**
+ * The internal used vtable for document
+ */
+struct dom_document_protected_vtable {
+ struct dom_node_protect_vtable base;
+ dom_exception (*dom_document_get_base)(dom_document *doc,
+ struct dom_string **base_uri);
+ /* Get the document's base uri */
+};
+
+typedef struct dom_document_protected_vtable dom_document_protected_vtable;
+
+/* Get the document's base URI */
+static inline dom_exception dom_document_get_base(dom_document *doc,
+ struct dom_string **base_uri)
+{
+ struct dom_node_internal *node = (struct dom_node_internal *) doc;
+ return ((dom_document_protected_vtable *) node->vtable)->
+ dom_document_get_base(doc, base_uri);
+}
+#define dom_document_get_base(d, b) dom_document_get_base( \
+ (dom_document *) (d), (struct dom_string **) (b))
/* Following comes the protected vtable */
void _dom_document_destroy(struct dom_node_internal *node);
Modified: trunk/dom/src/core/document_type.c
URL:
http://source.netsurf-browser.org/trunk/dom/src/core/document_type.c?rev=...
==============================================================================
--- trunk/dom/src/core/document_type.c (original)
+++ trunk/dom/src/core/document_type.c Mon Aug 30 08:06:19 2010
@@ -64,7 +64,7 @@
* explicitly. The client must unref the doctype once it has
* finished with it.
*/
-dom_exception dom_document_type_create(struct dom_string *qname,
+dom_exception _dom_document_type_create(struct dom_string *qname,
struct dom_string *public_id, struct dom_string *system_id,
dom_alloc alloc, void *pw,
struct dom_document_type **doctype)
Modified: trunk/dom/src/core/document_type.h
URL:
http://source.netsurf-browser.org/trunk/dom/src/core/document_type.h?rev=...
==============================================================================
--- trunk/dom/src/core/document_type.h (original)
+++ trunk/dom/src/core/document_type.h Mon Aug 30 08:06:19 2010
@@ -12,6 +12,12 @@
struct dom_resource_mgr;
struct dom_implementation;
+/* Create a DOM document type */
+dom_exception _dom_document_type_create(struct dom_string *qname,
+ struct dom_string *public_id,
+ struct dom_string *system_id,
+ dom_alloc alloc, void *pw,
+ struct dom_document_type **doctype);
/* Destroy a document type */
void _dom_document_type_destroy(struct dom_node_internal *doctypenode);
dom_exception _dom_document_type_initialise(struct dom_document_type *doctype,
Modified: trunk/dom/src/core/element.c
URL:
http://source.netsurf-browser.org/trunk/dom/src/core/element.c?rev=10724&...
==============================================================================
--- trunk/dom/src/core/element.c (original)
+++ trunk/dom/src/core/element.c Mon Aug 30 08:06:19 2010
@@ -35,14 +35,17 @@
#define CHAINS_NAMESPACE 7
#define CHAINS_NS_ATTRIBUTES 31
-static struct dom_element_vtable element_vtable = {
+struct dom_element_vtable _dom_element_vtable = {
{
DOM_NODE_VTABLE_ELEMENT
},
DOM_ELEMENT_VTABLE
};
-static struct dom_node_protect_vtable element_protect_vtable = {
+static struct dom_element_protected_vtable element_protect_vtable = {
+ {
+ DOM_NODE_PROTECT_VTABLE_ELEMENT
+ },
DOM_ELEMENT_PROTECT_VTABLE
};
@@ -145,7 +148,7 @@
return DOM_NO_MEM_ERR;
/* Initialise the vtables */
- (*result)->base.base.vtable = &element_vtable;
+ (*result)->base.base.vtable = &_dom_element_vtable;
(*result)->base.vtable = &element_protect_vtable;
return _dom_element_initialise(doc, *result, name, namespace, prefix);
@@ -1109,6 +1112,44 @@
/*----------------------------------------------------------------------*/
/* The protected virtual functions */
+/**
+ * The virtual function to parse some dom attribute
+ *
+ * \param ele The element object
+ * \param name The name of the attribute
+ * \param value The new value of the attribute
+ * \param parsed The parsed value of the attribute
+ * \return DOM_NO_ERR on success.
+ *
+ * @note: This virtual method is provided to serve as a template method.
+ * When any attribute is set or added, the attribute's value should be
+ * checked to make sure that it is a valid one. And the child class of
+ * dom_element may to do some special stuff on the attribute is set. Take
+ * some integer attribute as example:
+ *
+ * 1. The client call dom_element_set_attribute("size", "10.1"), but
the
+ * size attribute may only accept an integer, and only the specific
+ * dom_element know this. And the dom_attr_set_value method, which is
+ * called by dom_element_set_attribute should call the this virtual
+ * template method.
+ * 2. The overload virtual function of following one will truncate the
+ * "10.1" to "10" to make sure it is a integer. And of course, the
+ * overload method may also save the integer as a 'int' C type for
+ * later easy accessing by any client.
+ */
+dom_exception _dom_element_parse_attribute(dom_element *ele,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_string **parsed)
+{
+ UNUSED(ele);
+ UNUSED(name);
+
+ dom_string_ref(value);
+ *parsed = value;
+
+ return DOM_NO_ERR;
+}
+
/* The destroy virtual function of dom_element */
void __dom_element_destroy(struct dom_node_internal *node)
{
@@ -1296,9 +1337,13 @@
if (err != DOM_NO_ERR)
return err;
+ /* Set its parent, so that value parsing works */
+ dom_node_set_parent(attr, element);
+
/* Set its value */
err = dom_attr_set_value(attr, value);
if (err != DOM_NO_ERR) {
+ dom_node_set_parent(attr, NULL);
dom_node_unref(attr);
return err;
}
@@ -1310,6 +1355,7 @@
(dom_event_target *) attr, name,
DOM_MUTATION_ADDITION, &success);
if (err != DOM_NO_ERR) {
+ dom_node_set_parent(attr, NULL);
dom_node_unref(attr);
return err;
}
@@ -1319,6 +1365,7 @@
(dom_event_target *) element,
DOM_MUTATION_ADDITION, &success);
if (err != DOM_NO_ERR) {
+ dom_node_set_parent(attr, NULL);
dom_node_unref(attr);
return err;
}
@@ -1326,11 +1373,11 @@
added = _dom_hash_add(hs, str, attr, false);
if (added == false) {
/* If we failed at this step, there must be no memory */
+ dom_node_set_parent(attr, NULL);
dom_node_unref(attr);
return DOM_NO_MEM_ERR;
}
- dom_node_set_parent(attr, element);
dom_node_unref(attr);
dom_node_remove_pending(attr);
Modified: trunk/dom/src/core/element.h
URL:
http://source.netsurf-browser.org/trunk/dom/src/core/element.h?rev=10724&...
==============================================================================
--- trunk/dom/src/core/element.h (original)
+++ trunk/dom/src/core/element.h Mon Aug 30 08:06:19 2010
@@ -10,7 +10,9 @@
#include <stdbool.h>
-#include <dom/core/exceptions.h>
+#include <dom/core/element.h>
+
+#include "core/node.h"
struct dom_document;
struct dom_element;
@@ -175,8 +177,41 @@
_dom_node_set_user_data, \
_dom_node_get_user_data
+/**
+ * The internal used vtable for element
+ */
+struct dom_element_protected_vtable {
+ struct dom_node_protect_vtable base;
+
+ dom_exception (*dom_element_parse_attribute)(dom_element *ele,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_string **parsed);
+ /**< Called by dom_attr_set_value, and used to check
+ * whether the new attribute value is valid and
+ * return a valid on if it is not
+ */
+};
+
+typedef struct dom_element_protected_vtable dom_element_protected_vtable;
+
+/* Parse the attribute's value */
+static inline dom_exception dom_element_parse_attribute(dom_element *ele,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_string **parsed)
+{
+ struct dom_node_internal *node = (struct dom_node_internal *) ele;
+ return ((dom_element_protected_vtable *) node->vtable)->
+ dom_element_parse_attribute(ele, name, value, parsed);
+}
+#define dom_element_parse_attribute(e, n, v, p) dom_element_parse_attribute( \
+ (dom_element *) (e), (struct dom_string *) (n), \
+ (struct dom_string *) (v), (struct dom_string **) (p))
+
/* The protected virtual function */
+dom_exception _dom_element_parse_attribute(dom_element *ele,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_string **parsed);
void __dom_element_destroy(dom_node_internal *node);
dom_exception _dom_element_alloc(struct dom_document *doc,
struct dom_node_internal *n, struct dom_node_internal **ret);
@@ -184,6 +219,9 @@
struct dom_node_internal *old);
#define DOM_ELEMENT_PROTECT_VTABLE \
+ _dom_element_parse_attribute
+
+#define DOM_NODE_PROTECT_VTABLE_ELEMENT \
__dom_element_destroy, \
_dom_element_alloc, \
_dom_element_copy
@@ -192,4 +230,6 @@
dom_exception _dom_element_get_id(struct dom_element *ele,
struct lwc_string_s **id);
+extern struct dom_element_vtable _dom_element_vtable;
+
#endif
Modified: trunk/dom/src/core/node.c
URL:
http://source.netsurf-browser.org/trunk/dom/src/core/node.c?rev=10724&...
==============================================================================
--- trunk/dom/src/core/node.c (original)
+++ trunk/dom/src/core/node.c Mon Aug 30 08:06:19 2010
@@ -1491,10 +1491,10 @@
dom_exception _dom_node_get_base(dom_node_internal *node,
struct dom_string **result)
{
- UNUSED(node);
- UNUSED(result);
-
- return DOM_NOT_SUPPORTED_ERR;
+ struct dom_document *doc = node->owner;
+ assert(doc != NULL);
+
+ return dom_document_get_base(doc, result);
}
/**
@@ -2072,6 +2072,10 @@
if (n->type == DOM_DOCUMENT_TYPE_NODE ||
n->type == DOM_NOTATION_NODE)
return true;
+
+ /* Some Attr node are readonly */
+ if (n->type == DOM_ATTRIBUTE_NODE)
+ return _dom_attr_readonly((const dom_attr *) n);
/* Entity ns and their descendants are read only
* EntityReference ns and their descendants are read only */
@@ -2363,6 +2367,25 @@
}
/**
+ * Create a lwc_string using the node's owner's lwc_context
+ *
+ * \param node The node object
+ * \param data The string data
+ * \param len The length of the string data
+ * \param str The returned lwc_string
+ * \return DOM_NO_ERR on success, appropirate dom_exception on failure.
+ */
+dom_exception _dom_node_create_lwcstring(dom_node_internal *node,
+ const uint8_t *data, size_t len, struct lwc_string_s **str)
+{
+ dom_document *doc = dom_node_get_owner(node);
+
+ assert(doc != NULL);
+
+ return _dom_document_create_lwcstring(doc, data, len, str);
+}
+
+/**
* Try to destroy this node.
*
* \param node The node to destroy
Modified: trunk/dom/src/core/node.h
URL:
http://source.netsurf-browser.org/trunk/dom/src/core/node.h?rev=10724&...
==============================================================================
--- trunk/dom/src/core/node.h (original)
+++ trunk/dom/src/core/node.h Mon Aug 30 08:06:19 2010
@@ -286,6 +286,8 @@
struct dom_string *str, struct lwc_string_s **intern);
void _dom_node_unref_intern_string(dom_node_internal *node,
struct lwc_string_s *inter);
+dom_exception _dom_node_create_lwcstring(dom_node_internal *node,
+ const uint8_t *data, size_t len, struct lwc_string_s **str);
/* Try to destroy the node, if its refcnt is not zero, then append it to the
* owner document's pending list */
Modified: trunk/dom/src/events/event_target.c
URL:
http://source.netsurf-browser.org/trunk/dom/src/events/event_target.c?rev...
==============================================================================
--- trunk/dom/src/events/event_target.c (original)
+++ trunk/dom/src/events/event_target.c Mon Aug 30 08:06:19 2010
@@ -255,11 +255,8 @@
}
dom_string_unref(type);
- lwc_string *t = evt->type;
dom_event_target_entry list;
dom_event_target *target = et;
-
- assert(t != NULL);
*success = true;
@@ -286,6 +283,17 @@
/* Fill the target of the event */
evt->target = et;
evt->phase = DOM_CAPTURING_PHASE;
+
+ /* The started callback of default action */
+ struct dom_document_event_internal *dei = &doc->dei;
+ void *pw = NULL;
+ if (dei->actions != NULL) {
+ dom_default_action_callback cb = dei->actions(evt->type,
+ DOM_DEFAULT_ACTION_STARTED, &pw);
+ if (cb != NULL) {
+ cb(evt, pw);
+ }
+ }
/* The capture phase */
struct list_entry *e = list.entry.prev;
@@ -329,32 +337,26 @@
goto cleanup;
}
- struct dom_document_event_internal *dei = &doc->dei;
- if (dei->actions == NULL || evt->prevent_default == true)
- goto cleanup;
-
- /* The default action */
- struct dom_string *nodename;
- err = dom_node_get_node_name(et, &nodename);
- if (err != DOM_NO_ERR) {
- ret = err;
- goto cleanup;
- }
- lwc_string *lnodename = NULL;
- err = dom_string_get_intern(nodename, &lnodename);
- if (err != DOM_NO_ERR) {
- dom_string_unref(nodename);
- ret = err;
- goto cleanup;
- }
-
- dom_event_listener *da = dei->actions(lnodename, t);
- if (da != NULL) {
- da->handler(evt, da->pw);
- }
-
- dom_string_unref(nodename);
- lwc_string_unref(lnodename);
+ if (dei->actions == NULL)
+ goto cleanup;
+
+ /* The end callback of default action */
+ if (evt->prevent_default != true) {
+ dom_default_action_callback cb = dei->actions(evt->type,
+ DOM_DEFAULT_ACTION_END, &pw);
+ if (cb != NULL) {
+ cb(evt, pw);
+ }
+ }
+
+ /* The prevented callback of default action */
+ if (evt->prevent_default != true) {
+ dom_default_action_callback cb = dei->actions(evt->type,
+ DOM_DEFAULT_ACTION_PREVENTED, &pw);
+ if (cb != NULL) {
+ cb(evt, pw);
+ }
+ }
cleanup:
if (evt->prevent_default == true) {
@@ -707,9 +709,10 @@
/**
* Dispatch a DOMCharacterDataModified event
*
- * \param et The EventTarget object
- * \param prev The preValue of the DOMCharacterData
- * \param new The newValue of the DOMCharacterData
+ * \param et The EventTarget object
+ * \param prev The preValue of the DOMCharacterData
+ * \param new The newValue of the DOMCharacterData
+ * \param success Whether this event's default handler get called
* \return DOM_NO_ERR on success, appropirate dom_exception on failure.
*
* TODO:
@@ -761,7 +764,7 @@
*
* \param doc The Document
* \param et The EventTarget object
- * \param success The newValue of the DOMCharacterData
+ * \param success Whether this event's default handler get called
* \return DOM_NO_ERR on success, appropriate dom_exception on failure.
*/
dom_exception _dom_dispatch_subtree_modified_event(struct dom_document *doc,
@@ -802,3 +805,51 @@
return err;
}
+/**
+ * Dispatch a generic event
+ *
+ * \param doc The Document
+ * \param et The EventTarget object
+ * \param name The name of the event
+ * \param len The length of the name string
+ * \param bubble Whether this event bubbles
+ * \param cancelable Whether this event can be cancelable
+ * \param success Whether this event's default handler get called
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_dispatch_generic_event(struct dom_document *doc,
+ dom_event_target *et, const uint8_t *name, size_t len,
+ bool bubble, bool cancelable, bool *success)
+{
+ struct dom_event *evt;
+ dom_exception err;
+
+ err = _dom_event_create(doc, &evt);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ lwc_string *type = NULL;
+ err = _dom_document_create_lwcstring(doc, name, len, &type);
+ if (err != DOM_NO_ERR)
+ goto cleanup;
+
+ dom_string *t = NULL;
+ err = _dom_document_create_string_from_lwcstring(doc, type, &t);
+ _dom_document_unref_lwcstring(doc, type);
+ if (err != DOM_NO_ERR)
+ goto cleanup;
+
+ err = dom_event_init(evt, t, bubble, cancelable);
+ dom_string_unref(t);
+ if (err != DOM_NO_ERR) {
+ goto cleanup;
+ }
+
+ err = dom_event_target_dispatch_event(et, evt, success);
+
+cleanup:
+ _dom_event_destroy(doc, evt);
+
+ return err;
+}
+
Modified: trunk/dom/src/events/event_target.h
URL:
http://source.netsurf-browser.org/trunk/dom/src/events/event_target.h?rev...
==============================================================================
--- trunk/dom/src/events/event_target.h (original)
+++ trunk/dom/src/events/event_target.h Mon Aug 30 08:06:19 2010
@@ -85,4 +85,8 @@
dom_exception _dom_dispatch_subtree_modified_event(struct dom_document *doc,
dom_event_target *et, bool *success);
+/* Dispatch a generic event */
+dom_exception _dom_dispatch_generic_event(struct dom_document *doc,
+ dom_event_target *et, const uint8_t *name, size_t len,
+ bool bubble, bool cancelable, bool *success);
#endif
Modified: trunk/dom/src/html/Makefile
URL:
http://source.netsurf-browser.org/trunk/dom/src/html/Makefile?rev=10724&a...
==============================================================================
--- trunk/dom/src/html/Makefile (original)
+++ trunk/dom/src/html/Makefile Mon Aug 30 08:06:19 2010
@@ -1,10 +1,12 @@
# Sources
DIR_SOURCES := \
- html_collection.c html_options_collection.c html_element.c \
- html_html_element.c html_head_element.c html_link_element.c \
- html_title_element.c html_meta_element.c html_base_element.c \
- html_isindex_element.c html_style_element.c html_body_element.c \
- html_form_element.c html_select_element.c html_optgroup_element.c \
+ html_document.c html_collection.c html_options_collection.c \
+ html_element.c html_html_element.c html_head_element.c \
+ html_link_element.c html_title_element.c html_meta_element.c \
+ html_base_element.c html_isindex_element.c html_style_element.c \
+ html_body_element.c html_form_element.c html_select_element.c
+
+UNINMPLEMENTED_SOURCES := html_optgroup_element.c \
html_option_element.c html_input_element.c html_textarea_element.c \
html_button_element.c html_label_element.c html_fieldset_element.c \
html_legend_element.c html_ulist_element.c html_olist_element.c \
Modified: trunk/dom/src/html/html_document.c
URL:
http://source.netsurf-browser.org/trunk/dom/src/html/html_document.c?rev=...
==============================================================================
--- trunk/dom/src/html/html_document.c (original)
+++ trunk/dom/src/html/html_document.c Mon Aug 30 08:06:19 2010
@@ -5,13 +5,16 @@
* Copyright 2009 Bo Yang <struggleyb.nku(a)gmail.com>
*/
+#include <assert.h>
+
#include "html/html_document.h"
#include "core/string.h"
+#include "utils/utils.h"
/* Create a HTMLDocument */
dom_exception dom_html_document_create(dom_alloc alloc, void *pw, dom_msg msg,
- void *msg_pw, struct lwc_context_s *ctx,
+ void *msg_pw,
dom_events_default_action_fetcher daf, dom_ui_handler ui,
dom_parser_type pt, dom_html_document **doc)
{
@@ -20,18 +23,26 @@
if (*doc == NULL)
return DOM_NO_MEM_ERR;
- return _dom_html_document_initialise(*doc, alloc, pw, msn, msg_pw,
- ctx, daf, ui, pt);
+ return _dom_html_document_initialise(*doc, alloc, pw, msg, msg_pw,
+ daf, ui, pt);
}
/* Initialise a HTMLDocument */
dom_exception _dom_html_document_initialise(dom_html_document *doc,
dom_alloc alloc, void *pw, dom_msg msg, void *msg_pw,
- struct lwc_context_s *ctx,
dom_events_default_action_fetcher daf, dom_ui_handler ui,
dom_parser_type pt)
{
-
+ UNUSED(doc);
+ UNUSED(alloc);
+ UNUSED(pw);
+ UNUSED(msg);
+ UNUSED(msg_pw);
+ UNUSED(daf);
+ UNUSED(ui);
+ UNUSED(pt);
+
+ return DOM_NO_ERR;
}
/* Finalise a HTMLDocument */
@@ -63,6 +74,10 @@
dom_exception dom_html_document_get_title(dom_html_document *doc,
struct dom_string **title)
{
+ UNUSED(doc);
+ UNUSED(title);
+
+ return DOM_NO_ERR;
}
dom_exception dom_html_document_set_title(dom_html_document *doc,
@@ -78,15 +93,15 @@
dom_exception dom_html_document_set_body(dom_html_document *doc,
struct dom_html_element *body);
dom_exception dom_html_document_get_images(dom_html_document *doc,
- struct dom_html_collectoin **col);
+ struct dom_html_collection **col);
dom_exception dom_html_document_get_applets(dom_html_document *doc,
- struct dom_html_collectoin **col);
+ struct dom_html_collection **col);
dom_exception dom_html_document_get_links(dom_html_document *doc,
- struct dom_html_collectoin **col);
+ struct dom_html_collection **col);
dom_exception dom_html_document_get_forms(dom_html_document *doc,
- struct dom_html_collectoin **col);
+ struct dom_html_collection **col);
dom_exception dom_html_document_get_anchors(dom_html_document *doc,
- struct dom_html_collectoin **col);
+ struct dom_html_collection **col);
dom_exception dom_html_document_get_cookie(dom_html_document *doc,
struct dom_string **cookie);
dom_exception dom_html_document_set_cookie(dom_html_document *doc,
Modified: trunk/dom/src/html/html_document.h
URL:
http://source.netsurf-browser.org/trunk/dom/src/html/html_document.h?rev=...
==============================================================================
--- trunk/dom/src/html/html_document.h (original)
+++ trunk/dom/src/html/html_document.h Mon Aug 30 08:06:19 2010
@@ -8,7 +8,7 @@
#ifndef dom_internal_html_document_h_
#define dom_internal_html_document_h_
-#include <dom/core/html_document.h>
+#include <dom/html/html_document.h>
#include "core/document.h"
@@ -36,7 +36,6 @@
/* Initialise a HTMLDocument */
dom_exception _dom_html_document_initialise(dom_html_document *doc,
dom_alloc alloc, void *pw, dom_msg msg, void *msg_pw,
- struct lwc_context_s *ctx,
dom_events_default_action_fetcher daf, dom_ui_handler ui,
dom_parser_type pt);
/* Finalise a HTMLDocument */
Modified: trunk/dom/src/html/html_element.c
URL:
http://source.netsurf-browser.org/trunk/dom/src/html/html_element.c?rev=1...
==============================================================================
--- trunk/dom/src/html/html_element.c (original)
+++ trunk/dom/src/html/html_element.c Mon Aug 30 08:06:19 2010
@@ -56,6 +56,8 @@
UNUSED(ret);
assert("Should never be here" == NULL);
+
+ return DOM_NO_MEM_ERR;
}
/* The virtual copy function, see src/core/node.c for detail */
@@ -135,31 +137,33 @@
if (err != DOM_NO_ERR)
goto cleanup1;
- dom_node *res = NULL;
if (a != NULL && has == false) {
+ dom_attr *res = NULL;
+
err = dom_element_remove_attribute_node(ele, a, &res);
if (err != DOM_NO_ERR)
goto cleanup2;
+
dom_node_unref(res);
} else if (a == NULL && has == true) {
+ dom_attr *res = NULL;
lwc_string *lstr = NULL;
- lwc_context *ctx = _dom_document_get_intern_context(doc);
- assert(ctx != NULL);
-
- err = _dom_string_intern(str, ctx, &lstr);
+
+ err = _dom_string_intern(str, &lstr);
if (err != DOM_NO_ERR)
goto cleanup1;
err = _dom_attr_create(doc, lstr, NULL, NULL, true, &a);
if (err != DOM_NO_ERR) {
- lwc_context_string_unref(ctx, lstr);
+ lwc_string_unref(lstr);
goto cleanup1;
}
- lwc_context_string_unref(ctx, lstr);
+ lwc_string_unref(lstr);
err = dom_element_set_attribute_node(ele, a, &res);
if (err != DOM_NO_ERR)
goto cleanup2;
+
dom_node_unref(res);
}