OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 16 matching lines...) Expand all Loading... |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "core/events/ScopedEventQueue.h" | 31 #include "core/events/ScopedEventQueue.h" |
32 | 32 |
33 #include "core/events/Event.h" | 33 #include "core/events/Event.h" |
34 #include "core/events/EventDispatchMediator.h" | 34 #include "core/events/EventDispatchMediator.h" |
35 #include "core/events/EventDispatcher.h" | 35 #include "core/events/EventDispatcher.h" |
36 #include "core/events/EventTarget.h" | 36 #include "core/events/EventTarget.h" |
37 #include "wtf/PtrUtil.h" | 37 #include "wtf/OwnPtr.h" |
38 #include <memory> | |
39 | 38 |
40 namespace blink { | 39 namespace blink { |
41 | 40 |
42 ScopedEventQueue* ScopedEventQueue::s_instance = nullptr; | 41 ScopedEventQueue* ScopedEventQueue::s_instance = nullptr; |
43 | 42 |
44 ScopedEventQueue::ScopedEventQueue() | 43 ScopedEventQueue::ScopedEventQueue() |
45 : m_scopingLevel(0) | 44 : m_scopingLevel(0) |
46 { | 45 { |
47 } | 46 } |
48 | 47 |
49 ScopedEventQueue::~ScopedEventQueue() | 48 ScopedEventQueue::~ScopedEventQueue() |
50 { | 49 { |
51 ASSERT(!m_scopingLevel); | 50 ASSERT(!m_scopingLevel); |
52 ASSERT(!m_queuedEventDispatchMediators.size()); | 51 ASSERT(!m_queuedEventDispatchMediators.size()); |
53 } | 52 } |
54 | 53 |
55 void ScopedEventQueue::initialize() | 54 void ScopedEventQueue::initialize() |
56 { | 55 { |
57 ASSERT(!s_instance); | 56 ASSERT(!s_instance); |
58 std::unique_ptr<ScopedEventQueue> instance = wrapUnique(new ScopedEventQueue
); | 57 OwnPtr<ScopedEventQueue> instance = adoptPtr(new ScopedEventQueue); |
59 s_instance = instance.release(); | 58 s_instance = instance.leakPtr(); |
60 } | 59 } |
61 | 60 |
62 void ScopedEventQueue::enqueueEventDispatchMediator(EventDispatchMediator* media
tor) | 61 void ScopedEventQueue::enqueueEventDispatchMediator(EventDispatchMediator* media
tor) |
63 { | 62 { |
64 if (shouldQueueEvents()) | 63 if (shouldQueueEvents()) |
65 m_queuedEventDispatchMediators.append(mediator); | 64 m_queuedEventDispatchMediators.append(mediator); |
66 else | 65 else |
67 dispatchEvent(mediator); | 66 dispatchEvent(mediator); |
68 } | 67 } |
69 | 68 |
(...skipping 28 matching lines...) Expand all Loading... |
98 | 97 |
99 void ScopedEventQueue::decrementScopingLevel() | 98 void ScopedEventQueue::decrementScopingLevel() |
100 { | 99 { |
101 ASSERT(m_scopingLevel); | 100 ASSERT(m_scopingLevel); |
102 m_scopingLevel--; | 101 m_scopingLevel--; |
103 if (!m_scopingLevel) | 102 if (!m_scopingLevel) |
104 dispatchAllEvents(); | 103 dispatchAllEvents(); |
105 } | 104 } |
106 | 105 |
107 } // namespace blink | 106 } // namespace blink |
OLD | NEW |