MediaQueryMatcher.h [plain text]
#ifndef MediaQueryMatcher_h
#define MediaQueryMatcher_h
#include "ScriptState.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 : public RefCounted<MediaQueryMatcher> {
public:
static PassRefPtr<MediaQueryMatcher> create(Document* document) { return adoptRef(new MediaQueryMatcher(document)); }
~MediaQueryMatcher();
void documentDestroyed();
void addListener(PassRefPtr<MediaQueryListListener>, PassRefPtr<MediaQueryList>);
void removeListener(MediaQueryListListener*, MediaQueryList*);
PassRefPtr<MediaQueryList> matchMedia(const String&);
unsigned evaluationRound() const { return m_evaluationRound; }
void styleResolverChanged();
bool evaluate(const MediaQuerySet*);
private:
class Listener {
public:
Listener(PassRefPtr<MediaQueryListListener>, PassRefPtr<MediaQueryList>);
~Listener();
void evaluate(ScriptState*, MediaQueryEvaluator*);
MediaQueryListListener* listener() { return m_listener.get(); }
MediaQueryList* query() { return m_query.get(); }
private:
RefPtr<MediaQueryListListener> m_listener;
RefPtr<MediaQueryList> m_query;
};
MediaQueryMatcher(Document*);
PassOwnPtr<MediaQueryEvaluator> prepareEvaluator() const;
String mediaType() const;
Document* m_document;
Vector<OwnPtr<Listener> > m_listeners;
unsigned m_evaluationRound;
};
}
#endif // MediaQueryMatcher_h