mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 10:18:15 +09:00
LibWeb: Handle special cases of PseudoElement::Type correctly
There are some special values for CSS::Selector::PseudoElement::Type which are after `KnownPseudoElementCount` and therefore not present in various arrays of pseudo elements, this leads to some errors, if a type after `KnownPseudoElementCount` is used without checking first. This adds explicit checks to all usages
This commit is contained in:
parent
8620a2af47
commit
d21bfda900
Notes:
github-actions[bot]
2024-12-19 19:37:02 +00:00
Author: https://github.com/Totto16
Commit: d21bfda900
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2908
Reviewed-by: https://github.com/AtkinsSJ ✅
4 changed files with 59 additions and 7 deletions
|
@ -466,8 +466,14 @@ Vector<MatchingRule> StyleComputer::collect_matching_rules(DOM::Element const& e
|
|||
}
|
||||
if (auto it = rule_cache.rules_by_tag_name.find(element.local_name()); it != rule_cache.rules_by_tag_name.end())
|
||||
add_rules_to_run(it->value);
|
||||
if (pseudo_element.has_value())
|
||||
add_rules_to_run(rule_cache.rules_by_pseudo_element[to_underlying(pseudo_element.value())]);
|
||||
if (pseudo_element.has_value()) {
|
||||
if (CSS::Selector::PseudoElement::is_known_pseudo_element_type(pseudo_element.value())) {
|
||||
add_rules_to_run(rule_cache.rules_by_pseudo_element.at(to_underlying(pseudo_element.value())));
|
||||
} else {
|
||||
// NOTE: We don't cache rules for unknown pseudo-elements. They can't match anything anyway.
|
||||
}
|
||||
}
|
||||
|
||||
if (element.is_document_element())
|
||||
add_rules_to_run(rule_cache.root_rules);
|
||||
|
||||
|
@ -2632,7 +2638,7 @@ NonnullOwnPtr<StyleComputer::RuleCache> StyleComputer::make_rule_cache_for_casca
|
|||
}
|
||||
if (!added_to_bucket) {
|
||||
if (matching_rule.contains_pseudo_element) {
|
||||
if (to_underlying(pseudo_element.value()) < to_underlying(CSS::Selector::PseudoElement::Type::KnownPseudoElementCount)) {
|
||||
if (CSS::Selector::PseudoElement::is_known_pseudo_element_type(pseudo_element.value())) {
|
||||
rule_cache->rules_by_pseudo_element[to_underlying(pseudo_element.value())].append(move(matching_rule));
|
||||
} else {
|
||||
// NOTE: We don't cache rules for unknown pseudo-elements. They can't match anything anyway.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue