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..2ae0e035849b1852daf253e021d78828283cf497 100644 |
--- a/third_party/WebKit/Source/core/events/Event.cpp |
+++ b/third_party/WebKit/Source/core/events/Event.cpp |
@@ -29,6 +29,8 @@ |
#include "core/frame/OriginsUsingFeatures.h" |
#include "core/frame/UseCounter.h" |
#include "core/svg/SVGElement.h" |
+#include "core/timing/DOMWindowPerformance.h" |
+#include "core/timing/Performance.h" |
#include "wtf/CurrentTime.h" |
namespace blink { |
@@ -51,7 +53,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 +259,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()) { |
+ Performance* performance = DOMWindowPerformance::performance(*scriptState->domWindow()); |
+ timeStamp = performance->monotonicTimeToDOMHighResTimeStamp(m_platformTimeStamp); |
+ } |
+ } else { |
+ timeStamp = m_createTime; |
+ } |
+ |
+ return timeStamp; |
+} |
+ |
DEFINE_TRACE(Event) |
{ |
visitor->trace(m_currentTarget); |