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

Side by Side Diff: third_party/WebKit/Source/core/events/Event.cpp

Issue 2542693002: Use WTF::TimeTicks to represent timestamp in Platform/Core event types (Closed)
Patch Set: Add TimeTicks::{To,In}Seconds utility functions Created 4 years 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 unified diff | Download patch
OLDNEW
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
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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 324
326 EventDispatchMediator* Event::createMediator() { 325 EventDispatchMediator* Event::createMediator() {
327 return EventDispatchMediator::create(this); 326 return EventDispatchMediator::create(this);
328 } 327 }
329 328
330 double Event::timeStamp(ScriptState* scriptState) const { 329 double Event::timeStamp(ScriptState* scriptState) const {
331 double timeStamp = 0; 330 double timeStamp = 0;
332 if (scriptState && scriptState->domWindow()) { 331 if (scriptState && scriptState->domWindow()) {
333 Performance* performance = 332 Performance* performance =
334 DOMWindowPerformance::performance(*scriptState->domWindow()); 333 DOMWindowPerformance::performance(*scriptState->domWindow());
334 double timestampSeconds = (m_platformTimeStamp - TimeTicks()).InSecondsF();
335 timeStamp = 335 timeStamp =
336 performance->monotonicTimeToDOMHighResTimeStamp(m_platformTimeStamp); 336 performance->monotonicTimeToDOMHighResTimeStamp(timestampSeconds);
337 } 337 }
338 338
339 return timeStamp; 339 return timeStamp;
340 } 340 }
341 341
342 void Event::setCancelBubble(ExecutionContext* context, bool cancel) { 342 void Event::setCancelBubble(ExecutionContext* context, bool cancel) {
343 if (!m_cancelBubble && cancel) 343 if (!m_cancelBubble && cancel)
344 UseCounter::count(context, UseCounter::EventCancelBubbleWasChangedToTrue); 344 UseCounter::count(context, UseCounter::EventCancelBubbleWasChangedToTrue);
345 else if (m_cancelBubble && !cancel) 345 else if (m_cancelBubble && !cancel)
346 UseCounter::count(context, UseCounter::EventCancelBubbleWasChangedToFalse); 346 UseCounter::count(context, UseCounter::EventCancelBubbleWasChangedToFalse);
347 m_cancelBubble = cancel; 347 m_cancelBubble = cancel;
348 } 348 }
349 349
350 DEFINE_TRACE(Event) { 350 DEFINE_TRACE(Event) {
351 visitor->trace(m_currentTarget); 351 visitor->trace(m_currentTarget);
352 visitor->trace(m_target); 352 visitor->trace(m_target);
353 visitor->trace(m_underlyingEvent); 353 visitor->trace(m_underlyingEvent);
354 visitor->trace(m_eventPath); 354 visitor->trace(m_eventPath);
355 } 355 }
356 356
357 } // namespace blink 357 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698