diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2011-08-24 23:13:40 +0200 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2011-08-24 23:13:40 +0200 |
commit | 7ef21cbd8de03848230ca6d75f349bd586926aaa (patch) | |
tree | 2cd07d0ac7a0c0b3517cdc6672c8828bea93e133 /src/css.cc | |
parent | b245b5abf8e48ab81bbaaec9edb56a4a4b51af6e (diff) |
add support for CSS adjacent sibling selectors
Diffstat (limited to 'src/css.cc')
-rw-r--r-- | src/css.cc | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -104,6 +104,7 @@ CssSelector::CssSelector () { cs = selectorList->getRef (selectorList->size () - 1); cs->notMatchingBefore = -1; + cs->combinator = CHILD; cs->selector = new CssSimpleSelector (); }; @@ -133,6 +134,7 @@ bool CssSelector::match (Doctree *docTree, const DoctreeNode *node) { switch (comb) { case CHILD: + case ADJACENT_SIBLING: if (!sel->match (node)) return false; break; @@ -148,7 +150,7 @@ bool CssSelector::match (Doctree *docTree, const DoctreeNode *node) { if (sel->match (node)) break; - node = docTree->parent (node); + node = node->parent; } break; default: @@ -156,7 +158,11 @@ bool CssSelector::match (Doctree *docTree, const DoctreeNode *node) { } comb = cs->combinator; - node = docTree->parent (node); + + if (comb == ADJACENT_SIBLING) + node = node->sibling; + else + node = node->parent; } return true; @@ -200,6 +206,9 @@ void CssSelector::print () { case DESCENDANT: fprintf (stderr, "\" \" "); break; + case ADJACENT_SIBLING: + fprintf (stderr, "+ "); + break; default: fprintf (stderr, "? "); break; |