ladybird/Userland/Libraries/LibWeb/CSS/MediaQueryList.h
Andreas Kling 6f433c8656 LibWeb+LibJS: Make the EventTarget hierarchy (incl. DOM) GC-allocated
This is a monster patch that turns all EventTargets into GC-allocated
PlatformObjects. Their C++ wrapper classes are removed, and the LibJS
garbage collector is now responsible for their lifetimes.

There's a fair amount of hacks and band-aids in this patch, and we'll
have a lot of cleanup to do after this.
2022-09-06 00:27:09 +02:00

49 lines
1.3 KiB
C++

/*
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Forward.h>
#include <AK/RefCounted.h>
#include <AK/Weakable.h>
#include <LibWeb/Bindings/Wrappable.h>
#include <LibWeb/CSS/MediaQuery.h>
#include <LibWeb/DOM/EventTarget.h>
#include <LibWeb/Forward.h>
namespace Web::CSS {
// 4.2. The MediaQueryList Interface, https://drafts.csswg.org/cssom-view/#the-mediaquerylist-interface
class MediaQueryList final : public DOM::EventTarget {
WEB_PLATFORM_OBJECT(MediaQueryList, DOM::EventTarget);
public:
static JS::NonnullGCPtr<MediaQueryList> create(DOM::Document&, NonnullRefPtrVector<MediaQuery>&&);
virtual ~MediaQueryList() override = default;
String media() const;
bool matches() const;
bool evaluate();
void add_listener(DOM::IDLEventListener*);
void remove_listener(DOM::IDLEventListener*);
void set_onchange(Bindings::CallbackType*);
Bindings::CallbackType* onchange();
private:
MediaQueryList(DOM::Document&, NonnullRefPtrVector<MediaQuery>&&);
virtual void visit_edges(Cell::Visitor&) override;
JS::NonnullGCPtr<DOM::Document> m_document;
NonnullRefPtrVector<MediaQuery> m_media;
};
}
WRAPPER_HACK(MediaQueryList, Web::CSS)