| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 return nullptr; | 106 return nullptr; |
| 107 } | 107 } |
| 108 | 108 |
| 109 MessagePort* EventTarget::toMessagePort() | 109 MessagePort* EventTarget::toMessagePort() |
| 110 { | 110 { |
| 111 return nullptr; | 111 return nullptr; |
| 112 } | 112 } |
| 113 | 113 |
| 114 inline LocalDOMWindow* EventTarget::executingWindow() | 114 inline LocalDOMWindow* EventTarget::executingWindow() |
| 115 { | 115 { |
| 116 if (ExecutionContext* context = executionContext()) | 116 if (ExecutionContext* context = getExecutionContext()) |
| 117 return context->executingWindow(); | 117 return context->executingWindow(); |
| 118 return nullptr; | 118 return nullptr; |
| 119 } | 119 } |
| 120 | 120 |
| 121 bool EventTarget::addEventListener(const AtomicString& eventType, PassRefPtrWill
BeRawPtr<EventListener> listener, bool useCapture) | 121 bool EventTarget::addEventListener(const AtomicString& eventType, PassRefPtrWill
BeRawPtr<EventListener> listener, bool useCapture) |
| 122 { | 122 { |
| 123 EventListenerOptions options; | 123 EventListenerOptions options; |
| 124 setDefaultEventListenerOptionsLegacy(options, useCapture); | 124 setDefaultEventListenerOptionsLegacy(options, useCapture); |
| 125 return addEventListenerInternal(eventType, listener, options); | 125 return addEventListenerInternal(eventType, listener, options); |
| 126 } | 126 } |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 { | 253 { |
| 254 if (event->type().isEmpty()) { | 254 if (event->type().isEmpty()) { |
| 255 exceptionState.throwDOMException(InvalidStateError, "The event provided
is uninitialized."); | 255 exceptionState.throwDOMException(InvalidStateError, "The event provided
is uninitialized."); |
| 256 return false; | 256 return false; |
| 257 } | 257 } |
| 258 if (event->isBeingDispatched()) { | 258 if (event->isBeingDispatched()) { |
| 259 exceptionState.throwDOMException(InvalidStateError, "The event is alread
y being dispatched."); | 259 exceptionState.throwDOMException(InvalidStateError, "The event is alread
y being dispatched."); |
| 260 return false; | 260 return false; |
| 261 } | 261 } |
| 262 | 262 |
| 263 if (!executionContext()) | 263 if (!getExecutionContext()) |
| 264 return false; | 264 return false; |
| 265 | 265 |
| 266 event->setTrusted(false); | 266 event->setTrusted(false); |
| 267 | 267 |
| 268 // Return whether the event was cancelled or not to JS not that it | 268 // Return whether the event was cancelled or not to JS not that it |
| 269 // might have actually been default handled; so check only against | 269 // might have actually been default handled; so check only against |
| 270 // CanceledByEventHandler. | 270 // CanceledByEventHandler. |
| 271 return dispatchEventInternal(event) != DispatchEventResult::CanceledByEventH
andler; | 271 return dispatchEventInternal(event) != DispatchEventResult::CanceledByEventH
andler; |
| 272 } | 272 } |
| 273 | 273 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 | 370 |
| 371 if (listenersVector) { | 371 if (listenersVector) { |
| 372 fireEventListeners(event, d, *listenersVector); | 372 fireEventListeners(event, d, *listenersVector); |
| 373 } else if (legacyListenersVector) { | 373 } else if (legacyListenersVector) { |
| 374 AtomicString unprefixedTypeName = event->type(); | 374 AtomicString unprefixedTypeName = event->type(); |
| 375 event->setType(legacyTypeName); | 375 event->setType(legacyTypeName); |
| 376 fireEventListeners(event, d, *legacyListenersVector); | 376 fireEventListeners(event, d, *legacyListenersVector); |
| 377 event->setType(unprefixedTypeName); | 377 event->setType(unprefixedTypeName); |
| 378 } | 378 } |
| 379 | 379 |
| 380 Editor::countEvent(executionContext(), event); | 380 Editor::countEvent(getExecutionContext(), event); |
| 381 countLegacyEvents(legacyTypeName, listenersVector, legacyListenersVector); | 381 countLegacyEvents(legacyTypeName, listenersVector, legacyListenersVector); |
| 382 return dispatchEventResult(*event); | 382 return dispatchEventResult(*event); |
| 383 } | 383 } |
| 384 | 384 |
| 385 void EventTarget::fireEventListeners(Event* event, EventTargetData* d, EventList
enerVector& entry) | 385 void EventTarget::fireEventListeners(Event* event, EventTargetData* d, EventList
enerVector& entry) |
| 386 { | 386 { |
| 387 RefPtrWillBeRawPtr<EventTarget> protect(this); | 387 RefPtrWillBeRawPtr<EventTarget> protect(this); |
| 388 | 388 |
| 389 // Fire all listeners registered for this event. Don't fire listeners remove
d | 389 // Fire all listeners registered for this event. Don't fire listeners remove
d |
| 390 // during event dispatch. Also, don't fire event listeners added during even
t | 390 // during event dispatch. Also, don't fire event listeners added during even
t |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 if (event->eventPhase() == Event::CAPTURING_PHASE && !registeredListener
.useCapture) | 428 if (event->eventPhase() == Event::CAPTURING_PHASE && !registeredListener
.useCapture) |
| 429 continue; | 429 continue; |
| 430 if (event->eventPhase() == Event::BUBBLING_PHASE && registeredListener.u
seCapture) | 430 if (event->eventPhase() == Event::BUBBLING_PHASE && registeredListener.u
seCapture) |
| 431 continue; | 431 continue; |
| 432 | 432 |
| 433 // If stopImmediatePropagation has been called, we just break out immedi
ately, without | 433 // If stopImmediatePropagation has been called, we just break out immedi
ately, without |
| 434 // handling any more events on this target. | 434 // handling any more events on this target. |
| 435 if (event->immediatePropagationStopped()) | 435 if (event->immediatePropagationStopped()) |
| 436 break; | 436 break; |
| 437 | 437 |
| 438 ExecutionContext* context = executionContext(); | 438 ExecutionContext* context = getExecutionContext(); |
| 439 if (!context) | 439 if (!context) |
| 440 break; | 440 break; |
| 441 | 441 |
| 442 event->setHandlingPassive(registeredListener.passive); | 442 event->setHandlingPassive(registeredListener.passive); |
| 443 | 443 |
| 444 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willHa
ndleEvent(this, event, registeredListener.listener.get(), registeredListener.use
Capture); | 444 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willHa
ndleEvent(this, event, registeredListener.listener.get(), registeredListener.use
Capture); |
| 445 | 445 |
| 446 // To match Mozilla, the AT_TARGET phase fires both capturing and bubbli
ng | 446 // To match Mozilla, the AT_TARGET phase fires both capturing and bubbli
ng |
| 447 // event listeners, even though that violates some versions of the DOM s
pec. | 447 // event listeners, even though that violates some versions of the DOM s
pec. |
| 448 registeredListener.listener->handleEvent(context, event); | 448 registeredListener.listener->handleEvent(context, event); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 // they have one less listener to invoke. | 489 // they have one less listener to invoke. |
| 490 if (d->firingEventIterators) { | 490 if (d->firingEventIterators) { |
| 491 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { | 491 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { |
| 492 d->firingEventIterators->at(i).iterator = 0; | 492 d->firingEventIterators->at(i).iterator = 0; |
| 493 d->firingEventIterators->at(i).end = 0; | 493 d->firingEventIterators->at(i).end = 0; |
| 494 } | 494 } |
| 495 } | 495 } |
| 496 } | 496 } |
| 497 | 497 |
| 498 } // namespace blink | 498 } // namespace blink |
| OLD | NEW |