mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibWeb: Cache whether there are any :has() selectors present
As useful as they may be to web developers, :has() selectors complicate the style invalidation process quite a lot. Let's have StyleComputer keep track of whether they are present at all in the current set of active style sheets. This will allow us to implement fast-path optimizations when there are no :has() selectors.
This commit is contained in:
parent
df048e10f5
commit
8beb7c7700
Notes:
github-actions[bot]
2024-09-22 18:08:47 +00:00
Author: https://github.com/awesomekling
Commit: 8beb7c7700
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1483
Reviewed-by: https://github.com/kalenikaliaksandr
2 changed files with 9 additions and 0 deletions
|
@ -2479,6 +2479,8 @@ NonnullOwnPtr<StyleComputer::RuleCache> StyleComputer::make_rule_cache_for_casca
|
|||
Optional<CSS::Selector::PseudoElement::Type> pseudo_element;
|
||||
|
||||
for (auto const& simple_selector : selector.compound_selectors().last().simple_selectors) {
|
||||
if (!rule_cache->has_has_selectors && simple_selector.type == CSS::Selector::SimpleSelector::Type::PseudoClass && simple_selector.pseudo_class().type == CSS::PseudoClass::Has)
|
||||
rule_cache->has_has_selectors = true;
|
||||
if (!matching_rule.contains_pseudo_element) {
|
||||
if (simple_selector.type == CSS::Selector::SimpleSelector::Type::PseudoElement) {
|
||||
matching_rule.contains_pseudo_element = true;
|
||||
|
@ -2726,6 +2728,8 @@ void StyleComputer::build_rule_cache()
|
|||
m_author_rule_cache = make_rule_cache_for_cascade_origin(CascadeOrigin::Author);
|
||||
m_user_rule_cache = make_rule_cache_for_cascade_origin(CascadeOrigin::User);
|
||||
m_user_agent_rule_cache = make_rule_cache_for_cascade_origin(CascadeOrigin::UserAgent);
|
||||
|
||||
m_has_has_selectors = m_author_rule_cache->has_has_selectors || m_user_rule_cache->has_has_selectors || m_user_agent_rule_cache->has_has_selectors;
|
||||
}
|
||||
|
||||
void StyleComputer::invalidate_rule_cache()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue