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

Unified 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, 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/events/Event.cpp
diff --git a/third_party/WebKit/Source/core/events/Event.cpp b/third_party/WebKit/Source/core/events/Event.cpp
index 05c35a686ddbe70d07317c570f31dbe14db7f3da..59166484843deb86aae9b5d4d75a5e04329c0efb 100644
--- a/third_party/WebKit/Source/core/events/Event.cpp
+++ b/third_party/WebKit/Source/core/events/Event.cpp
@@ -29,10 +29,13 @@
#include "core/frame/OriginsUsingFeatures.h"
#include "core/frame/UseCounter.h"
#include "core/svg/SVGElement.h"
+#include "core/timing/PerformanceBase.h"
#include "wtf/CurrentTime.h"
namespace blink {
+static const double millisPerSecond = 1000.0;
+
Event::Event()
: Event("", false, false)
{
@@ -51,7 +54,7 @@ Event::Event(const AtomicString& eventType, bool canBubbleArg, bool cancelableAr
, m_eventPhase(0)
, m_currentTarget(nullptr)
, m_createTime(convertSecondsToDOMTimeStamp(currentTime()))
- , m_uiCreateTime(0)
+ , m_platformTimeStamp(monotonicallyIncreasingTime())
{
}
@@ -257,6 +260,24 @@ EventTarget* Event::currentTarget() const
return m_currentTarget.get();
}
+double Event::timeStamp(ScriptState* scriptState) const
+{
+ double timeStamp = 0;
+ // TODO(majidvp): Get rid of m_createTime once the flag is enabled by default;
+ if (UNLIKELY(RuntimeEnabledFeatures::hiResEventTimeStampEnabled())) {
+ // Only expose monotonic time after changing its origin to its target
+ // document's time origin.
+ 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
+ double docTimeStamp = scriptState->domWindow()->document()->monotonicTimeToZeroBasedDocumentTime(m_platformTimeStamp);
+ timeStamp = toSafePrecisionTime(docTimeStamp) * millisPerSecond;
+ }
+ } else {
+ timeStamp = m_createTime;
+ }
+
+ return timeStamp;
+}
+
DEFINE_TRACE(Event)
{
visitor->trace(m_currentTarget);

Powered by Google App Engine
This is Rietveld 408576698