mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:37:46 +00:00
LibWeb: Account for all simple-selectors when calculating specificity
This fixes the Acid2 blue nose when hovering. :^)
This commit is contained in:
parent
ab2c47542d
commit
b76ee0e30d
1 changed files with 7 additions and 0 deletions
|
@ -32,6 +32,7 @@ Optional<Selector::PseudoElement> Selector::pseudo_element() const
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://www.w3.org/TR/selectors-4/#specificity-rules
|
||||||
u32 Selector::specificity() const
|
u32 Selector::specificity() const
|
||||||
{
|
{
|
||||||
if (m_specificity.has_value())
|
if (m_specificity.has_value())
|
||||||
|
@ -48,9 +49,12 @@ u32 Selector::specificity() const
|
||||||
++ids;
|
++ids;
|
||||||
break;
|
break;
|
||||||
case SimpleSelector::Type::Class:
|
case SimpleSelector::Type::Class:
|
||||||
|
case SimpleSelector::Type::Attribute:
|
||||||
|
case SimpleSelector::Type::PseudoClass:
|
||||||
++classes;
|
++classes;
|
||||||
break;
|
break;
|
||||||
case SimpleSelector::Type::TagName:
|
case SimpleSelector::Type::TagName:
|
||||||
|
case SimpleSelector::Type::PseudoElement:
|
||||||
++tag_names;
|
++tag_names;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -180,6 +184,9 @@ String Selector::SimpleSelector::serialize() const
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case Selector::SimpleSelector::Type::PseudoElement:
|
||||||
|
// Note: Pseudo-elements are dealt with in Selector::serialize()
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
dbgln("FIXME: Unsupported simple selector serialization for type {}", to_underlying(type));
|
dbgln("FIXME: Unsupported simple selector serialization for type {}", to_underlying(type));
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue