| 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 12 matching lines...) Expand all Loading... |
| 23 #include "core/events/Event.h" | 23 #include "core/events/Event.h" |
| 24 | 24 |
| 25 #include "core/dom/StaticNodeList.h" | 25 #include "core/dom/StaticNodeList.h" |
| 26 #include "core/events/EventDispatchMediator.h" | 26 #include "core/events/EventDispatchMediator.h" |
| 27 #include "core/events/EventTarget.h" | 27 #include "core/events/EventTarget.h" |
| 28 #include "core/frame/HostsUsingFeatures.h" | 28 #include "core/frame/HostsUsingFeatures.h" |
| 29 #include "core/frame/UseCounter.h" | 29 #include "core/frame/UseCounter.h" |
| 30 #include "core/svg/SVGElement.h" | 30 #include "core/svg/SVGElement.h" |
| 31 #include "core/timing/DOMWindowPerformance.h" | 31 #include "core/timing/DOMWindowPerformance.h" |
| 32 #include "core/timing/Performance.h" | 32 #include "core/timing/Performance.h" |
| 33 #include "wtf/CurrentTime.h" | |
| 34 | 33 |
| 35 namespace blink { | 34 namespace blink { |
| 36 | 35 |
| 37 static bool isEventTypeScopedInV0(const AtomicString& eventType) { | 36 static bool isEventTypeScopedInV0(const AtomicString& eventType) { |
| 38 // WebKit never allowed selectstart event to cross the the shadow DOM | 37 // WebKit never allowed selectstart event to cross the the shadow DOM |
| 39 // boundary. Changing this breaks existing sites. | 38 // boundary. Changing this breaks existing sites. |
| 40 // See https://bugs.webkit.org/show_bug.cgi?id=52195 for details. | 39 // See https://bugs.webkit.org/show_bug.cgi?id=52195 for details. |
| 41 return eventType == EventTypeNames::abort || | 40 return eventType == EventTypeNames::abort || |
| 42 eventType == EventTypeNames::change || | 41 eventType == EventTypeNames::change || |
| 43 eventType == EventTypeNames::error || | 42 eventType == EventTypeNames::error || |
| 44 eventType == EventTypeNames::load || | 43 eventType == EventTypeNames::load || |
| 45 eventType == EventTypeNames::reset || | 44 eventType == EventTypeNames::reset || |
| 46 eventType == EventTypeNames::resize || | 45 eventType == EventTypeNames::resize || |
| 47 eventType == EventTypeNames::scroll || | 46 eventType == EventTypeNames::scroll || |
| 48 eventType == EventTypeNames::select || | 47 eventType == EventTypeNames::select || |
| 49 eventType == EventTypeNames::selectstart || | 48 eventType == EventTypeNames::selectstart || |
| 50 eventType == EventTypeNames::slotchange; | 49 eventType == EventTypeNames::slotchange; |
| 51 } | 50 } |
| 52 | 51 |
| 53 Event::Event() : Event("", false, false) { | 52 Event::Event() : Event("", false, false) { |
| 54 m_wasInitialized = false; | 53 m_wasInitialized = false; |
| 55 } | 54 } |
| 56 | 55 |
| 57 Event::Event(const AtomicString& eventType, | 56 Event::Event(const AtomicString& eventType, |
| 58 bool canBubbleArg, | 57 bool canBubbleArg, |
| 59 bool cancelableArg, | 58 bool cancelableArg, |
| 60 double platformTimeStamp) | 59 TimeTicks platformTimeStamp) |
| 61 : Event(eventType, | 60 : Event(eventType, |
| 62 canBubbleArg, | 61 canBubbleArg, |
| 63 cancelableArg, | 62 cancelableArg, |
| 64 ComposedMode::Scoped, | 63 ComposedMode::Scoped, |
| 65 platformTimeStamp) {} | 64 platformTimeStamp) {} |
| 66 | 65 |
| 67 Event::Event(const AtomicString& eventType, | 66 Event::Event(const AtomicString& eventType, |
| 68 bool canBubbleArg, | 67 bool canBubbleArg, |
| 69 bool cancelableArg, | 68 bool cancelableArg, |
| 70 ComposedMode composedMode) | 69 ComposedMode composedMode) |
| 71 : Event(eventType, | 70 : Event(eventType, |
| 72 canBubbleArg, | 71 canBubbleArg, |
| 73 cancelableArg, | 72 cancelableArg, |
| 74 composedMode, | 73 composedMode, |
| 75 monotonicallyIncreasingTime()) {} | 74 TimeTicks::Now()) {} |
| 76 | 75 |
| 77 Event::Event(const AtomicString& eventType, | 76 Event::Event(const AtomicString& eventType, |
| 78 bool canBubbleArg, | 77 bool canBubbleArg, |
| 79 bool cancelableArg, | 78 bool cancelableArg, |
| 80 ComposedMode composedMode, | 79 ComposedMode composedMode, |
| 81 double platformTimeStamp) | 80 TimeTicks platformTimeStamp) |
| 82 : m_type(eventType), | 81 : m_type(eventType), |
| 83 m_canBubble(canBubbleArg), | 82 m_canBubble(canBubbleArg), |
| 84 m_cancelable(cancelableArg), | 83 m_cancelable(cancelableArg), |
| 85 m_composed(composedMode == ComposedMode::Composed), | 84 m_composed(composedMode == ComposedMode::Composed), |
| 86 m_isEventTypeScopedInV0(isEventTypeScopedInV0(eventType)), | 85 m_isEventTypeScopedInV0(isEventTypeScopedInV0(eventType)), |
| 87 m_propagationStopped(false), | 86 m_propagationStopped(false), |
| 88 m_immediatePropagationStopped(false), | 87 m_immediatePropagationStopped(false), |
| 89 m_defaultPrevented(false), | 88 m_defaultPrevented(false), |
| 90 m_defaultHandled(false), | 89 m_defaultHandled(false), |
| 91 m_cancelBubble(false), | 90 m_cancelBubble(false), |
| 92 m_wasInitialized(true), | 91 m_wasInitialized(true), |
| 93 m_isTrusted(false), | 92 m_isTrusted(false), |
| 94 m_preventDefaultCalledOnUncancelableEvent(false), | 93 m_preventDefaultCalledOnUncancelableEvent(false), |
| 95 m_handlingPassive(PassiveMode::NotPassiveDefault), | 94 m_handlingPassive(PassiveMode::NotPassiveDefault), |
| 96 m_eventPhase(0), | 95 m_eventPhase(0), |
| 97 m_currentTarget(nullptr), | 96 m_currentTarget(nullptr), |
| 98 m_platformTimeStamp(platformTimeStamp) {} | 97 m_platformTimeStamp(platformTimeStamp) {} |
| 99 | 98 |
| 100 Event::Event(const AtomicString& eventType, const EventInit& initializer) | 99 Event::Event(const AtomicString& eventType, const EventInit& initializer) |
| 101 : Event(eventType, | 100 : Event(eventType, |
| 102 initializer.bubbles(), | 101 initializer.bubbles(), |
| 103 initializer.cancelable(), | 102 initializer.cancelable(), |
| 104 initializer.composed() ? ComposedMode::Composed | 103 initializer.composed() ? ComposedMode::Composed |
| 105 : ComposedMode::Scoped, | 104 : ComposedMode::Scoped, |
| 106 monotonicallyIncreasingTime()) {} | 105 TimeTicks::Now()) {} |
| 107 | 106 |
| 108 Event::~Event() {} | 107 Event::~Event() {} |
| 109 | 108 |
| 110 bool Event::isScopedInV0() const { | 109 bool Event::isScopedInV0() const { |
| 111 return isTrusted() && m_isEventTypeScopedInV0; | 110 return isTrusted() && m_isEventTypeScopedInV0; |
| 112 } | 111 } |
| 113 | 112 |
| 114 void Event::initEvent(const AtomicString& eventTypeArg, | 113 void Event::initEvent(const AtomicString& eventTypeArg, |
| 115 bool canBubbleArg, | 114 bool canBubbleArg, |
| 116 bool cancelableArg) { | 115 bool cancelableArg) { |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 | 321 |
| 323 EventDispatchMediator* Event::createMediator() { | 322 EventDispatchMediator* Event::createMediator() { |
| 324 return EventDispatchMediator::create(this); | 323 return EventDispatchMediator::create(this); |
| 325 } | 324 } |
| 326 | 325 |
| 327 double Event::timeStamp(ScriptState* scriptState) const { | 326 double Event::timeStamp(ScriptState* scriptState) const { |
| 328 double timeStamp = 0; | 327 double timeStamp = 0; |
| 329 if (scriptState && scriptState->domWindow()) { | 328 if (scriptState && scriptState->domWindow()) { |
| 330 Performance* performance = | 329 Performance* performance = |
| 331 DOMWindowPerformance::performance(*scriptState->domWindow()); | 330 DOMWindowPerformance::performance(*scriptState->domWindow()); |
| 331 double timestampSeconds = (m_platformTimeStamp - TimeTicks()).InSecondsF(); |
| 332 timeStamp = | 332 timeStamp = |
| 333 performance->monotonicTimeToDOMHighResTimeStamp(m_platformTimeStamp); | 333 performance->monotonicTimeToDOMHighResTimeStamp(timestampSeconds); |
| 334 } | 334 } |
| 335 | 335 |
| 336 return timeStamp; | 336 return timeStamp; |
| 337 } | 337 } |
| 338 | 338 |
| 339 void Event::setCancelBubble(ExecutionContext* context, bool cancel) { | 339 void Event::setCancelBubble(ExecutionContext* context, bool cancel) { |
| 340 if (!m_cancelBubble && cancel) | 340 if (!m_cancelBubble && cancel) |
| 341 UseCounter::count(context, UseCounter::EventCancelBubbleWasChangedToTrue); | 341 UseCounter::count(context, UseCounter::EventCancelBubbleWasChangedToTrue); |
| 342 else if (m_cancelBubble && !cancel) | 342 else if (m_cancelBubble && !cancel) |
| 343 UseCounter::count(context, UseCounter::EventCancelBubbleWasChangedToFalse); | 343 UseCounter::count(context, UseCounter::EventCancelBubbleWasChangedToFalse); |
| 344 m_cancelBubble = cancel; | 344 m_cancelBubble = cancel; |
| 345 } | 345 } |
| 346 | 346 |
| 347 DEFINE_TRACE(Event) { | 347 DEFINE_TRACE(Event) { |
| 348 visitor->trace(m_currentTarget); | 348 visitor->trace(m_currentTarget); |
| 349 visitor->trace(m_target); | 349 visitor->trace(m_target); |
| 350 visitor->trace(m_underlyingEvent); | 350 visitor->trace(m_underlyingEvent); |
| 351 visitor->trace(m_eventPath); | 351 visitor->trace(m_eventPath); |
| 352 } | 352 } |
| 353 | 353 |
| 354 } // namespace blink | 354 } // namespace blink |
| OLD | NEW |