| 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 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "platform/heap/Handle.h" | 28 #include "platform/heap/Handle.h" |
| 29 #include "wtf/Forward.h" | 29 #include "wtf/Forward.h" |
| 30 | 30 |
| 31 namespace blink { | 31 namespace blink { |
| 32 | 32 |
| 33 class ExecutionContext; | 33 class ExecutionContext; |
| 34 class MediaQueryListListener; | 34 class MediaQueryListListener; |
| 35 class MediaQueryMatcher; | 35 class MediaQueryMatcher; |
| 36 class MediaQuerySet; | 36 class MediaQuerySet; |
| 37 | 37 |
| 38 // MediaQueryList interface is specified at http://dev.w3.org/csswg/cssom-view/#
the-mediaquerylist-interface | 38 // MediaQueryList interface is specified at |
| 39 // The objects of this class are returned by window.matchMedia. They may be used
to | 39 // http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface |
| 40 // retrieve the current value of the given media query and to add/remove listene
rs that | 40 // The objects of this class are returned by window.matchMedia. They may be used |
| 41 // will be called whenever the value of the query changes. | 41 // to retrieve the current value of the given media query and to add/remove |
| 42 // listeners that will be called whenever the value of the query changes. |
| 42 | 43 |
| 43 class CORE_EXPORT MediaQueryList final : public EventTargetWithInlineData, | 44 class CORE_EXPORT MediaQueryList final : public EventTargetWithInlineData, |
| 44 public ActiveScriptWrappable, | 45 public ActiveScriptWrappable, |
| 45 public ActiveDOMObject { | 46 public ActiveDOMObject { |
| 46 DEFINE_WRAPPERTYPEINFO(); | 47 DEFINE_WRAPPERTYPEINFO(); |
| 47 USING_GARBAGE_COLLECTED_MIXIN(MediaQueryList); | 48 USING_GARBAGE_COLLECTED_MIXIN(MediaQueryList); |
| 48 WTF_MAKE_NONCOPYABLE(MediaQueryList); | 49 WTF_MAKE_NONCOPYABLE(MediaQueryList); |
| 49 | 50 |
| 50 public: | 51 public: |
| 51 static MediaQueryList* create(ExecutionContext*, | 52 static MediaQueryList* create(ExecutionContext*, |
| 52 MediaQueryMatcher*, | 53 MediaQueryMatcher*, |
| 53 MediaQuerySet*); | 54 MediaQuerySet*); |
| 54 ~MediaQueryList() override; | 55 ~MediaQueryList() override; |
| 55 | 56 |
| 56 String media() const; | 57 String media() const; |
| 57 bool matches(); | 58 bool matches(); |
| 58 | 59 |
| 59 DEFINE_ATTRIBUTE_EVENT_LISTENER(change); | 60 DEFINE_ATTRIBUTE_EVENT_LISTENER(change); |
| 60 | 61 |
| 61 // These two functions are provided for compatibility with JS code | 62 // These two functions are provided for compatibility with JS code |
| 62 // written before the change listener became a DOM event. | 63 // written before the change listener became a DOM event. |
| 63 void addDeprecatedListener(EventListener*); | 64 void addDeprecatedListener(EventListener*); |
| 64 void removeDeprecatedListener(EventListener*); | 65 void removeDeprecatedListener(EventListener*); |
| 65 | 66 |
| 66 // C++ code can use these functions to listen to changes instead of having to
use DOM event listeners. | 67 // C++ code can use these functions to listen to changes instead of having to |
| 68 // use DOM event listeners. |
| 67 void addListener(MediaQueryListListener*); | 69 void addListener(MediaQueryListListener*); |
| 68 void removeListener(MediaQueryListListener*); | 70 void removeListener(MediaQueryListListener*); |
| 69 | 71 |
| 70 // Will return true if a DOM event should be scheduled. | 72 // Will return true if a DOM event should be scheduled. |
| 71 bool mediaFeaturesChanged( | 73 bool mediaFeaturesChanged( |
| 72 HeapVector<Member<MediaQueryListListener>>* listenersToNotify); | 74 HeapVector<Member<MediaQueryListListener>>* listenersToNotify); |
| 73 | 75 |
| 74 DECLARE_VIRTUAL_TRACE(); | 76 DECLARE_VIRTUAL_TRACE(); |
| 75 | 77 |
| 76 // From ScriptWrappable | 78 // From ScriptWrappable |
| (...skipping 14 matching lines...) Expand all Loading... |
| 91 Member<MediaQuerySet> m_media; | 93 Member<MediaQuerySet> m_media; |
| 92 using ListenerList = HeapListHashSet<Member<MediaQueryListListener>>; | 94 using ListenerList = HeapListHashSet<Member<MediaQueryListListener>>; |
| 93 ListenerList m_listeners; | 95 ListenerList m_listeners; |
| 94 bool m_matchesDirty; | 96 bool m_matchesDirty; |
| 95 bool m_matches; | 97 bool m_matches; |
| 96 }; | 98 }; |
| 97 | 99 |
| 98 } // namespace blink | 100 } // namespace blink |
| 99 | 101 |
| 100 #endif // MediaQueryList_h | 102 #endif // MediaQueryList_h |
| OLD | NEW |