Chromium Code Reviews| 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..75994d5980c730c8e663715a931b619a8abb0e99 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.PassiveForcedEventDispatchBreakage", PassiveForcedListenerResultTypeMax)); |
|
tdresser
2016/07/08 17:37:11
How much work would it be to add a histogram test
dtapuska
2016/07/08 19:03:53
Added :-)
|
| + PassiveForcedListenerResultType breakageType = PreventDefaultNotCalled; |
| + if (event->preventDefaultCalledDuringPassive()) |
| + breakageType = DocumentLevelTouchPreventDefaultCalled; |
| + |
| + passiveForcedHistogram.count(breakageType); |
| + } |
| + |
| event->setHandlingPassive(false); |
| RELEASE_ASSERT(i <= size); |