| 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 | 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 } | 82 } |
| 83 | 83 |
| 84 bool DOMWindowEventQueue::enqueueEvent(Event* event) { | 84 bool DOMWindowEventQueue::enqueueEvent(Event* event) { |
| 85 if (m_isClosed) | 85 if (m_isClosed) |
| 86 return false; | 86 return false; |
| 87 | 87 |
| 88 DCHECK(event->target()); | 88 DCHECK(event->target()); |
| 89 InspectorInstrumentation::asyncTaskScheduled( | 89 InspectorInstrumentation::asyncTaskScheduled( |
| 90 event->target()->getExecutionContext(), event->type(), event); | 90 event->target()->getExecutionContext(), event->type(), event); |
| 91 | 91 |
| 92 bool wasAdded = m_queuedEvents.add(event).isNewEntry; | 92 bool wasAdded = m_queuedEvents.insert(event).isNewEntry; |
| 93 DCHECK(wasAdded); // It should not have already been in the list. | 93 DCHECK(wasAdded); // It should not have already been in the list. |
| 94 | 94 |
| 95 if (!m_pendingEventTimer->isActive()) | 95 if (!m_pendingEventTimer->isActive()) |
| 96 m_pendingEventTimer->startOneShot(0, BLINK_FROM_HERE); | 96 m_pendingEventTimer->startOneShot(0, BLINK_FROM_HERE); |
| 97 | 97 |
| 98 return true; | 98 return true; |
| 99 } | 99 } |
| 100 | 100 |
| 101 bool DOMWindowEventQueue::cancelEvent(Event* event) { | 101 bool DOMWindowEventQueue::cancelEvent(Event* event) { |
| 102 HeapListHashSet<Member<Event>, 16>::iterator it = m_queuedEvents.find(event); | 102 HeapListHashSet<Member<Event>, 16>::iterator it = m_queuedEvents.find(event); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 121 } | 121 } |
| 122 m_queuedEvents.clear(); | 122 m_queuedEvents.clear(); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void DOMWindowEventQueue::pendingEventTimerFired() { | 125 void DOMWindowEventQueue::pendingEventTimerFired() { |
| 126 DCHECK(!m_pendingEventTimer->isActive()); | 126 DCHECK(!m_pendingEventTimer->isActive()); |
| 127 DCHECK(!m_queuedEvents.isEmpty()); | 127 DCHECK(!m_queuedEvents.isEmpty()); |
| 128 | 128 |
| 129 // Insert a marker for where we should stop. | 129 // Insert a marker for where we should stop. |
| 130 DCHECK(!m_queuedEvents.contains(nullptr)); | 130 DCHECK(!m_queuedEvents.contains(nullptr)); |
| 131 bool wasAdded = m_queuedEvents.add(nullptr).isNewEntry; | 131 bool wasAdded = m_queuedEvents.insert(nullptr).isNewEntry; |
| 132 DCHECK(wasAdded); // It should not have already been in the list. | 132 DCHECK(wasAdded); // It should not have already been in the list. |
| 133 | 133 |
| 134 while (!m_queuedEvents.isEmpty()) { | 134 while (!m_queuedEvents.isEmpty()) { |
| 135 HeapListHashSet<Member<Event>, 16>::iterator iter = m_queuedEvents.begin(); | 135 HeapListHashSet<Member<Event>, 16>::iterator iter = m_queuedEvents.begin(); |
| 136 Event* event = *iter; | 136 Event* event = *iter; |
| 137 m_queuedEvents.remove(iter); | 137 m_queuedEvents.remove(iter); |
| 138 if (!event) | 138 if (!event) |
| 139 break; | 139 break; |
| 140 dispatchEvent(event); | 140 dispatchEvent(event); |
| 141 } | 141 } |
| 142 } | 142 } |
| 143 | 143 |
| 144 void DOMWindowEventQueue::dispatchEvent(Event* event) { | 144 void DOMWindowEventQueue::dispatchEvent(Event* event) { |
| 145 EventTarget* eventTarget = event->target(); | 145 EventTarget* eventTarget = event->target(); |
| 146 InspectorInstrumentation::AsyncTask asyncTask( | 146 InspectorInstrumentation::AsyncTask asyncTask( |
| 147 eventTarget->getExecutionContext(), event); | 147 eventTarget->getExecutionContext(), event); |
| 148 if (LocalDOMWindow* window = eventTarget->toLocalDOMWindow()) | 148 if (LocalDOMWindow* window = eventTarget->toLocalDOMWindow()) |
| 149 window->dispatchEvent(event, nullptr); | 149 window->dispatchEvent(event, nullptr); |
| 150 else | 150 else |
| 151 eventTarget->dispatchEvent(event); | 151 eventTarget->dispatchEvent(event); |
| 152 } | 152 } |
| 153 | 153 |
| 154 } // namespace blink | 154 } // namespace blink |
| OLD | NEW |