From 820224bb487d824890b1650e93bde41243a1a1d6 Mon Sep 17 00:00:00 2001 From: Tobias Christiansen Date: Sun, 23 May 2021 21:00:44 +0200 Subject: LibWeb: Match the :not pseudoclass When a Selector features a :not() pseudoclass we now check whether the current element matches with the given selector in the :not and act accordingly. --- Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'Userland/Libraries/LibWeb/CSS') diff --git a/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp b/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp index 44b7a48dba..bd7e24ae60 100644 --- a/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp +++ b/Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp @@ -4,6 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include #include #include #include @@ -100,6 +101,17 @@ static bool matches(const CSS::Selector::SimpleSelector& component, const DOM::E if (!element.has_attribute("checked")) return false; break; + case CSS::Selector::SimpleSelector::PseudoClass::Not: { + if (component.not_selector.is_empty()) + return false; + auto not_selector = Web::parse_selector(CSS::ParsingContext(element), component.not_selector); + if (!not_selector.has_value()) + return false; + auto not_matches = matches(not_selector.value(), element); + if (not_matches) + return false; + break; + } case CSS::Selector::SimpleSelector::PseudoClass::NthChild: case CSS::Selector::SimpleSelector::PseudoClass::NthLastChild: const auto step_size = component.nth_child_pattern.step_size; -- cgit v1.2.3