mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:58:12 +00:00
LibWeb: Actually incorporate style from imported style sheets
This commit is contained in:
parent
1b262f8c89
commit
7b55d79d3a
5 changed files with 40 additions and 2 deletions
|
@ -19,6 +19,7 @@
|
|||
#include <LibGfx/Font/VectorFont.h>
|
||||
#include <LibGfx/Font/WOFF/Font.h>
|
||||
#include <LibWeb/CSS/CSSFontFaceRule.h>
|
||||
#include <LibWeb/CSS/CSSImportRule.h>
|
||||
#include <LibWeb/CSS/CSSStyleRule.h>
|
||||
#include <LibWeb/CSS/Parser/Parser.h>
|
||||
#include <LibWeb/CSS/SelectorEngine.h>
|
||||
|
@ -131,6 +132,19 @@ 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
|
||||
{
|
||||
|
@ -140,9 +154,11 @@ void StyleComputer::for_each_stylesheet(CascadeOrigin cascade_origin, Callback c
|
|||
callback(quirks_mode_stylesheet(document()));
|
||||
}
|
||||
if (cascade_origin == CascadeOrigin::Author) {
|
||||
for (auto const& sheet : document().style_sheets().sheets()) {
|
||||
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