diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2012-01-13 22:23:26 +0100 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2012-01-13 22:23:26 +0100 |
commit | a987a45a6d6bdf27aecf1ef0625801834ab27e44 (patch) | |
tree | 98723f8992c65ad81aae9f66f06d0f0bfda5ccd2 /src/css.hh | |
parent | fe21a59c2c565d827147ac27f3398f2b3c2f22a4 (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.hh | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -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++; } |