aboutsummaryrefslogtreecommitdiffstats
path: root/src/css_selector.cpp
diff options
context:
space:
mode:
authorYuri Kobets <yuri.kobets@gmail.com>2014-10-21 00:10:16 +0400
committerYuri Kobets <yuri.kobets@gmail.com>2014-10-21 00:10:16 +0400
commit4da59f1a89c39fa68565f41c28d0020b05c2ffaf (patch)
tree34be7f1a3ab2ec35b3b0559142649ac878b33877 /src/css_selector.cpp
parent3d4cd350e4ff17308cb3ed59c2645155f6d0e529 (diff)
tokenize function is replaced to split_string.
some fixes in CSS parsing.
Diffstat (limited to 'src/css_selector.cpp')
-rw-r--r--src/css_selector.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/css_selector.cpp b/src/css_selector.cpp
index 5bfdeab5..ee42af89 100644
--- a/src/css_selector.cpp
+++ b/src/css_selector.cpp
@@ -1,6 +1,5 @@
#include "html.h"
#include "css_selector.h"
-#include "tokenizer.h"
#include "document.h"
void litehtml::css_element_selector::parse( const tstring& txt )
@@ -38,9 +37,23 @@ void litehtml::css_element_selector::parse( const tstring& txt )
tstring::size_type pos = txt.find_first_of(_t(".#[:("), el_end + 1);
if(pos != tstring::npos && txt.at(pos) == _t('('))
{
- pos = txt.find_last_of(_t(")"), pos + 1);
+ pos = find_close_bracket(txt, pos);
+ if(pos != tstring::npos)
+ {
+ pos++;
+ } else
+ {
+ int iii = 0;
+ iii++;
+ }
+ }
+ if(pos != tstring::npos)
+ {
+ attribute.val = txt.substr(el_end + 1, pos - el_end - 1);
+ } else
+ {
+ attribute.val = txt.substr(el_end + 1);
}
- attribute.val = txt.substr(el_end + 1, pos - el_end - 1);
litehtml::lcase(attribute.val);
if(attribute.val == _t("after") || attribute.val == _t("before"))
{
@@ -146,7 +159,8 @@ bool litehtml::css_selector::parse( const tstring& text )
return false;
}
string_vector tokens;
- tokenize(text, tokens, _t(""), _t(" \t>+~"), _t("()"));
+ split_string(text, tokens, _t(""), _t(" \t>+~"), _t("("));
+ //tokenize(text, tokens, _t(""), _t(" \t>+~"), _t("()"));
if(tokens.empty())
{
@@ -228,7 +242,7 @@ void litehtml::css_selector::calc_specificity()
if(i->attribute == _t("class"))
{
string_vector tokens;
- tokenize(i->val, tokens, _t(" "));
+ split_string(i->val, tokens, _t(" "));
m_specificity.c += (int) tokens.size();
} else
{