Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Unified Diff: third_party/WebKit/Source/core/events/EventTarget.cpp

Issue 2024913002: Fix runtime setting forcing passive event listeners to scroll blocking events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix layout test Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/events/EventTarget.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 102516b95bedb3b4394cebbe22d5275d4f9ef602..03975f55dccae5d83bfc62786ce24a87749c1c1d 100644
--- a/third_party/WebKit/Source/core/events/EventTarget.cpp
+++ b/third_party/WebKit/Source/core/events/EventTarget.cpp
@@ -65,18 +65,20 @@ Settings* windowSettings(LocalDOMWindow* executingWindow)
return nullptr;
}
+bool isScrollBlockingEvent(const AtomicString& eventType)
+{
+ return eventType == EventTypeNames::touchstart
+ || eventType == EventTypeNames::touchmove
+ || eventType == EventTypeNames::mousewheel
+ || eventType == EventTypeNames::wheel;
+}
+
double blockedEventsWarningThreshold(const ExecutionContext* context, const Event* event)
{
if (!event->cancelable())
return 0.0;
- const AtomicString& eventType = event->type();
- if (eventType != EventTypeNames::touchstart
- && eventType != EventTypeNames::touchmove
- && eventType != EventTypeNames::touchend
- && eventType != EventTypeNames::mousewheel
- && eventType != EventTypeNames::wheel) {
+ if (!isScrollBlockingEvent(event->type()))
return 0.0;
- }
if (!context->isDocument())
return 0.0;
@@ -182,8 +184,14 @@ inline LocalDOMWindow* EventTarget::executingWindow()
return nullptr;
}
-void EventTarget::setDefaultAddEventListenerOptions(AddEventListenerOptions& options)
+void EventTarget::setDefaultAddEventListenerOptions(const AtomicString& eventType, AddEventListenerOptions& options)
{
+ if (!isScrollBlockingEvent(eventType)) {
+ if (!options.hasPassive())
+ options.setPassive(false);
+ return;
+ }
+
if (Settings* settings = windowSettings(executingWindow())) {
switch (settings->passiveListenerDefault()) {
case PassiveListenerDefault::False:
@@ -219,7 +227,7 @@ bool EventTarget::addEventListener(const AtomicString& eventType, EventListener*
{
AddEventListenerOptions options;
options.setCapture(useCapture);
- setDefaultAddEventListenerOptions(options);
+ setDefaultAddEventListenerOptions(eventType, options);
return addEventListenerInternal(eventType, listener, options);
}
@@ -236,7 +244,7 @@ bool EventTarget::addEventListener(const AtomicString& eventType, EventListener*
bool EventTarget::addEventListener(const AtomicString& eventType, EventListener* listener, AddEventListenerOptions& options)
{
- setDefaultAddEventListenerOptions(options);
+ setDefaultAddEventListenerOptions(eventType, options);
return addEventListenerInternal(eventType, listener, options);
}
« no previous file with comments | « third_party/WebKit/Source/core/events/EventTarget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698