summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/CSS/Selector.cpp
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2022-02-25 12:56:55 +0000
committerAndreas Kling <kling@serenityos.org>2022-02-25 19:35:34 +0100
commitb76ee0e30d38200b1416a11d0daecb138daded0f (patch)
tree7679221a512852880f34a15c0a35655ae0086d47 /Userland/Libraries/LibWeb/CSS/Selector.cpp
parentab2c47542d92f54a2ed87c10f8f53000e03e4e05 (diff)
downloadserenity-b76ee0e30d38200b1416a11d0daecb138daded0f.zip
LibWeb: Account for all simple-selectors when calculating specificity
This fixes the Acid2 blue nose when hovering. :^)
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS/Selector.cpp')
-rw-r--r--Userland/Libraries/LibWeb/CSS/Selector.cpp7
1 files changed, 7 insertions, 0 deletions
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::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;