// Copyright 2018 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Copyright 2018 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_TIMING_IMAGE_PAINT_TIMING_DETECTOR_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_TIMING_IMAGE_PAINT_TIMING_DETECTOR_H_ #include <optional> #include "base/gtest_prod_util.h" #include "base/time/time.h" #include "third_party/blink/public/common/performance/largest_contentful_paint_type.h" #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/dom/dom_node_ids.h" #include "third_party/blink/renderer/core/loader/resource/image_resource_content.h" #include "third_party/blink/renderer/core/paint/timing/lcp_objects.h" #include "third_party/blink/renderer/core/paint/timing/media_record_id.h" #include "third_party/blink/renderer/core/paint/timing/paint_timing_visualizer.h" #include "third_party/blink/renderer/platform/allow_discouraged_type.h" #include "third_party/blink/renderer/platform/heap/collection_support/heap_deque.h" #include "third_party/blink/renderer/platform/heap/collection_support/heap_hash_set.h" #include "third_party/blink/renderer/platform/heap/garbage_collected.h" #include "third_party/blink/renderer/platform/loader/fetch/media_timing.h" #include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h" #include "third_party/blink/renderer/platform/wtf/hash_set.h" #include "ui/gfx/geometry/rect_conversions.h" namespace blink { class LayoutObject; class LocalFrameView; class PropertyTreeStateOrAlias; class TracedValue; class Image; class PaintTimingCallbackManager; class StyleImage; // TODO(crbug/960502): we should limit the access of these properties. // TODO(yoav): Rename all mentions of "image" to "media" class ImageRecord : public GarbageCollected<ImageRecord> { … }; // |ImageRecordsManager| is the manager of all of the images that Largest // Image Paint cares about. Note that an image does not necessarily correspond // to a node; it can also be one of the background images attached to a node. // |ImageRecordsManager| encapsulates the logic of |ImageRecord| handling, // providing interface for the external world to handle it in the language of // Node, LayoutObject, etc. class CORE_EXPORT ImageRecordsManager { … }; // ImagePaintTimingDetector contains Largest Image Paint. // // Largest Image Paint timing measures when the largest image element within // viewport finishes painting. Specifically, it: // 1. Tracks all images' first invalidation, recording their visual size, if // this image is within viewport. // 2. When an image finishes loading, record its paint time. // 3. At the end of each frame, if new images are added and loaded, the // algorithm will start an analysis. // // In the analysis: // 3.1 Largest Image Paint finds the largest image by the first visual size. If // it has finished loading, reports a candidate result as its first paint time // since loaded. // // For all these candidate results, Telemetry picks the lastly reported // Largest Image Paint candidate as its final result. // // See also: // https://docs.google.com/document/d/1DRVd4a2VU8-yyWftgOparZF-sf16daf0vfbsHuz2rws/edit#heading=h.1k2rnrs6mdmt class CORE_EXPORT ImagePaintTimingDetector final : public GarbageCollected<ImagePaintTimingDetector> { … }; } // namespace blink #endif // THIRD_PARTY_BLINK_RENDERER_CORE_PAINT_TIMING_IMAGE_PAINT_TIMING_DETECTOR_H_