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

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

Issue 1563623002: Support registering and dispatching passive event listeners. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adjust comments in layout tests Created 4 years, 11 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 9f09da20a324bab98a8f138c413bd6dbb14a4328..1b2daab043a2a7a1fcdf81159dcaf9ef8ca4989c 100644
--- a/third_party/WebKit/Source/core/events/Event.cpp
+++ b/third_party/WebKit/Source/core/events/Event.cpp
@@ -54,6 +54,7 @@ Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableAr
, m_defaultHandled(false)
, m_cancelBubble(false)
, m_isTrusted(false)
+ , m_handlingPassive(false)
, m_eventPhase(0)
, m_currentTarget(nullptr)
, m_createTime(convertSecondsToDOMTimeStamp(currentTime()))
@@ -179,6 +180,19 @@ bool Event::isBeforeUnloadEvent() const
return false;
}
+void Event::preventDefault()
+{
+ if (m_handlingPassive) {
+ const LocalDOMWindow* window = m_currentTarget ? m_currentTarget->toDOMWindow() : 0;
+ if (window)
+ window->printErrorMessage("Unable to preventDefault inside passive event listener invocation.");
+ return;
+ }
+
+ if (m_cancelable)
+ m_defaultPrevented = true;
+}
+
void Event::setTarget(PassRefPtrWillBeRawPtr<EventTarget> target)
{
if (m_target == target)
« no previous file with comments | « third_party/WebKit/Source/core/events/Event.h ('k') | third_party/WebKit/Source/core/events/EventListenerOptions.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698