OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MediaQueryListEvent_h | 5 #ifndef MediaQueryListEvent_h |
6 #define MediaQueryListEvent_h | 6 #define MediaQueryListEvent_h |
7 | 7 |
8 #include "core/css/MediaQueryList.h" | 8 #include "core/css/MediaQueryList.h" |
9 #include "core/events/Event.h" | 9 #include "core/events/Event.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 struct MediaQueryListEventInit : public EventInit { | 13 struct MediaQueryListEventInit : public EventInit { |
14 MediaQueryListEventInit() : matches(false) { } | 14 MediaQueryListEventInit() : matches(false) { } |
15 | 15 |
16 String media; | 16 String media; |
17 bool matches; | 17 bool matches; |
18 }; | 18 }; |
19 | 19 |
20 class MediaQueryListEvent FINAL : public Event { | 20 class MediaQueryListEvent final : public Event { |
21 DEFINE_WRAPPERTYPEINFO(); | 21 DEFINE_WRAPPERTYPEINFO(); |
22 public: | 22 public: |
23 static PassRefPtrWillBeRawPtr<MediaQueryListEvent> create() | 23 static PassRefPtrWillBeRawPtr<MediaQueryListEvent> create() |
24 { | 24 { |
25 return adoptRefWillBeNoop(new MediaQueryListEvent); | 25 return adoptRefWillBeNoop(new MediaQueryListEvent); |
26 } | 26 } |
27 | 27 |
28 static PassRefPtrWillBeRawPtr<MediaQueryListEvent> create(PassRefPtrWillBeRa
wPtr<MediaQueryList> list) | 28 static PassRefPtrWillBeRawPtr<MediaQueryListEvent> create(PassRefPtrWillBeRa
wPtr<MediaQueryList> list) |
29 { | 29 { |
30 return adoptRefWillBeNoop(new MediaQueryListEvent(list)); | 30 return adoptRefWillBeNoop(new MediaQueryListEvent(list)); |
31 } | 31 } |
32 | 32 |
33 static PassRefPtrWillBeRawPtr<MediaQueryListEvent> create(const String& medi
a, bool matches) | 33 static PassRefPtrWillBeRawPtr<MediaQueryListEvent> create(const String& medi
a, bool matches) |
34 { | 34 { |
35 return adoptRefWillBeNoop(new MediaQueryListEvent(media, matches)); | 35 return adoptRefWillBeNoop(new MediaQueryListEvent(media, matches)); |
36 } | 36 } |
37 | 37 |
38 static PassRefPtrWillBeRawPtr<MediaQueryListEvent> create(const AtomicString
& eventType, const MediaQueryListEventInit& initializer) | 38 static PassRefPtrWillBeRawPtr<MediaQueryListEvent> create(const AtomicString
& eventType, const MediaQueryListEventInit& initializer) |
39 { | 39 { |
40 return adoptRefWillBeNoop(new MediaQueryListEvent(eventType, initializer
)); | 40 return adoptRefWillBeNoop(new MediaQueryListEvent(eventType, initializer
)); |
41 } | 41 } |
42 | 42 |
43 String media() const { return m_mediaQueryList ? m_mediaQueryList->media() :
m_media; } | 43 String media() const { return m_mediaQueryList ? m_mediaQueryList->media() :
m_media; } |
44 bool matches() const { return m_mediaQueryList ? m_mediaQueryList->matches()
: m_matches; } | 44 bool matches() const { return m_mediaQueryList ? m_mediaQueryList->matches()
: m_matches; } |
45 | 45 |
46 virtual const AtomicString& interfaceName() const OVERRIDE { return EventNam
es::MediaQueryListEvent; } | 46 virtual const AtomicString& interfaceName() const override { return EventNam
es::MediaQueryListEvent; } |
47 | 47 |
48 virtual void trace(Visitor* visitor) OVERRIDE | 48 virtual void trace(Visitor* visitor) override |
49 { | 49 { |
50 Event::trace(visitor); | 50 Event::trace(visitor); |
51 visitor->trace(m_mediaQueryList); | 51 visitor->trace(m_mediaQueryList); |
52 } | 52 } |
53 | 53 |
54 private: | 54 private: |
55 MediaQueryListEvent() | 55 MediaQueryListEvent() |
56 : m_matches(false) { } | 56 : m_matches(false) { } |
57 | 57 |
58 MediaQueryListEvent(const String& media, bool matches) | 58 MediaQueryListEvent(const String& media, bool matches) |
(...skipping 14 matching lines...) Expand all Loading... |
73 // We have m_media/m_matches for JS-created events; we use m_mediaQueryList | 73 // We have m_media/m_matches for JS-created events; we use m_mediaQueryList |
74 // for events that blink generates. | 74 // for events that blink generates. |
75 RefPtrWillBeMember<MediaQueryList> m_mediaQueryList; | 75 RefPtrWillBeMember<MediaQueryList> m_mediaQueryList; |
76 String m_media; | 76 String m_media; |
77 bool m_matches; | 77 bool m_matches; |
78 }; | 78 }; |
79 | 79 |
80 } // namespace blink | 80 } // namespace blink |
81 | 81 |
82 #endif // MediaQueryListEvent_h | 82 #endif // MediaQueryListEvent_h |
OLD | NEW |