aboutsummaryrefslogtreecommitdiff
path: root/src/css.hh
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2012-01-13 22:23:26 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2012-01-13 22:23:26 +0100
commita987a45a6d6bdf27aecf1ef0625801834ab27e44 (patch)
tree98723f8992c65ad81aae9f66f06d0f0bfda5ccd2 /src/css.hh
parentfe21a59c2c565d827147ac27f3398f2b3c2f22a4 (diff)
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: <html> <head> <style type=text/css> .a > .b .c { font-weight:bold }</style> </head> <body> <div class=a> <div class=b> <div class=b> <div class=c>should be bold</div> </div> </div> </div> </body> </html> Noticed-by: Sebastian Geerken <sgeerken@dillo.org>
Diffstat (limited to 'src/css.hh')
-rw-r--r--src/css.hh13
1 files changed, 9 insertions, 4 deletions
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 <struct CombinatorAndSelector> *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++; }