| Index: third_party/WebKit/Source/core/events/EventTarget.cpp
|
| diff --git a/third_party/WebKit/Source/core/events/EventTarget.cpp b/third_party/WebKit/Source/core/events/EventTarget.cpp
|
| index fa2bd91f48672f34686e457e579d92afd6189357..444296f4fd7cf042306633812e89945337c2e14e 100644
|
| --- a/third_party/WebKit/Source/core/events/EventTarget.cpp
|
| +++ b/third_party/WebKit/Source/core/events/EventTarget.cpp
|
| @@ -39,6 +39,7 @@
|
| #include "core/events/Event.h"
|
| #include "core/inspector/InspectorInstrumentation.h"
|
| #include "core/frame/LocalDOMWindow.h"
|
| +#include "core/frame/Settings.h"
|
| #include "core/frame/UseCounter.h"
|
| #include "platform/EventDispatchForbiddenScope.h"
|
| #include "wtf/StdLibExtras.h"
|
| @@ -50,21 +51,14 @@ using namespace WTF;
|
| namespace blink {
|
| namespace {
|
|
|
| -void setDefaultEventListenerOptionsLegacy(EventListenerOptions& options, bool useCapture)
|
| +Settings* windowSettings(LocalDOMWindow* executingWindow)
|
| {
|
| - options.setCapture(useCapture);
|
| -}
|
| -
|
| -void setDefaultAddEventListenerOptionsLegacy(AddEventListenerOptions& options, bool useCapture)
|
| -{
|
| - setDefaultEventListenerOptionsLegacy(options, useCapture);
|
| - options.setPassive(false);
|
| -}
|
| -
|
| -void setDefaultAddEventListenerOptions(AddEventListenerOptions& options)
|
| -{
|
| - if (!options.hasPassive())
|
| - options.setPassive(false);
|
| + if (executingWindow) {
|
| + if (LocalFrame* frame = executingWindow->frame()) {
|
| + return frame->settings();
|
| + }
|
| + }
|
| + return nullptr;
|
| }
|
|
|
| } // namespace
|
| @@ -138,10 +132,44 @@ inline LocalDOMWindow* EventTarget::executingWindow()
|
| return nullptr;
|
| }
|
|
|
| +void EventTarget::setDefaultAddEventListenerOptions(AddEventListenerOptions& options)
|
| +{
|
| + if (Settings* settings = windowSettings(executingWindow())) {
|
| + switch (settings->passiveListenerDefault()) {
|
| + case PassiveListenerDefault::False:
|
| + if (!options.hasPassive())
|
| + options.setPassive(false);
|
| + break;
|
| + case PassiveListenerDefault::True:
|
| + if (!options.hasPassive())
|
| + options.setPassive(true);
|
| + break;
|
| + case PassiveListenerDefault::ForceAllTrue:
|
| + options.setPassive(true);
|
| + break;
|
| + case PassiveListenerDefault::DocumentTrue:
|
| + if (!options.hasPassive()) {
|
| + if (Node* node = toNode()) {
|
| + if (node->isDocumentNode() || node->document().documentElement() == node || node->document().body() == node) {
|
| + options.setPassive(true);
|
| + }
|
| + } else if (toLocalDOMWindow()) {
|
| + options.setPassive(true);
|
| + }
|
| + }
|
| + break;
|
| + }
|
| + } else {
|
| + if (!options.hasPassive())
|
| + options.setPassive(false);
|
| + }
|
| +}
|
| +
|
| bool EventTarget::addEventListener(const AtomicString& eventType, EventListener* listener, bool useCapture)
|
| {
|
| AddEventListenerOptions options;
|
| - setDefaultAddEventListenerOptionsLegacy(options, useCapture);
|
| + options.setCapture(useCapture);
|
| + setDefaultAddEventListenerOptions(options);
|
| return addEventListenerInternal(eventType, listener, options);
|
| }
|
|
|
| @@ -189,7 +217,7 @@ void EventTarget::addedEventListener(const AtomicString& eventType, RegisteredEv
|
| bool EventTarget::removeEventListener(const AtomicString& eventType, const EventListener* listener, bool useCapture)
|
| {
|
| EventListenerOptions options;
|
| - setDefaultEventListenerOptionsLegacy(options, useCapture);
|
| + options.setCapture(useCapture);
|
| return removeEventListenerInternal(eventType, listener, options);
|
| }
|
|
|
|
|