| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. |
| 6 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 6 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 7 * (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 7 * (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
| 8 * | 8 * |
| 9 * Redistribution and use in source and binary forms, with or without | 9 * Redistribution and use in source and binary forms, with or without |
| 10 * modification, are permitted provided that the following conditions | 10 * modification, are permitted provided that the following conditions |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 | 76 |
| 77 inline DOMWindow* EventTarget::executingWindow() | 77 inline DOMWindow* EventTarget::executingWindow() |
| 78 { | 78 { |
| 79 if (ExecutionContext* context = executionContext()) | 79 if (ExecutionContext* context = executionContext()) |
| 80 return context->executingWindow(); | 80 return context->executingWindow(); |
| 81 return 0; | 81 return 0; |
| 82 } | 82 } |
| 83 | 83 |
| 84 bool EventTarget::addEventListener(const AtomicString& eventType, PassRefPtr<Eve
ntListener> listener, bool useCapture) | 84 bool EventTarget::addEventListener(const AtomicString& eventType, PassRefPtr<Eve
ntListener> listener, bool useCapture) |
| 85 { | 85 { |
| 86 return ensureEventTargetData().eventListenerMap.add(eventType, listener, use
Capture); | 86 EventListener* eventListener = listener.get(); |
| 87 if (ensureEventTargetData().eventListenerMap.add(eventType, listener, useCap
ture)) { |
| 88 InspectorInstrumentation::didAddEventListener(this, eventType, eventList
ener, useCapture); |
| 89 return true; |
| 90 } |
| 91 return false; |
| 87 } | 92 } |
| 88 | 93 |
| 89 bool EventTarget::removeEventListener(const AtomicString& eventType, EventListen
er* listener, bool useCapture) | 94 bool EventTarget::removeEventListener(const AtomicString& eventType, EventListen
er* listener, bool useCapture) |
| 90 { | 95 { |
| 91 EventTargetData* d = eventTargetData(); | 96 EventTargetData* d = eventTargetData(); |
| 92 if (!d) | 97 if (!d) |
| 93 return false; | 98 return false; |
| 94 | 99 |
| 95 size_t indexOfRemovedListener; | 100 size_t indexOfRemovedListener; |
| 96 | 101 |
| 97 if (!d->eventListenerMap.remove(eventType, listener, useCapture, indexOfRemo
vedListener)) | 102 if (!d->eventListenerMap.remove(eventType, listener, useCapture, indexOfRemo
vedListener)) |
| 98 return false; | 103 return false; |
| 104 InspectorInstrumentation::didRemoveEventListener(this, eventType, listener,
useCapture); |
| 99 | 105 |
| 100 // Notify firing events planning to invoke the listener at 'index' that | 106 // Notify firing events planning to invoke the listener at 'index' that |
| 101 // they have one less listener to invoke. | 107 // they have one less listener to invoke. |
| 102 if (!d->firingEventIterators) | 108 if (!d->firingEventIterators) |
| 103 return true; | 109 return true; |
| 104 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { | 110 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { |
| 105 FiringEventIterator& firingIterator = d->firingEventIterators->at(i); | 111 FiringEventIterator& firingIterator = d->firingEventIterators->at(i); |
| 106 if (eventType != firingIterator.eventType) | 112 if (eventType != firingIterator.eventType) |
| 107 continue; | 113 continue; |
| 108 | 114 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 | 326 |
| 321 // If stopImmediatePropagation has been called, we just break out immedi
ately, without | 327 // If stopImmediatePropagation has been called, we just break out immedi
ately, without |
| 322 // handling any more events on this target. | 328 // handling any more events on this target. |
| 323 if (event->immediatePropagationStopped()) | 329 if (event->immediatePropagationStopped()) |
| 324 break; | 330 break; |
| 325 | 331 |
| 326 ExecutionContext* context = executionContext(); | 332 ExecutionContext* context = executionContext(); |
| 327 if (!context) | 333 if (!context) |
| 328 break; | 334 break; |
| 329 | 335 |
| 330 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willHa
ndleEvent(context, event); | 336 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willHa
ndleEvent(this, event->type(), registeredListener.listener.get(), registeredList
ener.useCapture); |
| 331 // To match Mozilla, the AT_TARGET phase fires both capturing and bubbli
ng | 337 // To match Mozilla, the AT_TARGET phase fires both capturing and bubbli
ng |
| 332 // event listeners, even though that violates some versions of the DOM s
pec. | 338 // event listeners, even though that violates some versions of the DOM s
pec. |
| 333 registeredListener.listener->handleEvent(context, event); | 339 registeredListener.listener->handleEvent(context, event); |
| 334 if (!userEventWasHandled && UserGestureIndicator::processingUserGesture(
)) | 340 if (!userEventWasHandled && UserGestureIndicator::processingUserGesture(
)) |
| 335 userEventWasHandled = true; | 341 userEventWasHandled = true; |
| 336 InspectorInstrumentation::didHandleEvent(cookie); | 342 InspectorInstrumentation::didHandleEvent(cookie); |
| 337 } | 343 } |
| 338 d->firingEventIterators->removeLast(); | 344 d->firingEventIterators->removeLast(); |
| 339 if (userEventWasHandled) { | 345 if (userEventWasHandled) { |
| 340 if (ExecutionContext* context = executionContext()) | 346 if (ExecutionContext* context = executionContext()) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 356 | 362 |
| 357 return *listenerVector; | 363 return *listenerVector; |
| 358 } | 364 } |
| 359 | 365 |
| 360 void EventTarget::removeAllEventListeners() | 366 void EventTarget::removeAllEventListeners() |
| 361 { | 367 { |
| 362 EventTargetData* d = eventTargetData(); | 368 EventTargetData* d = eventTargetData(); |
| 363 if (!d) | 369 if (!d) |
| 364 return; | 370 return; |
| 365 d->eventListenerMap.clear(); | 371 d->eventListenerMap.clear(); |
| 372 InspectorInstrumentation::didRemoveAllEventListeners(this); |
| 366 | 373 |
| 367 // Notify firing events planning to invoke the listener at 'index' that | 374 // Notify firing events planning to invoke the listener at 'index' that |
| 368 // they have one less listener to invoke. | 375 // they have one less listener to invoke. |
| 369 if (d->firingEventIterators) { | 376 if (d->firingEventIterators) { |
| 370 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { | 377 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { |
| 371 d->firingEventIterators->at(i).iterator = 0; | 378 d->firingEventIterators->at(i).iterator = 0; |
| 372 d->firingEventIterators->at(i).end = 0; | 379 d->firingEventIterators->at(i).end = 0; |
| 373 } | 380 } |
| 374 } | 381 } |
| 375 } | 382 } |
| 376 | 383 |
| 377 } // namespace WebCore | 384 } // namespace WebCore |
| OLD | NEW |