| 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 15 matching lines...) Expand all Loading... |
| 26 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 * | 29 * |
| 30 */ | 30 */ |
| 31 | 31 |
| 32 #include "config.h" | 32 #include "config.h" |
| 33 #include "core/events/EventTarget.h" | 33 #include "core/events/EventTarget.h" |
| 34 | 34 |
| 35 #include "RuntimeEnabledFeatures.h" | 35 #include "RuntimeEnabledFeatures.h" |
| 36 #include "bindings/v8/DOMWrapperWorld.h" | |
| 37 #include "bindings/v8/ExceptionState.h" | 36 #include "bindings/v8/ExceptionState.h" |
| 38 #include "core/events/Event.h" | 37 #include "core/events/Event.h" |
| 39 #include "core/dom/ExceptionCode.h" | 38 #include "core/dom/ExceptionCode.h" |
| 40 #include "core/inspector/InspectorInstrumentation.h" | 39 #include "core/inspector/InspectorInstrumentation.h" |
| 41 #include "core/frame/DOMWindow.h" | 40 #include "core/frame/DOMWindow.h" |
| 42 #include "platform/UserGestureIndicator.h" | 41 #include "platform/UserGestureIndicator.h" |
| 43 #include "wtf/StdLibExtras.h" | 42 #include "wtf/StdLibExtras.h" |
| 44 #include "wtf/Vector.h" | 43 #include "wtf/Vector.h" |
| 45 | 44 |
| 46 using namespace WTF; | 45 using namespace WTF; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 continue; | 115 continue; |
| 117 | 116 |
| 118 --firingIterator.end; | 117 --firingIterator.end; |
| 119 if (indexOfRemovedListener <= firingIterator.iterator) | 118 if (indexOfRemovedListener <= firingIterator.iterator) |
| 120 --firingIterator.iterator; | 119 --firingIterator.iterator; |
| 121 } | 120 } |
| 122 | 121 |
| 123 return true; | 122 return true; |
| 124 } | 123 } |
| 125 | 124 |
| 126 bool EventTarget::setAttributeEventListener(const AtomicString& eventType, PassR
efPtr<EventListener> listener, DOMWrapperWorld* isolatedWorld) | 125 bool EventTarget::setAttributeEventListener(const AtomicString& eventType, PassR
efPtr<EventListener> listener) |
| 127 { | 126 { |
| 128 clearAttributeEventListener(eventType, isolatedWorld); | 127 clearAttributeEventListener(eventType); |
| 129 if (!listener) | 128 if (!listener) |
| 130 return false; | 129 return false; |
| 131 return addEventListener(eventType, listener, false); | 130 return addEventListener(eventType, listener, false); |
| 132 } | 131 } |
| 133 | 132 |
| 134 EventListener* EventTarget::getAttributeEventListener(const AtomicString& eventT
ype, DOMWrapperWorld* isolatedWorld) | 133 EventListener* EventTarget::getAttributeEventListener(const AtomicString& eventT
ype) |
| 135 { | 134 { |
| 136 const EventListenerVector& entry = getEventListeners(eventType); | 135 const EventListenerVector& entry = getEventListeners(eventType); |
| 137 for (size_t i = 0; i < entry.size(); ++i) { | 136 for (size_t i = 0; i < entry.size(); ++i) { |
| 138 EventListener* listener = entry[i].listener.get(); | 137 EventListener* listener = entry[i].listener.get(); |
| 139 if (listener->isAttribute()) { | 138 if (listener->isAttribute() && listener->belongsToTheCurrentWorld()) |
| 140 DOMWrapperWorld* listenerWorld = listener->world(); | 139 return listener; |
| 141 // Worker listener | |
| 142 if (!listenerWorld) { | |
| 143 ASSERT(!isolatedWorld); | |
| 144 return listener; | |
| 145 } | |
| 146 if (listenerWorld->isMainWorld() && !isolatedWorld) | |
| 147 return listener; | |
| 148 if (listenerWorld == isolatedWorld) | |
| 149 return listener; | |
| 150 } | |
| 151 } | 140 } |
| 152 return 0; | 141 return 0; |
| 153 } | 142 } |
| 154 | 143 |
| 155 bool EventTarget::clearAttributeEventListener(const AtomicString& eventType, DOM
WrapperWorld* isolatedWorld) | 144 bool EventTarget::clearAttributeEventListener(const AtomicString& eventType) |
| 156 { | 145 { |
| 157 EventListener* listener = getAttributeEventListener(eventType, isolatedWorld
); | 146 EventListener* listener = getAttributeEventListener(eventType); |
| 158 if (!listener) | 147 if (!listener) |
| 159 return false; | 148 return false; |
| 160 return removeEventListener(eventType, listener, false); | 149 return removeEventListener(eventType, listener, false); |
| 161 } | 150 } |
| 162 | 151 |
| 163 bool EventTarget::dispatchEvent(PassRefPtr<Event> event, ExceptionState& excepti
onState) | 152 bool EventTarget::dispatchEvent(PassRefPtr<Event> event, ExceptionState& excepti
onState) |
| 164 { | 153 { |
| 165 if (!event) { | 154 if (!event) { |
| 166 exceptionState.throwDOMException(InvalidStateError, "The event provided
is null."); | 155 exceptionState.throwDOMException(InvalidStateError, "The event provided
is null."); |
| 167 return false; | 156 return false; |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 // they have one less listener to invoke. | 370 // they have one less listener to invoke. |
| 382 if (d->firingEventIterators) { | 371 if (d->firingEventIterators) { |
| 383 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { | 372 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { |
| 384 d->firingEventIterators->at(i).iterator = 0; | 373 d->firingEventIterators->at(i).iterator = 0; |
| 385 d->firingEventIterators->at(i).end = 0; | 374 d->firingEventIterators->at(i).end = 0; |
| 386 } | 375 } |
| 387 } | 376 } |
| 388 } | 377 } |
| 389 | 378 |
| 390 } // namespace WebCore | 379 } // namespace WebCore |
| OLD | NEW |