| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 m_timer.stop(); | 88 m_timer.stop(); |
| 89 | 89 |
| 90 return found; | 90 return found; |
| 91 } | 91 } |
| 92 | 92 |
| 93 void GenericEventQueue::timerFired(Timer<GenericEventQueue>*) | 93 void GenericEventQueue::timerFired(Timer<GenericEventQueue>*) |
| 94 { | 94 { |
| 95 ASSERT(!m_timer.isActive()); | 95 ASSERT(!m_timer.isActive()); |
| 96 ASSERT(!m_pendingEvents.isEmpty()); | 96 ASSERT(!m_pendingEvents.isEmpty()); |
| 97 | 97 |
| 98 WillBeHeapVector<RefPtrWillBeMember<Event> > pendingEvents; | 98 WillBeHeapVector<RefPtrWillBeMember<Event>> pendingEvents; |
| 99 m_pendingEvents.swap(pendingEvents); | 99 m_pendingEvents.swap(pendingEvents); |
| 100 | 100 |
| 101 RefPtrWillBeRawPtr<EventTarget> protect(m_owner.get()); | 101 RefPtrWillBeRawPtr<EventTarget> protect(m_owner.get()); |
| 102 for (size_t i = 0; i < pendingEvents.size(); ++i) { | 102 for (const auto& pendingEvent : pendingEvents) { |
| 103 Event* event = pendingEvents[i].get(); | 103 Event* event = pendingEvent.get(); |
| 104 EventTarget* target = event->target() ? event->target() : m_owner.get(); | 104 EventTarget* target = event->target() ? event->target() : m_owner.get(); |
| 105 CString type(event->type().ascii()); | 105 CString type(event->type().ascii()); |
| 106 TRACE_EVENT_ASYNC_STEP_INTO1("event", "GenericEventQueue:enqueueEvent",
event, "dispatch", "type", type); | 106 TRACE_EVENT_ASYNC_STEP_INTO1("event", "GenericEventQueue:enqueueEvent",
event, "dispatch", "type", type); |
| 107 target->dispatchEvent(pendingEvents[i]); | 107 target->dispatchEvent(pendingEvent); |
| 108 TRACE_EVENT_ASYNC_END1("event", "GenericEventQueue:enqueueEvent", event,
"type", type); | 108 TRACE_EVENT_ASYNC_END1("event", "GenericEventQueue:enqueueEvent", event,
"type", type); |
| 109 InspectorInstrumentation::didRemoveEvent(target, event); | 109 InspectorInstrumentation::didRemoveEvent(target, event); |
| 110 } | 110 } |
| 111 } | 111 } |
| 112 | 112 |
| 113 void GenericEventQueue::close() | 113 void GenericEventQueue::close() |
| 114 { | 114 { |
| 115 m_isClosed = true; | 115 m_isClosed = true; |
| 116 cancelAllEvents(); | 116 cancelAllEvents(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void GenericEventQueue::cancelAllEvents() | 119 void GenericEventQueue::cancelAllEvents() |
| 120 { | 120 { |
| 121 m_timer.stop(); | 121 m_timer.stop(); |
| 122 | 122 |
| 123 for (size_t i = 0; i < m_pendingEvents.size(); ++i) { | 123 for (const auto& pendingEvent : m_pendingEvents) { |
| 124 Event* event = m_pendingEvents[i].get(); | 124 Event* event = pendingEvent.get(); |
| 125 TRACE_EVENT_ASYNC_END2("event", "GenericEventQueue:enqueueEvent", event,
"type", event->type().ascii(), "status", "cancelled"); | 125 TRACE_EVENT_ASYNC_END2("event", "GenericEventQueue:enqueueEvent", event,
"type", event->type().ascii(), "status", "cancelled"); |
| 126 InspectorInstrumentation::didRemoveEvent(event->target() ? event->target
() : m_owner.get(), event); | 126 InspectorInstrumentation::didRemoveEvent(event->target() ? event->target
() : m_owner.get(), event); |
| 127 } | 127 } |
| 128 m_pendingEvents.clear(); | 128 m_pendingEvents.clear(); |
| 129 } | 129 } |
| 130 | 130 |
| 131 bool GenericEventQueue::hasPendingEvents() const | 131 bool GenericEventQueue::hasPendingEvents() const |
| 132 { | 132 { |
| 133 return m_pendingEvents.size(); | 133 return m_pendingEvents.size(); |
| 134 } | 134 } |
| 135 | 135 |
| 136 } | 136 } |
| OLD | NEW |