Chromium Code Reviews| Index: Source/core/css/MediaQueryList.h |
| diff --git a/Source/core/css/MediaQueryList.h b/Source/core/css/MediaQueryList.h |
| index 73beebd28ff5289dc3eedde5af2fb7f117f28cf1..b4b11cbb99f5bd72a6d28abdee5ba8fb2bb12755 100644 |
| --- a/Source/core/css/MediaQueryList.h |
| +++ b/Source/core/css/MediaQueryList.h |
| @@ -39,16 +39,35 @@ class MediaQuerySet; |
| class MediaQueryList FINAL : public RefCountedWillBeGarbageCollectedFinalized<MediaQueryList> { |
| public: |
| + class Listener : public RefCountedWillBeGarbageCollectedFinalized<Listener> { |
|
esprehn
2014/07/01 00:01:06
This virtual abstraction seems like it could be a
cbiesinger
2014/07/01 00:12:09
It could. Want me to do that?
|
| + public: |
| + virtual ~Listener() { } |
| + virtual void mediaQueryChanged() = 0; |
| + virtual bool equals(Listener* other) { return this == other; } |
|
esprehn
2014/07/01 00:01:06
This shouldn't need to be virtual.
cbiesinger
2014/07/01 00:12:09
How so? The implementation for JS listeners needs
|
| + |
| + virtual MediaQueryListListener* isMediaQueryListListener() { return nullptr; } |
| + |
| + // Used to keep the MediaQueryList alive and registered with the MediaQueryMatcher |
| + // as long as the listener exists. |
| + void setMediaQueryList(MediaQueryList* query) { m_query = query; } |
| + void clearMediaQueryList() { m_query = nullptr; } |
| + |
| + void trace(Visitor* visitor) { visitor->trace(m_query); } |
| + protected: |
| + RefPtrWillBeMember<MediaQueryList> m_query; |
| + }; |
| + |
| static PassRefPtrWillBeRawPtr<MediaQueryList> create(PassRefPtrWillBeRawPtr<MediaQueryMatcher>, PassRefPtrWillBeRawPtr<MediaQuerySet>); |
| virtual ~MediaQueryList(); |
| String media() const; |
| bool matches(); |
| - void addListener(PassRefPtrWillBeRawPtr<MediaQueryListListener>); |
| - void removeListener(PassRefPtrWillBeRawPtr<MediaQueryListListener>); |
| + // These listeners will be called at requestAnimationFrame time. |
| + void addListener(PassRefPtrWillBeRawPtr<Listener>); |
| + void removeListener(PassRefPtrWillBeRawPtr<Listener>); |
| - void mediaFeaturesChanged(WillBeHeapVector<RefPtrWillBeMember<MediaQueryListListener> >* toNotify); |
| + void mediaFeaturesChanged(WillBeHeapVector<RefPtrWillBeMember<Listener> >* listenersToNotify); |
| void trace(Visitor*); |
| @@ -61,7 +80,7 @@ private: |
| RefPtrWillBeMember<MediaQueryMatcher> m_matcher; |
| RefPtrWillBeMember<MediaQuerySet> m_media; |
| - typedef WillBeHeapListHashSet<RefPtrWillBeMember<MediaQueryListListener> > ListenerList; |
| + typedef WillBeHeapListHashSet<RefPtrWillBeMember<Listener> > ListenerList; |
| ListenerList m_listeners; |
| bool m_matchesDirty; |
| bool m_matches; |