summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2023-02-14 20:19:58 +0000
committerTim Flynn <trflynn89@pm.me>2023-02-15 12:48:26 -0500
commita0b1eddc56eebdfab7f8223b3ac9a6bf687a4190 (patch)
tree77ba2bd69780d3c226631bff8184c539c0d0e7eb /Userland
parenta381ce9519bd1098ed14fe495d830bafe5a3a49b (diff)
downloadserenity-a0b1eddc56eebdfab7f8223b3ac9a6bf687a4190.zip
LibWeb: Port CSS::MediaQuery to new Strings
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/CSS/MediaList.cpp2
-rw-r--r--Userland/Libraries/LibWeb/CSS/MediaQuery.cpp8
-rw-r--r--Userland/Libraries/LibWeb/CSS/MediaQuery.h5
-rw-r--r--Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp2
4 files changed, 7 insertions, 10 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/MediaList.cpp b/Userland/Libraries/LibWeb/CSS/MediaList.cpp
index 2999141b74..ca0a470c6a 100644
--- a/Userland/Libraries/LibWeb/CSS/MediaList.cpp
+++ b/Userland/Libraries/LibWeb/CSS/MediaList.cpp
@@ -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
diff --git a/Userland/Libraries/LibWeb/CSS/MediaQuery.cpp b/Userland/Libraries/LibWeb/CSS/MediaQuery.cpp
index 20a1f0ac36..b7e328122c 100644
--- a/Userland/Libraries/LibWeb/CSS/MediaQuery.cpp
+++ b/Userland/Libraries/LibWeb/CSS/MediaQuery.cpp
@@ -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)
diff --git a/Userland/Libraries/LibWeb/CSS/MediaQuery.h b/Userland/Libraries/LibWeb/CSS/MediaQuery.h
index ed31e57aa5..050c95cb8b 100644
--- a/Userland/Libraries/LibWeb/CSS/MediaQuery.h
+++ b/Userland/Libraries/LibWeb/CSS/MediaQuery.h
@@ -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);
diff --git a/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp b/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp
index c21f4c0bc2..127c50425c 100644
--- a/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp
+++ b/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp
@@ -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