summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrsk1994 <rsk1coder99@gmail.com>2014-05-19 23:51:14 (GMT)
committer Rupinder Singh Khokhar <rsk1coder99@gmail.com>2014-06-21 12:07:13 (GMT)
commitf766035ad6487544a6532c568b3beeb22da7ee34 (patch)
tree793a438f844bca2b552e7ecfc43e056d7921f09c
parentdee7e98d4b89ad7db172e569afe49d7374274ea0 (diff)
downloadlibdom-f766035ad6487544a6532c568b3beeb22da7ee34.tar.gz
libdom-f766035ad6487544a6532c568b3beeb22da7ee34.tar.bz2
TableCell Element Rev.2
-rw-r--r--src/html/html_tablecell_element.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/html/html_tablecell_element.c b/src/html/html_tablecell_element.c
index 6317686..b5d406f 100644
--- a/src/html/html_tablecell_element.c
+++ b/src/html/html_tablecell_element.c
@@ -185,9 +185,13 @@ dom_exception dom_html_table_cell_element_get_cell_index(
dom_node_internal *n = ((dom_node_internal *)table_cell)->parent;
dom_html_document *doc = (dom_html_document *)(n->owner);
int32_t cnt = 0;
-
- for (n = n->first_child; n != NULL; n = n->next) {
-
+ while(n != NULL) {
+ if(dom_string_caseless_isequal(doc->memoised[hds_TR],n->name)) {
+ break;
+ }
+ n = n->parent;
+ }
+ while(n != NULL) {
if(n == (dom_node_internal *)table_cell) {
break;
} else if((n->type == DOM_ELEMENT_NODE) &&
@@ -195,7 +199,27 @@ dom_exception dom_html_table_cell_element_get_cell_index(
dom_string_caseless_isequal(doc->memoised[hds_TH],n->name))) {
cnt += 1;
}
-
+ if(n->first_child != NULL) {
+ n = n->first_child;
+ } else if(n->next != NULL) {
+ n = n->next;
+ } else {
+ /* No children and siblings */
+ struct dom_node_internal *parent = n->parent;
+
+ while (parent !=NULL) {
+ if(n == parent->last_child) {
+ n = parent;
+ parent = parent->parent;
+ } else {
+ break;
+ }
+
+ }
+ if(parent == NULL) {
+ n = NULL;
+ }
+ }
}
table_cell->id = cnt;
}