mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 04:39:06 +00:00
LibWeb: Move media-query-list serialization code to MediaQuery.{h,cpp}
It's not a complicated algorithm, but having it in one place instead of 2, and with spec comments, is nice. :^)
This commit is contained in:
parent
caac0706c2
commit
46bba44f8b
Notes:
sideshowbarker
2024-07-18 02:20:35 +09:00
Author: https://github.com/AtkinsSJ
Commit: 46bba44f8b
Pull-request: https://github.com/SerenityOS/serenity/pull/10489
Reviewed-by: https://github.com/linusg ✅
4 changed files with 18 additions and 6 deletions
|
@ -227,4 +227,18 @@ bool MediaQuery::evaluate(DOM::Window const& window)
|
|||
return m_matches;
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/cssom-1/#serialize-a-media-query-list
|
||||
String serialize_a_media_query_list(NonnullRefPtrVector<MediaQuery> const& media_queries)
|
||||
{
|
||||
// 1. If the media query list is empty, then return the empty string.
|
||||
if (media_queries.is_empty())
|
||||
return "";
|
||||
|
||||
// 2. Serialize each media query in the list of media queries, in the same order as they
|
||||
// appear in the media query list, and then serialize the list.
|
||||
StringBuilder builder;
|
||||
builder.join(", ", media_queries);
|
||||
return builder.to_string();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue