chromium/third_party/blink/renderer/core/paint/timing/image_paint_timing_detector.cc

// 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.
#include "third_party/blink/renderer/core/paint/timing/image_paint_timing_detector.h"

#include "base/feature_list.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "services/metrics/public/cpp/ukm_recorder.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/frame/visual_viewport.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/layout/layout_image_resource.h"
#include "third_party/blink/renderer/core/layout/svg/layout_svg_image.h"
#include "third_party/blink/renderer/core/page/chrome_client.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/paint/timing/image_element_timing.h"
#include "third_party/blink/renderer/core/paint/timing/largest_contentful_paint_calculator.h"
#include "third_party/blink/renderer/core/paint/timing/paint_timing.h"
#include "third_party/blink/renderer/core/paint/timing/paint_timing_detector.h"
#include "third_party/blink/renderer/core/style/style_fetched_image.h"
#include "third_party/blink/renderer/core/timing/soft_navigation_heuristics.h"
#include "third_party/blink/renderer/platform/heap/thread_state.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/traced_value.h"

namespace blink {

namespace {

// In order for |rect_size| to align with the importance of the image, we
// use this heuristics to alleviate the effect of scaling. For example,
// an image has intrinsic size being 1x1 and scaled to 100x100, but only 50x100
// is visible in the viewport. In this case, |intrinsic_image_size| is 1x1;
// |displayed_image_size| is 100x100. |intrinsic_image_size| is 50x100.
// As the image do not have a lot of content, we down scale |visual_size| by the
// ratio of |intrinsic_image_size|/|displayed_image_size| = 1/10000.
//
// * |visual_size| refers to the size of the |displayed_image_size| after
// clipping and transforming. The size is in the main-frame's coordinate.
// * |intrinsic_image_size| refers to the the image object's original size
// before scaling. The size is in the image object's coordinate.
// * |displayed_image_size| refers to the paint size in the image object's
// coordinate.
uint64_t DownScaleIfIntrinsicSizeIsSmaller(
    uint64_t visual_size,
    const uint64_t& intrinsic_image_size,
    const uint64_t& displayed_image_size) {}

void RecordPotentialSoftNavigationPaint(LocalFrameView* frame_view,
                                        gfx::RectF rect,
                                        Node* node) {}

}  // namespace

double ImageRecord::EntropyForLCP() const {}

std::optional<WebURLRequest::Priority> ImageRecord::RequestPriority() const {}

void ImageRecord::Trace(Visitor* visitor) const {}

ImagePaintTimingDetector::ImagePaintTimingDetector(
    LocalFrameView* frame_view,
    PaintTimingCallbackManager* callback_manager)
    :{}

ImageRecord* ImageRecordsManager::LargestImage() const {}

void ImagePaintTimingDetector::PopulateTraceValue(
    TracedValue& value,
    const ImageRecord& first_image_paint) {}

void ImagePaintTimingDetector::ReportCandidateToTrace(
    ImageRecord& largest_image_record,
    base::TimeTicks time) {}

void ImagePaintTimingDetector::ReportNoCandidateToTrace() {}

std::pair<ImageRecord*, bool>
ImagePaintTimingDetector::UpdateMetricsCandidate() {}

void ImagePaintTimingDetector::OnPaintFinished() {}

void ImagePaintTimingDetector::NotifyImageRemoved(
    const LayoutObject& object,
    const MediaTiming* media_timing) {}

void ImagePaintTimingDetector::StopRecordEntries() {}

void ImagePaintTimingDetector::RegisterNotifyPresentationTime() {}

void ImagePaintTimingDetector::ReportPresentationTime(
    unsigned last_queued_frame_index,
    base::TimeTicks timestamp) {}

void ImageRecordsManager::AssignPaintTimeToRegisteredQueuedRecords(
    const base::TimeTicks& timestamp,
    unsigned last_queued_frame_index) {}

bool ImagePaintTimingDetector::RecordImage(
    const LayoutObject& object,
    const gfx::Size& intrinsic_size,
    const MediaTiming& media_timing,
    const PropertyTreeStateOrAlias& current_paint_chunk_properties,
    const StyleImage* style_image,
    const gfx::Rect& image_border) {}

uint64_t ImagePaintTimingDetector::ComputeImageRectSize(
    const gfx::Rect& image_border,
    const gfx::RectF& mapped_visual_rect,
    const gfx::Size& intrinsic_size,
    const PropertyTreeStateOrAlias& current_paint_chunk_properties,
    const LayoutObject& object,
    const MediaTiming& media_timing) {}

void ImagePaintTimingDetector::NotifyImageFinished(
    const LayoutObject& object,
    const MediaTiming* media_timing) {}

void ImagePaintTimingDetector::ReportLargestIgnoredImage() {}

ImageRecordsManager::ImageRecordsManager(LocalFrameView* frame_view)
    :{}

bool ImageRecordsManager::OnFirstAnimatedFramePainted(
    MediaRecordIdHash record_id_hash,
    unsigned current_frame_index) {}

void ImageRecordsManager::OnImageLoaded(MediaRecordIdHash record_id_hash,
                                        unsigned current_frame_index,
                                        const StyleImage* style_image) {}

void ImageRecordsManager::ReportLargestIgnoredImage(
    unsigned current_frame_index) {}

void ImageRecordsManager::OnImageLoadedInternal(ImageRecord* record,
                                                unsigned current_frame_index) {}

void ImageRecordsManager::MaybeUpdateLargestIgnoredImage(
    const MediaRecordId& record_id,
    const uint64_t& visual_size,
    const gfx::Rect& frame_visual_rect,
    const gfx::RectF& root_visual_rect) {}

bool ImageRecordsManager::RecordFirstPaintAndReturnIsPending(
    const MediaRecordId& record_id,
    const uint64_t& visual_size,
    const gfx::Rect& frame_visual_rect,
    const gfx::RectF& root_visual_rect,
    double bpp) {}
void ImageRecordsManager::AddPendingImage(ImageRecord* record) {}

ImageRecord* ImageRecordsManager::CreateImageRecord(
    const LayoutObject& object,
    const MediaTiming* media_timing,
    const uint64_t& visual_size,
    const gfx::Rect& frame_visual_rect,
    const gfx::RectF& root_visual_rect,
    MediaRecordIdHash hash) {}

void ImageRecordsManager::ClearImagesQueuedForPaintTime() {}

void ImageRecordsManager::Clear() {}

void ImageRecordsManager::Trace(Visitor* visitor) const {}

void ImagePaintTimingDetector::Trace(Visitor* visitor) const {}
}  // namespace blink