| 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 // MediaQueryList interface is specified at http://dev.w3.org/csswg/cssom-view/#
the-mediaquerylist-interface | 40 // MediaQueryList interface is specified at http://dev.w3.org/csswg/cssom-view/#
the-mediaquerylist-interface |
| 41 // The objects of this class are returned by window.matchMedia. They may be used
to | 41 // The objects of this class are returned by window.matchMedia. They may be used
to |
| 42 // retrieve the current value of the given media query and to add/remove listene
rs that | 42 // retrieve the current value of the given media query and to add/remove listene
rs that |
| 43 // will be called whenever the value of the query changes. | 43 // will be called whenever the value of the query changes. |
| 44 | 44 |
| 45 class CORE_EXPORT MediaQueryList final : public EventTargetWithInlineData, publi
c ActiveScriptWrappable, public ActiveDOMObject { | 45 class CORE_EXPORT MediaQueryList final : public EventTargetWithInlineData, publi
c ActiveScriptWrappable, public ActiveDOMObject { |
| 46 REFCOUNTED_EVENT_TARGET(MediaQueryList); | 46 REFCOUNTED_EVENT_TARGET(MediaQueryList); |
| 47 DEFINE_WRAPPERTYPEINFO(); | 47 DEFINE_WRAPPERTYPEINFO(); |
| 48 USING_GARBAGE_COLLECTED_MIXIN(MediaQueryList); | 48 USING_GARBAGE_COLLECTED_MIXIN(MediaQueryList); |
| 49 public: | 49 public: |
| 50 static RawPtr<MediaQueryList> create(ExecutionContext*, RawPtr<MediaQueryMat
cher>, RawPtr<MediaQuerySet>); | 50 static MediaQueryList* create(ExecutionContext*, MediaQueryMatcher*, MediaQu
erySet*); |
| 51 ~MediaQueryList() override; | 51 ~MediaQueryList() override; |
| 52 | 52 |
| 53 String media() const; | 53 String media() const; |
| 54 bool matches(); | 54 bool matches(); |
| 55 | 55 |
| 56 DEFINE_ATTRIBUTE_EVENT_LISTENER(change); | 56 DEFINE_ATTRIBUTE_EVENT_LISTENER(change); |
| 57 | 57 |
| 58 // These two functions are provided for compatibility with JS code | 58 // These two functions are provided for compatibility with JS code |
| 59 // written before the change listener became a DOM event. | 59 // written before the change listener became a DOM event. |
| 60 void addDeprecatedListener(RawPtr<EventListener>); | 60 void addDeprecatedListener(EventListener*); |
| 61 void removeDeprecatedListener(RawPtr<EventListener>); | 61 void removeDeprecatedListener(EventListener*); |
| 62 | 62 |
| 63 // C++ code can use these functions to listen to changes instead of having t
o use DOM event listeners. | 63 // C++ code can use these functions to listen to changes instead of having t
o use DOM event listeners. |
| 64 void addListener(RawPtr<MediaQueryListListener>); | 64 void addListener(MediaQueryListListener*); |
| 65 void removeListener(RawPtr<MediaQueryListListener>); | 65 void removeListener(MediaQueryListListener*); |
| 66 | 66 |
| 67 // Will return true if a DOM event should be scheduled. | 67 // Will return true if a DOM event should be scheduled. |
| 68 bool mediaFeaturesChanged(HeapVector<Member<MediaQueryListListener>>* listen
ersToNotify); | 68 bool mediaFeaturesChanged(HeapVector<Member<MediaQueryListListener>>* listen
ersToNotify); |
| 69 | 69 |
| 70 DECLARE_VIRTUAL_TRACE(); | 70 DECLARE_VIRTUAL_TRACE(); |
| 71 | 71 |
| 72 // From ActiveScriptWrappable | 72 // From ActiveScriptWrappable |
| 73 bool hasPendingActivity() const final; | 73 bool hasPendingActivity() const final; |
| 74 | 74 |
| 75 // From ActiveDOMObject | 75 // From ActiveDOMObject |
| 76 void stop() override; | 76 void stop() override; |
| 77 | 77 |
| 78 const AtomicString& interfaceName() const override; | 78 const AtomicString& interfaceName() const override; |
| 79 ExecutionContext* getExecutionContext() const override; | 79 ExecutionContext* getExecutionContext() const override; |
| 80 | 80 |
| 81 private: | 81 private: |
| 82 MediaQueryList(ExecutionContext*, RawPtr<MediaQueryMatcher>, RawPtr<MediaQue
rySet>); | 82 MediaQueryList(ExecutionContext*, MediaQueryMatcher*, MediaQuerySet*); |
| 83 | 83 |
| 84 bool updateMatches(); | 84 bool updateMatches(); |
| 85 | 85 |
| 86 Member<MediaQueryMatcher> m_matcher; | 86 Member<MediaQueryMatcher> m_matcher; |
| 87 Member<MediaQuerySet> m_media; | 87 Member<MediaQuerySet> m_media; |
| 88 using ListenerList = HeapListHashSet<Member<MediaQueryListListener>>; | 88 using ListenerList = HeapListHashSet<Member<MediaQueryListListener>>; |
| 89 ListenerList m_listeners; | 89 ListenerList m_listeners; |
| 90 bool m_matchesDirty; | 90 bool m_matchesDirty; |
| 91 bool m_matches; | 91 bool m_matches; |
| 92 }; | 92 }; |
| 93 | 93 |
| 94 } // namespace blink | 94 } // namespace blink |
| 95 | 95 |
| 96 #endif // MediaQueryList_h | 96 #endif // MediaQueryList_h |
| OLD | NEW |