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

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

Issue 2137483003: Add UMA metrics for root scroller intervention to track forcing passive breakage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change layout test to a unit test Created 4 years, 5 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
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 c9316bd79dfeb0e6a96a8137725369cb1e8aac53..e30128bc06110ebc4772b4b8ed62dc4893e338c7 100644
--- a/third_party/WebKit/Source/core/events/EventTarget.cpp
+++ b/third_party/WebKit/Source/core/events/EventTarget.cpp
@@ -46,6 +46,7 @@
#include "core/inspector/ConsoleMessage.h"
#include "core/inspector/InspectorInstrumentation.h"
#include "platform/EventDispatchForbiddenScope.h"
+#include "platform/Histogram.h"
#include "wtf/PtrUtil.h"
#include "wtf/StdLibExtras.h"
#include "wtf/Threading.h"
@@ -57,6 +58,12 @@ using namespace WTF;
namespace blink {
namespace {
+enum PassiveForcedListenerResultType {
+ PreventDefaultNotCalled,
+ DocumentLevelTouchPreventDefaultCalled,
+ PassiveForcedListenerResultTypeMax
+};
+
Settings* windowSettings(LocalDOMWindow* executingWindow)
{
if (executingWindow) {
@@ -190,7 +197,7 @@ inline LocalDOMWindow* EventTarget::executingWindow()
return nullptr;
}
-void EventTarget::setDefaultAddEventListenerOptions(const AtomicString& eventType, AddEventListenerOptions& options)
+void EventTarget::setDefaultAddEventListenerOptions(const AtomicString& eventType, AddEventListenerOptionsResolved& options)
{
if (!isScrollBlockingEvent(eventType)) {
if (!options.hasPassive())
@@ -209,10 +216,12 @@ void EventTarget::setDefaultAddEventListenerOptions(const AtomicString& eventTyp
if (Node* node = toNode()) {
if (node->isDocumentNode() || node->document().documentElement() == node || node->document().body() == node) {
options.setPassive(true);
+ options.setPassiveForcedForDocumentTarget(true);
return;
}
} else if (toLocalDOMWindow()) {
options.setPassive(true);
+ options.setPassiveForcedForDocumentTarget(true);
return;
}
}
@@ -240,7 +249,7 @@ void EventTarget::setDefaultAddEventListenerOptions(const AtomicString& eventTyp
bool EventTarget::addEventListener(const AtomicString& eventType, EventListener* listener, bool useCapture)
{
- AddEventListenerOptions options;
+ AddEventListenerOptionsResolved options;
options.setCapture(useCapture);
setDefaultAddEventListenerOptions(eventType, options);
return addEventListenerInternal(eventType, listener, options);
@@ -251,19 +260,19 @@ bool EventTarget::addEventListener(const AtomicString& eventType, EventListener*
if (optionsUnion.isBoolean())
return addEventListener(eventType, listener, optionsUnion.getAsBoolean());
if (optionsUnion.isAddEventListenerOptions()) {
- AddEventListenerOptions options = optionsUnion.getAsAddEventListenerOptions();
+ AddEventListenerOptionsResolved options = optionsUnion.getAsAddEventListenerOptions();
return addEventListener(eventType, listener, options);
}
return addEventListener(eventType, listener);
}
-bool EventTarget::addEventListener(const AtomicString& eventType, EventListener* listener, AddEventListenerOptions& options)
+bool EventTarget::addEventListener(const AtomicString& eventType, EventListener* listener, AddEventListenerOptionsResolved& options)
{
setDefaultAddEventListenerOptions(eventType, options);
return addEventListenerInternal(eventType, listener, options);
}
-bool EventTarget::addEventListenerInternal(const AtomicString& eventType, EventListener* listener, const AddEventListenerOptions& options)
+bool EventTarget::addEventListenerInternal(const AtomicString& eventType, EventListener* listener, const AddEventListenerOptionsResolved& options)
{
if (!listener)
return false;
@@ -597,6 +606,7 @@ bool EventTarget::fireEventListeners(Event* event, EventTargetData* d, EventList
break;
event->setHandlingPassive(registeredListener.passive());
+ bool passiveForced = registeredListener.passiveForcedForDocumentTarget();
InspectorInstrumentation::NativeBreakpoint nativeBreakpoint(context, this, event);
@@ -614,6 +624,15 @@ bool EventTarget::fireEventListeners(Event* event, EventTargetData* d, EventList
reportBlockedEvent(context, event, &entry[i - 1], now - event->platformTimeStamp());
}
+ if (passiveForced) {
+ DEFINE_STATIC_LOCAL(EnumerationHistogram, passiveForcedHistogram, ("Event.PassiveForcedEventDispatchCancelled", PassiveForcedListenerResultTypeMax));
+ PassiveForcedListenerResultType breakageType = PreventDefaultNotCalled;
+ if (event->preventDefaultCalledDuringPassive())
+ breakageType = DocumentLevelTouchPreventDefaultCalled;
+
+ passiveForcedHistogram.count(breakageType);
+ }
+
event->setHandlingPassive(false);
RELEASE_ASSERT(i <= size);
« no previous file with comments | « third_party/WebKit/Source/core/events/EventTarget.h ('k') | third_party/WebKit/Source/core/events/EventTargetTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698