summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/CSS
diff options
context:
space:
mode:
authorTobias Christiansen <tobi@tobyase.de>2021-05-23 21:00:44 +0200
committerLinus Groh <mail@linusgroh.de>2021-05-24 22:10:08 +0100
commit820224bb487d824890b1650e93bde41243a1a1d6 (patch)
tree84bc688882f1445cb260f9b37f63393ddbc44bc5 /Userland/Libraries/LibWeb/CSS
parent1ab82afee695d0671c767eff683a7fd1326c5609 (diff)
downloadserenity-820224bb487d824890b1650e93bde41243a1a1d6.zip
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.
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS')
-rw-r--r--Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp12
1 files changed, 12 insertions, 0 deletions
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 <LibWeb/CSS/Parser/DeprecatedCSSParser.h>
#include <LibWeb/CSS/SelectorEngine.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Element.h>
@@ -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;