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

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

Issue 2272993004: Clarify devtools console log when a passive event listener is preventDefaulted. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add not reached Created 4 years, 4 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/Event.cpp
diff --git a/third_party/WebKit/Source/core/events/Event.cpp b/third_party/WebKit/Source/core/events/Event.cpp
index a66885174e79b74898ae99c6dca6cd1cc3c70724..3f4f9738ab5a41f8a1bf82f77ac5280491cbcf3d 100644
--- a/third_party/WebKit/Source/core/events/Event.cpp
+++ b/third_party/WebKit/Source/core/events/Event.cpp
@@ -80,8 +80,8 @@ Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableAr
, m_cancelBubble(false)
, m_wasInitialized(true)
, m_isTrusted(false)
- , m_handlingPassive(false)
, m_preventDefaultCalledOnUncancelableEvent(false)
+ , m_handlingPassive(PassiveMode::NotPassive)
, m_eventPhase(0)
, m_currentTarget(nullptr)
, m_platformTimeStamp(platformTimeStamp)
@@ -225,11 +225,26 @@ bool Event::isBeforeUnloadEvent() const
void Event::preventDefault()
{
- if (m_handlingPassive) {
+ if (m_handlingPassive != PassiveMode::NotPassive) {
m_preventDefaultCalledDuringPassive = true;
+
const LocalDOMWindow* window = m_eventPath ? m_eventPath->windowEventContext().window() : 0;
- if (window)
- window->printErrorMessage("Unable to preventDefault inside passive event listener invocation.");
+ if (window) {
+ const char* devToolsMsg = nullptr;
+ switch (m_handlingPassive) {
+ case PassiveMode::NotPassive:
+ NOTREACHED();
+ break;
+ case PassiveMode::Passive:
+ devToolsMsg = "Unable to preventDefault inside passive event listener invocation.";
+ break;
+ case PassiveMode::PassiveForcedDocumentLevel:
+ devToolsMsg = "Unable to preventDefault inside passive event listener due to target being treated as passive. See https://www.chromestatus.com/features/5093566007214080";
+ break;
+ }
+ if (devToolsMsg)
+ window->printErrorMessage(devToolsMsg);
+ }
return;
}
@@ -281,9 +296,9 @@ HeapVector<Member<EventTarget>> Event::composedPath(ScriptState* scriptState) co
return pathInternal(scriptState, EmptyAfterDispatch);
}
-void Event::setHandlingPassive(bool value)
+void Event::setHandlingPassive(PassiveMode mode)
{
- m_handlingPassive = value;
+ m_handlingPassive = mode;
m_preventDefaultCalledDuringPassive = false;
}
« no previous file with comments | « third_party/WebKit/Source/core/events/Event.h ('k') | third_party/WebKit/Source/core/events/EventTarget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698