| 6768 | } |
| 6769 | |
| 6770 | PUGI__FN bool node_is_before(xml_node ln, unsigned int lh, xml_node rn, unsigned int rh) |
| 6771 | { |
| 6772 | // normalize heights |
| 6773 | for (unsigned int i = rh; i < lh; i++) |
| 6774 | ln = ln.parent(); |
| 6775 | for (unsigned int j = lh; j < rh; j++) |
| 6776 | rn = rn.parent(); |
| 6777 | |
| 6778 | // one node is the ancestor of the other |
| 6779 | if (ln == rn) |
| 6780 | return lh < rh; |
| 6781 | |
| 6782 | // find common ancestor |
| 6783 | while (ln.parent() != rn.parent()) |
| 6784 | { |
| 6785 | ln = ln.parent(); |
| 6786 | rn = rn.parent(); |
| 6787 | } |
| 6788 | |
| 6789 | // there is no common ancestor (the shared parent is null), nodes are from different documents |
| 6790 | if (!ln.parent()) |
| 6791 | return ln < rn; |
| 6792 | |
| 6793 | // determine sibling order |
| 6794 | for (; ln; ln = ln.next_sibling()) |
| 6795 | if (ln == rn) |
| 6796 | return true; |
| 6797 | |
| 6798 | return false; |
| 6799 | } |
| 6800 | |
| 6801 | PUGI__FN bool node_is_ancestor(xml_node parent, xml_node node) |
| 6802 | { |
no test coverage detected