| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Victor Carbune (victor@rosedu.org) | 2 * Copyright (C) 2012 Victor Carbune (victor@rosedu.org) |
| 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 | 27 |
| 28 #include "core/events/GenericEventQueue.h" | 28 #include "core/events/GenericEventQueue.h" |
| 29 | 29 |
| 30 #include "core/events/Event.h" | 30 #include "core/events/Event.h" |
| 31 #include "platform/TraceEvent.h" | 31 #include "platform/TraceEvent.h" |
| 32 | 32 |
| 33 namespace WebCore { | 33 namespace WebCore { |
| 34 | 34 |
| 35 PassOwnPtr<GenericEventQueue> GenericEventQueue::create(EventTarget* owner) | 35 PassOwnPtrWillBeRawPtr<GenericEventQueue> GenericEventQueue::create(EventTarget*
owner) |
| 36 { | 36 { |
| 37 return adoptPtr(new GenericEventQueue(owner)); | 37 return adoptPtrWillBeNoop(new GenericEventQueue(owner)); |
| 38 } | 38 } |
| 39 | 39 |
| 40 GenericEventQueue::GenericEventQueue(EventTarget* owner) | 40 GenericEventQueue::GenericEventQueue(EventTarget* owner) |
| 41 : m_owner(owner) | 41 : m_owner(owner) |
| 42 , m_timer(this, &GenericEventQueue::timerFired) | 42 , m_timer(this, &GenericEventQueue::timerFired) |
| 43 , m_isClosed(false) | 43 , m_isClosed(false) |
| 44 { | 44 { |
| 45 } | 45 } |
| 46 | 46 |
| 47 GenericEventQueue::~GenericEventQueue() | 47 GenericEventQueue::~GenericEventQueue() |
| 48 { | 48 { |
| 49 } | 49 } |
| 50 | 50 |
| 51 void GenericEventQueue::trace(Visitor* visitor) |
| 52 { |
| 53 visitor->trace(m_owner); |
| 54 visitor->trace(m_pendingEvents); |
| 55 EventQueue::trace(visitor); |
| 56 } |
| 57 |
| 51 bool GenericEventQueue::enqueueEvent(PassRefPtrWillBeRawPtr<Event> event) | 58 bool GenericEventQueue::enqueueEvent(PassRefPtrWillBeRawPtr<Event> event) |
| 52 { | 59 { |
| 53 if (m_isClosed) | 60 if (m_isClosed) |
| 54 return false; | 61 return false; |
| 55 | 62 |
| 56 if (event->target() == m_owner) | 63 if (event->target() == m_owner) |
| 57 event->setTarget(nullptr); | 64 event->setTarget(nullptr); |
| 58 | 65 |
| 59 TRACE_EVENT_ASYNC_BEGIN1("event", "GenericEventQueue:enqueueEvent", event.ge
t(), "type", event->type().ascii()); | 66 TRACE_EVENT_ASYNC_BEGIN1("event", "GenericEventQueue:enqueueEvent", event.ge
t(), "type", event->type().ascii()); |
| 60 m_pendingEvents.append(event); | 67 m_pendingEvents.append(event); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 81 } | 88 } |
| 82 | 89 |
| 83 void GenericEventQueue::timerFired(Timer<GenericEventQueue>*) | 90 void GenericEventQueue::timerFired(Timer<GenericEventQueue>*) |
| 84 { | 91 { |
| 85 ASSERT(!m_timer.isActive()); | 92 ASSERT(!m_timer.isActive()); |
| 86 ASSERT(!m_pendingEvents.isEmpty()); | 93 ASSERT(!m_pendingEvents.isEmpty()); |
| 87 | 94 |
| 88 WillBeHeapVector<RefPtrWillBeMember<Event> > pendingEvents; | 95 WillBeHeapVector<RefPtrWillBeMember<Event> > pendingEvents; |
| 89 m_pendingEvents.swap(pendingEvents); | 96 m_pendingEvents.swap(pendingEvents); |
| 90 | 97 |
| 91 RefPtrWillBeRawPtr<EventTarget> protect(m_owner); | 98 RefPtrWillBeRawPtr<EventTarget> protect(m_owner.get()); |
| 92 for (size_t i = 0; i < pendingEvents.size(); ++i) { | 99 for (size_t i = 0; i < pendingEvents.size(); ++i) { |
| 93 Event* event = pendingEvents[i].get(); | 100 Event* event = pendingEvents[i].get(); |
| 94 EventTarget* target = event->target() ? event->target() : m_owner; | 101 EventTarget* target = event->target() ? event->target() : m_owner.get(); |
| 95 CString type(event->type().ascii()); | 102 CString type(event->type().ascii()); |
| 96 TRACE_EVENT_ASYNC_STEP_INTO1("event", "GenericEventQueue:enqueueEvent",
event, "dispatch", "type", type); | 103 TRACE_EVENT_ASYNC_STEP_INTO1("event", "GenericEventQueue:enqueueEvent",
event, "dispatch", "type", type); |
| 97 target->dispatchEvent(pendingEvents[i].release()); | 104 target->dispatchEvent(pendingEvents[i].release()); |
| 98 TRACE_EVENT_ASYNC_END1("event", "GenericEventQueue:enqueueEvent", event,
"type", type); | 105 TRACE_EVENT_ASYNC_END1("event", "GenericEventQueue:enqueueEvent", event,
"type", type); |
| 99 } | 106 } |
| 100 } | 107 } |
| 101 | 108 |
| 102 void GenericEventQueue::close() | 109 void GenericEventQueue::close() |
| 103 { | 110 { |
| 104 m_isClosed = true; | 111 m_isClosed = true; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 115 } | 122 } |
| 116 m_pendingEvents.clear(); | 123 m_pendingEvents.clear(); |
| 117 } | 124 } |
| 118 | 125 |
| 119 bool GenericEventQueue::hasPendingEvents() const | 126 bool GenericEventQueue::hasPendingEvents() const |
| 120 { | 127 { |
| 121 return m_pendingEvents.size(); | 128 return m_pendingEvents.size(); |
| 122 } | 129 } |
| 123 | 130 |
| 124 } | 131 } |
| OLD | NEW |