mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:57:44 +00:00
LibWeb: Port CSS::MediaQuery to new Strings
This commit is contained in:
parent
a381ce9519
commit
a0b1eddc56
4 changed files with 7 additions and 10 deletions
|
@ -34,7 +34,7 @@ JS::ThrowCompletionOr<void> MediaList::initialize(JS::Realm& realm)
|
|||
// https://www.w3.org/TR/cssom-1/#dom-medialist-mediatext
|
||||
DeprecatedString MediaList::media_text() const
|
||||
{
|
||||
return serialize_a_media_query_list(m_media);
|
||||
return serialize_a_media_query_list(m_media).release_value_but_fixme_should_propagate_errors().to_deprecated_string();
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/cssom-1/#dom-medialist-mediatext
|
||||
|
|
|
@ -379,17 +379,15 @@ bool MediaQuery::evaluate(HTML::Window const& window)
|
|||
}
|
||||
|
||||
// https://www.w3.org/TR/cssom-1/#serialize-a-media-query-list
|
||||
DeprecatedString serialize_a_media_query_list(NonnullRefPtrVector<MediaQuery> const& media_queries)
|
||||
ErrorOr<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 "";
|
||||
return String {};
|
||||
|
||||
// 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(", "sv, media_queries);
|
||||
return builder.to_deprecated_string();
|
||||
return String::join(", "sv, media_queries);
|
||||
}
|
||||
|
||||
bool is_media_feature_name(StringView name)
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedFlyString.h>
|
||||
#include <AK/NonnullOwnPtrVector.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/Optional.h>
|
||||
|
@ -255,7 +254,7 @@ private:
|
|||
bool m_matches { false };
|
||||
};
|
||||
|
||||
DeprecatedString serialize_a_media_query_list(NonnullRefPtrVector<MediaQuery> const&);
|
||||
ErrorOr<String> serialize_a_media_query_list(NonnullRefPtrVector<MediaQuery> const&);
|
||||
|
||||
bool is_media_feature_name(StringView name);
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ void MediaQueryList::visit_edges(Cell::Visitor& visitor)
|
|||
// https://drafts.csswg.org/cssom-view/#dom-mediaquerylist-media
|
||||
DeprecatedString MediaQueryList::media() const
|
||||
{
|
||||
return serialize_a_media_query_list(m_media);
|
||||
return serialize_a_media_query_list(m_media).release_value_but_fixme_should_propagate_errors().to_deprecated_string();
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom-view/#dom-mediaquerylist-matches
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue