mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:27:45 +00:00
LibWeb: Actually visit rules and media queries in imported style sheets
Due to CSSImportRule::has_import_result() being backwards, we never actually entered imported style sheets when traversing style rules or media queries. With this fixed, we no longer need the "collect style sheets" step in StyleComputer, as normal for_each_effective_style_rule() will now actually find all the rules. :^)
This commit is contained in:
parent
fe761a4e9b
commit
45f8542965
6 changed files with 21 additions and 19 deletions
|
@ -162,19 +162,6 @@ static CSSStyleSheet& quirks_mode_stylesheet(DOM::Document const& document)
|
|||
return *sheet;
|
||||
}
|
||||
|
||||
static void collect_style_sheets(CSSStyleSheet const& sheet, Vector<JS::NonnullGCPtr<CSSStyleSheet const>>& sheets)
|
||||
{
|
||||
sheets.append(sheet);
|
||||
for (auto const& rule : sheet.rules()) {
|
||||
if (rule->type() == CSSRule::Type::Import) {
|
||||
auto const& import_rule = static_cast<CSSImportRule const&>(*rule);
|
||||
if (auto const* imported_sheet = import_rule.loaded_style_sheet()) {
|
||||
collect_style_sheets(*imported_sheet, sheets);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Callback>
|
||||
void StyleComputer::for_each_stylesheet(CascadeOrigin cascade_origin, Callback callback) const
|
||||
{
|
||||
|
@ -184,10 +171,7 @@ void StyleComputer::for_each_stylesheet(CascadeOrigin cascade_origin, Callback c
|
|||
callback(quirks_mode_stylesheet(document()));
|
||||
}
|
||||
if (cascade_origin == CascadeOrigin::Author) {
|
||||
Vector<JS::NonnullGCPtr<CSSStyleSheet const>> sheets;
|
||||
for (auto const& sheet : document().style_sheets().sheets())
|
||||
collect_style_sheets(sheet, sheets);
|
||||
for (auto const& sheet : sheets)
|
||||
callback(*sheet);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue