mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-22 02:52:52 +00:00
LibWeb/CSS: Support media queries in import at-rules
This commit is contained in:
parent
c1fe912bf9
commit
ac19b0cda8
Notes:
github-actions[bot]
2025-04-02 13:56:49 +00:00
Author: https://github.com/tcl3
Commit: ac19b0cda8
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4183
Reviewed-by: https://github.com/AtkinsSJ ✅
7 changed files with 51 additions and 15 deletions
|
@ -23,17 +23,18 @@ namespace Web::CSS {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(CSSImportRule);
|
||||
|
||||
GC::Ref<CSSImportRule> CSSImportRule::create(URL::URL url, DOM::Document& document, RefPtr<Supports> supports)
|
||||
GC::Ref<CSSImportRule> CSSImportRule::create(URL::URL url, DOM::Document& document, RefPtr<Supports> supports, Vector<NonnullRefPtr<MediaQuery>> media_query_list)
|
||||
{
|
||||
auto& realm = document.realm();
|
||||
return realm.create<CSSImportRule>(move(url), document, supports);
|
||||
return realm.create<CSSImportRule>(move(url), document, supports, move(media_query_list));
|
||||
}
|
||||
|
||||
CSSImportRule::CSSImportRule(URL::URL url, DOM::Document& document, RefPtr<Supports> supports)
|
||||
CSSImportRule::CSSImportRule(URL::URL url, DOM::Document& document, RefPtr<Supports> supports, Vector<NonnullRefPtr<MediaQuery>> media_query_list)
|
||||
: CSSRule(document.realm(), Type::Import)
|
||||
, m_url(move(url))
|
||||
, m_document(document)
|
||||
, m_supports(supports)
|
||||
, m_media_query_list(move(media_query_list))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -76,7 +77,9 @@ String CSSImportRule::serialized() const
|
|||
if (m_supports)
|
||||
builder.appendff(" supports({})", m_supports->to_string());
|
||||
|
||||
// FIXME: 3. If the rule’s associated media list is not empty, a single SPACE (U+0020) followed by the result of performing serialize a media query list on the media list.
|
||||
// 3. If the rule’s associated media list is not empty, a single SPACE (U+0020) followed by the result of performing serialize a media query list on the media list.
|
||||
if (!m_media_query_list.is_empty())
|
||||
builder.appendff(" {}", serialize_a_media_query_list(m_media_query_list));
|
||||
|
||||
// 4. The string ";", i.e., SEMICOLON (U+003B).
|
||||
builder.append(';');
|
||||
|
@ -148,7 +151,7 @@ void CSSImportRule::fetch()
|
|||
}
|
||||
auto decoded = decoded_or_error.release_value();
|
||||
|
||||
auto* imported_style_sheet = parse_css_stylesheet(Parser::ParsingParams(*strong_this->m_document, strong_this->url()), decoded, strong_this->url());
|
||||
auto* imported_style_sheet = parse_css_stylesheet(Parser::ParsingParams(*strong_this->m_document, strong_this->url()), decoded, strong_this->url(), strong_this->m_media_query_list);
|
||||
|
||||
// 5. Set importedStylesheet’s origin-clean flag to parentStylesheet’s origin-clean flag.
|
||||
imported_style_sheet->set_origin_clean(parent_style_sheet->is_origin_clean());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue