r13309 jmb - in /branches/jmb/dom-alloc-purge/src: core/element.c core/node.c events/event_target.c events/event_target.h utils/hashtable.c utils/hashtable.h
by netsurf@semichrome.net
Author: jmb
Date: Tue Dec 20 09:06:17 2011
New Revision: 13309
URL: http://source.netsurf-browser.org?rev=13309&view=rev
Log:
Make hashtable less insane.
Modified:
branches/jmb/dom-alloc-purge/src/core/element.c
branches/jmb/dom-alloc-purge/src/core/node.c
branches/jmb/dom-alloc-purge/src/events/event_target.c
branches/jmb/dom-alloc-purge/src/events/event_target.h
branches/jmb/dom-alloc-purge/src/utils/hashtable.c
branches/jmb/dom-alloc-purge/src/utils/hashtable.h
Modified: branches/jmb/dom-alloc-purge/src/core/element.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/core/e...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/core/element.c (original)
+++ branches/jmb/dom-alloc-purge/src/core/element.c Tue Dec 20 09:06:17 2011
@@ -114,10 +114,32 @@
attributes_equal
};
-static void *_key(void *key, void *key_pw, bool clone);
-static void *_value(void *value, void *value_pw, bool clone);
-static void *_nsattributes(void *value, void *value_pw, bool clone);
-
+static uint32_t attributes_hash(void *key, void *pw);
+static void *attributes_clone_key(void *key, void *pw);
+static void attributes_destroy_key(void *key, void *pw);
+static void *attributes_clone_value(void *value, void *pw);
+static void attributes_destroy_value(void *value, void *pw);
+static void *attributes_ns_clone_value(void *value, void *pw);
+static void attributes_ns_destroy_value(void *value, void *pw);
+static bool attributes_key_isequal(void *key1, void *key2, void *pw);
+
+static const struct dom_hash_vtable attributes_vtable = {
+ attributes_hash,
+ attributes_clone_key,
+ attributes_destroy_key,
+ attributes_clone_value,
+ attributes_destroy_value,
+ attributes_key_isequal
+};
+
+static const struct dom_hash_vtable attributes_ns_vtable = {
+ attributes_hash,
+ attributes_clone_key,
+ attributes_destroy_key,
+ attributes_ns_clone_value,
+ attributes_ns_destroy_value,
+ attributes_key_isequal
+};
/*----------------------------------------------------------------------*/
/* Constructors and Destructors */
@@ -183,14 +205,14 @@
assert(doc != NULL);
el->attributes = _dom_hash_create(CHAINS_ATTRIBUTES,
- (dom_hash_func) dom_string_hash);
+ &attributes_vtable, NULL);
if (el->attributes == NULL) {
free(el);
return DOM_NO_MEM_ERR;;
}
el->ns_attributes = _dom_hash_create(CHAINS_NAMESPACE,
- (dom_hash_func) dom_string_hash);
+ &attributes_ns_vtable, NULL);
if (el->ns_attributes == NULL) {
free(el->attributes);
free(el);
@@ -224,13 +246,12 @@
{
/* Destroy attributes attached to this node */
if (ele->attributes != NULL) {
- _dom_hash_destroy(ele->attributes, _key, NULL, _value, NULL);
+ _dom_hash_destroy(ele->attributes);
ele->attributes = NULL;
}
if (ele->ns_attributes != NULL) {
- _dom_hash_destroy(ele->ns_attributes, _key, NULL,
- _nsattributes, NULL);
+ _dom_hash_destroy(ele->ns_attributes);
ele->ns_attributes = NULL;
}
@@ -524,7 +545,7 @@
doc = dom_node_get_owner(element);
assert(doc != NULL);
attrs = _dom_hash_create(CHAINS_NS_ATTRIBUTES,
- (dom_hash_func) dom_string_hash);
+ &attributes_vtable, NULL);
if (attrs == NULL)
return DOM_NO_MEM_ERR;
@@ -532,6 +553,7 @@
false);
if (added == false)
return DOM_NO_MEM_ERR;
+ dom_string_ref(namespace);
}
return _dom_element_set_attr(element, attrs, localname, value);
@@ -650,7 +672,7 @@
doc = dom_node_get_owner(element);
assert(doc != NULL);
attrs = _dom_hash_create(CHAINS_NS_ATTRIBUTES,
- (dom_hash_func) dom_string_hash);
+ &attributes_vtable, NULL);
if (attrs == NULL)
return DOM_NO_MEM_ERR;
@@ -658,6 +680,7 @@
false);
if (added == false)
return DOM_NO_MEM_ERR;
+ dom_string_ref(namespace);
}
dom_string *localname;
@@ -1085,13 +1108,12 @@
}
/* Copy the hash tables */
- ht = _dom_hash_clone(olde->attributes, _key, NULL, _value, NULL);
+ ht = _dom_hash_clone(olde->attributes);
if (ht == NULL)
return DOM_NO_MEM_ERR;
e->attributes = ht;
- ht = _dom_hash_clone(olde->ns_attributes, _key, NULL,
- _nsattributes, NULL);
+ ht = _dom_hash_clone(olde->ns_attributes);
if (ht == NULL)
return DOM_NO_MEM_ERR;
e->ns_attributes = ht;
@@ -1244,6 +1266,7 @@
dom_node_unref(attr);
return DOM_NO_MEM_ERR;
}
+ dom_string_ref(name);
dom_node_unref(attr);
dom_node_remove_pending(attr);
@@ -1461,6 +1484,7 @@
/* If we failed at this step, there must be no memory */
return DOM_NO_MEM_ERR;
}
+ dom_string_ref(name);
dom_node_set_parent(attr, element);
dom_node_remove_pending(attr);
@@ -1736,7 +1760,7 @@
unsigned long *length)
{
unsigned int ret = 0;
- unsigned int c1, *c2 = NULL;
+ uintptr_t c1, *c2 = NULL;
void *key, *value;
dom_element *e = (dom_element *) priv;
@@ -1808,7 +1832,7 @@
unsigned int len;
dom_element *e = (dom_element *) priv;
void *key, *value;
- unsigned int c1, *c2 = NULL;
+ uintptr_t c1, *c2 = NULL;
len = _dom_hash_get_length(e->attributes);
if (num <= len) {
@@ -1920,63 +1944,80 @@
}
/*------------------ End of namednodemap functions -----------------------*/
-/* The key_func of the hash table, see utils/hashtable.h for details */
-void *_key(void *key, void *key_pw, bool clone)
-{
+uint32_t attributes_hash(void *key, void *pw)
+{
+ UNUSED(pw);
+
+ return dom_string_hash(key);
+}
+
+void *attributes_clone_key(void *key, void *pw)
+{
+ UNUSED(pw);
+
assert(key != NULL);
- UNUSED(key_pw);
-
- if (clone == false) {
- dom_string_unref((dom_string *) key);
+ return dom_string_ref(key);
+}
+
+void attributes_destroy_key(void *key, void *pw)
+{
+ UNUSED(pw);
+
+ assert(key != NULL);
+
+ dom_string_unref(key);
+}
+
+void *attributes_clone_value(void *value, void *pw)
+{
+ dom_exception err;
+ dom_node *node;
+
+ UNUSED(pw);
+
+ assert(value != NULL);
+
+ err = dom_node_clone_node(value, true, &node);
+ if (err != DOM_NO_ERR)
return NULL;
- } else {
- return dom_string_ref((dom_string *) key);
- }
-}
-
-/* The value_func of the hash table, see utils/hashtable.h for details */
-void *_value(void *value, void *value_pw, bool clone)
-{
+
+ return node;
+}
+
+void attributes_destroy_value(void *value, void *pw)
+{
+ dom_node_internal *a = (dom_node_internal *) value;
+
+ UNUSED(pw);
+
assert(value != NULL);
-
- UNUSED(value_pw);
-
- if (clone == false) {
- dom_node_internal *a = (dom_node_internal *) value;
- a->parent = NULL;
- dom_node_try_destroy(a);
- return NULL;
- } else {
- dom_exception err;
- dom_node *node;
-
- err = dom_node_clone_node(value, true, &node);
- if (err != DOM_NO_ERR)
- return NULL;
-
- return node;
- }
-}
-
-/* The value_func of the hash table, see utils/hashtable.h for details */
-void *_nsattributes(void *value, void *value_pw, bool clone)
-{
+
+ a->parent = NULL;
+ dom_node_try_destroy(a);
+}
+
+void *attributes_ns_clone_value(void *value, void *pw)
+{
+ UNUSED(pw);
+
assert(value != NULL);
- UNUSED(value_pw);
-
- if (clone == false) {
- _dom_hash_destroy((struct dom_hash_table *) value, _key,
- NULL, _value, NULL);
- return NULL;
- } else {
- struct dom_hash_table *ret = NULL;
-
- ret = _dom_hash_clone((struct dom_hash_table *) value,
- _key, NULL, _value, NULL);
-
- return ret;
- }
-}
-
+ return _dom_hash_clone(value);
+}
+
+void attributes_ns_destroy_value(void *value, void *pw)
+{
+ UNUSED(pw);
+
+ assert(value != NULL);
+
+ _dom_hash_destroy(value);
+}
+
+bool attributes_key_isequal(void *key1, void *key2, void *pw)
+{
+ UNUSED(pw);
+
+ return dom_string_isequal(key1, key2);
+}
Modified: branches/jmb/dom-alloc-purge/src/core/node.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/core/n...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/core/node.c (original)
+++ branches/jmb/dom-alloc-purge/src/core/node.c Tue Dec 20 09:06:17 2011
@@ -206,7 +206,7 @@
dom_node_mark_pending(node);
}
- return _dom_event_target_internal_initialise(doc, &node->eti);
+ return _dom_event_target_internal_initialise(&node->eti);
}
/**
@@ -262,7 +262,7 @@
* dom_event_target_internal structure.
*/
if (node->owner != NULL)
- _dom_event_target_internal_finalise(node->owner, &node->eti);
+ _dom_event_target_internal_finalise(&node->eti);
/* Detach from the pending list, if we are in it,
* this part of code should always be the end of this function. */
@@ -1875,7 +1875,7 @@
dom_node_mark_pending(new);
/* Intialise the EventTarget interface */
- return _dom_event_target_internal_initialise(new->owner, &new->eti);
+ return _dom_event_target_internal_initialise(&new->eti);
}
Modified: branches/jmb/dom-alloc-purge/src/events/event_target.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/events...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/events/event_target.c (original)
+++ branches/jmb/dom-alloc-purge/src/events/event_target.c Tue Dec 20 09:06:17 2011
@@ -22,28 +22,74 @@
/* The number of chains in the hash table used for hash event types */
#define CHAINS 11
-/* Hash key/value functions */
-static void *_key(void *key, void *pw, bool clone);
-static void *_value(void *value, void *pw, bool clone);
-
+static uint32_t event_target_hash(void *key, void *pw)
+{
+ UNUSED(pw);
+
+ return dom_string_hash(key);
+}
+
+static void event_target_destroy_key(void *key, void *pw)
+{
+ UNUSED(pw);
+
+ dom_string_unref(key);
+}
+
+static void event_target_destroy_value(void *value, void *pw)
+{
+ struct listener_entry *le = NULL;
+ struct list_entry *i = (struct list_entry *) value;
+
+ UNUSED(pw);
+
+ while (i != i->next) {
+ le = (struct listener_entry *) i->next;
+ list_del(i->next);
+ dom_event_listener_unref(le->listener);
+ free(le);
+ }
+
+ le = (struct listener_entry *) i;
+ list_del(i);
+ dom_event_listener_unref(le->listener);
+ free(le);
+}
+
+static bool event_target_key_isequal(void *key1, void *key2, void *pw)
+{
+ UNUSED(pw);
+
+ return dom_string_isequal(key1, key2);
+}
+
+static const dom_hash_vtable event_target_vtable = {
+ event_target_hash,
+ NULL,
+ event_target_destroy_key,
+ NULL,
+ event_target_destroy_value,
+ event_target_key_isequal
+};
/* Initialise this EventTarget */
-dom_exception _dom_event_target_internal_initialise(dom_document *doc,
+dom_exception _dom_event_target_internal_initialise(
dom_event_target_internal *eti)
{
- UNUSED(doc);
- eti->listeners = NULL;
+ eti->listeners = _dom_hash_create(CHAINS, &event_target_vtable, NULL);
+ if (eti->listeners == NULL)
+ return DOM_NO_MEM_ERR;
+
eti->ns_listeners = NULL;
return DOM_NO_ERR;
}
/* Finalise this EventTarget */
-void _dom_event_target_internal_finalise(dom_document *doc,
- dom_event_target_internal *eti)
-{
- if (eti->listeners != NULL)
- _dom_hash_destroy(eti->listeners, _key, NULL, _value, doc);
+void _dom_event_target_internal_finalise(dom_event_target_internal *eti)
+{
+ _dom_hash_destroy(eti->listeners);
+
/* TODO: Now, we did not support the EventListener with namespace,
* when we support it, we should deal with the ns_listeners hash
* table, too.
@@ -69,14 +115,6 @@
{
struct listener_entry *le = NULL;
dom_string *t = NULL;
-
- /* If there is no hash table, we should create one firstly */
- if (eti->listeners == NULL) {
- eti->listeners = _dom_hash_create(CHAINS,
- (dom_hash_func) dom_string_hash);
- if (eti->listeners == NULL)
- return DOM_NO_MEM_ERR;
- }
le = malloc(sizeof(struct listener_entry));
if (le == NULL)
@@ -199,49 +237,6 @@
}
/*-------------------------------------------------------------------------*/
-
-/* The key process function of the hash table, see utils/hash_table.h for
- * detail */
-static void *_key(void *key, void *pw, bool clone)
-{
- UNUSED(pw);
- /* There should never be the requirement of clone the event listener
- * list */
- assert(clone == false);
- UNUSED(clone);
-
- lwc_string_unref((lwc_string *) key);
-
- return NULL;
-}
-
-/* The value process function of the hash table, see utils/hash_table.h for
- * detail */
-static void *_value(void *value, void *pw, bool clone)
-{
- /* There should never be the requirement of clone the event listener
- * list */
- UNUSED(pw);
- assert(clone == false);
- UNUSED(clone);
-
- struct listener_entry *le = NULL;
- struct list_entry *i = (struct list_entry *) value;
-
- while (i != i->next) {
- le = (struct listener_entry *) i->next;
- list_del(i->next);
- dom_event_listener_unref(le->listener);
- le = malloc(sizeof(struct listener_entry));
- }
-
- le = (struct listener_entry *) i;
- list_del(i);
- dom_event_listener_unref(le->listener);
- le = malloc(sizeof(struct listener_entry));
-
- return NULL;
-}
/**
* Dispatch an event on certain EventTarget
Modified: branches/jmb/dom-alloc-purge/src/events/event_target.h
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/events...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/events/event_target.h (original)
+++ branches/jmb/dom-alloc-purge/src/events/event_target.h Tue Dec 20 09:06:17 2011
@@ -58,12 +58,11 @@
*/
/* Initialise this EventTarget */
-dom_exception _dom_event_target_internal_initialise(dom_document *doc,
+dom_exception _dom_event_target_internal_initialise(
dom_event_target_internal *eti);
/* Finalise this EventTarget */
-void _dom_event_target_internal_finalise(dom_document *doc,
- dom_event_target_internal *eti);
+void _dom_event_target_internal_finalise(dom_event_target_internal *eti);
dom_exception _dom_event_target_add_event_listener(
dom_event_target_internal *eti,
Modified: branches/jmb/dom-alloc-purge/src/utils/hashtable.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/utils/...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/utils/hashtable.c (original)
+++ branches/jmb/dom-alloc-purge/src/utils/hashtable.c Tue Dec 20 09:06:17 2011
@@ -27,10 +27,11 @@
/* The hash table */
struct dom_hash_table {
- unsigned int nchains; /**< The chains number */
- dom_hash_func hash; /**< The hash function */
+ const dom_hash_vtable *vtable; /**< Vtable */
+ void *pw; /**< Client data */
+ unsigned int nchains; /**< Number of chains */
struct _dom_hash_entry **chain; /**< The chain head */
- unsigned int number; /**< The entries in this table */
+ unsigned int nentries; /**< The entries in this table */
};
@@ -41,21 +42,23 @@
* \param chains Number of chains/buckets this hash table will have. This
* should be a prime number, and ideally a prime number just
* over a power of two, for best performance and distribution
- * \param hash The hash function
+ * \param vtable Client vtable
+ * \param pw Client private data
* \return struct dom_hash_table containing the context of this hash table or
* NULL if there is insufficent memory to create it and its chains.
*/
-struct dom_hash_table *_dom_hash_create(unsigned int chains, dom_hash_func hash)
-{
- struct dom_hash_table *r = malloc(sizeof(struct dom_hash_table));
-
+dom_hash_table *_dom_hash_create(unsigned int chains,
+ const dom_hash_vtable *vtable, void *pw)
+{
+ dom_hash_table *r = malloc(sizeof(struct dom_hash_table));
if (r == NULL) {
return NULL;
}
+ r->vtable = vtable;
+ r->pw = pw;
+ r->nentries = 0;
r->nchains = chains;
- r->hash = hash;
- r->number = 0;
r->chain = calloc(chains, sizeof(struct _dom_hash_entry *));
if (r->chain == NULL) {
free(r);
@@ -69,43 +72,37 @@
* Clone a hash table.
*
* \param ht Hash table to clone.
- * \param kf The function pointer used to copy the key.
- * \param key_pw The private data for the key cloner.
- * \param vf The function pointer used to copy the value.
- * \param value_pw The private data for the value cloner.
*
* \return The cloned hash table.
*/
-struct dom_hash_table *_dom_hash_clone(struct dom_hash_table *ht,
- dom_key_func kf, void *key_pw,
- dom_value_func vf, void *value_pw)
-{
+dom_hash_table *_dom_hash_clone(dom_hash_table *ht)
+{
+ void *key = NULL, *nkey = NULL;
+ void *value = NULL, *nvalue = NULL;
+ uintptr_t c1, *c2 = NULL;
struct dom_hash_table *ret;
- ret = _dom_hash_create(ht->nchains, ht->hash);
+ ret = _dom_hash_create(ht->nchains, ht->vtable, ht->pw);
if (ret == NULL)
return NULL;
- void *key = NULL, *nkey = NULL;
- void *value = NULL, *nvalue = NULL;
- unsigned int c1, *c2 = NULL;
while ( (key = _dom_hash_iterate(ht, &c1, &c2)) != NULL) {
- nkey = kf(key, key_pw, true);
+ nkey = ht->vtable->clone_key(key, ht->pw);
if (nkey == NULL) {
- _dom_hash_destroy(ret, kf, key_pw, vf, value_pw);
+ _dom_hash_destroy(ret);
return NULL;
}
value = _dom_hash_get(ht, key);
- nvalue = vf(value, value_pw, true);
+ nvalue = ht->vtable->clone_value(value, ht->pw);
if (nvalue == NULL) {
- kf(nkey, key_pw, false);
- _dom_hash_destroy(ret, kf, key_pw, vf, value_pw);
+ ht->vtable->destroy_key(nkey, ht->pw);
+ _dom_hash_destroy(ret);
return NULL;
}
if (_dom_hash_add(ret, nkey, nvalue, false) == false) {
- _dom_hash_destroy(ret, kf, key_pw, vf, value_pw);
+ _dom_hash_destroy(ret);
return NULL;
}
}
@@ -118,13 +115,8 @@
*
* \param ht Hash table to destroy. After the function returns, this
* will nolonger be valid
- * \param kf The key destroy function
- * \param key_pw The key destroy function private data
- * \param vf The value destroy function
- * \param value_pw The value destroy function private data
- */
-void _dom_hash_destroy(struct dom_hash_table *ht, dom_key_func kf,
- void *key_pw, dom_value_func vf, void *value_pw)
+ */
+void _dom_hash_destroy(dom_hash_table *ht)
{
unsigned int i;
@@ -136,12 +128,8 @@
struct _dom_hash_entry *e = ht->chain[i];
while (e) {
struct _dom_hash_entry *n = e->next;
- if (kf != NULL) {
- kf(e->key, key_pw, false);
- }
- if (vf != NULL) {
- vf(e->value, value_pw, false);
- }
+ ht->vtable->destroy_key(e->key, ht->pw);
+ ht->vtable->destroy_value(e->value, ht->pw);
free(e);
e = n;
}
@@ -161,7 +149,7 @@
* \return true if the add succeeded, false otherwise. (Failure most likely
* indicates insufficent memory to make copies of the key and value.
*/
-bool _dom_hash_add(struct dom_hash_table *ht, void *key, void *value,
+bool _dom_hash_add(dom_hash_table *ht, void *key, void *value,
bool replace)
{
unsigned int h, c;
@@ -170,11 +158,11 @@
if (ht == NULL || key == NULL || value == NULL)
return false;
- h = ht->hash(key);
+ h = ht->vtable->hash(key, ht->pw);
c = h % ht->nchains;
- for (e = ht->chain[c]; e; e = e->next)
- if (key == e->key) {
+ for (e = ht->chain[c]; e; e = e->next) {
+ if (ht->vtable->key_isequal(key, e->key, ht->pw)) {
if (replace == true) {
e->value = value;
return true;
@@ -182,6 +170,7 @@
return false;
}
}
+ }
e = malloc(sizeof(struct _dom_hash_entry));
if (e == NULL) {
@@ -193,7 +182,7 @@
e->next = ht->chain[c];
ht->chain[c] = e;
- ht->number ++;
+ ht->nentries++;
return true;
}
@@ -213,12 +202,13 @@
if (ht == NULL || key == NULL)
return NULL;
- h = ht->hash(key);
+ h = ht->vtable->hash(key, ht->pw);
c = h % ht->nchains;
- for (e = ht->chain[c]; e; e = e->next)
- if (key == e->key)
+ for (e = ht->chain[c]; e; e = e->next) {
+ if (ht->vtable->key_isequal(key, e->key, ht->pw))
return e->value;
+ }
return NULL;
}
@@ -239,12 +229,12 @@
if (ht == NULL || key == NULL)
return NULL;
- h = ht->hash(key);
+ h = ht->vtable->hash(key, ht->pw);
c = h % ht->nchains;
p = ht->chain[c];
- for (e = p; e; p = e, e = e->next)
- if (key == e->key) {
+ for (e = p; e; p = e, e = e->next) {
+ if (ht->vtable->key_isequal(key, e->key, ht->pw)) {
if (p != e) {
p->next = e->next;
} else {
@@ -254,9 +244,10 @@
ret = e->value;
free(e);
- ht->number --;
+ ht->nentries--;
return ret;
}
+ }
return NULL;
}
@@ -269,10 +260,10 @@
* \param c2 Pointer to second context (set to 0 on first call)
* \return The next hash key, or NULL for no more keys
*/
-void *_dom_hash_iterate(struct dom_hash_table *ht, unsigned int *c1,
- unsigned int **c2)
-{
- struct _dom_hash_entry **he = (struct _dom_hash_entry **)c2;
+void *_dom_hash_iterate(struct dom_hash_table *ht, uintptr_t *c1,
+ uintptr_t **c2)
+{
+ struct _dom_hash_entry **he = (struct _dom_hash_entry **) c2;
if (ht == NULL)
return NULL;
@@ -303,31 +294,7 @@
*/
unsigned int _dom_hash_get_length(struct dom_hash_table *ht)
{
- return ht->number;
-}
-
-/**
- * Get the chain number of this hash table
- *
- * \param ht The hash table
- *
- * \return the number of chains
- */
-unsigned int _dom_hash_get_chains(struct dom_hash_table *ht)
-{
- return ht->nchains;
-}
-
-/**
- * Get the hash function of this hash table
- *
- * \param ht The hash table
- *
- * \return the hash function
- */
-dom_hash_func _dom_hash_get_func(struct dom_hash_table *ht)
-{
- return ht->hash;
+ return ht->nentries;
}
/*-----------------------------------------------------------------------*/
Modified: branches/jmb/dom-alloc-purge/src/utils/hashtable.h
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/utils/...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/utils/hashtable.h (original)
+++ branches/jmb/dom-alloc-purge/src/utils/hashtable.h Tue Dec 20 09:06:17 2011
@@ -14,28 +14,24 @@
typedef struct dom_hash_table dom_hash_table;
-/* The hash function */
-typedef unsigned int (*dom_hash_func)(void *key);
-/* Function to clone/delete key */
-typedef void *(*dom_key_func)(void *key, void *pw, bool clone);
-/* Function to clone/delete value */
-typedef void *(*dom_value_func)(void *value, void *pw, bool clone);
+typedef struct dom_hash_vtable {
+ uint32_t (*hash)(void *key, void *pw);
+ void *(*clone_key)(void *key, void *pw);
+ void (*destroy_key)(void *key, void *pw);
+ void *(*clone_value)(void *value, void *pw);
+ void (*destroy_value)(void *value, void *pw);
+ bool (*key_isequal)(void *key1, void *key2, void *pw);
+} dom_hash_vtable;
-struct dom_hash_table *_dom_hash_create(unsigned int chains,
- dom_hash_func hash);
-struct dom_hash_table *_dom_hash_clone(struct dom_hash_table *ht,
- dom_key_func kf, void *key_pw,
- dom_value_func vf, void *value_pw);
-void _dom_hash_destroy(struct dom_hash_table *ht, dom_key_func kf, void *key_pw,
- dom_value_func vf, void *value_pw);
-bool _dom_hash_add(struct dom_hash_table *ht, void *key, void *value,
+dom_hash_table *_dom_hash_create(unsigned int chains,
+ const dom_hash_vtable *vtable, void *pw);
+dom_hash_table *_dom_hash_clone(dom_hash_table *ht);
+void _dom_hash_destroy(dom_hash_table *ht);
+bool _dom_hash_add(dom_hash_table *ht, void *key, void *value,
bool replace);
-void *_dom_hash_get(struct dom_hash_table *ht, void *key);
-void *_dom_hash_del(struct dom_hash_table *ht, void *key);
-void *_dom_hash_iterate(struct dom_hash_table *ht, unsigned int *c1,
- unsigned int **c2);
-unsigned int _dom_hash_get_length(struct dom_hash_table *ht);
-unsigned int _dom_hash_get_chains(struct dom_hash_table *ht);
-dom_hash_func _dom_hash_get_func(struct dom_hash_table *ht);
+void *_dom_hash_get(dom_hash_table *ht, void *key);
+void *_dom_hash_del(dom_hash_table *ht, void *key);
+void *_dom_hash_iterate(dom_hash_table *ht, uintptr_t *c1, uintptr_t **c2);
+uint32_t _dom_hash_get_length(dom_hash_table *ht);
#endif
11 years, 9 months
r13307 tlsa - /trunk/netsurf/desktop/tree.c
by netsurf@semichrome.net
Author: tlsa
Date: Tue Dec 20 08:51:47 2011
New Revision: 13307
URL: http://source.netsurf-browser.org?rev=13307&view=rev
Log:
Delete comment that seems incorrect.
Modified:
trunk/netsurf/desktop/tree.c
Modified: trunk/netsurf/desktop/tree.c
URL: http://source.netsurf-browser.org/trunk/netsurf/desktop/tree.c?rev=13307&...
==============================================================================
--- trunk/netsurf/desktop/tree.c (original)
+++ trunk/netsurf/desktop/tree.c Tue Dec 20 08:51:47 2011
@@ -155,9 +155,6 @@
};
struct tree {
- /* These coordinates are only added to the coordinates passed to the
- plotters. This means they are invisible to the tree, what has to be
- taken into account i.e in keyboard/mouse event passing */
struct node *root; /* Tree root element */
int width; /* Tree width */
int height; /* Tree height */
11 years, 9 months
r13306 tlsa - /trunk/netsurf/desktop/tree.c
by netsurf@semichrome.net
Author: tlsa
Date: Tue Dec 20 08:46:29 2011
New Revision: 13306
URL: http://source.netsurf-browser.org?rev=13306&view=rev
Log:
When deleting multiple treeview nodes, don't redraw after every node is deleted, only after the whole lot has gone. (Much faster.) Fix redraw to clear bottom of treeview after deleting nodes.
Modified:
trunk/netsurf/desktop/tree.c
Modified: trunk/netsurf/desktop/tree.c
URL: http://source.netsurf-browser.org/trunk/netsurf/desktop/tree.c?rev=13306&...
==============================================================================
--- trunk/netsurf/desktop/tree.c (original)
+++ trunk/netsurf/desktop/tree.c Tue Dec 20 08:46:29 2011
@@ -1132,7 +1132,8 @@
*/
void tree_delete(struct tree *tree)
{
- tree_set_redraw(tree, false);
+ tree->redraw = false;
+
if (tree->root->child != NULL)
tree_delete_node_internal(tree, tree->root->child, true);
@@ -1164,11 +1165,19 @@
void tree_delete_node(struct tree *tree, struct node *node, bool siblings)
{
int y = node->box.y;
+ int height = tree->height;
+ bool redraw_setting = tree->redraw;
+
+ tree->redraw = false;
+
tree_delete_node_internal(tree, node, siblings);
tree_recalculate_node_positions(tree, tree->root);
+
+ tree->redraw = redraw_setting;
+
if (tree->redraw)
- tree->callbacks->redraw_request(0, y, tree->width, tree->height,
- tree->client_data);
+ tree->callbacks->redraw_request(0, y,
+ tree->width, height, tree->client_data);
tree_recalculate_size(tree);
}
@@ -2107,10 +2116,22 @@
void tree_delete_selected_nodes(struct tree *tree, struct node *node)
{
struct node *next;
+ int y = node->box.y;
+ int height = tree->height;
+ bool redraw_setting = tree->redraw;
+
+ tree->redraw = false;
if (node == tree->root) {
if (node->child != NULL)
tree_delete_selected_nodes(tree, node->child);
+
+ tree->redraw = redraw_setting;
+
+ if (tree->redraw)
+ tree->callbacks->redraw_request(0, y,
+ tree->width, height,
+ tree->client_data);
return;
}
@@ -2122,6 +2143,13 @@
tree_delete_selected_nodes(tree, node->child);
node = next;
}
+
+ tree->redraw = redraw_setting;
+
+ if (tree->redraw)
+ tree->callbacks->redraw_request(0, y,
+ tree->width, height,
+ tree->client_data);
}
11 years, 9 months
r13305 jmb - /branches/jmb/dom-alloc-purge/src/core/string.c
by netsurf@semichrome.net
Author: jmb
Date: Mon Dec 19 19:24:19 2011
New Revision: 13305
URL: http://source.netsurf-browser.org?rev=13305&view=rev
Log:
Handle attempts to ref/unref NULL
Modified:
branches/jmb/dom-alloc-purge/src/core/string.c
Modified: branches/jmb/dom-alloc-purge/src/core/string.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/core/s...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/core/string.c (original)
+++ branches/jmb/dom-alloc-purge/src/core/string.c Mon Dec 19 19:24:19 2011
@@ -52,7 +52,8 @@
*/
dom_string *dom_string_ref(dom_string *str)
{
- str->refcnt++;
+ if (str != NULL)
+ str->refcnt++;
return str;
}
@@ -67,7 +68,7 @@
*/
void dom_string_unref(dom_string *str)
{
- if (--str->refcnt == 0) {
+ if (str != NULL && --str->refcnt == 0) {
switch (str->type) {
case DOM_STRING_INTERNED:
if (str->data.intern != NULL) {
11 years, 9 months
r13304 jmb - in /branches/jmb/dom-alloc-purge/test: DOMTSHandler.pm testutils/comparators.c testutils/domtsasserts.c testutils/load.c
by netsurf@semichrome.net
Author: jmb
Date: Mon Dec 19 19:23:57 2011
New Revision: 13304
URL: http://source.netsurf-browser.org?rev=13304&view=rev
Log:
Make testsuite compile
Modified:
branches/jmb/dom-alloc-purge/test/DOMTSHandler.pm
branches/jmb/dom-alloc-purge/test/testutils/comparators.c
branches/jmb/dom-alloc-purge/test/testutils/domtsasserts.c
branches/jmb/dom-alloc-purge/test/testutils/load.c
Modified: branches/jmb/dom-alloc-purge/test/DOMTSHandler.pm
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/test/DOMTS...
==============================================================================
--- branches/jmb/dom-alloc-purge/test/DOMTSHandler.pm (original)
+++ branches/jmb/dom-alloc-purge/test/DOMTSHandler.pm Mon Dec 19 19:23:57 2011
@@ -374,11 +374,6 @@
(void)argc;
(void)argv;
- /* Firstly, initialise dom and dom implementations */
- exp = dom_initialise(myrealloc, NULL);
- if (exp != DOM_NO_ERR)
- return exp;
-
if (chdir("$self->{chdir}") < 0) {
perror("chdir (\\"$self->{chdir})\\"");
return 1;
@@ -1215,7 +1210,7 @@
print "while(get_next_list($coll, \&iterator$iterator_index, ";
if ($conversion eq 1) {
print "\&tstring$temp_index)) {\n";
- print "exp = dom_string_create(myrealloc, NULL, (const uint8_t *)tstring$temp_index,";
+ print "exp = dom_string_create((const uint8_t *)tstring$temp_index,";
print "strlen(tstring$temp_index), &$member);";
print "if (exp != DOM_NO_ERR) {";
print "fprintf(stderr, \"Can't create DOMString\\n\");";
@@ -1275,7 +1270,7 @@
print << "__EOF__";
const char *string$string_index = $str;
dom_string *dstring$string_index;
- exp = dom_string_create(myrealloc, NULL, (const uint8_t *)string$string_index,
+ exp = dom_string_create((const uint8_t *)string$string_index,
strlen(string$string_index), &dstring$string_index);
if (exp != DOM_NO_ERR) {
fprintf(stderr, "Can't create DOMString\\n");
Modified: branches/jmb/dom-alloc-purge/test/testutils/comparators.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/test/testu...
==============================================================================
--- branches/jmb/dom-alloc-purge/test/testutils/comparators.c (original)
+++ branches/jmb/dom-alloc-purge/test/testutils/comparators.c Mon Dec 19 19:23:57 2011
@@ -27,12 +27,12 @@
dom_exception err;
bool ret;
- err = dom_string_create(myrealloc, NULL, expected, strlen((const char *)expected),
+ err = dom_string_create(expected, strlen((const char *)expected),
&exp);
if (err != DOM_NO_ERR)
return false;
- ret = dom_string_cmp(exp, actual) == 0;
+ ret = dom_string_isequal(exp, actual);
dom_string_unref(exp);
@@ -58,12 +58,12 @@
dom_exception err;
bool ret;
- err = dom_string_create(myrealloc, NULL, expected, strlen((const char *)expected),
+ err = dom_string_create(expected, strlen((const char *)expected),
&exp);
if (err != DOM_NO_ERR)
return false;
- ret = dom_string_icmp(exp, actual) == 0;
+ ret = dom_string_caseless_isequal(exp, actual);
dom_string_unref(exp);
Modified: branches/jmb/dom-alloc-purge/test/testutils/domtsasserts.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/test/testu...
==============================================================================
--- branches/jmb/dom-alloc-purge/test/testutils/domtsasserts.c (original)
+++ branches/jmb/dom-alloc-purge/test/testutils/domtsasserts.c Mon Dec 19 19:23:57 2011
@@ -90,15 +90,15 @@
dom_exception err;
bool ret;
- err = dom_string_create(myrealloc, NULL, (const uint8_t *)expected, strlen(expected),
+ err = dom_string_create((const uint8_t *)expected, strlen(expected),
&exp);
if (err != DOM_NO_ERR)
return false;
if (ignoreCase == true)
- ret = dom_string_icmp(exp, actual) == 0;
+ ret = dom_string_caseless_isequal(exp, actual);
else
- ret = dom_string_cmp(exp, actual) == 0;
+ ret = dom_string_isequal(exp, actual);
dom_string_unref(exp);
return ret;
@@ -109,9 +109,9 @@
bool ignoreCase)
{
if (ignoreCase == true)
- return dom_string_icmp(expected, actual) == 0;
+ return dom_string_caseless_isequal(expected, actual);
else
- return dom_string_cmp(expected, actual) == 0;
+ return dom_string_isequal(expected, actual);
}
/* The param actual should always contain dom_sting and expectd should
Modified: branches/jmb/dom-alloc-purge/test/testutils/load.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/test/testu...
==============================================================================
--- branches/jmb/dom-alloc-purge/test/testutils/load.c (original)
+++ branches/jmb/dom-alloc-purge/test/testutils/load.c Mon Dec 19 19:23:57 2011
@@ -42,8 +42,7 @@
UNUSED(willBeModified);
- parser = dom_xml_parser_create(NULL, NULL,
- myrealloc, NULL, mymsg, NULL);
+ parser = dom_xml_parser_create(NULL, NULL, mymsg, NULL);
if (parser == NULL) {
fprintf(stderr, "Can't create XMLParser\n");
return NULL;
@@ -104,8 +103,7 @@
UNUSED(willBeModified);
- parser = dom_hubbub_parser_create(NULL, true,
- myrealloc, NULL, mymsg, NULL);
+ parser = dom_hubbub_parser_create(NULL, true, mymsg, NULL);
if (parser == NULL) {
fprintf(stderr, "Can't create Hubbub Parser\n");
return NULL;
11 years, 9 months
r13302 jmb - /branches/jmb/dom-alloc-purge/src/utils/namespace.c
by netsurf@semichrome.net
Author: jmb
Date: Mon Dec 19 17:43:17 2011
New Revision: 13302
URL: http://source.netsurf-browser.org?rev=13302&view=rev
Log:
Auto-initialise namespace module.
ifdef out the finalisation code, as there's no hook to call it from any longer.
Fix string API usage
Modified:
branches/jmb/dom-alloc-purge/src/utils/namespace.c
Modified: branches/jmb/dom-alloc-purge/src/utils/namespace.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/utils/...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/utils/namespace.c (original)
+++ branches/jmb/dom-alloc-purge/src/utils/namespace.c Mon Dec 19 17:43:17 2011
@@ -38,23 +38,20 @@
/**
* Initialise the namespace component
*
- * \param alloc Pointer to memory (de)allocation function
- * \param pw Pointer to client-specific private data
* \return DOM_NO_ERR on success.
*/
-dom_exception _dom_namespace_initialise(dom_alloc alloc, void *pw)
+static dom_exception _dom_namespace_initialise(void)
{
int i;
dom_exception err;
- err = dom_string_create(alloc, pw,
- (const uint8_t *) "xml", SLEN("xml"), &xml);
+ err = dom_string_create((const uint8_t *) "xml", SLEN("xml"), &xml);
if (err != DOM_NO_ERR) {
return err;
}
- err = dom_string_create(alloc, pw,
- (const uint8_t *) "xmlns", SLEN("xmlns"), &xmlns);
+ err = dom_string_create((const uint8_t *) "xmlns", SLEN("xmlns"),
+ &xmlns);
if (err != DOM_NO_ERR) {
dom_string_unref(xml);
xml = NULL;
@@ -64,7 +61,7 @@
for (i = 1; i < DOM_NAMESPACE_COUNT; i++) {
err = dom_string_create(
- alloc, pw, (const uint8_t *) namespaces[i],
+ (const uint8_t *) namespaces[i],
strlen(namespaces[i]), &dom_namespaces[i]);
if (err != DOM_NO_ERR) {
dom_string_unref(xmlns);
@@ -80,6 +77,7 @@
return DOM_NO_ERR;
}
+#ifdef FINALISE_NAMESPACE
/**
* Finalise the namespace component
*
@@ -108,6 +106,7 @@
return DOM_NO_ERR;
}
+#endif
/**
* Ensure a QName is valid
@@ -134,7 +133,13 @@
{
uint32_t colon, len;
- if (qname == NULL){
+ if (xml == NULL) {
+ dom_exception err = _dom_namespace_initialise();
+ if (err != DOM_NO_ERR)
+ return err;
+ }
+
+ if (qname == NULL) {
if (namespace != NULL)
return DOM_NAMESPACE_ERR;
if (namespace == NULL)
@@ -153,16 +158,17 @@
/* No prefix */
/* If namespace URI is for xmlns, ensure qname == "xmlns" */
if (namespace != NULL &&
- dom_string_cmp(namespace,
- dom_namespaces[DOM_NAMESPACE_XMLNS]) == 0 &&
- dom_string_cmp(qname, xmlns) != 0) {
- return DOM_NAMESPACE_ERR;
- }
+ dom_string_isequal(namespace,
+ dom_namespaces[DOM_NAMESPACE_XMLNS]) &&
+ dom_string_isequal(qname, xmlns) == false) {
+ return DOM_NAMESPACE_ERR;
+ }
+
/* If qname == "xmlns", ensure namespace URI is for xmlns */
if (namespace != NULL &&
- dom_string_cmp(qname, xmlns) == 0 &&
- dom_string_cmp(namespace,
- dom_namespaces[DOM_NAMESPACE_XMLNS]) != 0) {
+ dom_string_isequal(qname, xmlns) &&
+ dom_string_isequal(namespace,
+ dom_namespaces[DOM_NAMESPACE_XMLNS]) == false) {
return DOM_NAMESPACE_ERR;
}
} else if (colon == 0) {
@@ -196,25 +202,25 @@
}
/* Test for invalid XML namespace */
- if (dom_string_cmp(prefix, xml) == 0 &&
- dom_string_cmp(namespace,
- dom_namespaces[DOM_NAMESPACE_XML]) != 0) {
+ if (dom_string_isequal(prefix, xml) &&
+ dom_string_isequal(namespace,
+ dom_namespaces[DOM_NAMESPACE_XML]) == false) {
dom_string_unref(prefix);
return DOM_NAMESPACE_ERR;
}
/* Test for invalid xmlns namespace */
- if (dom_string_cmp(prefix, xmlns) == 0 &&
- dom_string_cmp(namespace,
- dom_namespaces[DOM_NAMESPACE_XMLNS]) != 0) {
+ if (dom_string_isequal(prefix, xmlns) &&
+ dom_string_isequal(namespace,
+ dom_namespaces[DOM_NAMESPACE_XMLNS]) == false) {
dom_string_unref(prefix);
return DOM_NAMESPACE_ERR;
}
/* Test for presence of xmlns namespace with non xmlns prefix */
- if (dom_string_cmp(namespace,
- dom_namespaces[DOM_NAMESPACE_XMLNS]) == 0 &&
- dom_string_cmp(prefix, xmlns) != 0) {
+ if (dom_string_isequal(namespace,
+ dom_namespaces[DOM_NAMESPACE_XMLNS]) &&
+ dom_string_isequal(prefix, xmlns) == false) {
dom_string_unref(prefix);
return DOM_NAMESPACE_ERR;
}
@@ -244,16 +250,19 @@
uint32_t colon;
dom_exception err;
+ if (xml == NULL) {
+ err = _dom_namespace_initialise();
+ if (err != DOM_NO_ERR)
+ return err;
+ }
+
/* Find colon, if any */
colon = dom_string_index(qname, ':');
if (colon == (uint32_t) -1) {
/* None found => no prefix */
*prefix = NULL;
- err = dom_string_dup(qname, localname);
- if (err != DOM_NO_ERR) {
- return err;
- }
+ *localname = dom_string_ref(qname);
} else {
/* Found one => prefix */
err = dom_string_substr(qname, 0, colon, prefix);
@@ -285,6 +294,11 @@
*/
dom_string *_dom_namespace_get_xml_prefix(void)
{
+ if (xml == NULL) {
+ if (_dom_namespace_initialise() != DOM_NO_ERR)
+ return NULL;
+ }
+
return xml;
}
@@ -300,5 +314,11 @@
*/
dom_string *_dom_namespace_get_xmlns_prefix(void)
{
+ if (xml == NULL) {
+ if (_dom_namespace_initialise() != DOM_NO_ERR)
+ return NULL;
+ }
+
return xmlns;
}
+
11 years, 9 months
r13301 jmb - /branches/jmb/dom-alloc-purge/src/html/
by netsurf@semichrome.net
Author: jmb
Date: Mon Dec 19 17:31:57 2011
New Revision: 13301
URL: http://source.netsurf-browser.org?rev=13301&view=rev
Log:
Fix up HTML element implementations
Modified:
branches/jmb/dom-alloc-purge/src/html/html_base_element.c
branches/jmb/dom-alloc-purge/src/html/html_base_element.h
branches/jmb/dom-alloc-purge/src/html/html_body_element.c
branches/jmb/dom-alloc-purge/src/html/html_body_element.h
branches/jmb/dom-alloc-purge/src/html/html_collection.c
branches/jmb/dom-alloc-purge/src/html/html_document.c
branches/jmb/dom-alloc-purge/src/html/html_element.c
branches/jmb/dom-alloc-purge/src/html/html_element.h
branches/jmb/dom-alloc-purge/src/html/html_form_element.c
branches/jmb/dom-alloc-purge/src/html/html_form_element.h
branches/jmb/dom-alloc-purge/src/html/html_head_element.c
branches/jmb/dom-alloc-purge/src/html/html_head_element.h
branches/jmb/dom-alloc-purge/src/html/html_html_element.c
branches/jmb/dom-alloc-purge/src/html/html_html_element.h
branches/jmb/dom-alloc-purge/src/html/html_isindex_element.c
branches/jmb/dom-alloc-purge/src/html/html_isindex_element.h
branches/jmb/dom-alloc-purge/src/html/html_link_element.c
branches/jmb/dom-alloc-purge/src/html/html_link_element.h
branches/jmb/dom-alloc-purge/src/html/html_meta_element.c
branches/jmb/dom-alloc-purge/src/html/html_meta_element.h
branches/jmb/dom-alloc-purge/src/html/html_options_collection.c
branches/jmb/dom-alloc-purge/src/html/html_select_element.c
branches/jmb/dom-alloc-purge/src/html/html_select_element.h
branches/jmb/dom-alloc-purge/src/html/html_style_element.c
branches/jmb/dom-alloc-purge/src/html/html_style_element.h
branches/jmb/dom-alloc-purge/src/html/html_title_element.c
branches/jmb/dom-alloc-purge/src/html/html_title_element.h
Modified: branches/jmb/dom-alloc-purge/src/html/html_base_element.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/html/h...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/html/html_base_element.c (original)
+++ branches/jmb/dom-alloc-purge/src/html/html_base_element.c Mon Dec 19 17:31:57 2011
@@ -4,6 +4,8 @@
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2009 Bo Yang <struggleyb.nku.com>
*/
+
+#include <stdlib.h>
#include "html/html_base_element.h"
@@ -28,7 +30,7 @@
dom_exception _dom_html_base_element_create(struct dom_document *doc,
struct dom_html_base_element **ele)
{
- *ele = _dom_document_alloc(doc, NULL, sizeof(dom_html_base_element));
+ *ele = malloc(sizeof(dom_html_base_element));
if (*ele == NULL)
return DOM_NO_MEM_ERR;
@@ -50,17 +52,15 @@
dom_exception _dom_html_base_element_initialise(struct dom_document *doc,
struct dom_html_base_element *ele)
{
- const char *str = "BASE";
- lwc_string *name = NULL;
+ dom_string *name = NULL;
dom_exception err;
- err = _dom_document_create_lwcstring(doc, (const uint8_t *) str, SLEN(str),
- &name);
+ err = dom_string_create((const uint8_t *) "BASE", SLEN("BASE"), &name);
if (err != DOM_NO_ERR)
return err;
err = _dom_html_element_initialise(doc, &ele->base, name, NULL, NULL);
- _dom_document_unref_lwcstring(doc, name);
+ dom_string_unref(name);
return err;
}
@@ -68,26 +68,22 @@
/**
* Finalise a dom_html_base_element object
*
- * \param doc The document object
* \param ele The dom_html_base_element object
*/
-void _dom_html_base_element_finalise(struct dom_document *doc,
- struct dom_html_base_element *ele)
+void _dom_html_base_element_finalise(struct dom_html_base_element *ele)
{
- _dom_html_element_finalise(doc, &ele->base);
+ _dom_html_element_finalise(&ele->base);
}
/**
* Destroy a dom_html_base_element object
*
- * \param doc The document object
* \param ele The dom_html_base_element object
*/
-void _dom_html_base_element_destroy(struct dom_document *doc,
- struct dom_html_base_element *ele)
+void _dom_html_base_element_destroy(struct dom_html_base_element *ele)
{
- _dom_html_base_element_finalise(doc, ele);
- _dom_document_alloc(doc, ele, 0);
+ _dom_html_base_element_finalise(ele);
+ free(ele);
}
/*------------------------------------------------------------------------*/
@@ -111,27 +107,13 @@
/* The virtual destroy function, see src/core/node.c for detail */
void _dom_virtual_html_base_element_destroy(dom_node_internal *node)
{
- struct dom_document *doc = dom_node_get_owner(node);
- _dom_html_base_element_destroy(doc, (struct dom_html_base_element *) node);
-}
-
-/* The virtual allocation function, see src/core/node.c for detail */
-dom_exception _dom_html_base_element_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret)
-{
- UNUSED(n);
-
- *ret = _dom_document_alloc(doc, NULL, sizeof(dom_html_base_element));
- if (*ret == NULL)
- return DOM_NO_MEM_ERR;
-
- return DOM_NO_ERR;
+ _dom_html_base_element_destroy((struct dom_html_base_element *) node);
}
/* The virtual copy function, see src/core/node.c for detail */
-dom_exception _dom_html_base_element_copy(struct dom_node_internal *new,
- struct dom_node_internal *old)
+dom_exception _dom_html_base_element_copy(dom_node_internal *old,
+ dom_node_internal **copy)
{
- return _dom_html_element_copy(new, old);
+ return _dom_html_element_copy(old, copy);
}
Modified: branches/jmb/dom-alloc-purge/src/html/html_base_element.h
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/html/h...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/html/html_base_element.h (original)
+++ branches/jmb/dom-alloc-purge/src/html/html_base_element.h Mon Dec 19 17:31:57 2011
@@ -26,29 +26,24 @@
struct dom_html_base_element *ele);
/* Finalise a dom_html_base_element object */
-void _dom_html_base_element_finalise(struct dom_document *doc,
- struct dom_html_base_element *ele);
+void _dom_html_base_element_finalise(struct dom_html_base_element *ele);
/* Destroy a dom_html_base_element object */
-void _dom_html_base_element_destroy(struct dom_document *doc,
- struct dom_html_base_element *ele);
+void _dom_html_base_element_destroy(struct dom_html_base_element *ele);
/* The protected virtual functions */
dom_exception _dom_html_base_element_parse_attribute(dom_element *ele,
dom_string *name, dom_string *value,
dom_string **parsed);
void _dom_virtual_html_base_element_destroy(dom_node_internal *node);
-dom_exception _dom_html_base_element_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret);
-dom_exception _dom_html_base_element_copy(struct dom_node_internal *new,
- struct dom_node_internal *old);
+dom_exception _dom_html_base_element_copy(dom_node_internal *old,
+ dom_node_internal **copy);
#define DOM_HTML_BASE_ELEMENT_PROTECT_VTABLE \
_dom_html_base_element_parse_attribute
#define DOM_NODE_PROTECT_VTABLE_HTML_BASE_ELEMENT \
_dom_virtual_html_base_element_destroy, \
- _dom_html_base_element_alloc, \
_dom_html_base_element_copy
#endif
Modified: branches/jmb/dom-alloc-purge/src/html/html_body_element.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/html/h...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/html/html_body_element.c (original)
+++ branches/jmb/dom-alloc-purge/src/html/html_body_element.c Mon Dec 19 17:31:57 2011
@@ -4,6 +4,8 @@
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2009 Bo Yang <struggleyb.nku.com>
*/
+
+#include <stdlib.h>
#include "html/html_body_element.h"
@@ -28,7 +30,7 @@
dom_exception _dom_html_body_element_create(struct dom_document *doc,
struct dom_html_body_element **ele)
{
- *ele = _dom_document_alloc(doc, NULL, sizeof(dom_html_body_element));
+ *ele = malloc(sizeof(dom_html_body_element));
if (*ele == NULL)
return DOM_NO_MEM_ERR;
@@ -50,17 +52,15 @@
dom_exception _dom_html_body_element_initialise(struct dom_document *doc,
struct dom_html_body_element *ele)
{
- const char *str = "BODY";
- lwc_string *name = NULL;
+ dom_string *name = NULL;
dom_exception err;
- err = _dom_document_create_lwcstring(doc, (const uint8_t *) str, SLEN(str),
- &name);
+ err = dom_string_create((const uint8_t *) "BODY", SLEN("BODY"), &name);
if (err != DOM_NO_ERR)
return err;
err = _dom_html_element_initialise(doc, &ele->base, name, NULL, NULL);
- _dom_document_unref_lwcstring(doc, name);
+ dom_string_unref(name);
return err;
}
@@ -68,26 +68,22 @@
/**
* Finalise a dom_html_body_element object
*
- * \param doc The document object
* \param ele The dom_html_body_element object
*/
-void _dom_html_body_element_finalise(struct dom_document *doc,
- struct dom_html_body_element *ele)
+void _dom_html_body_element_finalise(struct dom_html_body_element *ele)
{
- _dom_html_element_finalise(doc, &ele->base);
+ _dom_html_element_finalise(&ele->base);
}
/**
* Destroy a dom_html_body_element object
*
- * \param doc The document object
* \param ele The dom_html_body_element object
*/
-void _dom_html_body_element_destroy(struct dom_document *doc,
- struct dom_html_body_element *ele)
+void _dom_html_body_element_destroy(struct dom_html_body_element *ele)
{
- _dom_html_body_element_finalise(doc, ele);
- _dom_document_alloc(doc, ele, 0);
+ _dom_html_body_element_finalise(ele);
+ free(ele);
}
/*------------------------------------------------------------------------*/
@@ -111,27 +107,13 @@
/* The virtual destroy function, see src/core/node.c for detail */
void _dom_virtual_html_body_element_destroy(dom_node_internal *node)
{
- struct dom_document *doc = dom_node_get_owner(node);
- _dom_html_body_element_destroy(doc, (struct dom_html_body_element *) node);
-}
-
-/* The virtual allocation function, see src/core/node.c for detail */
-dom_exception _dom_html_body_element_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret)
-{
- UNUSED(n);
-
- *ret = _dom_document_alloc(doc, NULL, sizeof(dom_html_body_element));
- if (*ret == NULL)
- return DOM_NO_MEM_ERR;
-
- return DOM_NO_ERR;
+ _dom_html_body_element_destroy((struct dom_html_body_element *) node);
}
/* The virtual copy function, see src/core/node.c for detail */
-dom_exception _dom_html_body_element_copy(struct dom_node_internal *new,
- struct dom_node_internal *old)
+dom_exception _dom_html_body_element_copy(dom_node_internal *old,
+ dom_node_internal **copy)
{
- return _dom_html_element_copy(new, old);
+ return _dom_html_element_copy(old, copy);
}
Modified: branches/jmb/dom-alloc-purge/src/html/html_body_element.h
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/html/h...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/html/html_body_element.h (original)
+++ branches/jmb/dom-alloc-purge/src/html/html_body_element.h Mon Dec 19 17:31:57 2011
@@ -26,29 +26,24 @@
struct dom_html_body_element *ele);
/* Finalise a dom_html_body_element object */
-void _dom_html_body_element_finalise(struct dom_document *doc,
- struct dom_html_body_element *ele);
+void _dom_html_body_element_finalise(struct dom_html_body_element *ele);
/* Destroy a dom_html_body_element object */
-void _dom_html_body_element_destroy(struct dom_document *doc,
- struct dom_html_body_element *ele);
+void _dom_html_body_element_destroy(struct dom_html_body_element *ele);
/* The protected virtual functions */
dom_exception _dom_html_body_element_parse_attribute(dom_element *ele,
dom_string *name, dom_string *value,
dom_string **parsed);
void _dom_virtual_html_body_element_destroy(dom_node_internal *node);
-dom_exception _dom_html_body_element_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret);
-dom_exception _dom_html_body_element_copy(struct dom_node_internal *new,
- struct dom_node_internal *old);
+dom_exception _dom_html_body_element_copy(dom_node_internal *old,
+ dom_node_internal **copy);
#define DOM_HTML_BODY_ELEMENT_PROTECT_VTABLE \
_dom_html_body_element_parse_attribute
#define DOM_NODE_PROTECT_VTABLE_HTML_BODY_ELEMENT \
_dom_virtual_html_body_element_destroy, \
- _dom_html_body_element_alloc, \
_dom_html_body_element_copy
#endif
Modified: branches/jmb/dom-alloc-purge/src/html/html_collection.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/html/h...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/html/html_collection.c (original)
+++ branches/jmb/dom-alloc-purge/src/html/html_collection.c Mon Dec 19 17:31:57 2011
@@ -6,6 +6,7 @@
*/
#include <assert.h>
+#include <stdlib.h>
#include <libwapcaplet/libwapcaplet.h>
@@ -34,7 +35,7 @@
dom_callback_is_in_collection ic,
struct dom_html_collection **col)
{
- *col = _dom_document_alloc(doc, NULL, sizeof(dom_html_collection));
+ *col = malloc(sizeof(dom_html_collection));
if (*col == NULL)
return DOM_NO_MEM_ERR;
@@ -94,10 +95,9 @@
*/
void _dom_html_collection_destroy(struct dom_html_collection *col)
{
- struct dom_document *doc = col->doc;
_dom_html_collection_finalise(col);
- _dom_document_alloc(doc, col, 0);
+ free(col);
}
@@ -210,33 +210,27 @@
{
struct dom_node_internal *n = col->root;
dom_exception err;
- lwc_string *str = NULL;
- err = _dom_node_get_intern_string(n, name, &str);
- if (err != DOM_NO_ERR)
- return err;
-
while (node != NULL) {
if (n->type == DOM_ELEMENT_NODE && col->ic(n) == true) {
- lwc_string *id = NULL;
+ dom_string *id = NULL;
+
err = _dom_element_get_id((struct dom_element *) n,
&id);
if (err != DOM_NO_ERR) {
- _dom_node_unref_intern_string(n, id);
return err;
}
- /* Compare the lwc_string directly */
- if (str == id) {
+ if (id != NULL && dom_string_isequal(name, id)) {
*node = (struct dom_node *) n;
dom_node_ref(n);
- _dom_node_unref_intern_string(n, id);
- _dom_node_unref_intern_string(n, str);
-
+ dom_string_unref(id);
+
return DOM_NO_ERR;
}
- _dom_node_unref_intern_string(n, id);
+ if (id != NULL)
+ dom_string_unref(id);
}
/* Depth first iterating */
@@ -263,7 +257,6 @@
/* Not found the target node */
*node = NULL;
- _dom_node_unref_intern_string(n, str);
return DOM_NO_ERR;
}
Modified: branches/jmb/dom-alloc-purge/src/html/html_document.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/html/h...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/html/html_document.c (original)
+++ branches/jmb/dom-alloc-purge/src/html/html_document.c Mon Dec 19 17:31:57 2011
@@ -6,6 +6,7 @@
*/
#include <assert.h>
+#include <stdlib.h>
#include "html/html_document.h"
@@ -13,29 +14,24 @@
#include "utils/utils.h"
/* 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)
{
- assert(alloc != NULL);
- *doc = alloc(NULL, sizeof(dom_html_document), pw);
+ *doc = malloc(sizeof(dom_html_document));
if (*doc == NULL)
return DOM_NO_MEM_ERR;
- return _dom_html_document_initialise(*doc, alloc, pw, msg, msg_pw,
- daf, ui, pt);
+ return _dom_html_document_initialise(*doc, 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,
+ dom_msg msg, void *msg_pw,
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);
Modified: branches/jmb/dom-alloc-purge/src/html/html_element.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/html/h...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/html/html_element.c (original)
+++ branches/jmb/dom-alloc-purge/src/html/html_element.c Mon Dec 19 17:31:57 2011
@@ -6,6 +6,7 @@
*/
#include <assert.h>
+#include <stdlib.h>
#include "html/html_element.h"
@@ -15,8 +16,8 @@
#include "utils/utils.h"
dom_exception _dom_html_element_initialise(struct dom_document *doc,
- struct dom_html_element *el, struct lwc_string_s *name,
- struct lwc_string_s *namespace, struct lwc_string_s *prefix)
+ struct dom_html_element *el, dom_string *name,
+ dom_string *namespace, dom_string *prefix)
{
dom_exception err;
@@ -28,13 +29,12 @@
return err;
}
-void _dom_html_element_finalise(struct dom_document *doc,
- struct dom_html_element *ele)
+void _dom_html_element_finalise(struct dom_html_element *ele)
{
dom_node_unref(ele->form);
ele->form = NULL;
- _dom_element_finalise(doc, &ele->base);
+ _dom_element_finalise(&ele->base);
}
/*------------------------------------------------------------------------*/
@@ -47,24 +47,11 @@
assert("Should never be here" == NULL);
}
-/* The virtual allocation function, see src/core/node.c for detail */
-dom_exception _dom_html_element_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret)
-{
- UNUSED(doc);
- UNUSED(n);
- UNUSED(ret);
-
- assert("Should never be here" == NULL);
-
- return DOM_NO_MEM_ERR;
-}
-
/* The virtual copy function, see src/core/node.c for detail */
-dom_exception _dom_html_element_copy(struct dom_node_internal *new,
- struct dom_node_internal *old)
-{
- return _dom_element_copy(new, old);
+dom_exception _dom_html_element_copy(dom_node_internal *old,
+ dom_node_internal **copy)
+{
+ return _dom_element_copy(old, copy);
}
/*-----------------------------------------------------------------------*/
@@ -74,18 +61,12 @@
dom_string **id)
{
dom_exception ret;
- dom_document *doc;
dom_string *idstr;
- ret = dom_node_get_owner_document(element, &doc);
+ ret = dom_string_create((const uint8_t *) "id", SLEN("id"), &idstr);
if (ret != DOM_NO_ERR)
return ret;
- ret = _dom_document_create_string(doc, (const uint8_t *) "id",
- SLEN("id"), &idstr);
- if (ret != DOM_NO_ERR)
- return ret;
-
ret = dom_element_get_attribute(element, idstr, id);
dom_string_unref(idstr);
@@ -97,15 +78,9 @@
dom_string *id)
{
dom_exception ret;
- dom_document *doc;
dom_string *idstr;
- ret = dom_node_get_owner_document(element, &doc);
- if (ret != DOM_NO_ERR)
- return ret;
-
- ret = _dom_document_create_string(doc, (const uint8_t *) "id",
- SLEN("id"), &idstr);
+ ret = dom_string_create((const uint8_t *) "id", SLEN("id"), &idstr);
if (ret != DOM_NO_ERR)
return ret;
@@ -131,13 +106,11 @@
dom_exception dom_html_element_get_bool_property(dom_html_element *ele,
const char *name, unsigned long len, bool *has)
{
- dom_document *doc = dom_node_get_owner(ele);
dom_string *str = NULL;
dom_attr *a = NULL;
dom_exception err;
- err = _dom_document_create_string(doc, (const uint8_t *) name,
- len, &str);
+ err = dom_string_create((const uint8_t *) name, len, &str);
if (err != DOM_NO_ERR)
goto fail;
@@ -172,13 +145,11 @@
dom_exception dom_html_element_set_bool_property(dom_html_element *ele,
const char *name, unsigned long len, bool has)
{
- dom_document *doc = dom_node_get_owner(ele);
dom_string *str = NULL;
dom_attr *a = NULL;
dom_exception err;
- err = _dom_document_create_string(doc, (const uint8_t *) name,
- len, &str);
+ err = dom_string_create((const uint8_t *) name, len, &str);
if (err != DOM_NO_ERR)
goto fail;
@@ -195,19 +166,13 @@
dom_node_unref(res);
} else if (a == NULL && has == true) {
+ dom_document *doc = dom_node_get_owner(ele);
dom_attr *res = NULL;
- lwc_string *lstr = NULL;
-
- err = _dom_string_intern(str, &lstr);
- if (err != DOM_NO_ERR)
- goto cleanup1;
-
- err = _dom_attr_create(doc, lstr, NULL, NULL, true, &a);
+
+ err = _dom_attr_create(doc, str, NULL, NULL, true, &a);
if (err != DOM_NO_ERR) {
- lwc_string_unref(lstr);
goto cleanup1;
}
- lwc_string_unref(lstr);
err = dom_element_set_attribute_node(ele, a, &res);
if (err != DOM_NO_ERR)
Modified: branches/jmb/dom-alloc-purge/src/html/html_element.h
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/html/h...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/html/html_element.h (original)
+++ branches/jmb/dom-alloc-purge/src/html/html_element.h Mon Dec 19 17:31:57 2011
@@ -28,18 +28,15 @@
};
dom_exception _dom_html_element_initialise(struct dom_document *doc,
- struct dom_html_element *el, struct lwc_string_s *name,
- struct lwc_string_s *namespace, struct lwc_string_s *prefix);
+ struct dom_html_element *el, dom_string *name,
+ dom_string *namespace, dom_string *prefix);
-void _dom_html_element_finalise(struct dom_document *doc,
- struct dom_html_element *ele);
+void _dom_html_element_finalise(struct dom_html_element *ele);
/* The protected virtual functions */
void _dom_virtual_html_element_destroy(dom_node_internal *node);
-dom_exception _dom_html_element_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret);
-dom_exception _dom_html_element_copy(struct dom_node_internal *new,
- struct dom_node_internal *old);
+dom_exception _dom_html_element_copy(dom_node_internal *old,
+ dom_node_internal **copy);
/* The API functions */
dom_exception _dom_html_element_get_id(dom_html_element *element,
Modified: branches/jmb/dom-alloc-purge/src/html/html_form_element.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/html/h...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/html/html_form_element.c (original)
+++ branches/jmb/dom-alloc-purge/src/html/html_form_element.c Mon Dec 19 17:31:57 2011
@@ -6,6 +6,7 @@
*/
#include <assert.h>
+#include <stdlib.h>
#include "html/html_form_element.h"
@@ -34,7 +35,7 @@
dom_exception _dom_html_form_element_create(struct dom_document *doc,
struct dom_html_form_element **ele)
{
- *ele = _dom_document_alloc(doc, NULL, sizeof(dom_html_form_element));
+ *ele = malloc(sizeof(dom_html_form_element));
if (*ele == NULL)
return DOM_NO_MEM_ERR;
@@ -56,17 +57,15 @@
dom_exception _dom_html_form_element_initialise(struct dom_document *doc,
struct dom_html_form_element *ele)
{
- const char *str = "FORM";
- lwc_string *name = NULL;
+ dom_string *name = NULL;
dom_exception err;
- err = _dom_document_create_lwcstring(doc, (const uint8_t *) str, SLEN(str),
- &name);
+ err = dom_string_create((const uint8_t *) "FORM", SLEN("FORM"), &name);
if (err != DOM_NO_ERR)
return err;
err = _dom_html_element_initialise(doc, &ele->base, name, NULL, NULL);
- _dom_document_unref_lwcstring(doc, name);
+ dom_string_unref(name);
ele->col = NULL;
@@ -76,26 +75,22 @@
/**
* Finalise a dom_html_form_element object
*
- * \param doc The document object
* \param ele The dom_html_form_element object
*/
-void _dom_html_form_element_finalise(struct dom_document *doc,
- struct dom_html_form_element *ele)
-{
- _dom_html_element_finalise(doc, &ele->base);
+void _dom_html_form_element_finalise(struct dom_html_form_element *ele)
+{
+ _dom_html_element_finalise(&ele->base);
}
/**
* Destroy a dom_html_form_element object
*
- * \param doc The document object
* \param ele The dom_html_form_element object
*/
-void _dom_html_form_element_destroy(struct dom_document *doc,
- struct dom_html_form_element *ele)
-{
- _dom_html_form_element_finalise(doc, ele);
- _dom_document_alloc(doc, ele, 0);
+void _dom_html_form_element_destroy(struct dom_html_form_element *ele)
+{
+ _dom_html_form_element_finalise(ele);
+ free(ele);
}
/*------------------------------------------------------------------------*/
@@ -119,28 +114,14 @@
/* The virtual destroy function, see src/core/node.c for detail */
void _dom_virtual_html_form_element_destroy(dom_node_internal *node)
{
- struct dom_document *doc = dom_node_get_owner(node);
- _dom_html_form_element_destroy(doc, (struct dom_html_form_element *) node);
-}
-
-/* The virtual allocation function, see src/core/node.c for detail */
-dom_exception _dom_html_form_element_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret)
-{
- UNUSED(n);
-
- *ret = _dom_document_alloc(doc, NULL, sizeof(dom_html_form_element));
- if (*ret == NULL)
- return DOM_NO_MEM_ERR;
-
- return DOM_NO_ERR;
+ _dom_html_form_element_destroy((struct dom_html_form_element *) node);
}
/* The virtual copy function, see src/core/node.c for detail */
-dom_exception _dom_html_form_element_copy(struct dom_node_internal *new,
- struct dom_node_internal *old)
-{
- return _dom_html_element_copy(new, old);
+dom_exception _dom_html_form_element_copy(dom_node_internal *old,
+ dom_node_internal **copy)
+{
+ return _dom_html_element_copy(old, copy);
}
/*-----------------------------------------------------------------------*/
Modified: branches/jmb/dom-alloc-purge/src/html/html_form_element.h
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/html/h...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/html/html_form_element.h (original)
+++ branches/jmb/dom-alloc-purge/src/html/html_form_element.h Mon Dec 19 17:31:57 2011
@@ -30,29 +30,24 @@
struct dom_html_form_element *ele);
/* Finalise a dom_html_form_element object */
-void _dom_html_form_element_finalise(struct dom_document *doc,
- struct dom_html_form_element *ele);
+void _dom_html_form_element_finalise(struct dom_html_form_element *ele);
/* Destroy a dom_html_form_element object */
-void _dom_html_form_element_destroy(struct dom_document *doc,
- struct dom_html_form_element *ele);
+void _dom_html_form_element_destroy(struct dom_html_form_element *ele);
/* The protected virtual functions */
dom_exception _dom_html_form_element_parse_attribute(dom_element *ele,
dom_string *name, dom_string *value,
dom_string **parsed);
void _dom_virtual_html_form_element_destroy(dom_node_internal *node);
-dom_exception _dom_html_form_element_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret);
-dom_exception _dom_html_form_element_copy(struct dom_node_internal *new,
- struct dom_node_internal *old);
+dom_exception _dom_html_form_element_copy(dom_node_internal *old,
+ dom_node_internal **copy);
#define DOM_HTML_FORM_ELEMENT_PROTECT_VTABLE \
_dom_html_form_element_parse_attribute
#define DOM_NODE_PROTECT_VTABLE_HTML_FORM_ELEMENT \
_dom_virtual_html_form_element_destroy, \
- _dom_html_form_element_alloc, \
_dom_html_form_element_copy
#endif
Modified: branches/jmb/dom-alloc-purge/src/html/html_head_element.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/html/h...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/html/html_head_element.c (original)
+++ branches/jmb/dom-alloc-purge/src/html/html_head_element.c Mon Dec 19 17:31:57 2011
@@ -4,6 +4,8 @@
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2009 Bo Yang <struggleyb.nku.com>
*/
+
+#include <stdlib.h>
#include "html/html_head_element.h"
@@ -28,7 +30,7 @@
dom_exception _dom_html_head_element_create(struct dom_document *doc,
struct dom_html_head_element **ele)
{
- *ele = _dom_document_alloc(doc, NULL, sizeof(dom_html_head_element));
+ *ele = malloc(sizeof(dom_html_head_element));
if (*ele == NULL)
return DOM_NO_MEM_ERR;
@@ -50,17 +52,15 @@
dom_exception _dom_html_head_element_initialise(struct dom_document *doc,
struct dom_html_head_element *ele)
{
- const char *str = "HEAD";
- lwc_string *name = NULL;
+ dom_string *name = NULL;
dom_exception err;
- err = _dom_document_create_lwcstring(doc, (const uint8_t *) str, SLEN(str),
- &name);
+ err = dom_string_create((const uint8_t *) "HEAD", SLEN("HEAD"), &name);
if (err != DOM_NO_ERR)
return err;
err = _dom_html_element_initialise(doc, &ele->base, name, NULL, NULL);
- _dom_document_unref_lwcstring(doc, name);
+ dom_string_unref(name);
return err;
}
@@ -68,26 +68,22 @@
/**
* Finalise a dom_html_head_element object
*
- * \param doc The document object
* \param ele The dom_html_head_element object
*/
-void _dom_html_head_element_finalise(struct dom_document *doc,
- struct dom_html_head_element *ele)
+void _dom_html_head_element_finalise(struct dom_html_head_element *ele)
{
- _dom_html_element_finalise(doc, &ele->base);
+ _dom_html_element_finalise(&ele->base);
}
/**
* Destroy a dom_html_head_element object
*
- * \param doc The document object
* \param ele The dom_html_head_element object
*/
-void _dom_html_head_element_destroy(struct dom_document *doc,
- struct dom_html_head_element *ele)
+void _dom_html_head_element_destroy(struct dom_html_head_element *ele)
{
- _dom_html_head_element_finalise(doc, ele);
- _dom_document_alloc(doc, ele, 0);
+ _dom_html_head_element_finalise(ele);
+ free(ele);
}
/*------------------------------------------------------------------------*/
@@ -111,27 +107,13 @@
/* The virtual destroy function, see src/core/node.c for detail */
void _dom_virtual_html_head_element_destroy(dom_node_internal *node)
{
- struct dom_document *doc = dom_node_get_owner(node);
- _dom_html_head_element_destroy(doc, (struct dom_html_head_element *) node);
-}
-
-/* The virtual allocation function, see src/core/node.c for detail */
-dom_exception _dom_html_head_element_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret)
-{
- UNUSED(n);
-
- *ret = _dom_document_alloc(doc, NULL, sizeof(dom_html_head_element));
- if (*ret == NULL)
- return DOM_NO_MEM_ERR;
-
- return DOM_NO_ERR;
+ _dom_html_head_element_destroy((struct dom_html_head_element *) node);
}
/* The virtual copy function, see src/core/node.c for detail */
-dom_exception _dom_html_head_element_copy(struct dom_node_internal *new,
- struct dom_node_internal *old)
+dom_exception _dom_html_head_element_copy(dom_node_internal *old,
+ dom_node_internal **copy)
{
- return _dom_html_element_copy(new, old);
+ return _dom_html_element_copy(old, copy);
}
Modified: branches/jmb/dom-alloc-purge/src/html/html_head_element.h
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/html/h...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/html/html_head_element.h (original)
+++ branches/jmb/dom-alloc-purge/src/html/html_head_element.h Mon Dec 19 17:31:57 2011
@@ -26,29 +26,24 @@
struct dom_html_head_element *ele);
/* Finalise a dom_html_head_element object */
-void _dom_html_head_element_finalise(struct dom_document *doc,
- struct dom_html_head_element *ele);
+void _dom_html_head_element_finalise(struct dom_html_head_element *ele);
/* Destroy a dom_html_head_element object */
-void _dom_html_head_element_destroy(struct dom_document *doc,
- struct dom_html_head_element *ele);
+void _dom_html_head_element_destroy(struct dom_html_head_element *ele);
/* The protected virtual functions */
dom_exception _dom_html_head_element_parse_attribute(dom_element *ele,
dom_string *name, dom_string *value,
dom_string **parsed);
void _dom_virtual_html_head_element_destroy(dom_node_internal *node);
-dom_exception _dom_html_head_element_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret);
-dom_exception _dom_html_head_element_copy(struct dom_node_internal *new,
- struct dom_node_internal *old);
+dom_exception _dom_html_head_element_copy(dom_node_internal *old,
+ dom_node_internal **copy);
#define DOM_HTML_HEAD_ELEMENT_PROTECT_VTABLE \
_dom_html_head_element_parse_attribute
#define DOM_NODE_PROTECT_VTABLE_HTML_HEAD_ELEMENT \
_dom_virtual_html_head_element_destroy, \
- _dom_html_head_element_alloc, \
_dom_html_head_element_copy
#endif
Modified: branches/jmb/dom-alloc-purge/src/html/html_html_element.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/html/h...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/html/html_html_element.c (original)
+++ branches/jmb/dom-alloc-purge/src/html/html_html_element.c Mon Dec 19 17:31:57 2011
@@ -4,6 +4,8 @@
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2009 Bo Yang <struggleyb.nku.com>
*/
+
+#include <stdlib.h>
#include "html/html_html_element.h"
@@ -28,7 +30,7 @@
dom_exception _dom_html_html_element_create(struct dom_document *doc,
struct dom_html_html_element **ele)
{
- *ele = _dom_document_alloc(doc, NULL, sizeof(dom_html_html_element));
+ *ele = malloc(sizeof(dom_html_html_element));
if (*ele == NULL)
return DOM_NO_MEM_ERR;
@@ -50,17 +52,15 @@
dom_exception _dom_html_html_element_initialise(struct dom_document *doc,
struct dom_html_html_element *ele)
{
- const char *str = "HTML";
- lwc_string *name = NULL;
+ dom_string *name = NULL;
dom_exception err;
- err = _dom_document_create_lwcstring(doc, (const uint8_t *) str, SLEN(str),
- &name);
+ err = dom_string_create((const uint8_t *) "HTML", SLEN("HTML"), &name);
if (err != DOM_NO_ERR)
return err;
err = _dom_html_element_initialise(doc, &ele->base, name, NULL, NULL);
- _dom_document_unref_lwcstring(doc, name);
+ dom_string_unref(name);
return err;
}
@@ -68,26 +68,23 @@
/**
* Finalise a dom_html_html_element object
*
- * \param doc The document object
* \param ele The dom_html_html_element object
*/
-void _dom_html_html_element_finalise(struct dom_document *doc,
- struct dom_html_html_element *ele)
+void _dom_html_html_element_finalise(struct dom_html_html_element *ele)
{
- _dom_html_element_finalise(doc, &ele->base);
+ _dom_html_element_finalise(&ele->base);
}
/**
* Destroy a dom_html_html_element object
*
- * \param doc The document object
* \param ele The dom_html_html_element object
*/
-void _dom_html_html_element_destroy(struct dom_document *doc,
- struct dom_html_html_element *ele)
+void _dom_html_html_element_destroy(struct dom_html_html_element *ele)
{
- _dom_html_html_element_finalise(doc, ele);
- _dom_document_alloc(doc, ele, 0);
+ _dom_html_html_element_finalise(ele);
+
+ free(ele);
}
/*------------------------------------------------------------------------*/
@@ -111,27 +108,13 @@
/* The virtual destroy function, see src/core/node.c for detail */
void _dom_virtual_html_html_element_destroy(dom_node_internal *node)
{
- struct dom_document *doc = dom_node_get_owner(node);
- _dom_html_html_element_destroy(doc, (struct dom_html_html_element *) node);
-}
-
-/* The virtual allocation function, see src/core/node.c for detail */
-dom_exception _dom_html_html_element_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret)
-{
- UNUSED(n);
-
- *ret = _dom_document_alloc(doc, NULL, sizeof(dom_html_html_element));
- if (*ret == NULL)
- return DOM_NO_MEM_ERR;
-
- return DOM_NO_ERR;
+ _dom_html_html_element_destroy((struct dom_html_html_element *) node);
}
/* The virtual copy function, see src/core/node.c for detail */
-dom_exception _dom_html_html_element_copy(struct dom_node_internal *new,
- struct dom_node_internal *old)
+dom_exception _dom_html_html_element_copy(dom_node_internal *old,
+ dom_node_internal **copy)
{
- return _dom_html_element_copy(new, old);
+ return _dom_html_element_copy(old, copy);
}
Modified: branches/jmb/dom-alloc-purge/src/html/html_html_element.h
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/html/h...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/html/html_html_element.h (original)
+++ branches/jmb/dom-alloc-purge/src/html/html_html_element.h Mon Dec 19 17:31:57 2011
@@ -26,29 +26,24 @@
struct dom_html_html_element *ele);
/* Finalise a dom_html_html_element object */
-void _dom_html_html_element_finalise(struct dom_document *doc,
- struct dom_html_html_element *ele);
+void _dom_html_html_element_finalise(struct dom_html_html_element *ele);
/* Destroy a dom_html_html_element object */
-void _dom_html_html_element_destroy(struct dom_document *doc,
- struct dom_html_html_element *ele);
+void _dom_html_html_element_destroy(struct dom_html_html_element *ele);
/* The protected virtual functions */
dom_exception _dom_html_html_element_parse_attribute(dom_element *ele,
dom_string *name, dom_string *value,
dom_string **parsed);
void _dom_virtual_html_html_element_destroy(dom_node_internal *node);
-dom_exception _dom_html_html_element_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret);
-dom_exception _dom_html_html_element_copy(struct dom_node_internal *new,
- struct dom_node_internal *old);
+dom_exception _dom_html_html_element_copy(dom_node_internal *old,
+ dom_node_internal **copy);
#define DOM_HTML_HTML_ELEMENT_PROTECT_VTABLE \
_dom_html_html_element_parse_attribute
#define DOM_NODE_PROTECT_VTABLE_HTML_HTML_ELEMENT \
_dom_virtual_html_html_element_destroy, \
- _dom_html_html_element_alloc, \
_dom_html_html_element_copy
#endif
Modified: branches/jmb/dom-alloc-purge/src/html/html_isindex_element.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/html/h...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/html/html_isindex_element.c (original)
+++ branches/jmb/dom-alloc-purge/src/html/html_isindex_element.c Mon Dec 19 17:31:57 2011
@@ -4,6 +4,8 @@
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2009 Bo Yang <struggleyb.nku.com>
*/
+
+#include <stdlib.h>
#include "html/html_isindex_element.h"
@@ -30,7 +32,7 @@
struct dom_html_form_element *form,
struct dom_html_isindex_element **ele)
{
- *ele = _dom_document_alloc(doc, NULL, sizeof(dom_html_isindex_element));
+ *ele = malloc(sizeof(dom_html_isindex_element));
if (*ele == NULL)
return DOM_NO_MEM_ERR;
@@ -54,17 +56,16 @@
struct dom_html_form_element *form,
struct dom_html_isindex_element *ele)
{
- const char *str = "ISINDEX";
- lwc_string *name = NULL;
+ dom_string *name = NULL;
dom_exception err;
- err = _dom_document_create_lwcstring(doc, (const uint8_t *) str, SLEN(str),
+ err = dom_string_create((const uint8_t *) "ISINDEX", SLEN("ISINDEX"),
&name);
if (err != DOM_NO_ERR)
return err;
err = _dom_html_element_initialise(doc, &ele->base, name, NULL, NULL);
- _dom_document_unref_lwcstring(doc, name);
+ dom_string_unref(name);
ele->base.form = form;
dom_node_ref(form);
@@ -75,26 +76,22 @@
/**
* Finalise a dom_html_isindex_element object
*
- * \param doc The document object
* \param ele The dom_html_isindex_element object
*/
-void _dom_html_isindex_element_finalise(struct dom_document *doc,
- struct dom_html_isindex_element *ele)
+void _dom_html_isindex_element_finalise(struct dom_html_isindex_element *ele)
{
- _dom_html_element_finalise(doc, &ele->base);
+ _dom_html_element_finalise(&ele->base);
}
/**
* Destroy a dom_html_isindex_element object
*
- * \param doc The document object
* \param ele The dom_html_isindex_element object
*/
-void _dom_html_isindex_element_destroy(struct dom_document *doc,
- struct dom_html_isindex_element *ele)
+void _dom_html_isindex_element_destroy(struct dom_html_isindex_element *ele)
{
- _dom_html_isindex_element_finalise(doc, ele);
- _dom_document_alloc(doc, ele, 0);
+ _dom_html_isindex_element_finalise(ele);
+ free(ele);
}
/*------------------------------------------------------------------------*/
@@ -118,28 +115,14 @@
/* The virtual destroy function, see src/core/node.c for detail */
void _dom_virtual_html_isindex_element_destroy(dom_node_internal *node)
{
- struct dom_document *doc = dom_node_get_owner(node);
- _dom_html_isindex_element_destroy(doc, (struct dom_html_isindex_element *) node);
-}
-
-/* The virtual allocation function, see src/core/node.c for detail */
-dom_exception _dom_html_isindex_element_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret)
-{
- UNUSED(n);
-
- *ret = _dom_document_alloc(doc, NULL, sizeof(dom_html_isindex_element));
- if (*ret == NULL)
- return DOM_NO_MEM_ERR;
-
- return DOM_NO_ERR;
+ _dom_html_isindex_element_destroy((struct dom_html_isindex_element *) node);
}
/* The virtual copy function, see src/core/node.c for detail */
-dom_exception _dom_html_isindex_element_copy(struct dom_node_internal *new,
- struct dom_node_internal *old)
+dom_exception _dom_html_isindex_element_copy(dom_node_internal *old,
+ dom_node_internal **copy)
{
- return _dom_html_element_copy(new, old);
+ return _dom_html_element_copy(old, copy);
}
Modified: branches/jmb/dom-alloc-purge/src/html/html_isindex_element.h
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/html/h...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/html/html_isindex_element.h (original)
+++ branches/jmb/dom-alloc-purge/src/html/html_isindex_element.h Mon Dec 19 17:31:57 2011
@@ -28,29 +28,24 @@
struct dom_html_isindex_element *ele);
/* Finalise a dom_html_isindex_element object */
-void _dom_html_isindex_element_finalise(struct dom_document *doc,
- struct dom_html_isindex_element *ele);
+void _dom_html_isindex_element_finalise(struct dom_html_isindex_element *ele);
/* Destroy a dom_html_isindex_element object */
-void _dom_html_isindex_element_destroy(struct dom_document *doc,
- struct dom_html_isindex_element *ele);
+void _dom_html_isindex_element_destroy(struct dom_html_isindex_element *ele);
/* The protected virtual functions */
dom_exception _dom_html_isindex_element_parse_attribute(dom_element *ele,
dom_string *name, dom_string *value,
dom_string **parsed);
void _dom_virtual_html_isindex_element_destroy(dom_node_internal *node);
-dom_exception _dom_html_isindex_element_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret);
-dom_exception _dom_html_isindex_element_copy(struct dom_node_internal *new,
- struct dom_node_internal *old);
+dom_exception _dom_html_isindex_element_copy(dom_node_internal *old,
+ dom_node_internal **copy);
#define DOM_HTML_ISINDEX_ELEMENT_PROTECT_VTABLE \
_dom_html_isindex_element_parse_attribute
#define DOM_NODE_PROTECT_VTABLE_HTML_ISINDEX_ELEMENT \
_dom_virtual_html_isindex_element_destroy, \
- _dom_html_isindex_element_alloc, \
_dom_html_isindex_element_copy
#endif
Modified: branches/jmb/dom-alloc-purge/src/html/html_link_element.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/html/h...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/html/html_link_element.c (original)
+++ branches/jmb/dom-alloc-purge/src/html/html_link_element.c Mon Dec 19 17:31:57 2011
@@ -6,6 +6,7 @@
*/
#include <assert.h>
+#include <stdlib.h>
#include "html/html_link_element.h"
@@ -31,7 +32,7 @@
dom_exception _dom_html_link_element_create(struct dom_document *doc,
struct dom_html_link_element **ele)
{
- *ele = _dom_document_alloc(doc, NULL, sizeof(dom_html_link_element));
+ *ele = malloc(sizeof(dom_html_link_element));
if (*ele == NULL)
return DOM_NO_MEM_ERR;
@@ -53,17 +54,15 @@
dom_exception _dom_html_link_element_initialise(struct dom_document *doc,
struct dom_html_link_element *ele)
{
- const char *str = "LINK";
- lwc_string *name = NULL;
+ dom_string *name = NULL;
dom_exception err;
- err = _dom_document_create_lwcstring(doc, (const uint8_t *) str, SLEN(str),
- &name);
+ err = dom_string_create((const uint8_t *) "HEAD", SLEN("HEAD"), &name);
if (err != DOM_NO_ERR)
return err;
err = _dom_html_element_initialise(doc, &ele->base, name, NULL, NULL);
- _dom_document_unref_lwcstring(doc, name);
+ dom_string_unref(name);
return err;
}
@@ -71,26 +70,22 @@
/**
* Finalise a dom_html_link_element object
*
- * \param doc The document object
* \param ele The dom_html_link_element object
*/
-void _dom_html_link_element_finalise(struct dom_document *doc,
- struct dom_html_link_element *ele)
+void _dom_html_link_element_finalise(struct dom_html_link_element *ele)
{
- _dom_html_element_finalise(doc, &ele->base);
+ _dom_html_element_finalise(&ele->base);
}
/**
* Destroy a dom_html_link_element object
*
- * \param doc The document object
* \param ele The dom_html_link_element object
*/
-void _dom_html_link_element_destroy(struct dom_document *doc,
- struct dom_html_link_element *ele)
+void _dom_html_link_element_destroy(struct dom_html_link_element *ele)
{
- _dom_html_link_element_finalise(doc, ele);
- _dom_document_alloc(doc, ele, 0);
+ _dom_html_link_element_finalise(ele);
+ free(ele);
}
/*-----------------------------------------------------------------------*/
@@ -145,27 +140,13 @@
/* The virtual destroy function, see src/core/node.c for detail */
void _dom_virtual_html_link_element_destroy(dom_node_internal *node)
{
- struct dom_document *doc = dom_node_get_owner(node);
- _dom_html_link_element_destroy(doc, (struct dom_html_link_element *) node);
-}
-
-/* The virtual allocation function, see src/core/node.c for detail */
-dom_exception _dom_html_link_element_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret)
-{
- UNUSED(n);
-
- *ret = _dom_document_alloc(doc, NULL, sizeof(dom_html_link_element));
- if (*ret == NULL)
- return DOM_NO_MEM_ERR;
-
- return DOM_NO_ERR;
+ _dom_html_link_element_destroy((struct dom_html_link_element *) node);
}
/* The virtual copy function, see src/core/node.c for detail */
-dom_exception _dom_html_link_element_copy(struct dom_node_internal *new,
- struct dom_node_internal *old)
+dom_exception _dom_html_link_element_copy(dom_node_internal *old,
+ dom_node_internal **copy)
{
- return _dom_html_element_copy(new, old);
+ return _dom_html_element_copy(old, copy);
}
Modified: branches/jmb/dom-alloc-purge/src/html/html_link_element.h
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/html/h...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/html/html_link_element.h (original)
+++ branches/jmb/dom-alloc-purge/src/html/html_link_element.h Mon Dec 19 17:31:57 2011
@@ -26,29 +26,24 @@
struct dom_html_link_element *ele);
/* Finalise a dom_html_link_element object */
-void _dom_html_link_element_finalise(struct dom_document *doc,
- struct dom_html_link_element *ele);
+void _dom_html_link_element_finalise(struct dom_html_link_element *ele);
/* Destroy a dom_html_link_element object */
-void _dom_html_link_element_destroy(struct dom_document *doc,
- struct dom_html_link_element *ele);
+void _dom_html_link_element_destroy(struct dom_html_link_element *ele);
/* The protected virtual functions */
dom_exception _dom_html_link_element_parse_attribute(dom_element *ele,
dom_string *name, dom_string *value,
dom_string **parsed);
void _dom_virtual_html_link_element_destroy(dom_node_internal *node);
-dom_exception _dom_html_link_element_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret);
-dom_exception _dom_html_link_element_copy(struct dom_node_internal *new,
- struct dom_node_internal *old);
+dom_exception _dom_html_link_element_copy(dom_node_internal *old,
+ dom_node_internal **copy);
#define DOM_HTML_LINK_ELEMENT_PROTECT_VTABLE \
_dom_html_link_element_parse_attribute
#define DOM_NODE_PROTECT_VTABLE_HTML_LINK_ELEMENT \
_dom_virtual_html_link_element_destroy, \
- _dom_html_link_element_alloc, \
_dom_html_link_element_copy
#endif
Modified: branches/jmb/dom-alloc-purge/src/html/html_meta_element.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/html/h...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/html/html_meta_element.c (original)
+++ branches/jmb/dom-alloc-purge/src/html/html_meta_element.c Mon Dec 19 17:31:57 2011
@@ -4,6 +4,8 @@
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2009 Bo Yang <struggleyb.nku.com>
*/
+
+#include <stdlib.h>
#include "html/html_meta_element.h"
@@ -28,7 +30,7 @@
dom_exception _dom_html_meta_element_create(struct dom_document *doc,
struct dom_html_meta_element **ele)
{
- *ele = _dom_document_alloc(doc, NULL, sizeof(dom_html_meta_element));
+ *ele = malloc(sizeof(dom_html_meta_element));
if (*ele == NULL)
return DOM_NO_MEM_ERR;
@@ -50,17 +52,15 @@
dom_exception _dom_html_meta_element_initialise(struct dom_document *doc,
struct dom_html_meta_element *ele)
{
- const char *str = "META";
- lwc_string *name = NULL;
+ dom_string *name = NULL;
dom_exception err;
- err = _dom_document_create_lwcstring(doc, (const uint8_t *) str, SLEN(str),
- &name);
+ err = dom_string_create((const uint8_t *) "META", SLEN("META"), &name);
if (err != DOM_NO_ERR)
return err;
err = _dom_html_element_initialise(doc, &ele->base, name, NULL, NULL);
- _dom_document_unref_lwcstring(doc, name);
+ dom_string_unref(name);
return err;
}
@@ -68,26 +68,22 @@
/**
* Finalise a dom_html_meta_element object
*
- * \param doc The document object
* \param ele The dom_html_meta_element object
*/
-void _dom_html_meta_element_finalise(struct dom_document *doc,
- struct dom_html_meta_element *ele)
+void _dom_html_meta_element_finalise(struct dom_html_meta_element *ele)
{
- _dom_html_element_finalise(doc, &ele->base);
+ _dom_html_element_finalise(&ele->base);
}
/**
* Destroy a dom_html_meta_element object
*
- * \param doc The document object
* \param ele The dom_html_meta_element object
*/
-void _dom_html_meta_element_destroy(struct dom_document *doc,
- struct dom_html_meta_element *ele)
+void _dom_html_meta_element_destroy(struct dom_html_meta_element *ele)
{
- _dom_html_meta_element_finalise(doc, ele);
- _dom_document_alloc(doc, ele, 0);
+ _dom_html_meta_element_finalise(ele);
+ free(ele);
}
/*------------------------------------------------------------------------*/
@@ -111,27 +107,13 @@
/* The virtual destroy function, see src/core/node.c for detail */
void _dom_virtual_html_meta_element_destroy(dom_node_internal *node)
{
- struct dom_document *doc = dom_node_get_owner(node);
- _dom_html_meta_element_destroy(doc, (struct dom_html_meta_element *) node);
-}
-
-/* The virtual allocation function, see src/core/node.c for detail */
-dom_exception _dom_html_meta_element_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret)
-{
- UNUSED(n);
-
- *ret = _dom_document_alloc(doc, NULL, sizeof(dom_html_meta_element));
- if (*ret == NULL)
- return DOM_NO_MEM_ERR;
-
- return DOM_NO_ERR;
+ _dom_html_meta_element_destroy((struct dom_html_meta_element *) node);
}
/* The virtual copy function, see src/core/node.c for detail */
-dom_exception _dom_html_meta_element_copy(struct dom_node_internal *new,
- struct dom_node_internal *old)
+dom_exception _dom_html_meta_element_copy(dom_node_internal *old,
+ dom_node_internal **copy)
{
- return _dom_html_element_copy(new, old);
+ return _dom_html_element_copy(old, copy);
}
Modified: branches/jmb/dom-alloc-purge/src/html/html_meta_element.h
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/html/h...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/html/html_meta_element.h (original)
+++ branches/jmb/dom-alloc-purge/src/html/html_meta_element.h Mon Dec 19 17:31:57 2011
@@ -26,29 +26,24 @@
struct dom_html_meta_element *ele);
/* Finalise a dom_html_meta_element object */
-void _dom_html_meta_element_finalise(struct dom_document *doc,
- struct dom_html_meta_element *ele);
+void _dom_html_meta_element_finalise(struct dom_html_meta_element *ele);
/* Destroy a dom_html_meta_element object */
-void _dom_html_meta_element_destroy(struct dom_document *doc,
- struct dom_html_meta_element *ele);
+void _dom_html_meta_element_destroy(struct dom_html_meta_element *ele);
/* The protected virtual functions */
dom_exception _dom_html_meta_element_parse_attribute(dom_element *ele,
dom_string *name, dom_string *value,
dom_string **parsed);
void _dom_virtual_html_meta_element_destroy(dom_node_internal *node);
-dom_exception _dom_html_meta_element_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret);
-dom_exception _dom_html_meta_element_copy(struct dom_node_internal *new,
- struct dom_node_internal *old);
+dom_exception _dom_html_meta_element_copy(dom_node_internal *old,
+ dom_node_internal **copy);
#define DOM_HTML_META_ELEMENT_PROTECT_VTABLE \
_dom_html_meta_element_parse_attribute
#define DOM_NODE_PROTECT_VTABLE_HTML_META_ELEMENT \
_dom_virtual_html_meta_element_destroy, \
- _dom_html_meta_element_alloc, \
_dom_html_meta_element_copy
#endif
Modified: branches/jmb/dom-alloc-purge/src/html/html_options_collection.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/html/h...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/html/html_options_collection.c (original)
+++ branches/jmb/dom-alloc-purge/src/html/html_options_collection.c Mon Dec 19 17:31:57 2011
@@ -6,6 +6,7 @@
*/
#include <assert.h>
+#include <stdlib.h>
#include <libwapcaplet/libwapcaplet.h>
@@ -35,8 +36,7 @@
dom_callback_is_in_collection ic,
struct dom_html_options_collection **col)
{
- *col = _dom_document_alloc(doc, NULL,
- sizeof(dom_html_options_collection));
+ *col = malloc(sizeof(dom_html_options_collection));
if (*col == NULL)
return DOM_NO_MEM_ERR;
@@ -77,10 +77,9 @@
*/
void _dom_html_options_collection_destroy(struct dom_html_options_collection *col)
{
- struct dom_document *doc = col->base.doc;
_dom_html_options_collection_finalise(col);
- _dom_document_alloc(doc, col, 0);
+ free(col);
}
Modified: branches/jmb/dom-alloc-purge/src/html/html_select_element.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/html/h...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/html/html_select_element.c (original)
+++ branches/jmb/dom-alloc-purge/src/html/html_select_element.c Mon Dec 19 17:31:57 2011
@@ -6,6 +6,7 @@
*/
#include <assert.h>
+#include <stdlib.h>
#include "html/html_select_element.h"
@@ -21,6 +22,7 @@
};
static bool is_option(struct dom_node_internal *node);
+
/**
* Create a dom_html_select_element object
*
@@ -31,7 +33,7 @@
dom_exception _dom_html_select_element_create(struct dom_document *doc,
struct dom_html_select_element **ele)
{
- *ele = _dom_document_alloc(doc, NULL, sizeof(dom_html_select_element));
+ *ele = malloc(sizeof(dom_html_select_element));
if (*ele == NULL)
return DOM_NO_MEM_ERR;
@@ -53,17 +55,16 @@
dom_exception _dom_html_select_element_initialise(struct dom_document *doc,
struct dom_html_select_element *ele)
{
- const char *str = "SELECT";
- lwc_string *name = NULL;
+ dom_string *name = NULL;
dom_exception err;
- err = _dom_document_create_lwcstring(doc, (const uint8_t *) str, SLEN(str),
+ err = dom_string_create((const uint8_t *) "SELECT", SLEN("SELECT"),
&name);
if (err != DOM_NO_ERR)
return err;
err = _dom_html_element_initialise(doc, &ele->base, name, NULL, NULL);
- _dom_document_unref_lwcstring(doc, name);
+ dom_string_unref(name);
ele->selected = -1;
ele->options = NULL;
@@ -74,26 +75,22 @@
/**
* Finalise a dom_html_select_element object
*
- * \param doc The document object
* \param ele The dom_html_select_element object
*/
-void _dom_html_select_element_finalise(struct dom_document *doc,
- struct dom_html_select_element *ele)
-{
- _dom_html_element_finalise(doc, &ele->base);
+void _dom_html_select_element_finalise(struct dom_html_select_element *ele)
+{
+ _dom_html_element_finalise(&ele->base);
}
/**
* Destroy a dom_html_select_element object
*
- * \param doc The document object
* \param ele The dom_html_select_element object
*/
-void _dom_html_select_element_destroy(struct dom_document *doc,
- struct dom_html_select_element *ele)
-{
- _dom_html_select_element_finalise(doc, ele);
- _dom_document_alloc(doc, ele, 0);
+void _dom_html_select_element_destroy(struct dom_html_select_element *ele)
+{
+ _dom_html_select_element_finalise(ele);
+ free(ele);
}
/*------------------------------------------------------------------------*/
@@ -117,28 +114,14 @@
/* The virtual destroy function, see src/core/node.c for detail */
void _dom_virtual_html_select_element_destroy(dom_node_internal *node)
{
- struct dom_document *doc = dom_node_get_owner(node);
- _dom_html_select_element_destroy(doc, (struct dom_html_select_element *) node);
-}
-
-/* The virtual allocation function, see src/core/node.c for detail */
-dom_exception _dom_html_select_element_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret)
-{
- UNUSED(n);
-
- *ret = _dom_document_alloc(doc, NULL, sizeof(dom_html_select_element));
- if (*ret == NULL)
- return DOM_NO_MEM_ERR;
-
- return DOM_NO_ERR;
+ _dom_html_select_element_destroy((struct dom_html_select_element *) node);
}
/* The virtual copy function, see src/core/node.c for detail */
-dom_exception _dom_html_select_element_copy(struct dom_node_internal *new,
- struct dom_node_internal *old)
-{
- return _dom_html_element_copy(new, old);
+dom_exception _dom_html_select_element_copy(dom_node_internal *old,
+ dom_node_internal **copy)
+{
+ return _dom_html_element_copy(old, copy);
}
/*-----------------------------------------------------------------------*/
@@ -327,18 +310,19 @@
/* Test whether certain node is an option node */
bool is_option(struct dom_node_internal *node)
{
- lwc_string *name = NULL;
+ dom_string *name = NULL;
bool ret = false;
dom_exception err;
- err = _dom_node_create_lwcstring(node, (const uint8_t *) "OPTION",
- SLEN("OPTION"), &name);
- assert(err == DOM_NO_ERR);
-
- if (name == node->name)
+ err = dom_string_create((const uint8_t *) "OPTION", SLEN("OPTION"),
+ &name);
+ if (err != DOM_NO_ERR)
+ return false;
+
+ if (dom_string_isequal(name, node->name))
ret = true;
- _dom_node_unref_intern_string(node, name);
+ dom_string_unref(name);
return ret;
}
Modified: branches/jmb/dom-alloc-purge/src/html/html_select_element.h
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/html/h...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/html/html_select_element.h (original)
+++ branches/jmb/dom-alloc-purge/src/html/html_select_element.h Mon Dec 19 17:31:57 2011
@@ -31,29 +31,24 @@
struct dom_html_select_element *ele);
/* Finalise a dom_html_select_element object */
-void _dom_html_select_element_finalise(struct dom_document *doc,
- struct dom_html_select_element *ele);
+void _dom_html_select_element_finalise(struct dom_html_select_element *ele);
/* Destroy a dom_html_select_element object */
-void _dom_html_select_element_destroy(struct dom_document *doc,
- struct dom_html_select_element *ele);
+void _dom_html_select_element_destroy(struct dom_html_select_element *ele);
/* The protected virtual functions */
dom_exception _dom_html_select_element_parse_attribute(dom_element *ele,
dom_string *name, dom_string *value,
dom_string **parsed);
void _dom_virtual_html_select_element_destroy(dom_node_internal *node);
-dom_exception _dom_html_select_element_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret);
-dom_exception _dom_html_select_element_copy(struct dom_node_internal *new,
- struct dom_node_internal *old);
+dom_exception _dom_html_select_element_copy(dom_node_internal *old,
+ dom_node_internal **copy);
#define DOM_HTML_SELECT_ELEMENT_PROTECT_VTABLE \
_dom_html_select_element_parse_attribute
#define DOM_NODE_PROTECT_VTABLE_HTML_SELECT_ELEMENT \
_dom_virtual_html_select_element_destroy, \
- _dom_html_select_element_alloc, \
_dom_html_select_element_copy
#endif
Modified: branches/jmb/dom-alloc-purge/src/html/html_style_element.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/html/h...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/html/html_style_element.c (original)
+++ branches/jmb/dom-alloc-purge/src/html/html_style_element.c Mon Dec 19 17:31:57 2011
@@ -4,6 +4,8 @@
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2009 Bo Yang <struggleyb.nku.com>
*/
+
+#include <stdlib.h>
#include "html/html_style_element.h"
@@ -28,7 +30,7 @@
dom_exception _dom_html_style_element_create(struct dom_document *doc,
struct dom_html_style_element **ele)
{
- *ele = _dom_document_alloc(doc, NULL, sizeof(dom_html_style_element));
+ *ele = malloc(sizeof(dom_html_style_element));
if (*ele == NULL)
return DOM_NO_MEM_ERR;
@@ -50,17 +52,16 @@
dom_exception _dom_html_style_element_initialise(struct dom_document *doc,
struct dom_html_style_element *ele)
{
- const char *str = "STYLE";
- lwc_string *name = NULL;
+ dom_string *name = NULL;
dom_exception err;
- err = _dom_document_create_lwcstring(doc, (const uint8_t *) str, SLEN(str),
+ err = dom_string_create((const uint8_t *) "STYLE", SLEN("STYLE"),
&name);
if (err != DOM_NO_ERR)
return err;
err = _dom_html_element_initialise(doc, &ele->base, name, NULL, NULL);
- _dom_document_unref_lwcstring(doc, name);
+ dom_string_unref(name);
return err;
}
@@ -68,26 +69,22 @@
/**
* Finalise a dom_html_style_element object
*
- * \param doc The document object
* \param ele The dom_html_style_element object
*/
-void _dom_html_style_element_finalise(struct dom_document *doc,
- struct dom_html_style_element *ele)
+void _dom_html_style_element_finalise(struct dom_html_style_element *ele)
{
- _dom_html_element_finalise(doc, &ele->base);
+ _dom_html_element_finalise(&ele->base);
}
/**
* Destroy a dom_html_style_element object
*
- * \param doc The document object
* \param ele The dom_html_style_element object
*/
-void _dom_html_style_element_destroy(struct dom_document *doc,
- struct dom_html_style_element *ele)
+void _dom_html_style_element_destroy(struct dom_html_style_element *ele)
{
- _dom_html_style_element_finalise(doc, ele);
- _dom_document_alloc(doc, ele, 0);
+ _dom_html_style_element_finalise(ele);
+ free(ele);
}
/*------------------------------------------------------------------------*/
@@ -111,28 +108,14 @@
/* The virtual destroy function, see src/core/node.c for detail */
void _dom_virtual_html_style_element_destroy(dom_node_internal *node)
{
- struct dom_document *doc = dom_node_get_owner(node);
- _dom_html_style_element_destroy(doc, (struct dom_html_style_element *) node);
-}
-
-/* The virtual allocation function, see src/core/node.c for detail */
-dom_exception _dom_html_style_element_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret)
-{
- UNUSED(n);
-
- *ret = _dom_document_alloc(doc, NULL, sizeof(dom_html_style_element));
- if (*ret == NULL)
- return DOM_NO_MEM_ERR;
-
- return DOM_NO_ERR;
+ _dom_html_style_element_destroy((struct dom_html_style_element *) node);
}
/* The virtual copy function, see src/core/node.c for detail */
-dom_exception _dom_html_style_element_copy(struct dom_node_internal *new,
- struct dom_node_internal *old)
+dom_exception _dom_html_style_element_copy(dom_node_internal *old,
+ dom_node_internal **copy)
{
- return _dom_html_element_copy(new, old);
+ return _dom_html_element_copy(old, copy);
}
/*-----------------------------------------------------------------------*/
Modified: branches/jmb/dom-alloc-purge/src/html/html_style_element.h
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/html/h...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/html/html_style_element.h (original)
+++ branches/jmb/dom-alloc-purge/src/html/html_style_element.h Mon Dec 19 17:31:57 2011
@@ -26,29 +26,24 @@
struct dom_html_style_element *ele);
/* Finalise a dom_html_style_element object */
-void _dom_html_style_element_finalise(struct dom_document *doc,
- struct dom_html_style_element *ele);
+void _dom_html_style_element_finalise(struct dom_html_style_element *ele);
/* Destroy a dom_html_style_element object */
-void _dom_html_style_element_destroy(struct dom_document *doc,
- struct dom_html_style_element *ele);
+void _dom_html_style_element_destroy(struct dom_html_style_element *ele);
/* The protected virtual functions */
dom_exception _dom_html_style_element_parse_attribute(dom_element *ele,
dom_string *name, dom_string *value,
dom_string **parsed);
void _dom_virtual_html_style_element_destroy(dom_node_internal *node);
-dom_exception _dom_html_style_element_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret);
-dom_exception _dom_html_style_element_copy(struct dom_node_internal *new,
- struct dom_node_internal *old);
+dom_exception _dom_html_style_element_copy(dom_node_internal *old,
+ dom_node_internal **copy);
#define DOM_HTML_STYLE_ELEMENT_PROTECT_VTABLE \
_dom_html_style_element_parse_attribute
#define DOM_NODE_PROTECT_VTABLE_HTML_STYLE_ELEMENT \
_dom_virtual_html_style_element_destroy, \
- _dom_html_style_element_alloc, \
_dom_html_style_element_copy
#endif
Modified: branches/jmb/dom-alloc-purge/src/html/html_title_element.c
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/html/h...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/html/html_title_element.c (original)
+++ branches/jmb/dom-alloc-purge/src/html/html_title_element.c Mon Dec 19 17:31:57 2011
@@ -6,6 +6,7 @@
*/
#include <assert.h>
+#include <stdlib.h>
#include <dom/core/characterdata.h>
#include <dom/core/text.h>
@@ -33,7 +34,7 @@
dom_exception _dom_html_title_element_create(struct dom_document *doc,
struct dom_html_title_element **ele)
{
- *ele = _dom_document_alloc(doc, NULL, sizeof(dom_html_title_element));
+ *ele = malloc(sizeof(dom_html_title_element));
if (*ele == NULL)
return DOM_NO_MEM_ERR;
@@ -55,17 +56,16 @@
dom_exception _dom_html_title_element_initialise(struct dom_document *doc,
struct dom_html_title_element *ele)
{
- const char *str = "TITLE";
- lwc_string *name = NULL;
+ dom_string *name = NULL;
dom_exception err;
- err = _dom_document_create_lwcstring(doc, (const uint8_t *) str, SLEN(str),
+ err = dom_string_create((const uint8_t *) "TITLE", SLEN("TITLE"),
&name);
if (err != DOM_NO_ERR)
return err;
err = _dom_html_element_initialise(doc, &ele->base, name, NULL, NULL);
- _dom_document_unref_lwcstring(doc, name);
+ dom_string_unref(name);
return err;
}
@@ -73,26 +73,22 @@
/**
* Finalise a dom_html_title_element object
*
- * \param doc The document object
* \param ele The dom_html_title_element object
*/
-void _dom_html_title_element_finalise(struct dom_document *doc,
- struct dom_html_title_element *ele)
+void _dom_html_title_element_finalise(struct dom_html_title_element *ele)
{
- _dom_html_element_finalise(doc, &ele->base);
+ _dom_html_element_finalise(&ele->base);
}
/**
* Destroy a dom_html_title_element object
*
- * \param doc The document object
* \param ele The dom_html_title_element object
*/
-void _dom_html_title_element_destroy(struct dom_document *doc,
- struct dom_html_title_element *ele)
+void _dom_html_title_element_destroy(struct dom_html_title_element *ele)
{
- _dom_html_title_element_finalise(doc, ele);
- _dom_document_alloc(doc, ele, 0);
+ _dom_html_title_element_finalise(ele);
+ free(ele);
}
/*------------------------------------------------------------------------*/
@@ -116,28 +112,14 @@
/* The virtual destroy function, see src/core/node.c for detail */
void _dom_virtual_html_title_element_destroy(dom_node_internal *node)
{
- struct dom_document *doc = dom_node_get_owner(node);
- _dom_html_title_element_destroy(doc, (struct dom_html_title_element *) node);
-}
-
-/* The virtual allocation function, see src/core/node.c for detail */
-dom_exception _dom_html_title_element_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret)
-{
- UNUSED(n);
-
- *ret = _dom_document_alloc(doc, NULL, sizeof(dom_html_title_element));
- if (*ret == NULL)
- return DOM_NO_MEM_ERR;
-
- return DOM_NO_ERR;
+ _dom_html_title_element_destroy((struct dom_html_title_element *) node);
}
/* The virtual copy function, see src/core/node.c for detail */
-dom_exception _dom_html_title_element_copy(struct dom_node_internal *new,
- struct dom_node_internal *old)
+dom_exception _dom_html_title_element_copy(dom_node_internal *old,
+ dom_node_internal **copy)
{
- return _dom_html_element_copy(new, old);
+ return _dom_html_element_copy(old, copy);
}
/*-----------------------------------------------------------------------*/
Modified: branches/jmb/dom-alloc-purge/src/html/html_title_element.h
URL: http://source.netsurf-browser.org/branches/jmb/dom-alloc-purge/src/html/h...
==============================================================================
--- branches/jmb/dom-alloc-purge/src/html/html_title_element.h (original)
+++ branches/jmb/dom-alloc-purge/src/html/html_title_element.h Mon Dec 19 17:31:57 2011
@@ -26,29 +26,24 @@
struct dom_html_title_element *ele);
/* Finalise a dom_html_title_element object */
-void _dom_html_title_element_finalise(struct dom_document *doc,
- struct dom_html_title_element *ele);
+void _dom_html_title_element_finalise(struct dom_html_title_element *ele);
/* Destroy a dom_html_title_element object */
-void _dom_html_title_element_destroy(struct dom_document *doc,
- struct dom_html_title_element *ele);
+void _dom_html_title_element_destroy(struct dom_html_title_element *ele);
/* The protected virtual functions */
dom_exception _dom_html_title_element_parse_attribute(dom_element *ele,
dom_string *name, dom_string *value,
dom_string **parsed);
void _dom_virtual_html_title_element_destroy(dom_node_internal *node);
-dom_exception _dom_html_title_element_alloc(struct dom_document *doc,
- struct dom_node_internal *n, struct dom_node_internal **ret);
-dom_exception _dom_html_title_element_copy(struct dom_node_internal *new,
- struct dom_node_internal *old);
+dom_exception _dom_html_title_element_copy(dom_node_internal *old,
+ dom_node_internal **copy);
#define DOM_HTML_TITLE_ELEMENT_PROTECT_VTABLE \
_dom_html_title_element_parse_attribute
#define DOM_NODE_PROTECT_VTABLE_HTML_TITLE_ELEMENT \
_dom_virtual_html_title_element_destroy, \
- _dom_html_title_element_alloc, \
_dom_html_title_element_copy
#endif
11 years, 9 months
r13300 stevef - in /trunk/netsurf/riscos: gui.c wimp.c wimp.h
by netsurf@semichrome.net
Author: stevef
Date: Mon Dec 19 17:27:10 2011
New Revision: 13300
URL: http://source.netsurf-browser.org?rev=13300&view=rev
Log:
Provide a generic fall-back scroll event handler for scroll wheels.
Modified:
trunk/netsurf/riscos/gui.c
trunk/netsurf/riscos/wimp.c
trunk/netsurf/riscos/wimp.h
Modified: trunk/netsurf/riscos/gui.c
URL: http://source.netsurf-browser.org/trunk/netsurf/riscos/gui.c?rev=13300&r1...
==============================================================================
--- trunk/netsurf/riscos/gui.c (original)
+++ trunk/netsurf/riscos/gui.c Mon Dec 19 17:27:10 2011
@@ -1032,8 +1032,13 @@
ro_gui_menu_selection(&(block->selection));
break;
+ /* Scroll requests fall back to a generic handler because we
+ * might get these events for any window from a scroll-wheel.
+ */
+
case wimp_SCROLL_REQUEST:
- ro_gui_wimp_event_scroll_window(&(block->scroll));
+ if (!ro_gui_wimp_event_scroll_window(&(block->scroll)))
+ ro_gui_scroll(&(block->scroll));
break;
case wimp_USER_MESSAGE:
Modified: trunk/netsurf/riscos/wimp.c
URL: http://source.netsurf-browser.org/trunk/netsurf/riscos/wimp.c?rev=13300&r...
==============================================================================
--- trunk/netsurf/riscos/wimp.c (original)
+++ trunk/netsurf/riscos/wimp.c Mon Dec 19 17:27:10 2011
@@ -1107,3 +1107,60 @@
}
return 0;
}
+
+
+/**
+ * Generic window scroll event handler.
+ *
+ * \param *scroll Pointer to Scroll Event block.
+ */
+
+void ro_gui_scroll(wimp_scroll *scroll)
+{
+ os_error *error;
+ int x = scroll->visible.x1 - scroll->visible.x0 - 32;
+ int y = scroll->visible.y1 - scroll->visible.y0 - 32;
+
+ switch (scroll->xmin) {
+ case wimp_SCROLL_PAGE_LEFT:
+ scroll->xscroll -= x;
+ break;
+ case wimp_SCROLL_COLUMN_LEFT:
+ scroll->xscroll -= 100;
+ break;
+ case wimp_SCROLL_COLUMN_RIGHT:
+ scroll->xscroll += 100;
+ break;
+ case wimp_SCROLL_PAGE_RIGHT:
+ scroll->xscroll += x;
+ break;
+ default:
+ scroll->xscroll += (x * (scroll->xmin>>2)) >> 2;
+ break;
+ }
+
+ switch (scroll->ymin) {
+ case wimp_SCROLL_PAGE_UP:
+ scroll->yscroll += y;
+ break;
+ case wimp_SCROLL_LINE_UP:
+ scroll->yscroll += 100;
+ break;
+ case wimp_SCROLL_LINE_DOWN:
+ scroll->yscroll -= 100;
+ break;
+ case wimp_SCROLL_PAGE_DOWN:
+ scroll->yscroll -= y;
+ break;
+ default:
+ scroll->yscroll += (y * (scroll->ymin>>2)) >> 2;
+ break;
+ }
+
+ error = xwimp_open_window((wimp_open *) scroll);
+ if (error) {
+ LOG(("xwimp_open_window: 0x%x: %s",
+ error->errnum, error->errmess));
+ }
+}
+
Modified: trunk/netsurf/riscos/wimp.h
URL: http://source.netsurf-browser.org/trunk/netsurf/riscos/wimp.h?rev=13300&r...
==============================================================================
--- trunk/netsurf/riscos/wimp.h (original)
+++ trunk/netsurf/riscos/wimp.h Mon Dec 19 17:27:10 2011
@@ -77,4 +77,7 @@
wimp_window_flags xor_mask);
bool ro_gui_wimp_check_window_furniture(wimp_w w, wimp_window_flags mask);
+void ro_gui_scroll(wimp_scroll *scroll);
+
#endif
+
11 years, 9 months