#pragma once
#include "ActiveDOMObject.h"
#include "EventTarget.h"
#include "MediaList.h"
#include "MediaQueryEvaluator.h"
#include "MediaQueryMatcher.h"
namespace WebCore {
class MediaQueryList final : public RefCounted<MediaQueryList>, public EventTargetWithInlineData, public CanMakeWeakPtr<MediaQueryList>, public ActiveDOMObject {
WTF_MAKE_ISO_ALLOCATED(MediaQueryList);
public:
static Ref<MediaQueryList> create(Document&, MediaQueryMatcher&, Ref<MediaQuerySet>&&, bool matches);
~MediaQueryList();
String media() const;
bool matches();
void addListener(RefPtr<EventListener>&&);
void removeListener(RefPtr<EventListener>&&);
void evaluate(MediaQueryEvaluator&, bool& notificationNeeded);
void detachFromMatcher();
using RefCounted::ref;
using RefCounted::deref;
private:
MediaQueryList(Document&, MediaQueryMatcher&, Ref<MediaQuerySet>&&, bool matches);
void setMatches(bool);
EventTargetInterface eventTargetInterface() const final { return MediaQueryListEventTargetInterfaceType; }
ScriptExecutionContext* scriptExecutionContext() const final { return ContextDestructionObserver::scriptExecutionContext(); }
void refEventTarget() final { ref(); }
void derefEventTarget() final { deref(); }
void eventListenersDidChange() final;
const char* activeDOMObjectName() const final;
bool virtualHasPendingActivity() const final;
RefPtr<MediaQueryMatcher> m_matcher;
Ref<MediaQuerySet> m_media;
unsigned m_evaluationRound; unsigned m_changeRound; bool m_matches;
bool m_hasChangeEventListener { false };
};
}