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 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
| |
237 case PassiveMode::Passive: | |
238 devToolsMsg = "Unable to preventDefault inside passive event lis tener invocation."; | |
239 break; | |
240 case PassiveMode::PassiveForcedDocumentLevel: | |
241 devToolsMsg = "Unable to preventDefault inside passive event lis tener due to target being treated as passive. See https://www.chromestatus.com/f eatures/5093566007214080"; | |
242 break; | |
243 } | |
244 if (devToolsMsg) | |
245 window->printErrorMessage(devToolsMsg); | |
246 } | |
233 return; | 247 return; |
234 } | 248 } |
235 | 249 |
236 if (m_cancelable) | 250 if (m_cancelable) |
237 m_defaultPrevented = true; | 251 m_defaultPrevented = true; |
238 else | 252 else |
239 m_preventDefaultCalledOnUncancelableEvent = true; | 253 m_preventDefaultCalledOnUncancelableEvent = true; |
240 } | 254 } |
241 | 255 |
242 void Event::setTarget(EventTarget* target) | 256 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 | 288 HeapVector<Member<EventTarget>> Event::path(ScriptState* scriptState) const |
275 { | 289 { |
276 return pathInternal(scriptState, NonEmptyAfterDispatch); | 290 return pathInternal(scriptState, NonEmptyAfterDispatch); |
277 } | 291 } |
278 | 292 |
279 HeapVector<Member<EventTarget>> Event::composedPath(ScriptState* scriptState) co nst | 293 HeapVector<Member<EventTarget>> Event::composedPath(ScriptState* scriptState) co nst |
280 { | 294 { |
281 return pathInternal(scriptState, EmptyAfterDispatch); | 295 return pathInternal(scriptState, EmptyAfterDispatch); |
282 } | 296 } |
283 | 297 |
284 void Event::setHandlingPassive(bool value) | 298 void Event::setHandlingPassive(PassiveMode mode) |
285 { | 299 { |
286 m_handlingPassive = value; | 300 m_handlingPassive = mode; |
287 m_preventDefaultCalledDuringPassive = false; | 301 m_preventDefaultCalledDuringPassive = false; |
288 } | 302 } |
289 | 303 |
290 HeapVector<Member<EventTarget>> Event::pathInternal(ScriptState* scriptState, Ev entPathMode mode) const | 304 HeapVector<Member<EventTarget>> Event::pathInternal(ScriptState* scriptState, Ev entPathMode mode) const |
291 { | 305 { |
292 if (m_target) | 306 if (m_target) |
293 HostsUsingFeatures::countHostOrIsolatedWorldHumanReadableName(scriptStat e, *m_target, HostsUsingFeatures::Feature::EventPath); | 307 HostsUsingFeatures::countHostOrIsolatedWorldHumanReadableName(scriptStat e, *m_target, HostsUsingFeatures::Feature::EventPath); |
294 | 308 |
295 if (!m_currentTarget) { | 309 if (!m_currentTarget) { |
296 DCHECK_EQ(Event::kNone, m_eventPhase); | 310 DCHECK_EQ(Event::kNone, m_eventPhase); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
351 | 365 |
352 DEFINE_TRACE(Event) | 366 DEFINE_TRACE(Event) |
353 { | 367 { |
354 visitor->trace(m_currentTarget); | 368 visitor->trace(m_currentTarget); |
355 visitor->trace(m_target); | 369 visitor->trace(m_target); |
356 visitor->trace(m_underlyingEvent); | 370 visitor->trace(m_underlyingEvent); |
357 visitor->trace(m_eventPath); | 371 visitor->trace(m_eventPath); |
358 } | 372 } |
359 | 373 |
360 } // namespace blink | 374 } // namespace blink |
OLD | NEW |