Record the reference time when Performance is constructed.
[WebKit-https.git] / Source / WebCore / page / Performance.cpp
index 62f3766..07de431 100644 (file)
@@ -60,7 +60,9 @@ Performance::Performance(Frame* frame)
 #if ENABLE(USER_TIMING)
     , m_userTiming(0)
 #endif // ENABLE(USER_TIMING)
+    , m_referenceTime(frame->document()->loader()->timing().referenceMonotonicTime())
 {
+    ASSERT(m_referenceTime);
 }
 
 Performance::~Performance()
@@ -228,10 +230,7 @@ void Performance::webkitClearMeasures(const String& measureName)
 
 double Performance::now() const
 {
-    if (!frame())
-        return 0;
-
-    return 1000.0 * m_frame->document()->loader()->timing().monotonicTimeToZeroBasedDocumentTime(monotonicallyIncreasingTime());
+    return 1000.0 * (WTF::monotonicallyIncreasingTime() - m_referenceTime);
 }
 
 } // namespace WebCore