LibWeb: Remove duplicate checks in for_each_effective_style_rule()

After confirming the rule types, we can use static_cast instead of
verify_cast to avoid some extra work.
This commit is contained in:
Andreas Kling 2022-01-19 09:42:49 +01:00
parent 39b2046c42
commit 77650fe886
Notes: sideshowbarker 2024-07-17 20:26:15 +09:00

View file

@ -80,22 +80,22 @@ DOM::ExceptionOr<void> CSSRuleList::remove_a_css_rule(u32 index)
void CSSRuleList::for_each_effective_style_rule(Function<void(CSSStyleRule const&)> const& callback) const
{
for (auto& rule : m_rules) {
for (auto const& rule : m_rules) {
switch (rule.type()) {
case CSSRule::Type::Style:
callback(verify_cast<CSSStyleRule>(rule));
callback(static_cast<CSSStyleRule const&>(rule));
break;
case CSSRule::Type::Import: {
auto const& import_rule = verify_cast<CSSImportRule>(rule);
auto const& import_rule = static_cast<CSSImportRule const&>(rule);
if (import_rule.has_import_result())
import_rule.loaded_style_sheet()->for_each_effective_style_rule(callback);
break;
}
case CSSRule::Type::Media:
verify_cast<CSSMediaRule>(rule).for_each_effective_style_rule(callback);
static_cast<CSSMediaRule const&>(rule).for_each_effective_style_rule(callback);
break;
case CSSRule::Type::Supports:
verify_cast<CSSSupportsRule>(rule).for_each_effective_style_rule(callback);
static_cast<CSSSupportsRule const&>(rule).for_each_effective_style_rule(callback);
break;
case CSSRule::Type::__Count:
VERIFY_NOT_REACHED();