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

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

Issue 396283004: Make the MediaQueryList listener an EventListener (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: argh, forgot a --reset-results Created 6 years, 5 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.h
diff --git a/Source/core/css/MediaQueryList.h b/Source/core/css/MediaQueryList.h
index 8d85c5bb391f520480b53f4810b7a1f76b5976a2..3411ded1335c61ce66713e12a6bad0ec8357c016 100644
--- a/Source/core/css/MediaQueryList.h
+++ b/Source/core/css/MediaQueryList.h
@@ -20,6 +20,7 @@
#ifndef MediaQueryList_h
#define MediaQueryList_h
+#include "core/events/EventTarget.h"
#include "platform/heap/Handle.h"
#include "wtf/Forward.h"
#include "wtf/RefCounted.h"
@@ -27,6 +28,7 @@
namespace WebCore {
+class Document;
class MediaQueryListListener;
class MediaQueryEvaluator;
class MediaQueryMatcher;
@@ -37,30 +39,44 @@ class MediaQuerySet;
// retrieve the current value of the given media query and to add/remove listeners that
// will be called whenever the value of the query changes.
-class MediaQueryList FINAL : public RefCountedWillBeGarbageCollectedFinalized<MediaQueryList> {
+class MediaQueryList FINAL : public RefCountedWillBeGarbageCollectedFinalized<MediaQueryList>, public EventTargetWithInlineData {
+ REFCOUNTED_EVENT_TARGET(MediaQueryList);
+ WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MediaQueryList);
public:
- static PassRefPtrWillBeRawPtr<MediaQueryList> create(PassRefPtrWillBeRawPtr<MediaQueryMatcher>, PassRefPtrWillBeRawPtr<MediaQuerySet>);
+ static PassRefPtrWillBeRawPtr<MediaQueryList> create(PassRefPtrWillBeRawPtr<MediaQueryMatcher>, PassRefPtrWillBeRawPtr<MediaQuerySet>, Document*);
virtual ~MediaQueryList();
String media() const;
bool matches();
- void addListener(PassRefPtrWillBeRawPtr<MediaQueryListListener>);
- void removeListener(PassRefPtrWillBeRawPtr<MediaQueryListListener>);
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(change);
- void mediaFeaturesChanged(WillBeHeapVector<RefPtrWillBeMember<MediaQueryListListener> >* listenersToNotify);
+ // These two functions are provided for compatibility with JS code
+ // written before the change listener became a DOM event.
+ void addListener(PassRefPtrWillBeRawPtr<EventListener>);
+ void removeListener(PassRefPtrWillBeRawPtr<EventListener>);
+
+ void addMediaQueryListListener(PassRefPtrWillBeRawPtr<MediaQueryListListener>);
+ void removeMediaQueryListListener(PassRefPtrWillBeRawPtr<MediaQueryListListener>);
+
+ // Will return true if a DOM event should be scheduled.
+ bool mediaFeaturesChanged(WillBeHeapVector<RefPtrWillBeMember<MediaQueryListListener> >* listenersToNotify);
void trace(Visitor*);
void documentDetached();
+ virtual const AtomicString& interfaceName() const OVERRIDE;
+ virtual ExecutionContext* executionContext() const OVERRIDE;
+
private:
- MediaQueryList(PassRefPtrWillBeRawPtr<MediaQueryMatcher>, PassRefPtrWillBeRawPtr<MediaQuerySet>);
+ MediaQueryList(PassRefPtrWillBeRawPtr<MediaQueryMatcher>, PassRefPtrWillBeRawPtr<MediaQuerySet>, Document*);
bool updateMatches();
RefPtrWillBeMember<MediaQueryMatcher> m_matcher;
RefPtrWillBeMember<MediaQuerySet> m_media;
+ RawPtrWillBeMember<Document> m_document;
typedef WillBeHeapListHashSet<RefPtrWillBeMember<MediaQueryListListener> > ListenerList;
ListenerList m_listeners;
bool m_matchesDirty;

Powered by Google App Engine
This is Rietveld 408576698