Serenity Operating System
at master 44 lines 1.2 kB view raw
1/* 2 * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org> 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7#pragma once 8 9#include <AK/Forward.h> 10#include <LibWeb/CSS/MediaQuery.h> 11#include <LibWeb/DOM/EventTarget.h> 12 13namespace Web::CSS { 14 15// 4.2. The MediaQueryList Interface, https://drafts.csswg.org/cssom-view/#the-mediaquerylist-interface 16class MediaQueryList final : public DOM::EventTarget { 17 WEB_PLATFORM_OBJECT(MediaQueryList, DOM::EventTarget); 18 19public: 20 static WebIDL::ExceptionOr<JS::NonnullGCPtr<MediaQueryList>> create(DOM::Document&, Vector<NonnullRefPtr<MediaQuery>>&&); 21 22 virtual ~MediaQueryList() override = default; 23 24 DeprecatedString media() const; 25 bool matches() const; 26 bool evaluate(); 27 28 void add_listener(DOM::IDLEventListener*); 29 void remove_listener(DOM::IDLEventListener*); 30 31 void set_onchange(WebIDL::CallbackType*); 32 WebIDL::CallbackType* onchange(); 33 34private: 35 MediaQueryList(DOM::Document&, Vector<NonnullRefPtr<MediaQuery>>&&); 36 37 virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; 38 virtual void visit_edges(Cell::Visitor&) override; 39 40 JS::NonnullGCPtr<DOM::Document> m_document; 41 Vector<NonnullRefPtr<MediaQuery>> m_media; 42}; 43 44}