Commit f523304b authored by Dave Tapuska's avatar Dave Tapuska Committed by Commit Bot

Add ability to count mouseup/down on disabled form controls.

This will count the number of pages we encounter with mouseup/down
listeners in the event path on disable form controls.

BUG=696686

Change-Id: I73102564444348c150714a8189bcab8738c9fa15
Reviewed-on: https://chromium-review.googlesource.com/847424Reviewed-by: default avatarMustaq Ahmed <mustaq@chromium.org>
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#526807}
parent de483b17
...@@ -2226,8 +2226,16 @@ void Node::HandleLocalEvents(Event& event) { ...@@ -2226,8 +2226,16 @@ void Node::HandleLocalEvents(Event& event) {
if (IsDisabledFormControl(this) && event.IsMouseEvent() && if (IsDisabledFormControl(this) && event.IsMouseEvent() &&
!RuntimeEnabledFeatures::SendMouseEventsDisabledFormControlsEnabled()) { !RuntimeEnabledFeatures::SendMouseEventsDisabledFormControlsEnabled()) {
UseCounter::Count(GetDocument(), if (HasEventListeners(event.type())) {
WebFeature::kDispatchMouseEventOnDisabledFormControl); UseCounter::Count(GetDocument(),
WebFeature::kDispatchMouseEventOnDisabledFormControl);
if (event.type() == EventTypeNames::mousedown ||
event.type() == EventTypeNames::mouseup) {
UseCounter::Count(
GetDocument(),
WebFeature::kDispatchMouseUpDownEventOnDisabledFormControl);
}
}
return; return;
} }
......
...@@ -380,6 +380,15 @@ bool EventPath::DisabledFormControlExistsInPath() const { ...@@ -380,6 +380,15 @@ bool EventPath::DisabledFormControlExistsInPath() const {
return false; return false;
} }
bool EventPath::HasEventListenersInPath(const AtomicString& event_type) const {
for (const auto& context : node_event_contexts_) {
const Node* target_node = context.GetNode();
if (target_node && target_node->HasEventListeners(event_type))
return true;
}
return false;
}
NodeEventContext& EventPath::TopNodeEventContext() { NodeEventContext& EventPath::TopNodeEventContext() {
DCHECK(!IsEmpty()); DCHECK(!IsEmpty());
return Last(); return Last();
......
...@@ -80,6 +80,7 @@ class CORE_EXPORT EventPath final ...@@ -80,6 +80,7 @@ class CORE_EXPORT EventPath final
void AdjustForTouchEvent(const TouchEvent&); void AdjustForTouchEvent(const TouchEvent&);
bool DisabledFormControlExistsInPath() const; bool DisabledFormControlExistsInPath() const;
bool HasEventListenersInPath(const AtomicString& event_type) const;
NodeEventContext& TopNodeEventContext(); NodeEventContext& TopNodeEventContext();
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "core/frame/LocalDOMWindow.h" #include "core/frame/LocalDOMWindow.h"
#include "core/frame/LocalFrame.h" #include "core/frame/LocalFrame.h"
#include "core/frame/LocalFrameView.h" #include "core/frame/LocalFrameView.h"
#include "core/frame/UseCounter.h"
#include "core/input/InputDeviceCapabilities.h" #include "core/input/InputDeviceCapabilities.h"
#include "core/layout/LayoutObject.h" #include "core/layout/LayoutObject.h"
#include "core/layout/LayoutView.h" #include "core/layout/LayoutView.h"
...@@ -447,8 +448,19 @@ DispatchEventResult MouseEvent::DispatchEvent(EventDispatcher& dispatcher) { ...@@ -447,8 +448,19 @@ DispatchEventResult MouseEvent::DispatchEvent(EventDispatcher& dispatcher) {
return dispatcher.Dispatch(); return dispatcher.Dispatch();
if (!send_to_disabled_form_controls && if (!send_to_disabled_form_controls &&
IsDisabledFormControl(&dispatcher.GetNode())) IsDisabledFormControl(&dispatcher.GetNode())) {
if (GetEventPath().HasEventListenersInPath(type())) {
UseCounter::Count(dispatcher.GetNode().GetDocument(),
WebFeature::kDispatchMouseEventOnDisabledFormControl);
if (type() == EventTypeNames::mousedown ||
type() == EventTypeNames::mouseup) {
UseCounter::Count(
dispatcher.GetNode().GetDocument(),
WebFeature::kDispatchMouseUpDownEventOnDisabledFormControl);
}
}
return DispatchEventResult::kCanceledBeforeDispatch; return DispatchEventResult::kCanceledBeforeDispatch;
}
if (type().IsEmpty()) if (type().IsEmpty())
return DispatchEventResult::kNotCanceled; // Shouldn't happen. return DispatchEventResult::kNotCanceled; // Shouldn't happen.
......
...@@ -1827,6 +1827,7 @@ enum WebFeature { ...@@ -1827,6 +1827,7 @@ enum WebFeature {
kCSSSelectorWebkitTextfieldDecorationContainer = 2318, kCSSSelectorWebkitTextfieldDecorationContainer = 2318,
kCSSSelectorWebkitUnknownPseudo = 2319, kCSSSelectorWebkitUnknownPseudo = 2319,
kFilterAsContainingBlockMayChangeOutput = 2320, kFilterAsContainingBlockMayChangeOutput = 2320,
kDispatchMouseUpDownEventOnDisabledFormControl = 2321,
// Add new features immediately above this line. Don't change assigned // Add new features immediately above this line. Don't change assigned
// numbers of any item, and don't reuse removed slots. // numbers of any item, and don't reuse removed slots.
......
...@@ -17333,6 +17333,7 @@ Called by update_net_error_codes.py.--> ...@@ -17333,6 +17333,7 @@ Called by update_net_error_codes.py.-->
<int value="2318" label="CSSSelectorWebkitTextfieldDecorationContainer"/> <int value="2318" label="CSSSelectorWebkitTextfieldDecorationContainer"/>
<int value="2319" label="CSSSelectorWebkitUnknownPseudo"/> <int value="2319" label="CSSSelectorWebkitUnknownPseudo"/>
<int value="2320" label="FilterAsContainingBlockMayChangeOutput"/> <int value="2320" label="FilterAsContainingBlockMayChangeOutput"/>
<int value="2321" label="DispatchMouseUpDownEventOnDisabledFormControl"/>
</enum> </enum>
<enum name="FeedbackSource"> <enum name="FeedbackSource">
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment