mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:27:35 +00:00
LibWeb: Make MediaQueryList store MediaQueries instead of a String
This commit is contained in:
parent
5bbbdb81dc
commit
f1af136925
3 changed files with 11 additions and 8 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <LibGUI/DisplayLink.h>
|
||||
#include <LibJS/Runtime/FunctionObject.h>
|
||||
#include <LibWeb/CSS/Parser/Parser.h>
|
||||
#include <LibWeb/CSS/ResolvedCSSStyleDeclaration.h>
|
||||
#include <LibWeb/Crypto/Crypto.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
|
@ -261,7 +262,7 @@ NonnullRefPtr<CSS::CSSStyleDeclaration> Window::get_computed_style(DOM::Element&
|
|||
|
||||
NonnullRefPtr<CSS::MediaQueryList> Window::match_media(String media)
|
||||
{
|
||||
return CSS::MediaQueryList::create(associated_document(), move(media));
|
||||
return CSS::MediaQueryList::create(associated_document(), parse_media_query_list(CSS::ParsingContext(associated_document()), media));
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/cssom-view/#dom-window-scrollx
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue