OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/PaintTiming.h" | 5 #include "core/paint/PaintTiming.h" |
6 | 6 |
7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
8 #include "core/frame/FrameView.h" | |
9 #include "core/frame/LocalFrame.h" | |
8 #include "core/loader/DocumentLoader.h" | 10 #include "core/loader/DocumentLoader.h" |
9 #include "platform/tracing/TraceEvent.h" | 11 #include "platform/tracing/TraceEvent.h" |
12 #include "public/platform/WebFrameScheduler.h" | |
10 | 13 |
11 namespace blink { | 14 namespace blink { |
12 | 15 |
13 static const char kSupplementName[] = "PaintTiming"; | 16 static const char kSupplementName[] = "PaintTiming"; |
14 | 17 |
15 PaintTiming& PaintTiming::from(Document& document) { | 18 PaintTiming& PaintTiming::from(Document& document) { |
16 PaintTiming* timing = static_cast<PaintTiming*>( | 19 PaintTiming* timing = static_cast<PaintTiming*>( |
17 Supplement<Document>::from(document, kSupplementName)); | 20 Supplement<Document>::from(document, kSupplementName)); |
18 if (!timing) { | 21 if (!timing) { |
19 timing = new PaintTiming(document); | 22 timing = new PaintTiming(document); |
(...skipping 38 matching lines...) Loading... | |
58 if (m_firstImagePaint != 0.0) | 61 if (m_firstImagePaint != 0.0) |
59 return; | 62 return; |
60 m_firstImagePaint = monotonicallyIncreasingTime(); | 63 m_firstImagePaint = monotonicallyIncreasingTime(); |
61 setFirstContentfulPaint(m_firstImagePaint); | 64 setFirstContentfulPaint(m_firstImagePaint); |
62 TRACE_EVENT_MARK_WITH_TIMESTAMP1( | 65 TRACE_EVENT_MARK_WITH_TIMESTAMP1( |
63 "blink.user_timing,rail", "firstImagePaint", | 66 "blink.user_timing,rail", "firstImagePaint", |
64 TraceEvent::toTraceTimestamp(m_firstImagePaint), "frame", frame()); | 67 TraceEvent::toTraceTimestamp(m_firstImagePaint), "frame", frame()); |
65 notifyPaintTimingChanged(); | 68 notifyPaintTimingChanged(); |
66 } | 69 } |
67 | 70 |
71 void PaintTiming::markFirstMeaningfulPaintCandidate() { | |
72 // The first meaningful paint candidate can be reported very early, even | |
73 // before the first contentful paint. To cut down on false positives, we only | |
74 // report the first meaningful paint candidate after the first contentful | |
75 // paint. | |
76 if (!m_firstContentfulPaint) | |
Kunihiko Sakamoto
2016/10/13 08:01:34
Within a single paint phase, this runs after Paint
Sami
2016/10/13 08:23:59
Good point. Perhaps the thing to do is to ignore t
Kunihiko Sakamoto
2016/10/13 08:38:46
Yeah, I think patch set 9 would work.
| |
77 return; | |
78 if (m_document->frame() && m_document->frame()->view() && | |
79 !m_document->frame()->view()->parent()) { | |
80 m_document->frame()->frameScheduler()->onFirstMeaningfulPaint(); | |
81 } | |
82 } | |
83 | |
68 void PaintTiming::setFirstMeaningfulPaint(double stamp) { | 84 void PaintTiming::setFirstMeaningfulPaint(double stamp) { |
69 DCHECK_EQ(m_firstMeaningfulPaint, 0.0); | 85 DCHECK_EQ(m_firstMeaningfulPaint, 0.0); |
70 m_firstMeaningfulPaint = stamp; | 86 m_firstMeaningfulPaint = stamp; |
71 TRACE_EVENT_MARK_WITH_TIMESTAMP1( | 87 TRACE_EVENT_MARK_WITH_TIMESTAMP1( |
72 "blink.user_timing", "firstMeaningfulPaint", | 88 "blink.user_timing", "firstMeaningfulPaint", |
73 TraceEvent::toTraceTimestamp(m_firstMeaningfulPaint), "frame", frame()); | 89 TraceEvent::toTraceTimestamp(m_firstMeaningfulPaint), "frame", frame()); |
74 notifyPaintTimingChanged(); | 90 notifyPaintTimingChanged(); |
75 } | 91 } |
76 | 92 |
77 void PaintTiming::notifyPaint(bool isFirstPaint, | 93 void PaintTiming::notifyPaint(bool isFirstPaint, |
(...skipping 38 matching lines...) Loading... | |
116 void PaintTiming::setFirstContentfulPaint(double stamp) { | 132 void PaintTiming::setFirstContentfulPaint(double stamp) { |
117 if (m_firstContentfulPaint != 0.0) | 133 if (m_firstContentfulPaint != 0.0) |
118 return; | 134 return; |
119 setFirstPaint(stamp); | 135 setFirstPaint(stamp); |
120 m_firstContentfulPaint = stamp; | 136 m_firstContentfulPaint = stamp; |
121 TRACE_EVENT_INSTANT1("blink.user_timing,rail", "firstContentfulPaint", | 137 TRACE_EVENT_INSTANT1("blink.user_timing,rail", "firstContentfulPaint", |
122 TRACE_EVENT_SCOPE_PROCESS, "frame", frame()); | 138 TRACE_EVENT_SCOPE_PROCESS, "frame", frame()); |
123 } | 139 } |
124 | 140 |
125 } // namespace blink | 141 } // namespace blink |
OLD | NEW |