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

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: 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« 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