| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 Settings* windowSettings(LocalDOMWindow* executingWindow) | 58 Settings* windowSettings(LocalDOMWindow* executingWindow) |
| 59 { | 59 { |
| 60 if (executingWindow) { | 60 if (executingWindow) { |
| 61 if (LocalFrame* frame = executingWindow->frame()) { | 61 if (LocalFrame* frame = executingWindow->frame()) { |
| 62 return frame->settings(); | 62 return frame->settings(); |
| 63 } | 63 } |
| 64 } | 64 } |
| 65 return nullptr; | 65 return nullptr; |
| 66 } | 66 } |
| 67 | 67 |
| 68 bool isScrollBlockingEvent(const AtomicString& eventType) |
| 69 { |
| 70 return eventType == EventTypeNames::touchstart |
| 71 || eventType == EventTypeNames::touchmove |
| 72 || eventType == EventTypeNames::mousewheel |
| 73 || eventType == EventTypeNames::wheel; |
| 74 } |
| 75 |
| 68 double blockedEventsWarningThreshold(const ExecutionContext* context, const Even
t* event) | 76 double blockedEventsWarningThreshold(const ExecutionContext* context, const Even
t* event) |
| 69 { | 77 { |
| 70 if (!event->cancelable()) | 78 if (!event->cancelable()) |
| 71 return 0.0; | 79 return 0.0; |
| 72 const AtomicString& eventType = event->type(); | 80 if (!isScrollBlockingEvent(event->type())) |
| 73 if (eventType != EventTypeNames::touchstart | |
| 74 && eventType != EventTypeNames::touchmove | |
| 75 && eventType != EventTypeNames::touchend | |
| 76 && eventType != EventTypeNames::mousewheel | |
| 77 && eventType != EventTypeNames::wheel) { | |
| 78 return 0.0; | 81 return 0.0; |
| 79 } | |
| 80 | 82 |
| 81 if (!context->isDocument()) | 83 if (!context->isDocument()) |
| 82 return 0.0; | 84 return 0.0; |
| 83 FrameHost* frameHost = toDocument(context)->frameHost(); | 85 FrameHost* frameHost = toDocument(context)->frameHost(); |
| 84 if (!frameHost) | 86 if (!frameHost) |
| 85 return 0.0; | 87 return 0.0; |
| 86 return frameHost->settings().blockedMainThreadEventsWarningThreshold(); | 88 return frameHost->settings().blockedMainThreadEventsWarningThreshold(); |
| 87 } | 89 } |
| 88 | 90 |
| 89 void reportBlockedEvent(ExecutionContext* context, const Event* event, Registere
dEventListener* registeredListener, double delayedSeconds) | 91 void reportBlockedEvent(ExecutionContext* context, const Event* event, Registere
dEventListener* registeredListener, double delayedSeconds) |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 return nullptr; | 177 return nullptr; |
| 176 } | 178 } |
| 177 | 179 |
| 178 inline LocalDOMWindow* EventTarget::executingWindow() | 180 inline LocalDOMWindow* EventTarget::executingWindow() |
| 179 { | 181 { |
| 180 if (ExecutionContext* context = getExecutionContext()) | 182 if (ExecutionContext* context = getExecutionContext()) |
| 181 return context->executingWindow(); | 183 return context->executingWindow(); |
| 182 return nullptr; | 184 return nullptr; |
| 183 } | 185 } |
| 184 | 186 |
| 185 void EventTarget::setDefaultAddEventListenerOptions(AddEventListenerOptions& opt
ions) | 187 void EventTarget::setDefaultAddEventListenerOptions(const AtomicString& eventTyp
e, AddEventListenerOptions& options) |
| 186 { | 188 { |
| 189 if (!isScrollBlockingEvent(eventType)) { |
| 190 if (!options.hasPassive()) |
| 191 options.setPassive(false); |
| 192 return; |
| 193 } |
| 194 |
| 187 if (Settings* settings = windowSettings(executingWindow())) { | 195 if (Settings* settings = windowSettings(executingWindow())) { |
| 188 switch (settings->passiveListenerDefault()) { | 196 switch (settings->passiveListenerDefault()) { |
| 189 case PassiveListenerDefault::False: | 197 case PassiveListenerDefault::False: |
| 190 if (!options.hasPassive()) | 198 if (!options.hasPassive()) |
| 191 options.setPassive(false); | 199 options.setPassive(false); |
| 192 break; | 200 break; |
| 193 case PassiveListenerDefault::True: | 201 case PassiveListenerDefault::True: |
| 194 if (!options.hasPassive()) | 202 if (!options.hasPassive()) |
| 195 options.setPassive(true); | 203 options.setPassive(true); |
| 196 break; | 204 break; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 212 } else { | 220 } else { |
| 213 if (!options.hasPassive()) | 221 if (!options.hasPassive()) |
| 214 options.setPassive(false); | 222 options.setPassive(false); |
| 215 } | 223 } |
| 216 } | 224 } |
| 217 | 225 |
| 218 bool EventTarget::addEventListener(const AtomicString& eventType, EventListener*
listener, bool useCapture) | 226 bool EventTarget::addEventListener(const AtomicString& eventType, EventListener*
listener, bool useCapture) |
| 219 { | 227 { |
| 220 AddEventListenerOptions options; | 228 AddEventListenerOptions options; |
| 221 options.setCapture(useCapture); | 229 options.setCapture(useCapture); |
| 222 setDefaultAddEventListenerOptions(options); | 230 setDefaultAddEventListenerOptions(eventType, options); |
| 223 return addEventListenerInternal(eventType, listener, options); | 231 return addEventListenerInternal(eventType, listener, options); |
| 224 } | 232 } |
| 225 | 233 |
| 226 bool EventTarget::addEventListener(const AtomicString& eventType, EventListener*
listener, const AddEventListenerOptionsOrBoolean& optionsUnion) | 234 bool EventTarget::addEventListener(const AtomicString& eventType, EventListener*
listener, const AddEventListenerOptionsOrBoolean& optionsUnion) |
| 227 { | 235 { |
| 228 if (optionsUnion.isBoolean()) | 236 if (optionsUnion.isBoolean()) |
| 229 return addEventListener(eventType, listener, optionsUnion.getAsBoolean()
); | 237 return addEventListener(eventType, listener, optionsUnion.getAsBoolean()
); |
| 230 if (optionsUnion.isAddEventListenerOptions()) { | 238 if (optionsUnion.isAddEventListenerOptions()) { |
| 231 AddEventListenerOptions options = optionsUnion.getAsAddEventListenerOpti
ons(); | 239 AddEventListenerOptions options = optionsUnion.getAsAddEventListenerOpti
ons(); |
| 232 return addEventListener(eventType, listener, options); | 240 return addEventListener(eventType, listener, options); |
| 233 } | 241 } |
| 234 return addEventListener(eventType, listener); | 242 return addEventListener(eventType, listener); |
| 235 } | 243 } |
| 236 | 244 |
| 237 bool EventTarget::addEventListener(const AtomicString& eventType, EventListener*
listener, AddEventListenerOptions& options) | 245 bool EventTarget::addEventListener(const AtomicString& eventType, EventListener*
listener, AddEventListenerOptions& options) |
| 238 { | 246 { |
| 239 setDefaultAddEventListenerOptions(options); | 247 setDefaultAddEventListenerOptions(eventType, options); |
| 240 return addEventListenerInternal(eventType, listener, options); | 248 return addEventListenerInternal(eventType, listener, options); |
| 241 } | 249 } |
| 242 | 250 |
| 243 bool EventTarget::addEventListenerInternal(const AtomicString& eventType, EventL
istener* listener, const AddEventListenerOptions& options) | 251 bool EventTarget::addEventListenerInternal(const AtomicString& eventType, EventL
istener* listener, const AddEventListenerOptions& options) |
| 244 { | 252 { |
| 245 if (!listener) | 253 if (!listener) |
| 246 return false; | 254 return false; |
| 247 | 255 |
| 248 V8DOMActivityLogger* activityLogger = V8DOMActivityLogger::currentActivityLo
ggerIfIsolatedWorld(); | 256 V8DOMActivityLogger* activityLogger = V8DOMActivityLogger::currentActivityLo
ggerIfIsolatedWorld(); |
| 249 if (activityLogger) { | 257 if (activityLogger) { |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 // they have one less listener to invoke. | 641 // they have one less listener to invoke. |
| 634 if (d->firingEventIterators) { | 642 if (d->firingEventIterators) { |
| 635 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { | 643 for (size_t i = 0; i < d->firingEventIterators->size(); ++i) { |
| 636 d->firingEventIterators->at(i).iterator = 0; | 644 d->firingEventIterators->at(i).iterator = 0; |
| 637 d->firingEventIterators->at(i).end = 0; | 645 d->firingEventIterators->at(i).end = 0; |
| 638 } | 646 } |
| 639 } | 647 } |
| 640 } | 648 } |
| 641 | 649 |
| 642 } // namespace blink | 650 } // namespace blink |
| OLD | NEW |