mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-03 07:07:23 +00:00
LibWeb: Speed up CSS namespace checking
CSSStyleSheet now caches the CSSNamespaceRule for the default namespace, which is the only one we currently care about. This saves us from iterating over its list of rules every time we want to know what that default namespace is. The spec dictates that `@namespace` rules are only valid near the start of a stylesheet, so we also take advantage of that to quit searching for namespaces as soon as we see a non-import rule. Also renamed `namespace_filter()` to `default_namespace()` since that's what it actually returns. This makes github.com/serenityos/serenity snappy again. :^)
This commit is contained in:
committed by
Andreas Kling
parent
496db17c2d
commit
0805060e5e
@@ -225,7 +225,7 @@ Vector<MatchingRule> StyleComputer::filter_namespace_rules(DOM::Element const& e
|
||||
Vector<MatchingRule> filtered_rules;
|
||||
|
||||
for (auto const& rule : rules) {
|
||||
auto namespace_uri = rule.sheet->namespace_filter();
|
||||
auto namespace_uri = rule.sheet->default_namespace();
|
||||
if (namespace_uri.has_value()) {
|
||||
if (namespace_uri.value() == element.namespace_uri())
|
||||
filtered_rules.append(rule);
|
||||
|
||||
Reference in New Issue
Block a user