| 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 21 matching lines...) Expand all Loading... |
| 32 #include "core/events/EventTarget.h" | 32 #include "core/events/EventTarget.h" |
| 33 | 33 |
| 34 #include "bindings/core/v8/ExceptionState.h" | 34 #include "bindings/core/v8/ExceptionState.h" |
| 35 #include "bindings/core/v8/V8AbstractEventListener.h" | 35 #include "bindings/core/v8/V8AbstractEventListener.h" |
| 36 #include "bindings/core/v8/V8DOMActivityLogger.h" | 36 #include "bindings/core/v8/V8DOMActivityLogger.h" |
| 37 #include "core/dom/ExceptionCode.h" | 37 #include "core/dom/ExceptionCode.h" |
| 38 #include "core/editing/Editor.h" | 38 #include "core/editing/Editor.h" |
| 39 #include "core/events/Event.h" | 39 #include "core/events/Event.h" |
| 40 #include "core/inspector/InspectorInstrumentation.h" | 40 #include "core/inspector/InspectorInstrumentation.h" |
| 41 #include "core/frame/LocalDOMWindow.h" | 41 #include "core/frame/LocalDOMWindow.h" |
| 42 #include "core/frame/Settings.h" |
| 42 #include "core/frame/UseCounter.h" | 43 #include "core/frame/UseCounter.h" |
| 43 #include "platform/EventDispatchForbiddenScope.h" | 44 #include "platform/EventDispatchForbiddenScope.h" |
| 44 #include "wtf/StdLibExtras.h" | 45 #include "wtf/StdLibExtras.h" |
| 45 #include "wtf/Threading.h" | 46 #include "wtf/Threading.h" |
| 46 #include "wtf/Vector.h" | 47 #include "wtf/Vector.h" |
| 47 | 48 |
| 48 using namespace WTF; | 49 using namespace WTF; |
| 49 | 50 |
| 50 namespace blink { | 51 namespace blink { |
| 51 namespace { | 52 namespace { |
| 52 | 53 |
| 53 void setDefaultEventListenerOptionsLegacy(EventListenerOptions& options, bool us
eCapture) | 54 Settings* windowSettings(LocalDOMWindow* executingWindow) |
| 54 { | 55 { |
| 55 options.setCapture(useCapture); | 56 if (executingWindow) { |
| 56 } | 57 if (LocalFrame* frame = executingWindow->frame()) { |
| 57 | 58 return frame->settings(); |
| 58 void setDefaultAddEventListenerOptionsLegacy(AddEventListenerOptions& options, b
ool useCapture) | 59 } |
| 59 { | 60 } |
| 60 setDefaultEventListenerOptionsLegacy(options, useCapture); | 61 return nullptr; |
| 61 options.setPassive(false); | |
| 62 } | |
| 63 | |
| 64 void setDefaultAddEventListenerOptions(AddEventListenerOptions& options) | |
| 65 { | |
| 66 if (!options.hasPassive()) | |
| 67 options.setPassive(false); | |
| 68 } | 62 } |
| 69 | 63 |
| 70 } // namespace | 64 } // namespace |
| 71 | 65 |
| 72 EventTargetData::EventTargetData() | 66 EventTargetData::EventTargetData() |
| 73 { | 67 { |
| 74 } | 68 } |
| 75 | 69 |
| 76 EventTargetData::~EventTargetData() | 70 EventTargetData::~EventTargetData() |
| 77 { | 71 { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 return nullptr; | 125 return nullptr; |
| 132 } | 126 } |
| 133 | 127 |
| 134 inline LocalDOMWindow* EventTarget::executingWindow() | 128 inline LocalDOMWindow* EventTarget::executingWindow() |
| 135 { | 129 { |
| 136 if (ExecutionContext* context = getExecutionContext()) | 130 if (ExecutionContext* context = getExecutionContext()) |
| 137 return context->executingWindow(); | 131 return context->executingWindow(); |
| 138 return nullptr; | 132 return nullptr; |
| 139 } | 133 } |
| 140 | 134 |
| 135 void EventTarget::setDefaultAddEventListenerOptions(AddEventListenerOptions& opt
ions) |
| 136 { |
| 137 if (Settings* settings = windowSettings(executingWindow())) { |
| 138 switch (settings->passiveListenerDefault()) { |
| 139 case PassiveListenerDefault::False: |
| 140 if (!options.hasPassive()) |
| 141 options.setPassive(false); |
| 142 break; |
| 143 case PassiveListenerDefault::True: |
| 144 if (!options.hasPassive()) |
| 145 options.setPassive(true); |
| 146 break; |
| 147 case PassiveListenerDefault::ForceAllTrue: |
| 148 options.setPassive(true); |
| 149 break; |
| 150 case PassiveListenerDefault::DocumentTrue: |
| 151 if (!options.hasPassive()) { |
| 152 if (Node* node = toNode()) { |
| 153 if (node->isDocumentNode() || node->document().documentEleme
nt() == node || node->document().body() == node) { |
| 154 options.setPassive(true); |
| 155 } |
| 156 } else if (toLocalDOMWindow()) { |
| 157 options.setPassive(true); |
| 158 } |
| 159 } |
| 160 break; |
| 161 } |
| 162 } else { |
| 163 if (!options.hasPassive()) |
| 164 options.setPassive(false); |
| 165 } |
| 166 } |
| 167 |
| 141 bool EventTarget::addEventListener(const AtomicString& eventType, EventListener*
listener, bool useCapture) | 168 bool EventTarget::addEventListener(const AtomicString& eventType, EventListener*
listener, bool useCapture) |
| 142 { | 169 { |
| 143 AddEventListenerOptions options; | 170 AddEventListenerOptions options; |
| 144 setDefaultAddEventListenerOptionsLegacy(options, useCapture); | 171 options.setCapture(useCapture); |
| 172 setDefaultAddEventListenerOptions(options); |
| 145 return addEventListenerInternal(eventType, listener, options); | 173 return addEventListenerInternal(eventType, listener, options); |
| 146 } | 174 } |
| 147 | 175 |
| 148 bool EventTarget::addEventListener(const AtomicString& eventType, EventListener*
listener, const AddEventListenerOptionsOrBoolean& optionsUnion) | 176 bool EventTarget::addEventListener(const AtomicString& eventType, EventListener*
listener, const AddEventListenerOptionsOrBoolean& optionsUnion) |
| 149 { | 177 { |
| 150 if (optionsUnion.isBoolean()) | 178 if (optionsUnion.isBoolean()) |
| 151 return addEventListener(eventType, listener, optionsUnion.getAsBoolean()
); | 179 return addEventListener(eventType, listener, optionsUnion.getAsBoolean()
); |
| 152 if (optionsUnion.isAddEventListenerOptions()) { | 180 if (optionsUnion.isAddEventListenerOptions()) { |
| 153 AddEventListenerOptions options = optionsUnion.getAsAddEventListenerOpti
ons(); | 181 AddEventListenerOptions options = optionsUnion.getAsAddEventListenerOpti
ons(); |
| 154 return addEventListener(eventType, listener, options); | 182 return addEventListener(eventType, listener, options); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 182 return added; | 210 return added; |
| 183 } | 211 } |
| 184 | 212 |
| 185 void EventTarget::addedEventListener(const AtomicString& eventType, RegisteredEv
entListener& registeredListener) | 213 void EventTarget::addedEventListener(const AtomicString& eventType, RegisteredEv
entListener& registeredListener) |
| 186 { | 214 { |
| 187 } | 215 } |
| 188 | 216 |
| 189 bool EventTarget::removeEventListener(const AtomicString& eventType, const Event
Listener* listener, bool useCapture) | 217 bool EventTarget::removeEventListener(const AtomicString& eventType, const Event
Listener* listener, bool useCapture) |
| 190 { | 218 { |
| 191 EventListenerOptions options; | 219 EventListenerOptions options; |
| 192 setDefaultEventListenerOptionsLegacy(options, useCapture); | 220 options.setCapture(useCapture); |
| 193 return removeEventListenerInternal(eventType, listener, options); | 221 return removeEventListenerInternal(eventType, listener, options); |
| 194 } | 222 } |
| 195 | 223 |
| 196 bool EventTarget::removeEventListener(const AtomicString& eventType, const Event
Listener* listener, const EventListenerOptionsOrBoolean& optionsUnion) | 224 bool EventTarget::removeEventListener(const AtomicString& eventType, const Event
Listener* listener, const EventListenerOptionsOrBoolean& optionsUnion) |
| 197 { | 225 { |
| 198 if (optionsUnion.isBoolean()) | 226 if (optionsUnion.isBoolean()) |
| 199 return removeEventListener(eventType, listener, optionsUnion.getAsBoolea
n()); | 227 return removeEventListener(eventType, listener, optionsUnion.getAsBoolea
n()); |
| 200 if (optionsUnion.isEventListenerOptions()) { | 228 if (optionsUnion.isEventListenerOptions()) { |
| 201 EventListenerOptions options = optionsUnion.getAsEventListenerOptions(); | 229 EventListenerOptions options = optionsUnion.getAsEventListenerOptions(); |
| 202 return removeEventListener(eventType, listener, options); | 230 return removeEventListener(eventType, listener, options); |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 // they have one less listener to invoke. | 546 // they have one less listener to invoke. |
| 519 if (d->firingEventIterators) { | 547 if (d->firingEventIterators) { |
| 520 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { | 548 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { |
| 521 d->firingEventIterators->at(i).iterator = 0; | 549 d->firingEventIterators->at(i).iterator = 0; |
| 522 d->firingEventIterators->at(i).end = 0; | 550 d->firingEventIterators->at(i).end = 0; |
| 523 } | 551 } |
| 524 } | 552 } |
| 525 } | 553 } |
| 526 | 554 |
| 527 } // namespace blink | 555 } // namespace blink |
| OLD | NEW |