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

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: . 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
« no previous file with comments | « Source/core/css/MediaQueryList.idl ('k') | Source/core/css/MediaQueryListEvent.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..708458e525f488e2a87417e0fb741d2fd4a20356
--- /dev/null
+++ b/Source/core/css/MediaQueryListEvent.h
@@ -0,0 +1,93 @@
+// 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/css/MediaQueryList.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(MediaQueryList* list)
+ {
+ return adoptRefWillBeNoop(new MediaQueryListEvent(list));
+ }
+
+ 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));
+ }
+
+ String media() const { return m_mediaQueryList ? m_mediaQueryList->media() : m_media; }
+ bool matches() const { return m_mediaQueryList ? m_mediaQueryList->matches() : m_matches; }
+
+ virtual const AtomicString& interfaceName() const OVERRIDE { return EventNames::MediaQueryListEvent; }
+
+ virtual void trace(Visitor* visitor) OVERRIDE
+ {
+ Event::trace(visitor);
+ visitor->trace(m_mediaQueryList);
+ }
+
+private:
+ MediaQueryListEvent()
+ : m_matches(false)
+ {
+ ScriptWrappable::init(this);
+ }
+
+ MediaQueryListEvent(const String& media, bool matches)
+ : Event(EventTypeNames::change, false, false)
+ , m_media(media)
+ , m_matches(matches)
+ {
+ ScriptWrappable::init(this);
+ }
+
+ explicit MediaQueryListEvent(MediaQueryList* list)
+ : Event(EventTypeNames::change, false, false)
+ , m_mediaQueryList(list)
+ , m_matches(false)
+ {
+ ScriptWrappable::init(this);
+ }
+
+ MediaQueryListEvent(const AtomicString& eventType, const MediaQueryListEventInit& initializer)
+ : Event(eventType, initializer)
+ , m_media(initializer.media)
+ , m_matches(initializer.matches)
+ {
+ ScriptWrappable::init(this);
+ }
+
+ // We have m_media/m_matches for JS-created events; we use m_mediaQueryList
+ // for events that blink generates.
+ RefPtrWillBeMember<MediaQueryList> m_mediaQueryList;
+ String m_media;
+ bool m_matches;
+};
+
+} // namespace blink
+
+#endif // MediaQueryListEvent_h
« no previous file with comments | « Source/core/css/MediaQueryList.idl ('k') | Source/core/css/MediaQueryListEvent.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698