| 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" |
| 31 #include "modules/EventModules.h" | 32 #include "modules/EventModules.h" |
| 32 #include "modules/EventTargetModules.h" | 33 #include "modules/EventTargetModules.h" |
| 33 | 34 |
| 34 namespace blink { | 35 namespace blink { |
| 35 | 36 |
| 36 DispatchEventResult IDBEventDispatcher::dispatch(Event* event, HeapVector<Member
<EventTarget>>& eventTargets) | 37 DispatchEventResult IDBEventDispatcher::dispatch(Event* event, HeapVector<Member
<EventTarget>>& eventTargets) |
| 37 { | 38 { |
| 38 size_t size = eventTargets.size(); | 39 size_t size = eventTargets.size(); |
| 39 ASSERT(size); | 40 ASSERT(size); |
| 40 | 41 |
| 41 event->setEventPhase(Event::CAPTURING_PHASE); | 42 event->setEventPhase(Event::CAPTURING_PHASE); |
| 42 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. |
| 43 event->setCurrentTarget(eventTargets[i].get()); | 44 event->setCurrentTarget(eventTargets[i].get()); |
| 44 eventTargets[i]->fireEventListeners(event); | 45 eventTargets[i]->fireEventListeners(event); |
| 45 if (event->propagationStopped()) | 46 if (event->propagationStopped()) |
| 46 goto doneDispatching; | 47 goto doneDispatching; |
| 47 } | 48 } |
| 48 | 49 |
| 49 event->setEventPhase(Event::AT_TARGET); | 50 event->setEventPhase(Event::AT_TARGET); |
| 50 event->setCurrentTarget(eventTargets[0].get()); | 51 event->setCurrentTarget(eventTargets[0].get()); |
| 51 eventTargets[0]->fireEventListeners(event); | 52 eventTargets[0]->fireEventListeners(event); |
| 52 if (event->propagationStopped() || !event->bubbles() || event->cancelBubble(
)) | 53 if (event->propagationStopped() || !event->bubbles()) |
| 53 goto doneDispatching; | 54 goto doneDispatching; |
| 55 if (event->bubbles() && event->cancelBubble()) { |
| 56 for (size_t i = 1; i < size; ++i) { // Don't do the first element. |
| 57 if (eventTargets[i]->hasEventListeners(event->type())) |
| 58 UseCounter::count(eventTargets[i]->getExecutionContext(), UseCou
nter::EventCancelBubbleAffected); |
| 59 } |
| 60 goto doneDispatching; |
| 61 } |
| 54 | 62 |
| 55 event->setEventPhase(Event::BUBBLING_PHASE); | 63 event->setEventPhase(Event::BUBBLING_PHASE); |
| 56 for (size_t i = 1; i < size; ++i) { // Don't do the first element. | 64 for (size_t i = 1; i < size; ++i) { // Don't do the first element. |
| 57 event->setCurrentTarget(eventTargets[i].get()); | 65 event->setCurrentTarget(eventTargets[i].get()); |
| 58 eventTargets[i]->fireEventListeners(event); | 66 eventTargets[i]->fireEventListeners(event); |
| 59 if (event->propagationStopped() || event->cancelBubble()) | 67 if (event->propagationStopped()) |
| 60 goto doneDispatching; | 68 goto doneDispatching; |
| 69 if (event->cancelBubble()) { |
| 70 for (size_t j = i + 1; j < size; ++j) { |
| 71 if (eventTargets[j]->hasEventListeners(event->type())) |
| 72 UseCounter::count(eventTargets[j]->getExecutionContext(), Us
eCounter::EventCancelBubbleAffected); |
| 73 } |
| 74 goto doneDispatching; |
| 75 } |
| 61 } | 76 } |
| 62 | 77 |
| 63 doneDispatching: | 78 doneDispatching: |
| 64 event->setCurrentTarget(nullptr); | 79 event->setCurrentTarget(nullptr); |
| 65 event->setEventPhase(Event::NONE); | 80 event->setEventPhase(Event::NONE); |
| 66 return EventTarget::dispatchEventResult(*event); | 81 return EventTarget::dispatchEventResult(*event); |
| 67 } | 82 } |
| 68 | 83 |
| 69 } // namespace blink | 84 } // namespace blink |
| OLD | NEW |