2021-09-12 16:55:10 +01:00
|
|
|
/*
|
2022-08-22 18:31:08 +01:00
|
|
|
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
|
2021-09-12 16:55:10 +01:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/Forward.h>
|
2021-09-29 12:58:22 +01:00
|
|
|
#include <LibWeb/CSS/MediaQuery.h>
|
2021-09-12 16:55:10 +01:00
|
|
|
#include <LibWeb/DOM/EventTarget.h>
|
|
|
|
|
|
|
|
namespace Web::CSS {
|
|
|
|
|
|
|
|
// 4.2. The MediaQueryList Interface, https://drafts.csswg.org/cssom-view/#the-mediaquerylist-interface
|
2022-08-28 13:42:07 +02:00
|
|
|
class MediaQueryList final : public DOM::EventTarget {
|
|
|
|
WEB_PLATFORM_OBJECT(MediaQueryList, DOM::EventTarget);
|
2021-09-12 16:55:10 +01:00
|
|
|
|
|
|
|
public:
|
2023-02-14 19:49:09 +01:00
|
|
|
static WebIDL::ExceptionOr<JS::NonnullGCPtr<MediaQueryList>> create(DOM::Document&, NonnullRefPtrVector<MediaQuery>&&);
|
2021-09-12 16:55:10 +01:00
|
|
|
|
2022-03-14 13:21:51 -06:00
|
|
|
virtual ~MediaQueryList() override = default;
|
2021-09-12 16:55:10 +01:00
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString media() const;
|
2021-09-12 16:55:10 +01:00
|
|
|
bool matches() const;
|
2021-10-03 19:39:48 +01:00
|
|
|
bool evaluate();
|
2021-09-12 16:55:10 +01:00
|
|
|
|
2022-08-08 14:12:01 +02:00
|
|
|
void add_listener(DOM::IDLEventListener*);
|
|
|
|
void remove_listener(DOM::IDLEventListener*);
|
2021-09-13 00:18:28 +01:00
|
|
|
|
2022-09-24 16:02:41 +01:00
|
|
|
void set_onchange(WebIDL::CallbackType*);
|
|
|
|
WebIDL::CallbackType* onchange();
|
2021-10-01 01:33:10 +01:00
|
|
|
|
2021-09-12 16:55:10 +01:00
|
|
|
private:
|
2021-09-29 12:58:22 +01:00
|
|
|
MediaQueryList(DOM::Document&, NonnullRefPtrVector<MediaQuery>&&);
|
2021-09-12 16:55:10 +01:00
|
|
|
|
2023-01-28 12:33:35 -05:00
|
|
|
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
2022-08-28 13:42:07 +02:00
|
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
|
|
|
|
|
|
JS::NonnullGCPtr<DOM::Document> m_document;
|
2021-09-29 12:58:22 +01:00
|
|
|
NonnullRefPtrVector<MediaQuery> m_media;
|
2021-09-12 16:55:10 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|