From b76ee0e30d38200b1416a11d0daecb138daded0f Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Fri, 25 Feb 2022 12:56:55 +0000 Subject: [PATCH] LibWeb: Account for all simple-selectors when calculating specificity This fixes the Acid2 blue nose when hovering. :^) --- Userland/Libraries/LibWeb/CSS/Selector.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Userland/Libraries/LibWeb/CSS/Selector.cpp b/Userland/Libraries/LibWeb/CSS/Selector.cpp index 83a4feaed3..7bae069541 100644 --- a/Userland/Libraries/LibWeb/CSS/Selector.cpp +++ b/Userland/Libraries/LibWeb/CSS/Selector.cpp @@ -32,6 +32,7 @@ Optional 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;