diff options
author | rsk1994 <rsk1coder99@gmail.com> | 2014-05-20 05:21:14 +0530 |
---|---|---|
committer | Rupinder Singh Khokhar <rsk1coder99@gmail.com> | 2014-06-11 04:27:10 +0530 |
commit | bb1f7872c8dd7721b2bde9f0924b8284b5f7c3f0 (patch) | |
tree | 0fc32b2006a8945a2893a79478eadb4cffd4ed67 /src/html/html_tablecell_element.c | |
parent | 913ca00c2745f342146fd62494ad85baacf2b008 (diff) | |
download | libdom-bb1f7872c8dd7721b2bde9f0924b8284b5f7c3f0.tar.gz libdom-bb1f7872c8dd7721b2bde9f0924b8284b5f7c3f0.tar.bz2 |
TableCell Element Rev.2
Diffstat (limited to 'src/html/html_tablecell_element.c')
-rw-r--r-- | src/html/html_tablecell_element.c | 32 |
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; } |