| // Copyright 2016 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #include "core/css/CSSTiming.h" |
| |
| #include "core/paint/PaintTiming.h" |
| |
| namespace blink { |
| |
| static const char kSupplementName[] = "CSSTiming"; |
| |
| CSSTiming& CSSTiming::From(Document& document) { |
| CSSTiming* timing = static_cast<CSSTiming*>( |
| Supplement<Document>::From(document, kSupplementName)); |
| if (!timing) { |
| timing = new CSSTiming(document); |
| Supplement<Document>::ProvideTo(document, kSupplementName, timing); |
| } |
| return *timing; |
| } |
| |
| void CSSTiming::RecordAuthorStyleSheetParseTime(double seconds) { |
| if (!paint_timing_->FirstContentfulPaint()) |
| parse_time_before_fcp_ += seconds; |
| } |
| |
| void CSSTiming::RecordUpdateDuration(double seconds) { |
| if (!paint_timing_->FirstContentfulPaint()) |
| update_time_before_fcp_ += seconds; |
| } |
| |
| DEFINE_TRACE(CSSTiming) { |
| visitor->Trace(paint_timing_); |
| Supplement<Document>::Trace(visitor); |
| } |
| |
| CSSTiming::CSSTiming(Document& document) |
| : Supplement<Document>(document), |
| paint_timing_(PaintTiming::From(document)) {} |
| |
| } // namespace blink |