2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
20 #ifndef MediaQueryList_h
21 #define MediaQueryList_h
23 #include <wtf/Forward.h>
24 #include <wtf/RefCounted.h>
25 #include <wtf/RefPtr.h>
30 class MediaQueryListListener;
31 class MediaQueryEvaluator;
32 class MediaQueryMatcher;
34 // MediaQueryList interface is specified at http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface
35 // The objects of this class are returned by window.matchMedia. They may be used to
36 // retrieve the current value of the given media query and to add/remove listeners that
37 // will be called whenever the value of the query changes.
39 class MediaQueryList : public RefCounted<MediaQueryList> {
41 static PassRefPtr<MediaQueryList> create(PassRefPtr<MediaQueryMatcher>, PassRefPtr<MediaList>, bool);
47 void addListener(PassRefPtr<MediaQueryListListener>);
48 void removeListener(PassRefPtr<MediaQueryListListener>);
50 void evaluate(MediaQueryEvaluator*, bool& notificationNeeded);
53 MediaQueryList(PassRefPtr<MediaQueryMatcher>, PassRefPtr<MediaList>, bool matches);
54 void setMatches(bool);
56 RefPtr<MediaQueryMatcher> m_matcher;
57 RefPtr<MediaList> m_media;
58 unsigned m_evaluationRound; // Indicates if the query has been evaluated after the last style selector change.
59 unsigned m_changeRound; // Used to know if the query has changed in the last style selector change.
65 #endif // MediaQueryList_h