Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(685)

Unified Diff: Source/core/css/MediaQueryList.cpp

Issue 337883003: Call media query change listeners asynchronously. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: tests fixed Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/css/MediaQueryList.cpp
diff --git a/Source/core/css/MediaQueryList.cpp b/Source/core/css/MediaQueryList.cpp
index fd55bd562cd84a0be5ef9fd317acd3f327b092b8..0fd6ec6bab1f1edaafe8ca4aa2506babecac060d 100644
--- a/Source/core/css/MediaQueryList.cpp
+++ b/Source/core/css/MediaQueryList.cpp
@@ -54,7 +54,7 @@ String MediaQueryList::media() const
return m_media->mediaText();
}
-void MediaQueryList::addListener(PassRefPtrWillBeRawPtr<MediaQueryListListener> listener)
+void MediaQueryList::addListener(PassRefPtrWillBeRawPtr<Listener> listener)
{
if (!listener)
return;
@@ -63,7 +63,7 @@ void MediaQueryList::addListener(PassRefPtrWillBeRawPtr<MediaQueryListListener>
m_listeners.add(listener);
}
-void MediaQueryList::removeListener(PassRefPtrWillBeRawPtr<MediaQueryListListener> listener)
+void MediaQueryList::removeListener(PassRefPtrWillBeRawPtr<Listener> listener)
{
if (!listener)
return;
@@ -71,10 +71,10 @@ void MediaQueryList::removeListener(PassRefPtrWillBeRawPtr<MediaQueryListListene
RefPtrWillBeRawPtr<MediaQueryList> protect(this);
listener->clearMediaQueryList();
+ // We can't just use m_listeners.remove() here, because we get a new wrapper for the
+ // listener callback every time. We have to use MediaQueryListListener::operator==.
for (ListenerList::iterator it = m_listeners.begin(), end = m_listeners.end(); it != end; ++it) {
- // We can't just use m_listeners.remove() here, because we get a new wrapper for the
- // listener callback every time. We have to use MediaQueryListListener::operator==.
- if (**it == *listener.get()) {
+ if ((*it)->equals(listener.get())) {
m_listeners.remove(it);
break;
}
@@ -86,13 +86,13 @@ void MediaQueryList::documentDetached()
m_listeners.clear();
}
-void MediaQueryList::mediaFeaturesChanged(WillBeHeapVector<RefPtrWillBeMember<MediaQueryListListener> >* toNotify)
+void MediaQueryList::mediaFeaturesChanged(WillBeHeapVector<RefPtrWillBeMember<Listener> >* listenersToNotify)
{
m_matchesDirty = true;
if (!updateMatches())
return;
for (ListenerList::const_iterator it = m_listeners.begin(), end = m_listeners.end(); it != end; ++it) {
- toNotify->append(*it);
+ listenersToNotify->append(*it);
}
}

Powered by Google App Engine
This is Rietveld 408576698