#ifndef MediaQueryMatcher_h
#define MediaQueryMatcher_h
#include "bindings/v8/ScriptState.h"
#include "heap/Handle.h"
#include "wtf/Forward.h"
#include "wtf/RefCounted.h"
#include "wtf/Vector.h"
namespace WebCore {
class Document;
class MediaQueryList;
class MediaQueryListListener;
class MediaQueryEvaluator;
class MediaQuerySet;
class MediaQueryMatcher FINAL : public RefCountedWillBeGarbageCollected<MediaQueryMatcher> {
DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(MediaQueryMatcher);
public:
static PassRefPtrWillBeRawPtr<MediaQueryMatcher> create(Document* document) { return adoptRefWillBeNoop(new MediaQueryMatcher(document)); }
void documentDestroyed();
void addListener(PassRefPtrWillBeRawPtr<MediaQueryListListener>, PassRefPtrWillBeRawPtr<MediaQueryList>);
void removeListener(MediaQueryListListener*, MediaQueryList*);
PassRefPtrWillBeRawPtr<MediaQueryList> matchMedia(const String&);
unsigned evaluationRound() const { return m_evaluationRound; }
void styleResolverChanged();
bool evaluate(const MediaQuerySet*);
void trace(Visitor*);
private:
class Listener FINAL : public NoBaseWillBeGarbageCollected<Listener> {
public:
Listener(PassRefPtrWillBeRawPtr<MediaQueryListListener>, PassRefPtrWillBeRawPtr<MediaQueryList>);
void evaluate(ScriptState*, MediaQueryEvaluator*);
MediaQueryListListener* listener() { return m_listener.get(); }
MediaQueryList* query() { return m_query.get(); }
void trace(Visitor*);
private:
RefPtrWillBeMember<MediaQueryListListener> m_listener;
RefPtrWillBeMember<MediaQueryList> m_query;
};
MediaQueryMatcher(Document*);
PassOwnPtr<MediaQueryEvaluator> prepareEvaluator() const;
AtomicString mediaType() const;
Document* m_document;
WillBeHeapVector<OwnPtrWillBeMember<Listener> > m_listeners;
unsigned m_evaluationRound;
};
}
#endif