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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 m_pendingEventTimer->stop(); | 102 m_pendingEventTimer->stop(); |
103 return found; | 103 return found; |
104 } | 104 } |
105 | 105 |
106 void DOMWindowEventQueue::close() | 106 void DOMWindowEventQueue::close() |
107 { | 107 { |
108 m_isClosed = true; | 108 m_isClosed = true; |
109 m_pendingEventTimer->stop(); | 109 m_pendingEventTimer->stop(); |
110 if (InspectorInstrumentation::hasFrontends()) { | 110 if (InspectorInstrumentation::hasFrontends()) { |
111 WillBeHeapListHashSet<RefPtrWillBeMember<Event>, 16>::iterator it = m_qu euedEvents.begin(); | 111 WillBeHeapListHashSet<RefPtrWillBeMember<Event>, 16>::iterator it = m_qu euedEvents.begin(); |
112 for (; it != m_queuedEvents.end(); ++it) | 112 for (; it != m_queuedEvents.end(); ++it) { |
113 InspectorInstrumentation::didRemoveEvent((*it)->target(), it->get()) ; | 113 RefPtrWillBeRawPtr<Event> event = *it; |
114 if (event) | |
115 InspectorInstrumentation::didRemoveEvent(event->target(), event. get()); | |
116 } | |
114 } | 117 } |
115 m_queuedEvents.clear(); | 118 m_queuedEvents.clear(); |
116 } | 119 } |
117 | 120 |
118 void DOMWindowEventQueue::pendingEventTimerFired() | 121 void DOMWindowEventQueue::pendingEventTimerFired() |
119 { | 122 { |
120 ASSERT(!m_pendingEventTimer->isActive()); | 123 ASSERT(!m_pendingEventTimer->isActive()); |
121 ASSERT(!m_queuedEvents.isEmpty()); | 124 ASSERT(!m_queuedEvents.isEmpty()); |
122 | 125 |
123 // Insert a marker for where we should stop. | 126 // Insert a marker for where we should stop. |
124 ASSERT(!m_queuedEvents.contains(nullptr)); | 127 ASSERT(!m_queuedEvents.contains(nullptr)); |
125 bool wasAdded = m_queuedEvents.add(nullptr).isNewEntry; | 128 bool wasAdded = m_queuedEvents.add(nullptr).isNewEntry; |
aandrey
2014/08/08 14:07:02
there can be NULL's in the queue, thus the crash
| |
126 ASSERT_UNUSED(wasAdded, wasAdded); // It should not have already been in the list. | 129 ASSERT_UNUSED(wasAdded, wasAdded); // It should not have already been in the list. |
127 | 130 |
128 RefPtrWillBeRawPtr<DOMWindowEventQueue> protector(this); | 131 RefPtrWillBeRawPtr<DOMWindowEventQueue> protector(this); |
129 | 132 |
130 while (!m_queuedEvents.isEmpty()) { | 133 while (!m_queuedEvents.isEmpty()) { |
131 WillBeHeapListHashSet<RefPtrWillBeMember<Event>, 16>::iterator iter = m_ queuedEvents.begin(); | 134 WillBeHeapListHashSet<RefPtrWillBeMember<Event>, 16>::iterator iter = m_ queuedEvents.begin(); |
132 RefPtrWillBeRawPtr<Event> event = *iter; | 135 RefPtrWillBeRawPtr<Event> event = *iter; |
133 m_queuedEvents.remove(iter); | 136 m_queuedEvents.remove(iter); |
134 if (!event) | 137 if (!event) |
135 break; | 138 break; |
136 dispatchEvent(event.get()); | 139 dispatchEvent(event.get()); |
137 InspectorInstrumentation::didRemoveEvent(event->target(), event.get()); | 140 InspectorInstrumentation::didRemoveEvent(event->target(), event.get()); |
138 } | 141 } |
139 } | 142 } |
140 | 143 |
141 void DOMWindowEventQueue::dispatchEvent(PassRefPtrWillBeRawPtr<Event> event) | 144 void DOMWindowEventQueue::dispatchEvent(PassRefPtrWillBeRawPtr<Event> event) |
142 { | 145 { |
143 EventTarget* eventTarget = event->target(); | 146 EventTarget* eventTarget = event->target(); |
144 if (eventTarget->toDOMWindow()) | 147 if (eventTarget->toDOMWindow()) |
145 eventTarget->toDOMWindow()->dispatchEvent(event, nullptr); | 148 eventTarget->toDOMWindow()->dispatchEvent(event, nullptr); |
146 else | 149 else |
147 eventTarget->dispatchEvent(event); | 150 eventTarget->dispatchEvent(event); |
148 } | 151 } |
149 | 152 |
150 } | 153 } |
OLD | NEW |