| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) | 2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) |
| 3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) | 3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) |
| 4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
| 5 * Copyright (C) 2003, 2005, 2006, 2008 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003, 2005, 2006, 2008 Apple Inc. All rights reserved. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 , m_cancelable(cancelableArg) | 73 , m_cancelable(cancelableArg) |
| 74 , m_composed(composedMode == ComposedMode::Composed) | 74 , m_composed(composedMode == ComposedMode::Composed) |
| 75 , m_isEventTypeScopedInV0(isEventTypeScopedInV0(eventType)) | 75 , m_isEventTypeScopedInV0(isEventTypeScopedInV0(eventType)) |
| 76 , m_propagationStopped(false) | 76 , m_propagationStopped(false) |
| 77 , m_immediatePropagationStopped(false) | 77 , m_immediatePropagationStopped(false) |
| 78 , m_defaultPrevented(false) | 78 , m_defaultPrevented(false) |
| 79 , m_defaultHandled(false) | 79 , m_defaultHandled(false) |
| 80 , m_cancelBubble(false) | 80 , m_cancelBubble(false) |
| 81 , m_wasInitialized(true) | 81 , m_wasInitialized(true) |
| 82 , m_isTrusted(false) | 82 , m_isTrusted(false) |
| 83 , m_handlingPassive(false) | |
| 84 , m_preventDefaultCalledOnUncancelableEvent(false) | 83 , m_preventDefaultCalledOnUncancelableEvent(false) |
| 84 , m_handlingPassive(PassiveMode::NotPassive) |
| 85 , m_eventPhase(0) | 85 , m_eventPhase(0) |
| 86 , m_currentTarget(nullptr) | 86 , m_currentTarget(nullptr) |
| 87 , m_platformTimeStamp(platformTimeStamp) | 87 , m_platformTimeStamp(platformTimeStamp) |
| 88 { | 88 { |
| 89 } | 89 } |
| 90 | 90 |
| 91 Event::Event(const AtomicString& eventType, const EventInit& initializer) | 91 Event::Event(const AtomicString& eventType, const EventInit& initializer) |
| 92 : Event(eventType, initializer.bubbles(), initializer.cancelable(), initiali
zer.composed() ? ComposedMode::Composed : ComposedMode::Scoped, monotonicallyInc
reasingTime()) | 92 : Event(eventType, initializer.bubbles(), initializer.cancelable(), initiali
zer.composed() ? ComposedMode::Composed : ComposedMode::Scoped, monotonicallyInc
reasingTime()) |
| 93 { | 93 { |
| 94 } | 94 } |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 return false; | 218 return false; |
| 219 } | 219 } |
| 220 | 220 |
| 221 bool Event::isBeforeUnloadEvent() const | 221 bool Event::isBeforeUnloadEvent() const |
| 222 { | 222 { |
| 223 return false; | 223 return false; |
| 224 } | 224 } |
| 225 | 225 |
| 226 void Event::preventDefault() | 226 void Event::preventDefault() |
| 227 { | 227 { |
| 228 if (m_handlingPassive) { | 228 if (m_handlingPassive != PassiveMode::NotPassive) { |
| 229 m_preventDefaultCalledDuringPassive = true; | 229 m_preventDefaultCalledDuringPassive = true; |
| 230 |
| 230 const LocalDOMWindow* window = m_eventPath ? m_eventPath->windowEventCon
text().window() : 0; | 231 const LocalDOMWindow* window = m_eventPath ? m_eventPath->windowEventCon
text().window() : 0; |
| 231 if (window) | 232 if (window) { |
| 232 window->printErrorMessage("Unable to preventDefault inside passive e
vent listener invocation."); | 233 const char* devToolsMsg = nullptr; |
| 234 switch (m_handlingPassive) { |
| 235 case PassiveMode::NotPassive: |
| 236 NOTREACHED(); |
| 237 break; |
| 238 case PassiveMode::Passive: |
| 239 devToolsMsg = "Unable to preventDefault inside passive event lis
tener invocation."; |
| 240 break; |
| 241 case PassiveMode::PassiveForcedDocumentLevel: |
| 242 devToolsMsg = "Unable to preventDefault inside passive event lis
tener due to target being treated as passive. See https://www.chromestatus.com/f
eatures/5093566007214080"; |
| 243 break; |
| 244 } |
| 245 if (devToolsMsg) |
| 246 window->printErrorMessage(devToolsMsg); |
| 247 } |
| 233 return; | 248 return; |
| 234 } | 249 } |
| 235 | 250 |
| 236 if (m_cancelable) | 251 if (m_cancelable) |
| 237 m_defaultPrevented = true; | 252 m_defaultPrevented = true; |
| 238 else | 253 else |
| 239 m_preventDefaultCalledOnUncancelableEvent = true; | 254 m_preventDefaultCalledOnUncancelableEvent = true; |
| 240 } | 255 } |
| 241 | 256 |
| 242 void Event::setTarget(EventTarget* target) | 257 void Event::setTarget(EventTarget* target) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 HeapVector<Member<EventTarget>> Event::path(ScriptState* scriptState) const | 289 HeapVector<Member<EventTarget>> Event::path(ScriptState* scriptState) const |
| 275 { | 290 { |
| 276 return pathInternal(scriptState, NonEmptyAfterDispatch); | 291 return pathInternal(scriptState, NonEmptyAfterDispatch); |
| 277 } | 292 } |
| 278 | 293 |
| 279 HeapVector<Member<EventTarget>> Event::composedPath(ScriptState* scriptState) co
nst | 294 HeapVector<Member<EventTarget>> Event::composedPath(ScriptState* scriptState) co
nst |
| 280 { | 295 { |
| 281 return pathInternal(scriptState, EmptyAfterDispatch); | 296 return pathInternal(scriptState, EmptyAfterDispatch); |
| 282 } | 297 } |
| 283 | 298 |
| 284 void Event::setHandlingPassive(bool value) | 299 void Event::setHandlingPassive(PassiveMode mode) |
| 285 { | 300 { |
| 286 m_handlingPassive = value; | 301 m_handlingPassive = mode; |
| 287 m_preventDefaultCalledDuringPassive = false; | 302 m_preventDefaultCalledDuringPassive = false; |
| 288 } | 303 } |
| 289 | 304 |
| 290 HeapVector<Member<EventTarget>> Event::pathInternal(ScriptState* scriptState, Ev
entPathMode mode) const | 305 HeapVector<Member<EventTarget>> Event::pathInternal(ScriptState* scriptState, Ev
entPathMode mode) const |
| 291 { | 306 { |
| 292 if (m_target) | 307 if (m_target) |
| 293 HostsUsingFeatures::countHostOrIsolatedWorldHumanReadableName(scriptStat
e, *m_target, HostsUsingFeatures::Feature::EventPath); | 308 HostsUsingFeatures::countHostOrIsolatedWorldHumanReadableName(scriptStat
e, *m_target, HostsUsingFeatures::Feature::EventPath); |
| 294 | 309 |
| 295 if (!m_currentTarget) { | 310 if (!m_currentTarget) { |
| 296 DCHECK_EQ(Event::kNone, m_eventPhase); | 311 DCHECK_EQ(Event::kNone, m_eventPhase); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 | 366 |
| 352 DEFINE_TRACE(Event) | 367 DEFINE_TRACE(Event) |
| 353 { | 368 { |
| 354 visitor->trace(m_currentTarget); | 369 visitor->trace(m_currentTarget); |
| 355 visitor->trace(m_target); | 370 visitor->trace(m_target); |
| 356 visitor->trace(m_underlyingEvent); | 371 visitor->trace(m_underlyingEvent); |
| 357 visitor->trace(m_eventPath); | 372 visitor->trace(m_eventPath); |
| 358 } | 373 } |
| 359 | 374 |
| 360 } // namespace blink | 375 } // namespace blink |
| OLD | NEW |