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