| 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/OwnPtr.h" | 37 #include "wtf/PtrUtil.h" |
| 38 #include <memory> |
| 38 | 39 |
| 39 namespace blink { | 40 namespace blink { |
| 40 | 41 |
| 41 ScopedEventQueue* ScopedEventQueue::s_instance = nullptr; | 42 ScopedEventQueue* ScopedEventQueue::s_instance = nullptr; |
| 42 | 43 |
| 43 ScopedEventQueue::ScopedEventQueue() | 44 ScopedEventQueue::ScopedEventQueue() |
| 44 : m_scopingLevel(0) | 45 : m_scopingLevel(0) |
| 45 { | 46 { |
| 46 } | 47 } |
| 47 | 48 |
| 48 ScopedEventQueue::~ScopedEventQueue() | 49 ScopedEventQueue::~ScopedEventQueue() |
| 49 { | 50 { |
| 50 ASSERT(!m_scopingLevel); | 51 ASSERT(!m_scopingLevel); |
| 51 ASSERT(!m_queuedEventDispatchMediators.size()); | 52 ASSERT(!m_queuedEventDispatchMediators.size()); |
| 52 } | 53 } |
| 53 | 54 |
| 54 void ScopedEventQueue::initialize() | 55 void ScopedEventQueue::initialize() |
| 55 { | 56 { |
| 56 ASSERT(!s_instance); | 57 ASSERT(!s_instance); |
| 57 OwnPtr<ScopedEventQueue> instance = adoptPtr(new ScopedEventQueue); | 58 std::unique_ptr<ScopedEventQueue> instance = wrapUnique(new ScopedEventQueue
); |
| 58 s_instance = instance.leakPtr(); | 59 s_instance = instance.release(); |
| 59 } | 60 } |
| 60 | 61 |
| 61 void ScopedEventQueue::enqueueEventDispatchMediator(EventDispatchMediator* media
tor) | 62 void ScopedEventQueue::enqueueEventDispatchMediator(EventDispatchMediator* media
tor) |
| 62 { | 63 { |
| 63 if (shouldQueueEvents()) | 64 if (shouldQueueEvents()) |
| 64 m_queuedEventDispatchMediators.append(mediator); | 65 m_queuedEventDispatchMediators.append(mediator); |
| 65 else | 66 else |
| 66 dispatchEvent(mediator); | 67 dispatchEvent(mediator); |
| 67 } | 68 } |
| 68 | 69 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 97 | 98 |
| 98 void ScopedEventQueue::decrementScopingLevel() | 99 void ScopedEventQueue::decrementScopingLevel() |
| 99 { | 100 { |
| 100 ASSERT(m_scopingLevel); | 101 ASSERT(m_scopingLevel); |
| 101 m_scopingLevel--; | 102 m_scopingLevel--; |
| 102 if (!m_scopingLevel) | 103 if (!m_scopingLevel) |
| 103 dispatchAllEvents(); | 104 dispatchAllEvents(); |
| 104 } | 105 } |
| 105 | 106 |
| 106 } // namespace blink | 107 } // namespace blink |
| OLD | NEW |