| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 #include "platform/EventDispatchForbiddenScope.h" | 47 #include "platform/EventDispatchForbiddenScope.h" |
| 48 #include "wtf/StdLibExtras.h" | 48 #include "wtf/StdLibExtras.h" |
| 49 #include "wtf/Threading.h" | 49 #include "wtf/Threading.h" |
| 50 #include "wtf/Vector.h" | 50 #include "wtf/Vector.h" |
| 51 | 51 |
| 52 using namespace WTF; | 52 using namespace WTF; |
| 53 | 53 |
| 54 namespace blink { | 54 namespace blink { |
| 55 namespace { | 55 namespace { |
| 56 | 56 |
| 57 void setDefaultEventListenerOptionsLegacy(EventListenerOptions& options, bool us
eCapture) | 57 Settings* windowSettings(LocalDOMWindow* executingWindow) |
| 58 { | 58 { |
| 59 options.setCapture(useCapture); | 59 if (executingWindow) { |
| 60 } | 60 if (LocalFrame* frame = executingWindow->frame()) { |
| 61 | 61 return frame->settings(); |
| 62 void setDefaultAddEventListenerOptionsLegacy(AddEventListenerOptions& options, b
ool useCapture) | 62 } |
| 63 { | 63 } |
| 64 setDefaultEventListenerOptionsLegacy(options, useCapture); | 64 return nullptr; |
| 65 options.setPassive(false); | |
| 66 } | |
| 67 | |
| 68 void setDefaultAddEventListenerOptions(AddEventListenerOptions& options) | |
| 69 { | |
| 70 if (!options.hasPassive()) | |
| 71 options.setPassive(false); | |
| 72 } | 65 } |
| 73 | 66 |
| 74 double blockedEventsWarningThreshold(const ExecutionContext* context, const Even
t* event) | 67 double blockedEventsWarningThreshold(const ExecutionContext* context, const Even
t* event) |
| 75 { | 68 { |
| 76 if (!event->cancelable()) | 69 if (!event->cancelable()) |
| 77 return 0.0; | 70 return 0.0; |
| 78 const AtomicString& eventType = event->type(); | 71 const AtomicString& eventType = event->type(); |
| 79 if (eventType != EventTypeNames::touchstart | 72 if (eventType != EventTypeNames::touchstart |
| 80 && eventType != EventTypeNames::touchmove | 73 && eventType != EventTypeNames::touchmove |
| 81 && eventType != EventTypeNames::touchend | 74 && eventType != EventTypeNames::touchend |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 return nullptr; | 175 return nullptr; |
| 183 } | 176 } |
| 184 | 177 |
| 185 inline LocalDOMWindow* EventTarget::executingWindow() | 178 inline LocalDOMWindow* EventTarget::executingWindow() |
| 186 { | 179 { |
| 187 if (ExecutionContext* context = getExecutionContext()) | 180 if (ExecutionContext* context = getExecutionContext()) |
| 188 return context->executingWindow(); | 181 return context->executingWindow(); |
| 189 return nullptr; | 182 return nullptr; |
| 190 } | 183 } |
| 191 | 184 |
| 185 void EventTarget::setDefaultAddEventListenerOptions(AddEventListenerOptions& opt
ions) |
| 186 { |
| 187 if (Settings* settings = windowSettings(executingWindow())) { |
| 188 switch (settings->passiveListenerDefault()) { |
| 189 case PassiveListenerDefault::False: |
| 190 if (!options.hasPassive()) |
| 191 options.setPassive(false); |
| 192 break; |
| 193 case PassiveListenerDefault::True: |
| 194 if (!options.hasPassive()) |
| 195 options.setPassive(true); |
| 196 break; |
| 197 case PassiveListenerDefault::ForceAllTrue: |
| 198 options.setPassive(true); |
| 199 break; |
| 200 case PassiveListenerDefault::DocumentTrue: |
| 201 if (!options.hasPassive()) { |
| 202 if (Node* node = toNode()) { |
| 203 if (node->isDocumentNode() || node->document().documentEleme
nt() == node || node->document().body() == node) { |
| 204 options.setPassive(true); |
| 205 } |
| 206 } else if (toLocalDOMWindow()) { |
| 207 options.setPassive(true); |
| 208 } |
| 209 } |
| 210 break; |
| 211 } |
| 212 } else { |
| 213 if (!options.hasPassive()) |
| 214 options.setPassive(false); |
| 215 } |
| 216 } |
| 217 |
| 192 bool EventTarget::addEventListener(const AtomicString& eventType, EventListener*
listener, bool useCapture) | 218 bool EventTarget::addEventListener(const AtomicString& eventType, EventListener*
listener, bool useCapture) |
| 193 { | 219 { |
| 194 AddEventListenerOptions options; | 220 AddEventListenerOptions options; |
| 195 setDefaultAddEventListenerOptionsLegacy(options, useCapture); | 221 options.setCapture(useCapture); |
| 222 setDefaultAddEventListenerOptions(options); |
| 196 return addEventListenerInternal(eventType, listener, options); | 223 return addEventListenerInternal(eventType, listener, options); |
| 197 } | 224 } |
| 198 | 225 |
| 199 bool EventTarget::addEventListener(const AtomicString& eventType, EventListener*
listener, const AddEventListenerOptionsOrBoolean& optionsUnion) | 226 bool EventTarget::addEventListener(const AtomicString& eventType, EventListener*
listener, const AddEventListenerOptionsOrBoolean& optionsUnion) |
| 200 { | 227 { |
| 201 if (optionsUnion.isBoolean()) | 228 if (optionsUnion.isBoolean()) |
| 202 return addEventListener(eventType, listener, optionsUnion.getAsBoolean()
); | 229 return addEventListener(eventType, listener, optionsUnion.getAsBoolean()
); |
| 203 if (optionsUnion.isAddEventListenerOptions()) { | 230 if (optionsUnion.isAddEventListenerOptions()) { |
| 204 AddEventListenerOptions options = optionsUnion.getAsAddEventListenerOpti
ons(); | 231 AddEventListenerOptions options = optionsUnion.getAsAddEventListenerOpti
ons(); |
| 205 return addEventListener(eventType, listener, options); | 232 return addEventListener(eventType, listener, options); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 if (EventUtil::isPointerEventType(eventType)) { | 265 if (EventUtil::isPointerEventType(eventType)) { |
| 239 if (LocalDOMWindow* executingWindow = this->executingWindow()) { | 266 if (LocalDOMWindow* executingWindow = this->executingWindow()) { |
| 240 UseCounter::count(executingWindow->document(), UseCounter::PointerEv
entAddListenerCount); | 267 UseCounter::count(executingWindow->document(), UseCounter::PointerEv
entAddListenerCount); |
| 241 } | 268 } |
| 242 } | 269 } |
| 243 } | 270 } |
| 244 | 271 |
| 245 bool EventTarget::removeEventListener(const AtomicString& eventType, const Event
Listener* listener, bool useCapture) | 272 bool EventTarget::removeEventListener(const AtomicString& eventType, const Event
Listener* listener, bool useCapture) |
| 246 { | 273 { |
| 247 EventListenerOptions options; | 274 EventListenerOptions options; |
| 248 setDefaultEventListenerOptionsLegacy(options, useCapture); | 275 options.setCapture(useCapture); |
| 249 return removeEventListenerInternal(eventType, listener, options); | 276 return removeEventListenerInternal(eventType, listener, options); |
| 250 } | 277 } |
| 251 | 278 |
| 252 bool EventTarget::removeEventListener(const AtomicString& eventType, const Event
Listener* listener, const EventListenerOptionsOrBoolean& optionsUnion) | 279 bool EventTarget::removeEventListener(const AtomicString& eventType, const Event
Listener* listener, const EventListenerOptionsOrBoolean& optionsUnion) |
| 253 { | 280 { |
| 254 if (optionsUnion.isBoolean()) | 281 if (optionsUnion.isBoolean()) |
| 255 return removeEventListener(eventType, listener, optionsUnion.getAsBoolea
n()); | 282 return removeEventListener(eventType, listener, optionsUnion.getAsBoolea
n()); |
| 256 if (optionsUnion.isEventListenerOptions()) { | 283 if (optionsUnion.isEventListenerOptions()) { |
| 257 EventListenerOptions options = optionsUnion.getAsEventListenerOptions(); | 284 EventListenerOptions options = optionsUnion.getAsEventListenerOptions(); |
| 258 return removeEventListener(eventType, listener, options); | 285 return removeEventListener(eventType, listener, options); |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 // they have one less listener to invoke. | 614 // they have one less listener to invoke. |
| 588 if (d->firingEventIterators) { | 615 if (d->firingEventIterators) { |
| 589 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { | 616 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { |
| 590 d->firingEventIterators->at(i).iterator = 0; | 617 d->firingEventIterators->at(i).iterator = 0; |
| 591 d->firingEventIterators->at(i).end = 0; | 618 d->firingEventIterators->at(i).end = 0; |
| 592 } | 619 } |
| 593 } | 620 } |
| 594 } | 621 } |
| 595 | 622 |
| 596 } // namespace blink | 623 } // namespace blink |
| OLD | NEW |