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

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: rebased 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 52c73ef0a7ec4f39b30c8a495257824be1a3d9cb..a5e43bb763191f61495ad5c4d6c00cb1af007252 100644
--- a/Source/core/css/MediaQueryList.h
+++ b/Source/core/css/MediaQueryList.h
@@ -21,6 +21,7 @@
#define MediaQueryList_h
#include "core/dom/ActiveDOMObject.h"
+#include "core/events/EventTarget.h"
#include "platform/heap/Handle.h"
#include "wtf/Forward.h"
#include "wtf/RefCounted.h"
@@ -28,6 +29,7 @@
namespace blink {
+class Document;
class ExecutionContext;
class MediaQueryListListener;
class MediaQueryEvaluator;
@@ -39,7 +41,11 @@ 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>, public ActiveDOMObject {
+class MediaQueryList FINAL : public RefCountedWillBeGarbageCollectedFinalized<MediaQueryList>, public EventTargetWithInlineData, public ActiveDOMObject {
+#if !ENABLE_OILPAN
+ REFCOUNTED_EVENT_TARGET(MediaQueryList);
haraken 2014/07/20 05:14:49 You can use DEFINE_EVENT_TARGET_REFCOUNTING_WILL_B
cbiesinger 2014/07/21 22:07:19 Hm... then I'd have to duplicate the superclass na
haraken 2014/07/22 01:30:12 We normally duplicate the superclass name... proba
+#endif
+ WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MediaQueryList);
public:
static PassRefPtrWillBeRawPtr<MediaQueryList> create(ExecutionContext*, PassRefPtrWillBeRawPtr<MediaQueryMatcher>, PassRefPtrWillBeRawPtr<MediaQuerySet>);
virtual ~MediaQueryList();
@@ -47,10 +53,18 @@ public:
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(PassRefPtr<EventListener>);
+ void removeListener(PassRefPtr<EventListener>);
haraken 2014/07/20 05:14:49 Shall we rename these methods to addDeprecatedList
cbiesinger 2014/07/21 22:07:19 That's a great suggestion! Thanks, done.
+
+ 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*);
@@ -58,6 +72,9 @@ public:
virtual bool hasPendingActivity() const OVERRIDE;
virtual void stop() OVERRIDE;
+ virtual const AtomicString& interfaceName() const OVERRIDE;
+ virtual ExecutionContext* executionContext() const OVERRIDE;
+
private:
MediaQueryList(ExecutionContext*, PassRefPtrWillBeRawPtr<MediaQueryMatcher>, PassRefPtrWillBeRawPtr<MediaQuerySet>);

Powered by Google App Engine
This is Rietveld 408576698