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

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

Issue 361003004: Make it possible to subclass MediaQueryListListener (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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
« no previous file with comments | « no previous file | Source/core/css/MediaQueryListListener.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/MediaQueryListListener.h
diff --git a/Source/core/css/MediaQueryListListener.h b/Source/core/css/MediaQueryListListener.h
index d6630f03fa2e01f76f6e8e7ef0916d158a55942b..244da9886d35e7bfb808de9a242e07deba7d2e43 100644
--- a/Source/core/css/MediaQueryListListener.h
+++ b/Source/core/css/MediaQueryListListener.h
@@ -31,7 +31,9 @@ namespace WebCore {
class MediaQueryList;
// See http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface
-// FIXME: MediaQueryListListener should be implemented using callback interface
+// FIXME: For JS use this should become a DOM Event.
+// C++ listeners can subclass this class and override call(). The no-argument constructor
+// is provided for this purpose.
class MediaQueryListListener : public RefCountedWillBeGarbageCollectedFinalized<MediaQueryListListener> {
public:
static PassRefPtrWillBeRawPtr<MediaQueryListListener> create(ScriptState* scriptState, const ScriptValue& value)
@@ -40,25 +42,29 @@ public:
return nullptr;
return adoptRefWillBeNoop(new MediaQueryListListener(scriptState, value));
}
- ~MediaQueryListListener();
+ virtual ~MediaQueryListListener();
- void call();
+ virtual 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; }
- bool operator==(const MediaQueryListListener& other) const { return m_function == other.m_function; }
+ bool operator==(const MediaQueryListListener& other) const { return m_function.isNull() ? this == &other : m_function == other.m_function; }
void trace(Visitor* visitor) { visitor->trace(m_query); }
+protected:
+ MediaQueryListListener();
+
+ RefPtrWillBeMember<MediaQueryList> m_query;
+
private:
MediaQueryListListener(ScriptState*, const ScriptValue&);
RefPtr<ScriptState> m_scriptState;
ScriptValue m_function;
- RefPtrWillBeMember<MediaQueryList> m_query;
};
}
« no previous file with comments | « no previous file | Source/core/css/MediaQueryListListener.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698