Chromium Code Reviews| 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 14 matching lines...) Expand all Loading... | |
| 25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 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/dom/EventTarget.h" | 33 #include "core/dom/EventTarget.h" |
| 34 | 34 |
| 35 #include "bindings/v8/DOMWrapperWorld.h" | |
| 35 #include "bindings/v8/ScriptController.h" | 36 #include "bindings/v8/ScriptController.h" |
| 36 #include "core/dom/Event.h" | 37 #include "core/dom/Event.h" |
| 37 #include "core/dom/ExceptionCode.h" | 38 #include "core/dom/ExceptionCode.h" |
| 38 #include "core/inspector/InspectorInstrumentation.h" | 39 #include "core/inspector/InspectorInstrumentation.h" |
| 39 #include <wtf/MainThread.h> | 40 #include <wtf/MainThread.h> |
| 40 #include <wtf/StdLibExtras.h> | 41 #include <wtf/StdLibExtras.h> |
| 41 #include <wtf/Vector.h> | 42 #include <wtf/Vector.h> |
| 42 | 43 |
| 43 using namespace WTF; | 44 using namespace WTF; |
| 44 | 45 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 continue; | 97 continue; |
| 97 | 98 |
| 98 --firingIterator.end; | 99 --firingIterator.end; |
| 99 if (indexOfRemovedListener <= firingIterator.iterator) | 100 if (indexOfRemovedListener <= firingIterator.iterator) |
| 100 --firingIterator.iterator; | 101 --firingIterator.iterator; |
| 101 } | 102 } |
| 102 | 103 |
| 103 return true; | 104 return true; |
| 104 } | 105 } |
| 105 | 106 |
| 106 bool EventTarget::setAttributeEventListener(const AtomicString& eventType, PassR efPtr<EventListener> listener) | 107 bool EventTarget::setAttributeEventListener(const AtomicString& eventType, PassR efPtr<EventListener> listener, DOMWrapperWorld* world) |
| 107 { | 108 { |
| 108 clearAttributeEventListener(eventType); | 109 clearAttributeEventListener(eventType, world); |
| 109 if (!listener) | 110 if (!listener) |
| 110 return false; | 111 return false; |
| 112 ASSERT(listener->world() == world); | |
| 111 return addEventListener(eventType, listener, false); | 113 return addEventListener(eventType, listener, false); |
| 112 } | 114 } |
| 113 | 115 |
| 114 EventListener* EventTarget::getAttributeEventListener(const AtomicString& eventT ype) | 116 EventListener* EventTarget::getAttributeEventListener(const AtomicString& eventT ype, DOMWrapperWorld* world) |
| 115 { | 117 { |
| 116 const EventListenerVector& entry = getEventListeners(eventType); | 118 const EventListenerVector& entry = getEventListeners(eventType); |
| 117 for (size_t i = 0; i < entry.size(); ++i) { | 119 for (size_t i = 0; i < entry.size(); ++i) { |
| 118 if (entry[i].listener->isAttribute()) | 120 if (entry[i].listener->isAttribute()) { |
| 119 return entry[i].listener.get(); | 121 DOMWrapperWorld* listenerWorld = entry[i].listener->world(); |
| 122 if ((listenerWorld && listenerWorld->isMainWorld() && !world) | |
|
adamk
2013/06/13 00:18:09
This is the really ugly part of the current change
abarth-chromium
2013/06/13 00:30:44
We talked a bit about this in person, and we reali
adamk
2013/06/13 18:55:07
Updated the logic somewhat, though not exactly as
| |
| 123 || (listenerWorld == world)) { | |
| 124 return entry[i].listener.get(); | |
| 125 } | |
| 126 } | |
| 120 } | 127 } |
| 121 return 0; | 128 return 0; |
| 122 } | 129 } |
| 123 | 130 |
| 124 bool EventTarget::clearAttributeEventListener(const AtomicString& eventType) | 131 bool EventTarget::clearAttributeEventListener(const AtomicString& eventType, DOM WrapperWorld* world) |
| 125 { | 132 { |
| 126 EventListener* listener = getAttributeEventListener(eventType); | 133 EventListener* listener = getAttributeEventListener(eventType, world); |
| 127 if (!listener) | 134 if (!listener) |
| 128 return false; | 135 return false; |
| 129 return removeEventListener(eventType, listener, false); | 136 return removeEventListener(eventType, listener, false); |
| 130 } | 137 } |
| 131 | 138 |
| 132 bool EventTarget::dispatchEvent(PassRefPtr<Event> event, ExceptionCode& ec) | 139 bool EventTarget::dispatchEvent(PassRefPtr<Event> event, ExceptionCode& ec) |
| 133 { | 140 { |
| 134 if (!event || event->type().isEmpty() || event->isBeingDispatched()) { | 141 if (!event || event->type().isEmpty() || event->isBeingDispatched()) { |
| 135 ec = INVALID_STATE_ERR; | 142 ec = INVALID_STATE_ERR; |
| 136 return false; | 143 return false; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 280 // they have one less listener to invoke. | 287 // they have one less listener to invoke. |
| 281 if (d->firingEventIterators) { | 288 if (d->firingEventIterators) { |
| 282 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { | 289 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { |
| 283 d->firingEventIterators->at(i).iterator = 0; | 290 d->firingEventIterators->at(i).iterator = 0; |
| 284 d->firingEventIterators->at(i).end = 0; | 291 d->firingEventIterators->at(i).end = 0; |
| 285 } | 292 } |
| 286 } | 293 } |
| 287 } | 294 } |
| 288 | 295 |
| 289 } // namespace WebCore | 296 } // namespace WebCore |
| OLD | NEW |