| 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 #ifndef PaintTiming_h | 5 #ifndef PaintTiming_h |
| 6 #define PaintTiming_h | 6 #define PaintTiming_h |
| 7 | 7 |
| 8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 9 #include "core/paint/FirstMeaningfulPaintDetector.h" | 9 #include "core/paint/FirstMeaningfulPaintDetector.h" |
| 10 #include "platform/Supplementable.h" | 10 #include "platform/Supplementable.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 // markFirstTextPaint, markFirstImagePaint, and markFirstContentfulPaint | 37 // markFirstTextPaint, markFirstImagePaint, and markFirstContentfulPaint |
| 38 // will also record first paint if first paint hasn't been recorded yet. | 38 // will also record first paint if first paint hasn't been recorded yet. |
| 39 void markFirstContentfulPaint(); | 39 void markFirstContentfulPaint(); |
| 40 | 40 |
| 41 // markFirstTextPaint and markFirstImagePaint will also record first | 41 // markFirstTextPaint and markFirstImagePaint will also record first |
| 42 // contentful paint if first contentful paint hasn't been recorded yet. | 42 // contentful paint if first contentful paint hasn't been recorded yet. |
| 43 void markFirstTextPaint(); | 43 void markFirstTextPaint(); |
| 44 void markFirstImagePaint(); | 44 void markFirstImagePaint(); |
| 45 | 45 |
| 46 void markFirstMeaningfulPaintCandidate(); |
| 46 void setFirstMeaningfulPaint(double stamp); | 47 void setFirstMeaningfulPaint(double stamp); |
| 47 void notifyPaint(bool isFirstPaint, bool textPainted, bool imagePainted); | 48 void notifyPaint(bool isFirstPaint, bool textPainted, bool imagePainted); |
| 48 | 49 |
| 49 // The getters below return monotonically-increasing seconds, or zero if the | 50 // The getters below return monotonically-increasing seconds, or zero if the |
| 50 // given paint event has not yet occurred. See the comments for | 51 // given paint event has not yet occurred. See the comments for |
| 51 // monotonicallyIncreasingTime in wtf/CurrentTime.h for additional details. | 52 // monotonicallyIncreasingTime in wtf/CurrentTime.h for additional details. |
| 52 | 53 |
| 53 // firstPaint returns the first time that anything was painted for the | 54 // firstPaint returns the first time that anything was painted for the |
| 54 // current document. | 55 // current document. |
| 55 double firstPaint() const { return m_firstPaint; } | 56 double firstPaint() const { return m_firstPaint; } |
| 56 | 57 |
| 57 // firstContentfulPaint returns the first time that 'contentful' content was | 58 // firstContentfulPaint returns the first time that 'contentful' content was |
| 58 // painted. For instance, the first time that text or image content was | 59 // painted. For instance, the first time that text or image content was |
| 59 // painted. | 60 // painted. |
| 60 double firstContentfulPaint() const { return m_firstContentfulPaint; } | 61 double firstContentfulPaint() const { return m_firstContentfulPaint; } |
| 61 | 62 |
| 62 // firstTextPaint returns the first time that text content was painted. | 63 // firstTextPaint returns the first time that text content was painted. |
| 63 double firstTextPaint() const { return m_firstTextPaint; } | 64 double firstTextPaint() const { return m_firstTextPaint; } |
| 64 | 65 |
| 65 // firstImagePaint returns the first time that image content was painted. | 66 // firstImagePaint returns the first time that image content was painted. |
| 66 double firstImagePaint() const { return m_firstImagePaint; } | 67 double firstImagePaint() const { return m_firstImagePaint; } |
| 67 | 68 |
| 68 // firstMeaningfulPaint returns the first time that page's primary content | 69 // firstMeaningfulPaint returns the first time that page's primary content |
| 69 // was painted. | 70 // was painted. |
| 70 double firstMeaningfulPaint() const { return m_firstMeaningfulPaint; } | 71 double firstMeaningfulPaint() const { return m_firstMeaningfulPaint; } |
| 71 | 72 |
| 73 // firstMeaningfulPaintCandidate indicates the first time we considered a |
| 74 // paint to qualify as the potentially first meaningful paint. Unlike |
| 75 // firstMeaningfulPaint, this signal is available in real time, but it may be |
| 76 // an optimistic (i.e., too early) estimate. |
| 77 double firstMeaningfulPaintCandidate() const { |
| 78 return m_firstMeaningfulPaintCandidate; |
| 79 } |
| 80 |
| 72 Document* document() { return m_document.get(); } | 81 Document* document() { return m_document.get(); } |
| 73 FirstMeaningfulPaintDetector& firstMeaningfulPaintDetector() { | 82 FirstMeaningfulPaintDetector& firstMeaningfulPaintDetector() { |
| 74 return *m_fmpDetector; | 83 return *m_fmpDetector; |
| 75 } | 84 } |
| 76 | 85 |
| 77 DECLARE_VIRTUAL_TRACE(); | 86 DECLARE_VIRTUAL_TRACE(); |
| 78 | 87 |
| 79 private: | 88 private: |
| 80 explicit PaintTiming(Document&); | 89 explicit PaintTiming(Document&); |
| 81 LocalFrame* frame() const; | 90 LocalFrame* frame() const; |
| 82 void notifyPaintTimingChanged(); | 91 void notifyPaintTimingChanged(); |
| 83 | 92 |
| 84 // set*() set the timing for the given paint event to the given timestamp | 93 // set*() set the timing for the given paint event to the given timestamp |
| 85 // and record a trace event if the value is currently zero, but do not | 94 // and record a trace event if the value is currently zero, but do not |
| 86 // notify that paint timing changed. These methods can be invoked from other | 95 // notify that paint timing changed. These methods can be invoked from other |
| 87 // mark*() or set*() methods to make sure that first paint is marked as part | 96 // mark*() or set*() methods to make sure that first paint is marked as part |
| 88 // of marking first contentful paint, or that first contentful paint is | 97 // of marking first contentful paint, or that first contentful paint is |
| 89 // marked as part of marking first text/image paint, for example. | 98 // marked as part of marking first text/image paint, for example. |
| 90 void setFirstPaint(double stamp); | 99 void setFirstPaint(double stamp); |
| 91 | 100 |
| 92 // setFirstContentfulPaint will also set first paint time if first paint | 101 // setFirstContentfulPaint will also set first paint time if first paint |
| 93 // time has not yet been recorded. | 102 // time has not yet been recorded. |
| 94 void setFirstContentfulPaint(double stamp); | 103 void setFirstContentfulPaint(double stamp); |
| 95 | 104 |
| 96 double m_firstPaint = 0.0; | 105 double m_firstPaint = 0.0; |
| 97 double m_firstTextPaint = 0.0; | 106 double m_firstTextPaint = 0.0; |
| 98 double m_firstImagePaint = 0.0; | 107 double m_firstImagePaint = 0.0; |
| 99 double m_firstContentfulPaint = 0.0; | 108 double m_firstContentfulPaint = 0.0; |
| 100 double m_firstMeaningfulPaint = 0.0; | 109 double m_firstMeaningfulPaint = 0.0; |
| 110 double m_firstMeaningfulPaintCandidate = 0.0; |
| 101 | 111 |
| 102 Member<Document> m_document; | 112 Member<Document> m_document; |
| 103 Member<FirstMeaningfulPaintDetector> m_fmpDetector; | 113 Member<FirstMeaningfulPaintDetector> m_fmpDetector; |
| 104 }; | 114 }; |
| 105 | 115 |
| 106 } // namespace blink | 116 } // namespace blink |
| 107 | 117 |
| 108 #endif | 118 #endif |
| OLD | NEW |