| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 if (shouldQueueEvents()) | 59 if (shouldQueueEvents()) |
| 60 m_queuedEventDispatchMediators.append(mediator); | 60 m_queuedEventDispatchMediators.append(mediator); |
| 61 else | 61 else |
| 62 dispatchEvent(mediator); | 62 dispatchEvent(mediator); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void ScopedEventQueue::dispatchAllEvents() { | 65 void ScopedEventQueue::dispatchAllEvents() { |
| 66 HeapVector<Member<EventDispatchMediator>> queuedEventDispatchMediators; | 66 HeapVector<Member<EventDispatchMediator>> queuedEventDispatchMediators; |
| 67 queuedEventDispatchMediators.swap(m_queuedEventDispatchMediators); | 67 queuedEventDispatchMediators.swap(m_queuedEventDispatchMediators); |
| 68 | 68 |
| 69 for (size_t i = 0; i < queuedEventDispatchMediators.size(); i++) | 69 for (auto& mediator : queuedEventDispatchMediators) |
| 70 dispatchEvent(queuedEventDispatchMediators[i].release()); | 70 dispatchEvent(mediator.release()); |
| 71 } | 71 } |
| 72 | 72 |
| 73 void ScopedEventQueue::dispatchEvent(EventDispatchMediator* mediator) const { | 73 void ScopedEventQueue::dispatchEvent(EventDispatchMediator* mediator) const { |
| 74 DCHECK(mediator->event().target()); | 74 DCHECK(mediator->event().target()); |
| 75 Node* node = mediator->event().target()->toNode(); | 75 Node* node = mediator->event().target()->toNode(); |
| 76 EventDispatcher::dispatchEvent(*node, mediator); | 76 EventDispatcher::dispatchEvent(*node, mediator); |
| 77 } | 77 } |
| 78 | 78 |
| 79 ScopedEventQueue* ScopedEventQueue::instance() { | 79 ScopedEventQueue* ScopedEventQueue::instance() { |
| 80 if (!s_instance) | 80 if (!s_instance) |
| 81 initialize(); | 81 initialize(); |
| 82 | 82 |
| 83 return s_instance; | 83 return s_instance; |
| 84 } | 84 } |
| 85 | 85 |
| 86 void ScopedEventQueue::incrementScopingLevel() { | 86 void ScopedEventQueue::incrementScopingLevel() { |
| 87 m_scopingLevel++; | 87 m_scopingLevel++; |
| 88 } | 88 } |
| 89 | 89 |
| 90 void ScopedEventQueue::decrementScopingLevel() { | 90 void ScopedEventQueue::decrementScopingLevel() { |
| 91 DCHECK(m_scopingLevel); | 91 DCHECK(m_scopingLevel); |
| 92 m_scopingLevel--; | 92 m_scopingLevel--; |
| 93 if (!m_scopingLevel) | 93 if (!m_scopingLevel) |
| 94 dispatchAllEvents(); | 94 dispatchAllEvents(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 } // namespace blink | 97 } // namespace blink |
| OLD | NEW |