mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:08:12 +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:
parent
496db17c2d
commit
0805060e5e
3 changed files with 43 additions and 11 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue