| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU Library General Public License | 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 | 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, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
| 18 */ | 18 */ |
| 19 | 19 |
| 20 #ifndef MediaQueryList_h | 20 #ifndef MediaQueryList_h |
| 21 #define MediaQueryList_h | 21 #define MediaQueryList_h |
| 22 | 22 |
| 23 #include "heap/Handle.h" |
| 23 #include "wtf/Forward.h" | 24 #include "wtf/Forward.h" |
| 24 #include "wtf/RefCounted.h" | 25 #include "wtf/RefCounted.h" |
| 25 #include "wtf/RefPtr.h" | 26 #include "wtf/RefPtr.h" |
| 26 | 27 |
| 27 namespace WebCore { | 28 namespace WebCore { |
| 28 | 29 |
| 29 class MediaQueryListListener; | 30 class MediaQueryListListener; |
| 30 class MediaQueryEvaluator; | 31 class MediaQueryEvaluator; |
| 31 class MediaQueryMatcher; | 32 class MediaQueryMatcher; |
| 32 class MediaQuerySet; | 33 class MediaQuerySet; |
| 33 | 34 |
| 34 // MediaQueryList interface is specified at http://dev.w3.org/csswg/cssom-view/#
the-mediaquerylist-interface | 35 // 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 // 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 listene
rs that | 37 // retrieve the current value of the given media query and to add/remove listene
rs that |
| 37 // will be called whenever the value of the query changes. | 38 // will be called whenever the value of the query changes. |
| 38 | 39 |
| 39 class MediaQueryList : public RefCounted<MediaQueryList> { | 40 class MediaQueryList : public RefCounted<MediaQueryList> { |
| 40 public: | 41 public: |
| 41 static PassRefPtr<MediaQueryList> create(PassRefPtr<MediaQueryMatcher>, Pass
RefPtr<MediaQuerySet>, bool); | 42 static PassRefPtr<MediaQueryList> create(PassRefPtr<MediaQueryMatcher>, Pass
RefPtrWillBeRawPtr<MediaQuerySet>, bool); |
| 42 ~MediaQueryList(); | 43 ~MediaQueryList(); |
| 43 | 44 |
| 44 String media() const; | 45 String media() const; |
| 45 bool matches(); | 46 bool matches(); |
| 46 | 47 |
| 47 void addListener(PassRefPtr<MediaQueryListListener>); | 48 void addListener(PassRefPtr<MediaQueryListListener>); |
| 48 void removeListener(PassRefPtr<MediaQueryListListener>); | 49 void removeListener(PassRefPtr<MediaQueryListListener>); |
| 49 | 50 |
| 50 void evaluate(MediaQueryEvaluator*, bool& notificationNeeded); | 51 void evaluate(MediaQueryEvaluator*, bool& notificationNeeded); |
| 51 | 52 |
| 52 private: | 53 private: |
| 53 MediaQueryList(PassRefPtr<MediaQueryMatcher>, PassRefPtr<MediaQuerySet>, boo
l matches); | 54 MediaQueryList(PassRefPtr<MediaQueryMatcher>, PassRefPtrWillBeRawPtr<MediaQu
erySet>, bool matches); |
| 54 void setMatches(bool); | 55 void setMatches(bool); |
| 55 | 56 |
| 56 RefPtr<MediaQueryMatcher> m_matcher; | 57 RefPtr<MediaQueryMatcher> m_matcher; |
| 57 RefPtr<MediaQuerySet> m_media; | 58 RefPtrWillBePersistent<MediaQuerySet> m_media; |
| 58 unsigned m_evaluationRound; // Indicates if the query has been evaluated aft
er the last style selector change. | 59 unsigned m_evaluationRound; // Indicates if the query has been evaluated aft
er the last style selector change. |
| 59 unsigned m_changeRound; // Used to know if the query has changed in the last
style selector change. | 60 unsigned m_changeRound; // Used to know if the query has changed in the last
style selector change. |
| 60 bool m_matches; | 61 bool m_matches; |
| 61 }; | 62 }; |
| 62 | 63 |
| 63 } | 64 } |
| 64 | 65 |
| 65 #endif // MediaQueryList_h | 66 #endif // MediaQueryList_h |
| OLD | NEW |