1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 17:28:11 +00:00

LibWeb: Account for all simple-selectors when calculating specificity

This fixes the Acid2 blue nose when hovering. :^)
This commit is contained in:
Sam Atkins 2022-02-25 12:56:55 +00:00 committed by Andreas Kling
parent ab2c47542d
commit b76ee0e30d

View file

@ -32,6 +32,7 @@ Optional<Selector::PseudoElement> Selector::pseudo_element() const
return {};
}
// https://www.w3.org/TR/selectors-4/#specificity-rules
u32 Selector::specificity() const
{
if (m_specificity.has_value())
@ -48,9 +49,12 @@ u32 Selector::specificity() const
++ids;
break;
case SimpleSelector::Type::Class:
case SimpleSelector::Type::Attribute:
case SimpleSelector::Type::PseudoClass:
++classes;
break;
case SimpleSelector::Type::TagName:
case SimpleSelector::Type::PseudoElement:
++tag_names;
break;
default:
@ -180,6 +184,9 @@ String Selector::SimpleSelector::serialize() const
VERIFY_NOT_REACHED();
}
break;
case Selector::SimpleSelector::Type::PseudoElement:
// Note: Pseudo-elements are dealt with in Selector::serialize()
break;
default:
dbgln("FIXME: Unsupported simple selector serialization for type {}", to_underlying(type));
break;