summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorFrançois Revel <mmu_man@netsurf-browser.org>2012-03-24 09:41:34 +0000
committerFrançois Revel <mmu_man@netsurf-browser.org>2012-03-24 09:41:34 +0000
commit81c06a1c10903aaaab877945208825c7244e7b7a (patch)
treea4be6838c3ffd1b837f743db4a8e505520adac03 /src/core
parent8a96fb5802b83e5194e538017ff106014712715f (diff)
downloadlibdom-81c06a1c10903aaaab877945208825c7244e7b7a.tar.gz
libdom-81c06a1c10903aaaab877945208825c7244e7b7a.tar.bz2
C89 for BeOS build.
svn path=/trunk/libdom/; revision=13581
Diffstat (limited to 'src/core')
-rw-r--r--src/core/attr.c38
-rw-r--r--src/core/characterdata.c27
-rw-r--r--src/core/document.c9
-rw-r--r--src/core/element.c41
-rw-r--r--src/core/node.c65
-rw-r--r--src/core/text.c12
6 files changed, 115 insertions, 77 deletions
diff --git a/src/core/attr.c b/src/core/attr.c
index 9da6ae3..dc14a93 100644
--- a/src/core/attr.c
+++ b/src/core/attr.c
@@ -225,6 +225,11 @@ dom_exception dom_attr_get_integer(dom_attr *a, unsigned long *value)
*/
dom_exception dom_attr_set_integer(dom_attr *a, unsigned long value)
{
+ struct dom_document *doc;
+ struct dom_node_internal *ele;
+ bool success = true;
+ dom_exception err;
+
/* If this is the first set method, we should fix this attribute
* type */
if (a->type == DOM_ATTR_UNSET)
@@ -238,10 +243,8 @@ dom_exception dom_attr_set_integer(dom_attr *a, unsigned long value)
a->value.lvalue = value;
- struct dom_document *doc = dom_node_get_owner(a);
- struct dom_node_internal *ele = dom_node_get_parent(a);
- bool success = true;
- dom_exception err;
+ doc = dom_node_get_owner(a);
+ ele = dom_node_get_parent(a);
err = _dom_dispatch_attr_modified_event(doc, ele, NULL, NULL,
(dom_event_target *) a, NULL,
DOM_MUTATION_MODIFICATION, &success);
@@ -284,6 +287,11 @@ dom_exception dom_attr_get_short(dom_attr *a, unsigned short *value)
*/
dom_exception dom_attr_set_short(dom_attr *a, unsigned short value)
{
+ struct dom_document *doc;
+ struct dom_node_internal *ele;
+ bool success = true;
+ dom_exception err;
+
/* If this is the first set method, we should fix this attribute
* type */
if (a->type == DOM_ATTR_UNSET)
@@ -297,10 +305,8 @@ dom_exception dom_attr_set_short(dom_attr *a, unsigned short value)
a->value.svalue = value;
- struct dom_document *doc = dom_node_get_owner(a);
- struct dom_node_internal *ele = dom_node_get_parent(a);
- bool success = true;
- dom_exception err;
+ doc = dom_node_get_owner(a);
+ ele = dom_node_get_parent(a);
err = _dom_dispatch_attr_modified_event(doc, ele, NULL, NULL,
(dom_event_target *) a, NULL,
DOM_MUTATION_MODIFICATION, &success);
@@ -343,6 +349,11 @@ dom_exception dom_attr_get_bool(dom_attr *a, bool *value)
*/
dom_exception dom_attr_set_bool(dom_attr *a, bool value)
{
+ struct dom_document *doc;
+ struct dom_node_internal *ele;
+ bool success = true;
+ dom_exception err;
+
/* If this is the first set method, we should fix this attribute
* type */
if (a->type == DOM_ATTR_UNSET)
@@ -356,10 +367,8 @@ dom_exception dom_attr_set_bool(dom_attr *a, bool value)
a->value.bvalue = value;
- struct dom_document *doc = dom_node_get_owner(a);
- struct dom_node_internal *ele = dom_node_get_parent(a);
- bool success = true;
- dom_exception err;
+ doc = dom_node_get_owner(a);
+ ele = dom_node_get_parent(a);
err = _dom_dispatch_attr_modified_event(doc, ele, NULL, NULL,
(dom_event_target *) a, NULL,
DOM_MUTATION_MODIFICATION, &success);
@@ -520,6 +529,8 @@ dom_exception _dom_attr_set_value(struct dom_attr *attr,
struct dom_node_internal *c, *d;
struct dom_text *text;
dom_exception err;
+ dom_string *name = NULL;
+ dom_string *parsed = NULL;
/* Ensure attribute is writable */
if (_dom_node_readonly(a))
@@ -533,13 +544,10 @@ dom_exception _dom_attr_set_value(struct dom_attr *attr,
if (attr->type != DOM_ATTR_STRING)
return DOM_ATTR_WRONG_TYPE_ERR;
- dom_string *name = NULL;
-
err = _dom_attr_get_name(attr, &name);
if (err != DOM_NO_ERR)
return err;
- dom_string *parsed = NULL;
err = dom_element_parse_attribute(a->parent, name, value, &parsed);
dom_string_unref(name);
if (err != DOM_NO_ERR) {
diff --git a/src/core/characterdata.c b/src/core/characterdata.c
index 91a0764..ff89401 100644
--- a/src/core/characterdata.c
+++ b/src/core/characterdata.c
@@ -125,15 +125,16 @@ dom_exception _dom_characterdata_set_data(struct dom_characterdata *cdata,
dom_string *data)
{
struct dom_node_internal *c = (struct dom_node_internal *) cdata;
+ dom_exception err;
+ struct dom_document *doc;
+ bool success = true;
if (_dom_node_readonly(c)) {
return DOM_NO_MODIFICATION_ALLOWED_ERR;
}
/* Dispatch a DOMCharacterDataModified event */
- dom_exception err;
- struct dom_document *doc = dom_node_get_owner(cdata);
- bool success = true;
+ doc = dom_node_get_owner(cdata);
err = _dom_dispatch_characterdata_modified_event(doc, c, c->value,
data, &success);
if (err != DOM_NO_ERR)
@@ -230,6 +231,8 @@ dom_exception _dom_characterdata_append_data(struct dom_characterdata *cdata,
struct dom_node_internal *c = (struct dom_node_internal *) cdata;
dom_string *temp;
dom_exception err;
+ struct dom_document *doc;
+ bool success = true;
if (_dom_node_readonly(c)) {
return DOM_NO_MODIFICATION_ALLOWED_ERR;
@@ -241,8 +244,7 @@ dom_exception _dom_characterdata_append_data(struct dom_characterdata *cdata,
}
/* Dispatch a DOMCharacterDataModified event */
- struct dom_document *doc = dom_node_get_owner(cdata);
- bool success = true;
+ doc = dom_node_get_owner(cdata);
err = _dom_dispatch_characterdata_modified_event(doc, c, c->value,
temp, &success);
if (err != DOM_NO_ERR)
@@ -277,6 +279,8 @@ dom_exception _dom_characterdata_insert_data(struct dom_characterdata *cdata,
dom_string *temp;
uint32_t len;
dom_exception err;
+ struct dom_document *doc;
+ bool success = true;
if (_dom_node_readonly(c)) {
return DOM_NO_MODIFICATION_ALLOWED_ERR;
@@ -302,8 +306,7 @@ dom_exception _dom_characterdata_insert_data(struct dom_characterdata *cdata,
}
/* Dispatch a DOMCharacterDataModified event */
- struct dom_document *doc = dom_node_get_owner(cdata);
- bool success = true;
+ doc = dom_node_get_owner(cdata);
err = _dom_dispatch_characterdata_modified_event(doc, c, c->value,
temp, &success);
if (err != DOM_NO_ERR)
@@ -338,6 +341,8 @@ dom_exception _dom_characterdata_delete_data(struct dom_characterdata *cdata,
dom_string *temp;
uint32_t len, end;
dom_exception err;
+ struct dom_document *doc;
+ bool success = true;
if (_dom_node_readonly(c)) {
return DOM_NO_MODIFICATION_ALLOWED_ERR;
@@ -365,8 +370,7 @@ dom_exception _dom_characterdata_delete_data(struct dom_characterdata *cdata,
}
/* Dispatch a DOMCharacterDataModified event */
- struct dom_document *doc = dom_node_get_owner(cdata);
- bool success = true;
+ doc = dom_node_get_owner(cdata);
err = _dom_dispatch_characterdata_modified_event(doc, c, c->value,
temp, &success);
if (err != DOM_NO_ERR)
@@ -403,6 +407,8 @@ dom_exception _dom_characterdata_replace_data(struct dom_characterdata *cdata,
dom_string *temp;
uint32_t len, end;
dom_exception err;
+ struct dom_document *doc;
+ bool success = true;
if (_dom_node_readonly(c)) {
return DOM_NO_MODIFICATION_ALLOWED_ERR;
@@ -430,8 +436,7 @@ dom_exception _dom_characterdata_replace_data(struct dom_characterdata *cdata,
}
/* Dispatch a DOMCharacterDataModified event */
- struct dom_document *doc = dom_node_get_owner(cdata);
- bool success = true;
+ doc = dom_node_get_owner(cdata);
err = _dom_dispatch_characterdata_modified_event(doc, c, c->value, temp,
&success);
if (err != DOM_NO_ERR)
diff --git a/src/core/document.c b/src/core/document.c
index 1a38abe..df5fffa 100644
--- a/src/core/document.c
+++ b/src/core/document.c
@@ -916,6 +916,8 @@ dom_exception _dom_document_adopt_node(dom_document *doc,
{
dom_node_internal *n = (dom_node_internal *) node;
dom_exception err;
+ dom_node_internal *parent;
+ dom_node_internal *tmp;
*result = NULL;
@@ -945,8 +947,7 @@ dom_exception _dom_document_adopt_node(dom_document *doc,
return err;
}
- dom_node_internal *parent = n->parent;
- dom_node_internal *tmp;
+ parent = n->parent;
if (parent != NULL) {
err = dom_node_remove_child(parent, node, (void *) &tmp);
if (err != DOM_NO_ERR) {
@@ -1243,6 +1244,8 @@ dom_exception dom_document_dup_node(dom_document *doc, dom_node *node,
dom_node_internal *n = (dom_node_internal *) node;
dom_node_internal *ret;
dom_exception err;
+ dom_node_internal *child, *r;
+ dom_user_data *ud;
if (opt == DOM_NODE_ADOPTED && _dom_node_readonly(n))
return DOM_NO_MODIFICATION_ALLOWED_ERR;
@@ -1276,7 +1279,6 @@ dom_exception dom_document_dup_node(dom_document *doc, dom_node *node,
return DOM_NOT_SUPPORTED_ERR;
}
- dom_node_internal *child, *r;
if (deep == true) {
child = ((dom_node_internal *) node)->first_child;
while (child != NULL) {
@@ -1300,7 +1302,6 @@ dom_exception dom_document_dup_node(dom_document *doc, dom_node *node,
}
/* Call the dom_user_data_handlers */
- dom_user_data *ud;
ud = n->user_data;
while (ud != NULL) {
if (ud->handler != NULL) {
diff --git a/src/core/element.c b/src/core/element.c
index beb64da..b50ce92 100644
--- a/src/core/element.c
+++ b/src/core/element.c
@@ -1125,14 +1125,15 @@ dom_exception _dom_element_is_default_namespace(dom_node_internal *node,
struct dom_element *ele = (struct dom_element *) node;
dom_string *value;
dom_exception err;
+ bool has;
+ dom_string *xmlns;
if (node->prefix == NULL) {
*result = dom_string_isequal(node->namespace, namespace);
return DOM_NO_ERR;
}
- bool has;
- dom_string *xmlns = _dom_namespace_get_xmlns_prefix();
+ xmlns = _dom_namespace_get_xmlns_prefix();
err = dom_element_has_attribute(ele, xmlns, &has);
if (err != DOM_NO_ERR)
return err;
@@ -1164,6 +1165,8 @@ dom_exception _dom_element_lookup_namespace(dom_node_internal *node,
dom_string *prefix, dom_string **result)
{
dom_exception err;
+ bool has;
+ dom_string *xmlns;
if (node->namespace != NULL &&
dom_string_isequal(node->prefix, prefix)) {
@@ -1171,8 +1174,7 @@ dom_exception _dom_element_lookup_namespace(dom_node_internal *node,
return DOM_NO_ERR;
}
- bool has;
- dom_string *xmlns = _dom_namespace_get_xmlns_prefix();
+ xmlns = _dom_namespace_get_xmlns_prefix();
err = dom_element_has_attribute_ns(node, xmlns, prefix, &has);
if (err != DOM_NO_ERR)
return err;
@@ -1376,6 +1378,8 @@ dom_exception _dom_element_set_attr(struct dom_element *element,
/* No existing attribute, so create one */
struct dom_attr *attr;
struct dom_attr_list *list_node;
+ struct dom_document *doc;
+ bool success = true;
err = _dom_attr_create(e->owner, name, namespace, NULL,
true, &attr);
@@ -1394,8 +1398,7 @@ dom_exception _dom_element_set_attr(struct dom_element *element,
}
/* Dispatch a DOMAttrModified event */
- struct dom_document *doc = dom_node_get_owner(element);
- bool success = true;
+ doc = dom_node_get_owner(element);
err = _dom_dispatch_attr_modified_event(doc, e, NULL, value,
(dom_event_target *) attr, name,
DOM_MUTATION_ADDITION, &success);
@@ -1473,6 +1476,7 @@ dom_exception _dom_element_remove_attr(struct dom_element *element,
bool success = true;
dom_attr *a = match->attr;
struct dom_document *doc = dom_node_get_owner(element);
+ dom_string *old = NULL;
err = dom_node_dispatch_node_change_event(doc, match->attr,
element, DOM_MUTATION_REMOVAL, &success);
@@ -1497,7 +1501,6 @@ dom_exception _dom_element_remove_attr(struct dom_element *element,
/* Dispatch a DOMAttrModified event */
success = true;
- dom_string *old = NULL;
err = dom_attr_get_value(a, &old);
/* TODO: We did not support some node type such as entity
* reference, in that case, we should ignore the error to
@@ -1583,6 +1586,9 @@ dom_exception _dom_element_set_attr_node(struct dom_element *element,
dom_node_internal *e = (dom_node_internal *) element;
dom_node_internal *attr_node = (dom_node_internal *) attr;
dom_attr *old_attr;
+ dom_string *new = NULL;
+ struct dom_document *doc;
+ bool success = true;
/** \todo validate name */
@@ -1608,8 +1614,8 @@ dom_exception _dom_element_set_attr_node(struct dom_element *element,
*result = NULL;
if (match != NULL) {
/* Disptach DOMNodeRemoval event */
- bool success = true;
- struct dom_document *doc = dom_node_get_owner(element);
+ dom_string *old = NULL;
+ doc = dom_node_get_owner(element);
old_attr = match->attr;
err = dom_node_dispatch_node_change_event(doc, old_attr,
@@ -1625,7 +1631,6 @@ dom_exception _dom_element_set_attr_node(struct dom_element *element,
_dom_element_attr_list_node_destroy(match);
/* Dispatch a DOMAttrModified event */
- dom_string *old = NULL;
success = true;
err = dom_attr_get_value(old_attr, &old);
/* TODO: We did not support some node type such as entity
@@ -1669,9 +1674,8 @@ dom_exception _dom_element_set_attr_node(struct dom_element *element,
dom_node_remove_pending(attr);
/* Dispatch a DOMAttrModified event */
- dom_string *new = NULL;
- struct dom_document *doc = dom_node_get_owner(element);
- bool success = true;
+ doc = dom_node_get_owner(element);
+ success = true;
err = dom_attr_get_value(attr, &new);
/* TODO: We did not support some node type such as entity reference, in
* that case, we should ignore the error to make sure the event model
@@ -1732,6 +1736,9 @@ dom_exception _dom_element_remove_attr_node(struct dom_element *element,
dom_string *name;
dom_node_internal *e = (dom_node_internal *) element;
dom_attr *a;
+ bool success = true;
+ struct dom_document *doc;
+ dom_string *old = NULL;
/* Ensure element can be written to */
if (_dom_node_readonly(e))
@@ -1754,8 +1761,7 @@ dom_exception _dom_element_remove_attr_node(struct dom_element *element,
a = match->attr;
/* Dispatch a DOMNodeRemoved event */
- bool success = true;
- struct dom_document *doc = dom_node_get_owner(element);
+ doc = dom_node_get_owner(element);
err = dom_node_dispatch_node_change_event(doc, a, element,
DOM_MUTATION_REMOVAL, &success);
if (err != DOM_NO_ERR) {
@@ -1780,7 +1786,6 @@ dom_exception _dom_element_remove_attr_node(struct dom_element *element,
dom_string_unref(name);
/* Dispatch a DOMAttrModified event */
- dom_string *old = NULL;
success = true;
err = dom_attr_get_value(a, &old);
/* TODO: We did not support some node type such as entity reference, in
@@ -1891,6 +1896,8 @@ dom_exception _dom_element_get_id(struct dom_element *ele, dom_string **id)
{
dom_exception err;
dom_string *ret = NULL;
+ dom_document *doc;
+ dom_string *name;
*id = NULL;
@@ -1906,10 +1913,8 @@ dom_exception _dom_element_get_id(struct dom_element *ele, dom_string **id)
return err;
}
- dom_document *doc;
doc = dom_node_get_owner(ele);
assert(doc != NULL);
- dom_string *name;
if (ele->id_name != NULL) {
name = ele->id_name;
diff --git a/src/core/node.c b/src/core/node.c
index 988ed1d..918c355 100644
--- a/src/core/node.c
+++ b/src/core/node.c
@@ -220,6 +220,8 @@ dom_exception _dom_node_initialise(dom_node_internal *node,
void _dom_node_finalise(dom_node_internal *node)
{
struct dom_user_data *u, *v;
+ struct dom_node_internal *p;
+ struct dom_node_internal *n = NULL;
/* Destroy user data */
for (u = node->user_data; u != NULL; u = v) {
@@ -236,8 +238,7 @@ void _dom_node_finalise(dom_node_internal *node)
dom_string_unref(node->namespace);
/* Destroy all the child nodes of this node */
- struct dom_node_internal *p = node->first_child;
- struct dom_node_internal *n = NULL;
+ p = node->first_child;
while (p != NULL) {
n = p->next;
p->parent = NULL;
@@ -716,6 +717,7 @@ dom_exception _dom_node_insert_before(dom_node_internal *node,
dom_node_internal **result)
{
dom_exception err;
+ dom_node_internal *n;
/* Ensure that new_child and node are owned by the same document */
if ((new_child->type == DOM_DOCUMENT_TYPE_NODE &&
@@ -734,7 +736,7 @@ dom_exception _dom_node_insert_before(dom_node_internal *node,
return DOM_NOT_FOUND_ERR;
/* Ensure that new_child is not an ancestor of node, nor node itself */
- for (dom_node_internal *n = node; n != NULL; n = n->parent) {
+ for (n = node; n != NULL; n = n->parent) {
if (n == new_child)
return DOM_HIERARCHY_REQUEST_ERR;
}
@@ -855,6 +857,8 @@ dom_exception _dom_node_replace_child(dom_node_internal *node,
dom_node_internal *new_child, dom_node_internal *old_child,
dom_node_internal **result)
{
+ dom_node_internal *n;
+
/* We don't support replacement of DocumentType or root Elements */
if (node->type == DOM_DOCUMENT_NODE &&
(new_child->type == DOM_DOCUMENT_TYPE_NODE ||
@@ -874,7 +878,7 @@ dom_exception _dom_node_replace_child(dom_node_internal *node,
return DOM_NOT_FOUND_ERR;
/* Ensure that new_child is not an ancestor of node, nor node itself */
- for (dom_node_internal *n = node; n != NULL; n = n->parent) {
+ for (n = node; n != NULL; n = n->parent) {
if (n == new_child)
return DOM_HIERARCHY_REQUEST_ERR;
}
@@ -951,6 +955,9 @@ dom_exception _dom_node_remove_child(dom_node_internal *node,
dom_node_internal *old_child,
dom_node_internal **result)
{
+ dom_exception err;
+ bool success = true;
+
/* We don't support removal of DocumentType or root Element nodes */
if (node->type == DOM_DOCUMENT_NODE &&
(old_child->type == DOM_DOCUMENT_TYPE_NODE ||
@@ -966,8 +973,6 @@ dom_exception _dom_node_remove_child(dom_node_internal *node,
return DOM_NO_MODIFICATION_ALLOWED_ERR;
/* Dispatch a DOMNodeRemoval event */
- dom_exception err;
- bool success = true;
err = dom_node_dispatch_node_change_event(node->owner, old_child, node,
DOM_MUTATION_REMOVAL, &success);
if (err != DOM_NO_ERR)
@@ -1929,7 +1934,8 @@ bool _dom_node_permitted_child(const dom_node_internal *parent,
/* Ensure that the document doesn't already
* have a root element */
if (child->type == DOM_ELEMENT_NODE) {
- for (dom_node_internal *n = parent->first_child;
+ dom_node_internal *n;
+ for (n = parent->first_child;
n != NULL; n = n->next) {
if (n->type == DOM_ELEMENT_NODE)
valid = false;
@@ -1939,7 +1945,8 @@ bool _dom_node_permitted_child(const dom_node_internal *parent,
/* Ensure that the document doesn't already
* have a document type */
if (child->type == DOM_DOCUMENT_TYPE_NODE) {
- for (dom_node_internal *n = parent->first_child;
+ dom_node_internal *n;
+ for (n = parent->first_child;
n != NULL; n = n->next) {
if (n->type == DOM_DOCUMENT_TYPE_NODE)
valid = false;
@@ -2030,6 +2037,10 @@ dom_exception _dom_node_attach_range(dom_node_internal *first,
dom_node_internal *previous,
dom_node_internal *next)
{
+ dom_exception err;
+ bool success = true;
+ dom_node_internal *n;
+
first->previous = previous;
last->next = next;
@@ -2043,9 +2054,7 @@ dom_exception _dom_node_attach_range(dom_node_internal *first,
else
parent->last_child = last;
- dom_exception err;
- bool success = true;
- for (dom_node_internal *n = first; n != last->next; n = n->next) {
+ for (n = first; n != last->next; n = n->next) {
n->parent = parent;
/* Dispatch a DOMNodeInserted event */
err = dom_node_dispatch_node_change_event(parent->owner,
@@ -2074,6 +2083,10 @@ dom_exception _dom_node_attach_range(dom_node_internal *first,
void _dom_node_detach_range(dom_node_internal *first,
dom_node_internal *last)
{
+ bool success = true;
+ dom_node_internal *parent;
+ dom_node_internal *n;
+
if (first->previous != NULL)
first->previous->next = last->next;
else
@@ -2084,9 +2097,8 @@ void _dom_node_detach_range(dom_node_internal *first,
else
last->parent->last_child = first->previous;
- bool success = true;
- dom_node_internal *parent = first->parent;
- for (dom_node_internal *n = first; n != last->next; n = n->next) {
+ parent = first->parent;
+ for (n = first; n != last->next; n = n->next) {
/* Dispatch a DOMNodeRemoval event */
dom_node_dispatch_node_change_event(n->owner, n, n->parent,
DOM_MUTATION_REMOVAL, &success);
@@ -2116,6 +2128,7 @@ void _dom_node_replace(dom_node_internal *old,
dom_node_internal *replacement)
{
dom_node_internal *first, *last;
+ dom_node_internal *n;
if (replacement->type == DOM_DOCUMENT_FRAGMENT_NODE) {
first = replacement->first_child;
@@ -2140,7 +2153,7 @@ void _dom_node_replace(dom_node_internal *old,
else
old->parent->last_child = last;
- for (dom_node_internal *n = first; n != last->next; n = n->next) {
+ for (n = first; n != last->next; n = n->next) {
n->parent = old->parent;
}
@@ -2157,12 +2170,12 @@ void _dom_node_replace(dom_node_internal *old,
dom_exception _dom_merge_adjacent_text(dom_node_internal *p,
dom_node_internal *n)
{
- assert(p->type = DOM_TEXT_NODE);
- assert(n->type = DOM_TEXT_NODE);
-
dom_string *str;
dom_exception err;
+ assert(p->type = DOM_TEXT_NODE);
+ assert(n->type = DOM_TEXT_NODE);
+
err = dom_text_get_whole_text(n, &str);
if (err != DOM_NO_ERR)
return err;
@@ -2310,6 +2323,12 @@ dom_exception _dom_node_dispatch_event(dom_event_target *et,
struct dom_event *evt, bool *success)
{
dom_exception err, ret = DOM_NO_ERR;
+ dom_event_target_entry list;
+ dom_node_internal *target = (dom_node_internal *) et;
+ dom_document *doc;
+ dom_document_event_internal *dei;
+ void *pw = NULL;
+ struct list_entry *e;
assert(et != NULL);
assert(evt != NULL);
@@ -2328,7 +2347,7 @@ dom_exception _dom_node_dispatch_event(dom_event_target *et,
if (evt->doc == NULL)
return DOM_NOT_SUPPORTED_ERR;
- dom_document *doc = dom_node_get_owner(et);
+ doc = dom_node_get_owner(et);
if (doc == NULL) {
/* TODO: In the progress of parsing, many Nodes in the DTD has
* no document at all, do nothing for this kind of node */
@@ -2339,9 +2358,6 @@ dom_exception _dom_node_dispatch_event(dom_event_target *et,
return DOM_INVALID_CHARACTER_ERR;
}
- dom_event_target_entry list;
- dom_node_internal *target = (dom_node_internal *) et;
-
*success = true;
/* Compose the event target list */
@@ -2368,8 +2384,7 @@ dom_exception _dom_node_dispatch_event(dom_event_target *et,
evt->phase = DOM_CAPTURING_PHASE;
/* The started callback of default action */
- dom_document_event_internal *dei = &doc->dei;
- void *pw = NULL;
+ dei = &doc->dei;
if (dei->actions != NULL) {
dom_default_action_callback cb = dei->actions(evt->type,
DOM_DEFAULT_ACTION_STARTED, &pw);
@@ -2379,7 +2394,7 @@ dom_exception _dom_node_dispatch_event(dom_event_target *et,
}
/* The capture phase */
- struct list_entry *e = list.entry.prev;
+ e = list.entry.prev;
for (; e != &list.entry; e = e->prev) {
dom_event_target_entry *l = (dom_event_target_entry *) e;
dom_node_internal *node = (dom_node_internal *) l->et;
diff --git a/src/core/text.c b/src/core/text.c
index 58f2c41..1a5adaa 100644
--- a/src/core/text.c
+++ b/src/core/text.c
@@ -350,6 +350,10 @@ dom_exception walk_logic_adjacent_text_in_order(
dom_node_internal *node, walk_operation opt,
walk_order order, dom_string **ret, bool *cont)
{
+ dom_exception err;
+ dom_string *data, *tmp;
+ dom_node_internal *parent;
+
/* If we reach the leaf of the DOM tree, just return to continue
* to next sibling of our parent */
if (node == NULL) {
@@ -357,11 +361,11 @@ dom_exception walk_logic_adjacent_text_in_order(
return DOM_NO_ERR;
}
- dom_exception err;
- dom_string *data, *tmp;
- dom_node_internal *parent = dom_node_get_parent(node);
+ parent = dom_node_get_parent(node);
while (node != NULL) {
+ dom_node_internal *p;
+
/* If we reach the boundary of logical-adjacent text, we stop */
if (node->type == DOM_ELEMENT_NODE ||
node->type == DOM_COMMENT_NODE ||
@@ -411,7 +415,7 @@ dom_exception walk_logic_adjacent_text_in_order(
}
}
- dom_node_internal *p = dom_node_get_parent(node);
+ p = dom_node_get_parent(node);
if (order == LEFT) {
if (node->last_child != NULL) {
node = node->last_child;