| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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); |
| 103 bool found = it != m_queuedEvents.end(); | 103 bool found = it != m_queuedEvents.end(); |
| 104 if (found) { | 104 if (found) { |
| 105 probe::asyncTaskCanceled(event->target()->getExecutionContext(), event); | 105 probe::asyncTaskCanceled(event->target()->getExecutionContext(), event); |
| 106 m_queuedEvents.remove(it); | 106 m_queuedEvents.erase(it); |
| 107 } | 107 } |
| 108 if (m_queuedEvents.isEmpty()) | 108 if (m_queuedEvents.isEmpty()) |
| 109 m_pendingEventTimer->stop(); | 109 m_pendingEventTimer->stop(); |
| 110 return found; | 110 return found; |
| 111 } | 111 } |
| 112 | 112 |
| 113 void DOMWindowEventQueue::close() { | 113 void DOMWindowEventQueue::close() { |
| 114 m_isClosed = true; | 114 m_isClosed = true; |
| 115 m_pendingEventTimer->stop(); | 115 m_pendingEventTimer->stop(); |
| 116 for (const auto& queuedEvent : m_queuedEvents) { | 116 for (const auto& queuedEvent : m_queuedEvents) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 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.insert(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.erase(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 probe::AsyncTask asyncTask(eventTarget->getExecutionContext(), event); | 146 probe::AsyncTask asyncTask(eventTarget->getExecutionContext(), event); |
| 147 if (LocalDOMWindow* window = eventTarget->toLocalDOMWindow()) | 147 if (LocalDOMWindow* window = eventTarget->toLocalDOMWindow()) |
| 148 window->dispatchEvent(event, nullptr); | 148 window->dispatchEvent(event, nullptr); |
| 149 else | 149 else |
| 150 eventTarget->dispatchEvent(event); | 150 eventTarget->dispatchEvent(event); |
| 151 } | 151 } |
| 152 | 152 |
| 153 } // namespace blink | 153 } // namespace blink |
| OLD | NEW |