mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-12 11:09:18 +00:00
LibWeb/CSS: Evaluate media queries in shadow roots
This fixes a rendering issue on https://prodengi.kz/ that someone on Discord reported. :^)
This commit is contained in:
parent
1aab7b51ea
commit
0b775da7c7
Notes:
github-actions[bot]
2024-10-20 06:58:04 +00:00
Author: https://github.com/thislooksfun
Commit: 0b775da7c7
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1869
Reviewed-by: https://github.com/AtkinsSJ ✅
5 changed files with 43 additions and 13 deletions
|
@ -2784,7 +2784,7 @@ void Document::evaluate_media_rules()
|
|||
return;
|
||||
|
||||
bool any_media_queries_changed_match_state = false;
|
||||
for_each_active_css_style_sheet([&](CSS::CSSStyleSheet& style_sheet) {
|
||||
for_each_active_css_style_sheet([&](CSS::CSSStyleSheet& style_sheet, auto) {
|
||||
if (style_sheet.evaluate_media_queries(*window))
|
||||
any_media_queries_changed_match_state = true;
|
||||
});
|
||||
|
@ -5173,21 +5173,28 @@ WebIDL::ExceptionOr<void> Document::set_adopted_style_sheets(JS::Value new_value
|
|||
return {};
|
||||
}
|
||||
|
||||
void Document::for_each_active_css_style_sheet(Function<void(CSS::CSSStyleSheet&)>&& callback) const
|
||||
void Document::for_each_active_css_style_sheet(Function<void(CSS::CSSStyleSheet&, JS::GCPtr<DOM::ShadowRoot>)>&& callback) const
|
||||
{
|
||||
if (m_style_sheets) {
|
||||
for (auto& style_sheet : m_style_sheets->sheets()) {
|
||||
if (!(style_sheet->is_alternate() && style_sheet->disabled()))
|
||||
callback(*style_sheet);
|
||||
callback(*style_sheet, {});
|
||||
}
|
||||
}
|
||||
|
||||
if (m_adopted_style_sheets) {
|
||||
m_adopted_style_sheets->for_each<CSS::CSSStyleSheet>([&](auto& style_sheet) {
|
||||
if (!style_sheet.disabled())
|
||||
callback(style_sheet);
|
||||
callback(style_sheet, {});
|
||||
});
|
||||
}
|
||||
|
||||
for_each_shadow_root([&](auto& shadow_root) {
|
||||
shadow_root.for_each_css_style_sheet([&](auto& style_sheet) {
|
||||
if (!style_sheet.disabled())
|
||||
callback(style_sheet, &shadow_root);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
static Optional<CSS::CSSStyleSheet&> find_style_sheet_with_url(String const& url, CSS::CSSStyleSheet& style_sheet)
|
||||
|
@ -5277,6 +5284,12 @@ void Document::for_each_shadow_root(Function<void(DOM::ShadowRoot&)>&& callback)
|
|||
callback(shadow_root);
|
||||
}
|
||||
|
||||
void Document::for_each_shadow_root(Function<void(DOM::ShadowRoot&)>&& callback) const
|
||||
{
|
||||
for (auto& shadow_root : m_shadow_roots)
|
||||
callback(shadow_root);
|
||||
}
|
||||
|
||||
bool Document::is_decoded_svg() const
|
||||
{
|
||||
return is<Web::SVG::SVGDecodedImageData::SVGPageClient>(page().client());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue