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

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

Issue 1352523002: Use high precision timestamp for Event.timestamp (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 2 months 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 11 matching lines...) Expand all
22 22
23 #include "config.h" 23 #include "config.h"
24 #include "core/events/Event.h" 24 #include "core/events/Event.h"
25 25
26 #include "core/dom/StaticNodeList.h" 26 #include "core/dom/StaticNodeList.h"
27 #include "core/events/EventDispatchMediator.h" 27 #include "core/events/EventDispatchMediator.h"
28 #include "core/events/EventTarget.h" 28 #include "core/events/EventTarget.h"
29 #include "core/frame/OriginsUsingFeatures.h" 29 #include "core/frame/OriginsUsingFeatures.h"
30 #include "core/frame/UseCounter.h" 30 #include "core/frame/UseCounter.h"
31 #include "core/svg/SVGElement.h" 31 #include "core/svg/SVGElement.h"
32 #include "core/timing/PerformanceBase.h"
32 #include "wtf/CurrentTime.h" 33 #include "wtf/CurrentTime.h"
33 34
34 namespace blink { 35 namespace blink {
35 36
37 static const double millisPerSecond = 1000.0;
38
36 Event::Event() 39 Event::Event()
37 : Event("", false, false) 40 : Event("", false, false)
38 { 41 {
39 } 42 }
40 43
41 Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableAr g) 44 Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableAr g)
42 : m_type(eventType) 45 : m_type(eventType)
43 , m_canBubble(canBubbleArg) 46 , m_canBubble(canBubbleArg)
44 , m_cancelable(cancelableArg) 47 , m_cancelable(cancelableArg)
45 , m_propagationStopped(false) 48 , m_propagationStopped(false)
46 , m_immediatePropagationStopped(false) 49 , m_immediatePropagationStopped(false)
47 , m_defaultPrevented(false) 50 , m_defaultPrevented(false)
48 , m_defaultHandled(false) 51 , m_defaultHandled(false)
49 , m_cancelBubble(false) 52 , m_cancelBubble(false)
50 , m_isTrusted(false) 53 , m_isTrusted(false)
51 , m_eventPhase(0) 54 , m_eventPhase(0)
52 , m_currentTarget(nullptr) 55 , m_currentTarget(nullptr)
53 , m_createTime(convertSecondsToDOMTimeStamp(currentTime())) 56 , m_createTime(convertSecondsToDOMTimeStamp(currentTime()))
54 , m_uiCreateTime(0) 57 , m_platformTimeStamp(monotonicallyIncreasingTime())
55 { 58 {
56 } 59 }
57 60
58 Event::Event(const AtomicString& eventType, const EventInit& initializer) 61 Event::Event(const AtomicString& eventType, const EventInit& initializer)
59 : Event(eventType, initializer.bubbles(), initializer.cancelable()) 62 : Event(eventType, initializer.bubbles(), initializer.cancelable())
60 { 63 {
61 } 64 }
62 65
63 Event::~Event() 66 Event::~Event()
64 { 67 {
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 if (!m_currentTarget) 253 if (!m_currentTarget)
251 return nullptr; 254 return nullptr;
252 Node* node = m_currentTarget->toNode(); 255 Node* node = m_currentTarget->toNode();
253 if (node && node->isSVGElement()) { 256 if (node && node->isSVGElement()) {
254 if (SVGElement* svgElement = toSVGElement(node)->correspondingElement()) 257 if (SVGElement* svgElement = toSVGElement(node)->correspondingElement())
255 return svgElement; 258 return svgElement;
256 } 259 }
257 return m_currentTarget.get(); 260 return m_currentTarget.get();
258 } 261 }
259 262
263 double Event::timeStamp(ScriptState* scriptState) const
264 {
265 double timeStamp = 0;
266 // TODO(majidvp): Get rid of m_createTime once the flag is enabled by defaul t;
267 if (UNLIKELY(RuntimeEnabledFeatures::hiResEventTimeStampEnabled())) {
268 // Only expose monotonic time after changing its origin to its target
269 // document's time origin.
270 if (scriptState && scriptState->domWindow() && scriptState->domWindow()- >document()) {
Rick Byers 2015/09/25 17:29:33 It feels a little weird to depend on a Document he
majidvp 2015/09/29 14:21:31 There is a way to obtain the performance timing di
Rick Byers 2015/09/29 15:57:59 Nice, this makes a lot more sense to me (and seems
271 double docTimeStamp = scriptState->domWindow()->document()->monotoni cTimeToZeroBasedDocumentTime(m_platformTimeStamp);
272 timeStamp = toSafePrecisionTime(docTimeStamp) * millisPerSecond;
273 }
274 } else {
275 timeStamp = m_createTime;
276 }
277
278 return timeStamp;
279 }
280
260 DEFINE_TRACE(Event) 281 DEFINE_TRACE(Event)
261 { 282 {
262 visitor->trace(m_currentTarget); 283 visitor->trace(m_currentTarget);
263 visitor->trace(m_target); 284 visitor->trace(m_target);
264 visitor->trace(m_underlyingEvent); 285 visitor->trace(m_underlyingEvent);
265 visitor->trace(m_eventPath); 286 visitor->trace(m_eventPath);
266 } 287 }
267 288
268 } // namespace blink 289 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698