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

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

Issue 396283004: Make the MediaQueryList listener an EventListener (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebased Created 6 years, 4 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/MediaQueryListEvent.h
diff --git a/Source/core/css/MediaQueryListEvent.h b/Source/core/css/MediaQueryListEvent.h
new file mode 100644
index 0000000000000000000000000000000000000000..865ac47f73160fb389fd07315a8ca10543b58b50
--- /dev/null
+++ b/Source/core/css/MediaQueryListEvent.h
@@ -0,0 +1,71 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MediaQueryListEvent_h
+#define MediaQueryListEvent_h
+
+#include "core/events/Event.h"
+
+namespace blink {
+
+struct MediaQueryListEventInit : public EventInit {
+ MediaQueryListEventInit() : matches(false) { }
+
+ String media;
+ bool matches;
+};
+
+class MediaQueryListEvent FINAL : public Event {
+public:
+ static PassRefPtrWillBeRawPtr<MediaQueryListEvent> create()
+ {
+ return adoptRefWillBeNoop(new MediaQueryListEvent);
+ }
+
+ static PassRefPtrWillBeRawPtr<MediaQueryListEvent> create(const String& media, bool matches)
+ {
+ return adoptRefWillBeNoop(new MediaQueryListEvent(media, matches));
+ }
+
+ static PassRefPtrWillBeRawPtr<MediaQueryListEvent> create(const AtomicString& eventType, const MediaQueryListEventInit& initializer)
+ {
+ return adoptRefWillBeNoop(new MediaQueryListEvent(eventType, initializer));
+ }
+
+ const String& media() const { return m_media; }
+ bool matches() const { return m_matches; }
esprehn 2014/08/13 22:48:36 return m_mediaList->matches; and make them live.
cbiesinger 2014/08/16 00:00:47 Done.
+
+ virtual const AtomicString& interfaceName() const OVERRIDE { return EventNames::MediaQueryListEvent; }
+
+ virtual void trace(Visitor* visitor) OVERRIDE { Event::trace(visitor); }
+
+private:
+ MediaQueryListEvent()
+ {
esprehn 2014/08/13 22:48:36 m_matches(false)
cbiesinger 2014/08/16 00:00:47 Done.
+ ScriptWrappable::init(this);
+ }
+
+ MediaQueryListEvent(const String& media, bool matches)
+ : Event(EventTypeNames::change, false, false)
+ , m_media(media)
+ , m_matches(matches)
+ {
+ ScriptWrappable::init(this);
+ }
+
+ MediaQueryListEvent(const AtomicString& eventType, const MediaQueryListEventInit& initializer)
+ : Event(eventType, initializer)
+ , m_media(initializer.media)
+ , m_matches(initializer.matches)
+ {
+ ScriptWrappable::init(this);
+ }
+
+ String m_media;
+ bool m_matches;
+};
+
+} // namespace blink
+
+#endif // MediaQueryListEvent_h

Powered by Google App Engine
This is Rietveld 408576698