| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 ASSERT(!m_queuedEventDispatchMediators.size()); | 51 ASSERT(!m_queuedEventDispatchMediators.size()); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void ScopedEventQueue::initialize() | 54 void ScopedEventQueue::initialize() |
| 55 { | 55 { |
| 56 ASSERT(!s_instance); | 56 ASSERT(!s_instance); |
| 57 OwnPtr<ScopedEventQueue> instance = adoptPtr(new ScopedEventQueue); | 57 OwnPtr<ScopedEventQueue> instance = adoptPtr(new ScopedEventQueue); |
| 58 s_instance = instance.leakPtr(); | 58 s_instance = instance.leakPtr(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 void ScopedEventQueue::enqueueEventDispatchMediator(PassRefPtrWillBeRawPtr<Event
DispatchMediator> mediator) | 61 void ScopedEventQueue::enqueueEventDispatchMediator(RawPtr<EventDispatchMediator
> mediator) |
| 62 { | 62 { |
| 63 if (shouldQueueEvents()) | 63 if (shouldQueueEvents()) |
| 64 m_queuedEventDispatchMediators.append(mediator); | 64 m_queuedEventDispatchMediators.append(mediator); |
| 65 else | 65 else |
| 66 dispatchEvent(mediator); | 66 dispatchEvent(mediator); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void ScopedEventQueue::dispatchAllEvents() | 69 void ScopedEventQueue::dispatchAllEvents() |
| 70 { | 70 { |
| 71 WillBeHeapVector<RefPtrWillBeMember<EventDispatchMediator>> queuedEventDispa
tchMediators; | 71 HeapVector<Member<EventDispatchMediator>> queuedEventDispatchMediators; |
| 72 queuedEventDispatchMediators.swap(m_queuedEventDispatchMediators); | 72 queuedEventDispatchMediators.swap(m_queuedEventDispatchMediators); |
| 73 | 73 |
| 74 for (size_t i = 0; i < queuedEventDispatchMediators.size(); i++) | 74 for (size_t i = 0; i < queuedEventDispatchMediators.size(); i++) |
| 75 dispatchEvent(queuedEventDispatchMediators[i].release()); | 75 dispatchEvent(queuedEventDispatchMediators[i].release()); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void ScopedEventQueue::dispatchEvent(PassRefPtrWillBeRawPtr<EventDispatchMediato
r> mediator) const | 78 void ScopedEventQueue::dispatchEvent(RawPtr<EventDispatchMediator> mediator) con
st |
| 79 { | 79 { |
| 80 ASSERT(mediator->event().target()); | 80 ASSERT(mediator->event().target()); |
| 81 Node* node = mediator->event().target()->toNode(); | 81 Node* node = mediator->event().target()->toNode(); |
| 82 EventDispatcher::dispatchEvent(*node, mediator); | 82 EventDispatcher::dispatchEvent(*node, mediator); |
| 83 } | 83 } |
| 84 | 84 |
| 85 ScopedEventQueue* ScopedEventQueue::instance() | 85 ScopedEventQueue* ScopedEventQueue::instance() |
| 86 { | 86 { |
| 87 if (!s_instance) | 87 if (!s_instance) |
| 88 initialize(); | 88 initialize(); |
| 89 | 89 |
| 90 return s_instance; | 90 return s_instance; |
| 91 } | 91 } |
| 92 | 92 |
| 93 void ScopedEventQueue::incrementScopingLevel() | 93 void ScopedEventQueue::incrementScopingLevel() |
| 94 { | 94 { |
| 95 m_scopingLevel++; | 95 m_scopingLevel++; |
| 96 } | 96 } |
| 97 | 97 |
| 98 void ScopedEventQueue::decrementScopingLevel() | 98 void ScopedEventQueue::decrementScopingLevel() |
| 99 { | 99 { |
| 100 ASSERT(m_scopingLevel); | 100 ASSERT(m_scopingLevel); |
| 101 m_scopingLevel--; | 101 m_scopingLevel--; |
| 102 if (!m_scopingLevel) | 102 if (!m_scopingLevel) |
| 103 dispatchAllEvents(); | 103 dispatchAllEvents(); |
| 104 } | 104 } |
| 105 | 105 |
| 106 } // namespace blink | 106 } // namespace blink |
| OLD | NEW |