mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 17:44:56 +09:00

Before this change, checking if fast selector matching could be used was only enabled in style recalculation and hover invalidation. With this change it's enabled for all callers of SelectorEngine::matches() by default. This way APIs like `Element.matches()` and `querySelector()` could take advantage of this optimization.
28 lines
850 B
C++
28 lines
850 B
C++
/*
|
|
* Copyright (c) 2018-2024, Andreas Kling <andreas@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/CSS/Selector.h>
|
|
#include <LibWeb/DOM/Element.h>
|
|
|
|
namespace Web::SelectorEngine {
|
|
|
|
enum class SelectorKind {
|
|
Normal,
|
|
Relative,
|
|
};
|
|
|
|
struct MatchContext {
|
|
GC::Ptr<CSS::CSSStyleSheet const> style_sheet_for_rule {};
|
|
GC::Ptr<DOM::Element const> subject {};
|
|
bool collect_per_element_selector_involvement_metadata { false };
|
|
bool did_match_any_hover_rules { false };
|
|
};
|
|
|
|
bool matches(CSS::Selector const&, DOM::Element const&, GC::Ptr<DOM::Element const> shadow_host, MatchContext& context, Optional<CSS::Selector::PseudoElement::Type> = {}, GC::Ptr<DOM::ParentNode const> scope = {}, SelectorKind selector_kind = SelectorKind::Normal, GC::Ptr<DOM::Element const> anchor = nullptr);
|
|
|
|
}
|