| 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 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #include "modules/indexeddb/IDBEventDispatcher.h" | 29 #include "modules/indexeddb/IDBEventDispatcher.h" |
| 30 | 30 |
| 31 #include "core/frame/UseCounter.h" | |
| 32 #include "modules/EventModules.h" | 31 #include "modules/EventModules.h" |
| 33 #include "modules/EventTargetModules.h" | 32 #include "modules/EventTargetModules.h" |
| 34 | 33 |
| 35 namespace blink { | 34 namespace blink { |
| 36 | 35 |
| 37 DispatchEventResult IDBEventDispatcher::dispatch( | 36 DispatchEventResult IDBEventDispatcher::dispatch( |
| 38 Event* event, | 37 Event* event, |
| 39 HeapVector<Member<EventTarget>>& eventTargets) { | 38 HeapVector<Member<EventTarget>>& eventTargets) { |
| 40 size_t size = eventTargets.size(); | 39 size_t size = eventTargets.size(); |
| 41 ASSERT(size); | 40 ASSERT(size); |
| 42 | 41 |
| 43 event->setEventPhase(Event::kCapturingPhase); | 42 event->setEventPhase(Event::kCapturingPhase); |
| 44 for (size_t i = size - 1; i; --i) { // Don't do the first element. | 43 for (size_t i = size - 1; i; --i) { // Don't do the first element. |
| 45 event->setCurrentTarget(eventTargets[i].get()); | 44 event->setCurrentTarget(eventTargets[i].get()); |
| 46 eventTargets[i]->fireEventListeners(event); | 45 eventTargets[i]->fireEventListeners(event); |
| 47 if (event->propagationStopped()) | 46 if (event->propagationStopped()) |
| 48 goto doneDispatching; | 47 goto doneDispatching; |
| 49 } | 48 } |
| 50 | 49 |
| 51 event->setEventPhase(Event::kAtTarget); | 50 event->setEventPhase(Event::kAtTarget); |
| 52 event->setCurrentTarget(eventTargets[0].get()); | 51 event->setCurrentTarget(eventTargets[0].get()); |
| 53 eventTargets[0]->fireEventListeners(event); | 52 eventTargets[0]->fireEventListeners(event); |
| 54 if (event->propagationStopped() || !event->bubbles()) | 53 if (event->propagationStopped() || !event->bubbles() || event->cancelBubble()) |
| 55 goto doneDispatching; | 54 goto doneDispatching; |
| 56 if (event->bubbles() && event->cancelBubble()) { | |
| 57 for (size_t i = 1; i < size; ++i) { // Don't do the first element. | |
| 58 if (eventTargets[i]->hasEventListeners(event->type())) | |
| 59 UseCounter::count(eventTargets[i]->getExecutionContext(), | |
| 60 UseCounter::EventCancelBubbleAffected); | |
| 61 } | |
| 62 goto doneDispatching; | |
| 63 } | |
| 64 | 55 |
| 65 event->setEventPhase(Event::kBubblingPhase); | 56 event->setEventPhase(Event::kBubblingPhase); |
| 66 for (size_t i = 1; i < size; ++i) { // Don't do the first element. | 57 for (size_t i = 1; i < size; ++i) { // Don't do the first element. |
| 67 event->setCurrentTarget(eventTargets[i].get()); | 58 event->setCurrentTarget(eventTargets[i].get()); |
| 68 eventTargets[i]->fireEventListeners(event); | 59 eventTargets[i]->fireEventListeners(event); |
| 69 if (event->propagationStopped()) | 60 if (event->propagationStopped() || event->cancelBubble()) |
| 70 goto doneDispatching; | 61 goto doneDispatching; |
| 71 if (event->cancelBubble()) { | |
| 72 for (size_t j = i + 1; j < size; ++j) { | |
| 73 if (eventTargets[j]->hasEventListeners(event->type())) | |
| 74 UseCounter::count(eventTargets[j]->getExecutionContext(), | |
| 75 UseCounter::EventCancelBubbleAffected); | |
| 76 } | |
| 77 goto doneDispatching; | |
| 78 } | |
| 79 } | 62 } |
| 80 | 63 |
| 81 doneDispatching: | 64 doneDispatching: |
| 82 event->setCurrentTarget(nullptr); | 65 event->setCurrentTarget(nullptr); |
| 83 event->setEventPhase(Event::kNone); | 66 event->setEventPhase(Event::kNone); |
| 84 return EventTarget::dispatchEventResult(*event); | 67 return EventTarget::dispatchEventResult(*event); |
| 85 } | 68 } |
| 86 | 69 |
| 87 } // namespace blink | 70 } // namespace blink |
| OLD | NEW |