From a987a45a6d6bdf27aecf1ef0625801834ab27e44 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Fri, 13 Jan 2012 22:23:26 +0100 Subject: fix descendant selector matching When matching descendant selectors we need to test all possibilities and not just the first one. While at it refactor CssSelector::match (). Testcase:
should be bold
Noticed-by: Sebastian Geerken --- src/css.hh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/css.hh') diff --git a/src/css.hh b/src/css.hh index 394f7add..6f6cc75f 100644 --- a/src/css.hh +++ b/src/css.hh @@ -355,9 +355,10 @@ class CssSimpleSelector { class CssSelector { public: typedef enum { - DESCENDANT, - CHILD, - ADJACENT_SIBLING, + COMB_NONE, + COMB_DESCENDANT, + COMB_CHILD, + COMB_ADJACENT_SIBLING, } Combinator; private: @@ -370,6 +371,8 @@ class CssSelector { int refCount; lout::misc::SimpleVector *selectorList; + bool match (Doctree *dt, const DoctreeNode *node, int i, Combinator comb); + public: CssSelector (); ~CssSelector (); @@ -378,7 +381,9 @@ class CssSelector { return selectorList->getRef (selectorList->size () - 1)->selector; }; inline int size () { return selectorList->size (); }; - bool match (Doctree *dt, const DoctreeNode *node); + inline bool match (Doctree *dt, const DoctreeNode *node) { + return match (dt, node, selectorList->size () - 1, COMB_NONE); + }; int specificity (); void print (); inline void ref () { refCount++; } -- cgit v1.2.3