Fixed: Invalid pseudo element selector match
--HG-- branch : develop
This commit is contained in:
parent
077f57c4b9
commit
5ac0279754
3 changed files with 44 additions and 12 deletions
|
@ -84,6 +84,9 @@ namespace NLGUI
|
||||||
// NOTE: Does not check combinator
|
// NOTE: Does not check combinator
|
||||||
bool match(const CHtmlElement &elm) const;
|
bool match(const CHtmlElement &elm) const;
|
||||||
|
|
||||||
|
// debug
|
||||||
|
std::string toString() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool matchClass(const CHtmlElement &elm) const;
|
bool matchClass(const CHtmlElement &elm) const;
|
||||||
bool matchAttributes(const CHtmlElement &elm) const;
|
bool matchAttributes(const CHtmlElement &elm) const;
|
||||||
|
@ -91,7 +94,7 @@ namespace NLGUI
|
||||||
|
|
||||||
// match An+B rule to child index (1 based)
|
// match An+B rule to child index (1 based)
|
||||||
bool matchNth(sint childNr, sint a, sint b) const;
|
bool matchNth(sint childNr, sint a, sint b) const;
|
||||||
|
|
||||||
// parse nth-child string to 'a' and 'b' components
|
// parse nth-child string to 'a' and 'b' components
|
||||||
// :nth-child(odd)
|
// :nth-child(odd)
|
||||||
// :nth-child(even)
|
// :nth-child(even)
|
||||||
|
|
|
@ -631,18 +631,9 @@ namespace NLGUI
|
||||||
{
|
{
|
||||||
result.clear();
|
result.clear();
|
||||||
}
|
}
|
||||||
else if (result.empty() || !current.empty())
|
else if (!current.empty())
|
||||||
{
|
{
|
||||||
// pseudo element like ':before' can only be set on the last selector
|
result.push_back(current);
|
||||||
if (!result.empty() && !pseudoElement.empty())
|
|
||||||
{
|
|
||||||
// failed
|
|
||||||
result.clear();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result.push_back(current);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -310,5 +310,43 @@ namespace NLGUI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string CCssSelector::toString() const
|
||||||
|
{
|
||||||
|
std::string ret;
|
||||||
|
ret += Element;
|
||||||
|
ret += Id;
|
||||||
|
if (!Class.empty())
|
||||||
|
{
|
||||||
|
for(uint i = 0; i<Class.size(); i++)
|
||||||
|
ret += "." + Class[i];
|
||||||
|
}
|
||||||
|
if (!Attr.empty())
|
||||||
|
{
|
||||||
|
for(uint i = 0; i<Attr.size(); ++i)
|
||||||
|
{
|
||||||
|
ret += "[" + Attr[i].key;
|
||||||
|
if (Attr[i].op != ' ')
|
||||||
|
{
|
||||||
|
ret += Attr[i].op + Attr[i].value;
|
||||||
|
}
|
||||||
|
ret += "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!PseudoClass.empty())
|
||||||
|
{
|
||||||
|
for(uint i = 0; i<PseudoClass.size(); ++i)
|
||||||
|
{
|
||||||
|
ret += ":" + PseudoClass[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Combinator != '\0')
|
||||||
|
{
|
||||||
|
ret += Combinator;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ret += ":" + PseudoClass;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue