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); |