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

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: rebase 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/DOMWindowPerformance.h"
33 #include "core/timing/Performance.h"
32 #include "wtf/CurrentTime.h" 34 #include "wtf/CurrentTime.h"
33 35
34 namespace blink { 36 namespace blink {
35 37
36 Event::Event() 38 Event::Event()
37 : Event("", false, false) 39 : Event("", false, false)
38 { 40 {
39 } 41 }
40 42
41 Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableAr g) 43 Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableAr g)
42 : m_type(eventType) 44 : m_type(eventType)
43 , m_canBubble(canBubbleArg) 45 , m_canBubble(canBubbleArg)
44 , m_cancelable(cancelableArg) 46 , m_cancelable(cancelableArg)
45 , m_propagationStopped(false) 47 , m_propagationStopped(false)
46 , m_immediatePropagationStopped(false) 48 , m_immediatePropagationStopped(false)
47 , m_defaultPrevented(false) 49 , m_defaultPrevented(false)
48 , m_defaultHandled(false) 50 , m_defaultHandled(false)
49 , m_cancelBubble(false) 51 , m_cancelBubble(false)
50 , m_isTrusted(false) 52 , m_isTrusted(false)
51 , m_eventPhase(0) 53 , m_eventPhase(0)
52 , m_currentTarget(nullptr) 54 , m_currentTarget(nullptr)
53 , m_createTime(convertSecondsToDOMTimeStamp(currentTime())) 55 , m_createTime(convertSecondsToDOMTimeStamp(currentTime()))
54 , m_uiCreateTime(0) 56 , m_platformTimeStamp(monotonicallyIncreasingTime())
55 { 57 {
56 } 58 }
57 59
58 Event::Event(const AtomicString& eventType, const EventInit& initializer) 60 Event::Event(const AtomicString& eventType, const EventInit& initializer)
59 : Event(eventType, initializer.bubbles(), initializer.cancelable()) 61 : Event(eventType, initializer.bubbles(), initializer.cancelable())
60 { 62 {
61 } 63 }
62 64
63 Event::~Event() 65 Event::~Event()
64 { 66 {
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 if (!m_currentTarget) 252 if (!m_currentTarget)
251 return nullptr; 253 return nullptr;
252 Node* node = m_currentTarget->toNode(); 254 Node* node = m_currentTarget->toNode();
253 if (node && node->isSVGElement()) { 255 if (node && node->isSVGElement()) {
254 if (SVGElement* svgElement = toSVGElement(node)->correspondingElement()) 256 if (SVGElement* svgElement = toSVGElement(node)->correspondingElement())
255 return svgElement; 257 return svgElement;
256 } 258 }
257 return m_currentTarget.get(); 259 return m_currentTarget.get();
258 } 260 }
259 261
262 double Event::timeStamp(ScriptState* scriptState) const
263 {
264 double timeStamp = 0;
265 // TODO(majidvp): Get rid of m_createTime once the flag is enabled by defaul t;
266 if (UNLIKELY(RuntimeEnabledFeatures::hiResEventTimeStampEnabled())) {
267 // Only expose monotonic time after changing its origin to its target
268 // document's time origin.
269 if (scriptState && scriptState->domWindow()) {
270 Performance* performance = DOMWindowPerformance::performance(*script State->domWindow());
271 timeStamp = performance->monotonicTimeToDOMHighResTimeStamp(m_platfo rmTimeStamp);
272 }
273 } else {
274 timeStamp = m_createTime;
275 }
276
277 return timeStamp;
278 }
279
260 DEFINE_TRACE(Event) 280 DEFINE_TRACE(Event)
261 { 281 {
262 visitor->trace(m_currentTarget); 282 visitor->trace(m_currentTarget);
263 visitor->trace(m_target); 283 visitor->trace(m_target);
264 visitor->trace(m_underlyingEvent); 284 visitor->trace(m_underlyingEvent);
265 visitor->trace(m_eventPath); 285 visitor->trace(m_eventPath);
266 } 286 }
267 287
268 } // namespace blink 288 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/events/Event.h ('k') | third_party/WebKit/Source/core/events/Event.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698