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 29 matching lines...) Expand all Loading... |
40 // The objects of this class are returned by window.matchMedia. They may be used
to | 40 // The objects of this class are returned by window.matchMedia. They may be used
to |
41 // retrieve the current value of the given media query and to add/remove listene
rs that | 41 // retrieve the current value of the given media query and to add/remove listene
rs that |
42 // will be called whenever the value of the query changes. | 42 // will be called whenever the value of the query changes. |
43 | 43 |
44 class CORE_EXPORT MediaQueryList final : public EventTargetWithInlineData, publi
c RefCountedWillBeNoBase<MediaQueryList>, public ActiveDOMObject { | 44 class CORE_EXPORT MediaQueryList final : public EventTargetWithInlineData, publi
c RefCountedWillBeNoBase<MediaQueryList>, public ActiveDOMObject { |
45 REFCOUNTED_EVENT_TARGET(MediaQueryList); | 45 REFCOUNTED_EVENT_TARGET(MediaQueryList); |
46 DEFINE_WRAPPERTYPEINFO(); | 46 DEFINE_WRAPPERTYPEINFO(); |
47 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MediaQueryList); | 47 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MediaQueryList); |
48 public: | 48 public: |
49 static PassRefPtrWillBeRawPtr<MediaQueryList> create(ExecutionContext*, Pass
RefPtrWillBeRawPtr<MediaQueryMatcher>, PassRefPtrWillBeRawPtr<MediaQuerySet>); | 49 static PassRefPtrWillBeRawPtr<MediaQueryList> create(ExecutionContext*, Pass
RefPtrWillBeRawPtr<MediaQueryMatcher>, PassRefPtrWillBeRawPtr<MediaQuerySet>); |
50 virtual ~MediaQueryList(); | 50 ~MediaQueryList() override; |
51 | 51 |
52 String media() const; | 52 String media() const; |
53 bool matches(); | 53 bool matches(); |
54 | 54 |
55 DEFINE_ATTRIBUTE_EVENT_LISTENER(change); | 55 DEFINE_ATTRIBUTE_EVENT_LISTENER(change); |
56 | 56 |
57 // These two functions are provided for compatibility with JS code | 57 // These two functions are provided for compatibility with JS code |
58 // written before the change listener became a DOM event. | 58 // written before the change listener became a DOM event. |
59 void addDeprecatedListener(PassRefPtr<EventListener>); | 59 void addDeprecatedListener(PassRefPtr<EventListener>); |
60 void removeDeprecatedListener(PassRefPtr<EventListener>); | 60 void removeDeprecatedListener(PassRefPtr<EventListener>); |
61 | 61 |
62 // C++ code can use these functions to listen to changes instead of having t
o use DOM event listeners. | 62 // C++ code can use these functions to listen to changes instead of having t
o use DOM event listeners. |
63 void addListener(PassRefPtrWillBeRawPtr<MediaQueryListListener>); | 63 void addListener(PassRefPtrWillBeRawPtr<MediaQueryListListener>); |
64 void removeListener(PassRefPtrWillBeRawPtr<MediaQueryListListener>); | 64 void removeListener(PassRefPtrWillBeRawPtr<MediaQueryListListener>); |
65 | 65 |
66 // Will return true if a DOM event should be scheduled. | 66 // Will return true if a DOM event should be scheduled. |
67 bool mediaFeaturesChanged(WillBeHeapVector<RefPtrWillBeMember<MediaQueryList
Listener>>* listenersToNotify); | 67 bool mediaFeaturesChanged(WillBeHeapVector<RefPtrWillBeMember<MediaQueryList
Listener>>* listenersToNotify); |
68 | 68 |
69 DECLARE_VIRTUAL_TRACE(); | 69 DECLARE_VIRTUAL_TRACE(); |
70 | 70 |
71 // From ActiveDOMObject | 71 // From ActiveDOMObject |
72 virtual bool hasPendingActivity() const override; | 72 bool hasPendingActivity() const override; |
73 virtual void stop() override; | 73 void stop() override; |
74 | 74 |
75 virtual const AtomicString& interfaceName() const override; | 75 const AtomicString& interfaceName() const override; |
76 virtual ExecutionContext* executionContext() const override; | 76 ExecutionContext* executionContext() const override; |
77 | 77 |
78 private: | 78 private: |
79 MediaQueryList(ExecutionContext*, PassRefPtrWillBeRawPtr<MediaQueryMatcher>,
PassRefPtrWillBeRawPtr<MediaQuerySet>); | 79 MediaQueryList(ExecutionContext*, PassRefPtrWillBeRawPtr<MediaQueryMatcher>,
PassRefPtrWillBeRawPtr<MediaQuerySet>); |
80 | 80 |
81 bool updateMatches(); | 81 bool updateMatches(); |
82 | 82 |
83 RefPtrWillBeMember<MediaQueryMatcher> m_matcher; | 83 RefPtrWillBeMember<MediaQueryMatcher> m_matcher; |
84 RefPtrWillBeMember<MediaQuerySet> m_media; | 84 RefPtrWillBeMember<MediaQuerySet> m_media; |
85 typedef WillBeHeapListHashSet<RefPtrWillBeMember<MediaQueryListListener>> Li
stenerList; | 85 typedef WillBeHeapListHashSet<RefPtrWillBeMember<MediaQueryListListener>> Li
stenerList; |
86 ListenerList m_listeners; | 86 ListenerList m_listeners; |
87 bool m_matchesDirty; | 87 bool m_matchesDirty; |
88 bool m_matches; | 88 bool m_matches; |
89 }; | 89 }; |
90 | 90 |
91 } // namespace blink | 91 } // namespace blink |
92 | 92 |
93 #endif // MediaQueryList_h | 93 #endif // MediaQueryList_h |
OLD | NEW |