mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 01:20:25 +00:00
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.
This commit is contained in:
parent
1ab82afee6
commit
820224bb48
Notes:
sideshowbarker
2024-07-18 17:25:46 +09:00
Author: https://github.com/TobyAsE Commit: https://github.com/SerenityOS/serenity/commit/820224bb487 Pull-request: https://github.com/SerenityOS/serenity/pull/7422
1 changed files with 12 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue