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-10 22:57:10 (GMT)
commitbb1f7872c8dd7721b2bde9f0924b8284b5f7c3f0 (patch)
tree0fc32b2006a8945a2893a79478eadb4cffd4ed67
parent913ca00c2745f342146fd62494ad85baacf2b008 (diff)
downloadlibdom-bb1f7872c8dd7721b2bde9f0924b8284b5f7c3f0.tar.gz
libdom-bb1f7872c8dd7721b2bde9f0924b8284b5f7c3f0.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;
}