| 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 30 matching lines...) Expand all Loading... |
| 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 bool GenericEventQueue::enqueueEvent(PassRefPtr<Event> event) | 51 bool GenericEventQueue::enqueueEvent(PassRefPtrWillBeRawPtr<Event> event) |
| 52 { | 52 { |
| 53 if (m_isClosed) | 53 if (m_isClosed) |
| 54 return false; | 54 return false; |
| 55 | 55 |
| 56 if (event->target() == m_owner) | 56 if (event->target() == m_owner) |
| 57 event->setTarget(nullptr); | 57 event->setTarget(nullptr); |
| 58 | 58 |
| 59 TRACE_EVENT_ASYNC_BEGIN1("event", "GenericEventQueue:enqueueEvent", event.ge
t(), "type", event->type().ascii()); | 59 TRACE_EVENT_ASYNC_BEGIN1("event", "GenericEventQueue:enqueueEvent", event.ge
t(), "type", event->type().ascii()); |
| 60 m_pendingEvents.append(event); | 60 m_pendingEvents.append(event); |
| 61 | 61 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 78 m_timer.stop(); | 78 m_timer.stop(); |
| 79 | 79 |
| 80 return found; | 80 return found; |
| 81 } | 81 } |
| 82 | 82 |
| 83 void GenericEventQueue::timerFired(Timer<GenericEventQueue>*) | 83 void GenericEventQueue::timerFired(Timer<GenericEventQueue>*) |
| 84 { | 84 { |
| 85 ASSERT(!m_timer.isActive()); | 85 ASSERT(!m_timer.isActive()); |
| 86 ASSERT(!m_pendingEvents.isEmpty()); | 86 ASSERT(!m_pendingEvents.isEmpty()); |
| 87 | 87 |
| 88 Vector<RefPtr<Event> > pendingEvents; | 88 WillBeHeapVector<RefPtrWillBeMember<Event> > pendingEvents; |
| 89 m_pendingEvents.swap(pendingEvents); | 89 m_pendingEvents.swap(pendingEvents); |
| 90 | 90 |
| 91 RefPtr<EventTarget> protect(m_owner); | 91 RefPtr<EventTarget> protect(m_owner); |
| 92 for (size_t i = 0; i < pendingEvents.size(); ++i) { | 92 for (size_t i = 0; i < pendingEvents.size(); ++i) { |
| 93 Event* event = pendingEvents[i].get(); | 93 Event* event = pendingEvents[i].get(); |
| 94 EventTarget* target = event->target() ? event->target() : m_owner; | 94 EventTarget* target = event->target() ? event->target() : m_owner; |
| 95 CString type(event->type().ascii()); | 95 CString type(event->type().ascii()); |
| 96 TRACE_EVENT_ASYNC_STEP_INTO1("event", "GenericEventQueue:enqueueEvent",
event, "dispatch", "type", type); | 96 TRACE_EVENT_ASYNC_STEP_INTO1("event", "GenericEventQueue:enqueueEvent",
event, "dispatch", "type", type); |
| 97 target->dispatchEvent(pendingEvents[i].release()); | 97 target->dispatchEvent(pendingEvents[i].release()); |
| 98 TRACE_EVENT_ASYNC_END1("event", "GenericEventQueue:enqueueEvent", event,
"type", type); | 98 TRACE_EVENT_ASYNC_END1("event", "GenericEventQueue:enqueueEvent", event,
"type", type); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 115 } | 115 } |
| 116 m_pendingEvents.clear(); | 116 m_pendingEvents.clear(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 bool GenericEventQueue::hasPendingEvents() const | 119 bool GenericEventQueue::hasPendingEvents() const |
| 120 { | 120 { |
| 121 return m_pendingEvents.size(); | 121 return m_pendingEvents.size(); |
| 122 } | 122 } |
| 123 | 123 |
| 124 } | 124 } |
| OLD | NEW |