summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/CSS
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2021-09-29 12:58:22 +0100
committerAndreas Kling <kling@serenityos.org>2021-10-01 20:03:03 +0200
commitf1af136925bd2728d15b2094879628c8738b4180 (patch)
treeeb3cd283838083a62822f9a787c7af4236ab48cf /Userland/Libraries/LibWeb/CSS
parent5bbbdb81dca9b80b431e080d180aee93900fbd09 (diff)
downloadserenity-f1af136925bd2728d15b2094879628c8738b4180.zip
LibWeb: Make MediaQueryList store MediaQueries instead of a String
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS')
-rw-r--r--Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp7
-rw-r--r--Userland/Libraries/LibWeb/CSS/MediaQueryList.h9
2 files changed, 9 insertions, 7 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp b/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp
index 2af28d4128..d3295c3075 100644
--- a/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp
+++ b/Userland/Libraries/LibWeb/CSS/MediaQueryList.cpp
@@ -13,7 +13,7 @@
namespace Web::CSS {
-MediaQueryList::MediaQueryList(DOM::Document& document, String media)
+MediaQueryList::MediaQueryList(DOM::Document& document, NonnullRefPtrVector<MediaQuery>&& media)
: DOM::EventTarget(static_cast<Bindings::ScriptExecutionContext&>(document))
, m_document(document)
, m_media(move(media))
@@ -27,8 +27,9 @@ MediaQueryList::~MediaQueryList()
// https://drafts.csswg.org/cssom-view/#dom-mediaquerylist-media
String MediaQueryList::media() const
{
- // TODO: Replace this with a "media query list" and serialize on demand
- return m_media;
+ StringBuilder builder;
+ builder.join(", ", m_media);
+ return builder.to_string();
}
// https://drafts.csswg.org/cssom-view/#dom-mediaquerylist-matches
diff --git a/Userland/Libraries/LibWeb/CSS/MediaQueryList.h b/Userland/Libraries/LibWeb/CSS/MediaQueryList.h
index 117da92d1b..45c2caf099 100644
--- a/Userland/Libraries/LibWeb/CSS/MediaQueryList.h
+++ b/Userland/Libraries/LibWeb/CSS/MediaQueryList.h
@@ -9,6 +9,7 @@
#include <AK/Forward.h>
#include <AK/RefCounted.h>
#include <LibWeb/Bindings/Wrappable.h>
+#include <LibWeb/CSS/MediaQuery.h>
#include <LibWeb/DOM/EventTarget.h>
#include <LibWeb/Forward.h>
@@ -26,9 +27,9 @@ public:
using RefCounted::ref;
using RefCounted::unref;
- static NonnullRefPtr<MediaQueryList> create(DOM::Document& document, String media)
+ static NonnullRefPtr<MediaQueryList> create(DOM::Document& document, NonnullRefPtrVector<MediaQuery>&& media_queries)
{
- return adopt_ref(*new MediaQueryList(document, move(media)));
+ return adopt_ref(*new MediaQueryList(document, move(media_queries)));
}
virtual ~MediaQueryList() override;
@@ -48,10 +49,10 @@ public:
HTML::EventHandler onchange();
private:
- MediaQueryList(DOM::Document&, String);
+ MediaQueryList(DOM::Document&, NonnullRefPtrVector<MediaQuery>&&);
DOM::Document& m_document;
- String m_media;
+ NonnullRefPtrVector<MediaQuery> m_media;
};
}