| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 TraceEvent::toTraceTimestamp(m_firstImagePaint), "frame", frame()); | 67 TraceEvent::toTraceTimestamp(m_firstImagePaint), "frame", frame()); |
| 65 notifyPaintTimingChanged(); | 68 notifyPaintTimingChanged(); |
| 66 } | 69 } |
| 67 | 70 |
| 68 void PaintTiming::setFirstMeaningfulPaint(double stamp) { | 71 void PaintTiming::setFirstMeaningfulPaint(double stamp) { |
| 69 DCHECK_EQ(m_firstMeaningfulPaint, 0.0); | 72 DCHECK_EQ(m_firstMeaningfulPaint, 0.0); |
| 70 m_firstMeaningfulPaint = stamp; | 73 m_firstMeaningfulPaint = stamp; |
| 71 TRACE_EVENT_MARK_WITH_TIMESTAMP1( | 74 TRACE_EVENT_MARK_WITH_TIMESTAMP1( |
| 72 "blink.user_timing", "firstMeaningfulPaint", | 75 "blink.user_timing", "firstMeaningfulPaint", |
| 73 TraceEvent::toTraceTimestamp(m_firstMeaningfulPaint), "frame", frame()); | 76 TraceEvent::toTraceTimestamp(m_firstMeaningfulPaint), "frame", frame()); |
| 77 if (m_document->frame() && m_document->frame()->view() && |
| 78 !m_document->frame()->view()->parent()) { |
| 79 m_document->frame()->frameScheduler()->onFirstMeaningfulPaint(); |
| 80 } |
| 74 notifyPaintTimingChanged(); | 81 notifyPaintTimingChanged(); |
| 75 } | 82 } |
| 76 | 83 |
| 77 void PaintTiming::notifyPaint(bool isFirstPaint, | 84 void PaintTiming::notifyPaint(bool isFirstPaint, |
| 78 bool textPainted, | 85 bool textPainted, |
| 79 bool imagePainted) { | 86 bool imagePainted) { |
| 80 if (isFirstPaint) | 87 if (isFirstPaint) |
| 81 markFirstPaint(); | 88 markFirstPaint(); |
| 82 if (textPainted) | 89 if (textPainted) |
| 83 markFirstTextPaint(); | 90 markFirstTextPaint(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 void PaintTiming::setFirstContentfulPaint(double stamp) { | 123 void PaintTiming::setFirstContentfulPaint(double stamp) { |
| 117 if (m_firstContentfulPaint != 0.0) | 124 if (m_firstContentfulPaint != 0.0) |
| 118 return; | 125 return; |
| 119 setFirstPaint(stamp); | 126 setFirstPaint(stamp); |
| 120 m_firstContentfulPaint = stamp; | 127 m_firstContentfulPaint = stamp; |
| 121 TRACE_EVENT_INSTANT1("blink.user_timing,rail", "firstContentfulPaint", | 128 TRACE_EVENT_INSTANT1("blink.user_timing,rail", "firstContentfulPaint", |
| 122 TRACE_EVENT_SCOPE_PROCESS, "frame", frame()); | 129 TRACE_EVENT_SCOPE_PROCESS, "frame", frame()); |
| 123 } | 130 } |
| 124 | 131 |
| 125 } // namespace blink | 132 } // namespace blink |
| OLD | NEW |