Chromium Code Reviews| 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..d43f7777385277931e973ae5d89b3a73cd2e4bec 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,25 @@ 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: |
| + break; |
|
bokan
2016/08/25 13:19:44
perhaps this should be an ASSERT_NOT_REACHED?
dtapuska
2016/08/25 14:02:57
done; used NOTREACHED as ASSERT_NOT_REACHED is dep
|
| + 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 +295,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; |
| } |