mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:27:45 +00:00
LibWeb: Add actual document loading for the CSS (at)import rule
This commit is contained in:
parent
54617e1a91
commit
183ebaee91
11 changed files with 229 additions and 56 deletions
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include <AK/NonnullRefPtrVector.h>
|
||||
#include <AK/TypeCasts.h>
|
||||
#include <LibWeb/CSS/CSSImportRule.h>
|
||||
#include <LibWeb/CSS/CSSRule.h>
|
||||
#include <LibWeb/Loader/Resource.h>
|
||||
|
||||
|
@ -52,9 +53,32 @@ public:
|
|||
for (auto& rule : m_rules)
|
||||
if (rule.type() == CSSRule::Type::Style) {
|
||||
callback(downcast<StyleRule>(rule));
|
||||
} else if (rule.type() == CSSRule::Type::Import) {
|
||||
const CSSImportRule& import_rule = downcast<CSSImportRule>(rule);
|
||||
if (import_rule.has_import_result())
|
||||
import_rule.loaded_style_sheet()->for_each_effective_style_rule(callback);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Callback>
|
||||
bool for_first_not_loaded_import_rule(Callback callback)
|
||||
{
|
||||
for (auto& rule : m_rules)
|
||||
if (rule.type() == CSSRule::Type::Import) {
|
||||
CSSImportRule& import_rule = downcast<CSSImportRule>(rule);
|
||||
if (!import_rule.has_import_result()) {
|
||||
callback(import_rule);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (import_rule.loaded_style_sheet()->for_first_not_loaded_import_rule(callback)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
explicit StyleSheet(NonnullRefPtrVector<CSSRule>&&);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue