mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 20:29:18 +00:00
LibWeb/CSS: Skip build of rule cache for inactive documents
Some websites (Reddit, for example) create lots of temporary documents for fragment parsing. Before this change, we had to build a rule cache for these documents just to determine whether there are :has, :defined, or attribute selectors, while it should be safe to simply return `false` right away.
This commit is contained in:
parent
34b8a9ab75
commit
ccb543ebb8
Notes:
github-actions[bot]
2025-01-03 10:14:31 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: ccb543ebb8
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3105
1 changed files with 9 additions and 1 deletions
|
@ -3017,20 +3017,28 @@ size_t StyleComputer::number_of_css_font_faces_with_loading_in_progress() const
|
||||||
|
|
||||||
bool StyleComputer::has_has_selectors() const
|
bool StyleComputer::has_has_selectors() const
|
||||||
{
|
{
|
||||||
|
if (!document().is_active())
|
||||||
|
return false;
|
||||||
|
|
||||||
build_rule_cache_if_needed();
|
build_rule_cache_if_needed();
|
||||||
return m_selector_insights->has_has_selectors;
|
return m_selector_insights->has_has_selectors;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StyleComputer::has_defined_selectors() const
|
bool StyleComputer::has_defined_selectors() const
|
||||||
{
|
{
|
||||||
|
if (!document().is_active())
|
||||||
|
return false;
|
||||||
|
|
||||||
build_rule_cache_if_needed();
|
build_rule_cache_if_needed();
|
||||||
return m_selector_insights->has_defined_selectors;
|
return m_selector_insights->has_defined_selectors;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StyleComputer::has_attribute_selector(FlyString const& attribute_name) const
|
bool StyleComputer::has_attribute_selector(FlyString const& attribute_name) const
|
||||||
{
|
{
|
||||||
build_rule_cache_if_needed();
|
if (!document().is_active())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
build_rule_cache_if_needed();
|
||||||
return m_selector_insights->all_names_used_in_attribute_selectors.contains(attribute_name);
|
return m_selector_insights->all_names_used_in_attribute_selectors.contains(attribute_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue