mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibWeb: Bucket div.foo and div#foo as class/ID rather than tag(div)
By bucketing these seletors by class or ID, we can avoid running them in more cases. Before, we were only avoiding them if the context element wasn't a div. Now we avoid them for any element that doesn't have that specific class or ID. This reduces the number of selectors ran on https://vercel.com by a bit more, from 1.90% to 1.65%.
This commit is contained in:
parent
ad37c8cd26
commit
b365a5c42f
Notes:
github-actions[bot]
2024-09-09 10:47:55 +00:00
Author: https://github.com/awesomekling
Commit: b365a5c42f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1341
1 changed files with 3 additions and 1 deletions
|
@ -2700,8 +2700,10 @@ NonnullOwnPtr<StyleComputer::RuleCache> StyleComputer::make_rule_cache_for_casca
|
|||
}
|
||||
}
|
||||
|
||||
// NOTE: We traverse the simple selectors in reverse order to make sure that class/ID buckets are preferred over tag buckets
|
||||
// in the common case of div.foo or div#foo selectors.
|
||||
bool added_to_bucket = false;
|
||||
for (auto const& simple_selector : selector.compound_selectors().last().simple_selectors) {
|
||||
for (auto const& simple_selector : selector.compound_selectors().last().simple_selectors.in_reverse()) {
|
||||
if (simple_selector.type == CSS::Selector::SimpleSelector::Type::Id) {
|
||||
rule_cache->rules_by_id.ensure(simple_selector.name()).append(move(matching_rule));
|
||||
++num_id_rules;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue