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

Unified Diff: Source/core/css/MediaQueryListListener.h

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/MediaQueryListListener.h
diff --git a/Source/core/css/MediaQueryListListener.h b/Source/core/css/MediaQueryListListener.h
index d9299b0b3d650dd345c4febcb4dc8022ea23a282..ba2877695a1c4ee651a81a56e132d6378ff70b7a 100644
--- a/Source/core/css/MediaQueryListListener.h
+++ b/Source/core/css/MediaQueryListListener.h
@@ -22,6 +22,7 @@
#include "bindings/v8/ScriptState.h"
#include "bindings/v8/ScriptValue.h"
+#include "core/css/MediaQueryList.h"
#include "platform/heap/Handle.h"
#include "wtf/RefCounted.h"
@@ -31,7 +32,7 @@ class MediaQueryList;
// See http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface
// FIXME: MediaQueryListListener should be implemented using callback interface
-class MediaQueryListListener : public RefCountedWillBeGarbageCollectedFinalized<MediaQueryListListener> {
+class MediaQueryListListener : public MediaQueryList::Listener {
public:
static PassRefPtrWillBeRawPtr<MediaQueryListListener> create(ScriptState* scriptState, const ScriptValue& value)
{
@@ -41,21 +42,23 @@ public:
}
void call();
- // 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; }
+ virtual void mediaQueryChanged() { call(); }
+ virtual MediaQueryListListener* isMediaQueryListListener() { return this; }
bool operator==(const MediaQueryListListener& other) const { return m_function == other.m_function; }
-
- void trace(Visitor* visitor) { visitor->trace(m_query); }
+ virtual bool equals(MediaQueryList::Listener* other)
+ {
+ MediaQueryListListener* otherListener = other->isMediaQueryListListener();
esprehn 2014/07/01 00:01:06 "is" methods shouldn't return a pointer.
cbiesinger 2014/07/01 00:12:09 Can I rename it "to" even without adding an assert
+ if (!otherListener)
+ return false;
+ return *this == *otherListener;
+ }
private:
MediaQueryListListener(ScriptState*, const ScriptValue&);
RefPtr<ScriptState> m_scriptState;
ScriptValue m_function;
- RefPtrWillBeMember<MediaQueryList> m_query;
};
}

Powered by Google App Engine
This is Rietveld 408576698