| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/paint/FirstMeaningfulPaintDetector.h" | 5 #include "core/paint/FirstMeaningfulPaintDetector.h" |
| 6 | 6 |
| 7 #include "core/css/FontFaceSet.h" | 7 #include "core/css/FontFaceSet.h" |
| 8 #include "core/dom/TaskRunnerHelper.h" | 8 #include "core/dom/TaskRunnerHelper.h" |
| 9 #include "core/paint/PaintTiming.h" | 9 #include "core/paint/PaintTiming.h" |
| 10 #include "platform/instrumentation/tracing/TraceEvent.h" | 10 #include "platform/instrumentation/tracing/TraceEvent.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 m_networkStableTimer.startOneShot(kSecondsWithoutNetworkActivityThreshold, | 115 m_networkStableTimer.startOneShot(kSecondsWithoutNetworkActivityThreshold, |
| 116 BLINK_FROM_HERE); | 116 BLINK_FROM_HERE); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void FirstMeaningfulPaintDetector::networkStableTimerFired(TimerBase*) { | 119 void FirstMeaningfulPaintDetector::networkStableTimerFired(TimerBase*) { |
| 120 if (m_state == Reported || !document() || | 120 if (m_state == Reported || !document() || |
| 121 document()->fetcher()->hasPendingRequest() || | 121 document()->fetcher()->hasPendingRequest() || |
| 122 !m_paintTiming->firstContentfulPaint()) | 122 !m_paintTiming->firstContentfulPaint()) |
| 123 return; | 123 return; |
| 124 | 124 |
| 125 if (m_provisionalFirstMeaningfulPaint) | 125 if (m_provisionalFirstMeaningfulPaint) { |
| 126 m_paintTiming->setFirstMeaningfulPaint(m_provisionalFirstMeaningfulPaint); | 126 // Enforce FirstContentfulPaint <= FirstMeaningfulPaint. |
| 127 double timestamp = std::max(m_provisionalFirstMeaningfulPaint, |
| 128 m_paintTiming->firstContentfulPaint()); |
| 129 m_paintTiming->setFirstMeaningfulPaint(timestamp); |
| 130 } |
| 127 m_state = Reported; | 131 m_state = Reported; |
| 128 } | 132 } |
| 129 | 133 |
| 130 DEFINE_TRACE(FirstMeaningfulPaintDetector) { | 134 DEFINE_TRACE(FirstMeaningfulPaintDetector) { |
| 131 visitor->trace(m_paintTiming); | 135 visitor->trace(m_paintTiming); |
| 132 } | 136 } |
| 133 | 137 |
| 134 } // namespace blink | 138 } // namespace blink |
| OLD | NEW |