chromium/third_party/blink/renderer/core/loader/image_loader.cc

/*
 * Copyright (C) 1999 Lars Knoll ([email protected])
 *           (C) 1999 Antti Koivisto ([email protected])
 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010 Apple Inc. All rights
 * reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "third_party/blink/renderer/core/loader/image_loader.h"

#include <memory>
#include <utility>

#include "services/network/public/mojom/attribution.mojom-blink.h"
#include "services/network/public/mojom/web_client_hints_types.mojom-blink.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom-blink.h"
#include "third_party/blink/public/platform/web_url_request.h"
#include "third_party/blink/renderer/bindings/core/v8/script_controller.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/core/css/css_primitive_value.h"
#include "third_party/blink/renderer/core/css/css_property_name.h"
#include "third_party/blink/renderer/core/css/css_property_value_set.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/element.h"
#include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/dom/increment_load_event_delay_count.h"
#include "third_party/blink/renderer/core/execution_context/agent.h"
#include "third_party/blink/renderer/core/frame/attribution_src_loader.h"
#include "third_party/blink/renderer/core/frame/frame_owner.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame_client.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/html/cross_origin_attribute.h"
#include "third_party/blink/renderer/core/html/html_embed_element.h"
#include "third_party/blink/renderer/core/html/html_image_element.h"
#include "third_party/blink/renderer/core/html/html_object_element.h"
#include "third_party/blink/renderer/core/html/html_picture_element.h"
#include "third_party/blink/renderer/core/html/loading_attribute.h"
#include "third_party/blink/renderer/core/html/media/html_video_element.h"
#include "third_party/blink/renderer/core/html/parser/html_parser_idioms.h"
#include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/core/layout/layout_image.h"
#include "third_party/blink/renderer/core/layout/layout_video.h"
#include "third_party/blink/renderer/core/layout/svg/layout_svg_image.h"
#include "third_party/blink/renderer/core/loader/fetch_priority_attribute.h"
#include "third_party/blink/renderer/core/loader/lazy_image_helper.h"
#include "third_party/blink/renderer/core/probe/async_task_context.h"
#include "third_party/blink/renderer/core/probe/core_probes.h"
#include "third_party/blink/renderer/core/svg/graphics/svg_image.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/bindings/v8_per_isolate_data.h"
#include "third_party/blink/renderer/platform/heap/cross_thread_handle.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/loader/fetch/fetch_parameters.h"
#include "third_party/blink/renderer/platform/loader/fetch/memory_cache.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_fetcher.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_loading_log.h"
#include "third_party/blink/renderer/platform/scheduler/public/event_loop.h"
#include "third_party/blink/renderer/platform/weborigin/security_origin.h"
#include "third_party/blink/renderer/platform/weborigin/security_policy.h"

namespace blink {

namespace {

// This implements the HTML Standard's list of available images tuple-matching
// logic [1]. In our implementation, it is only used to determine whether or not
// we should skip queueing the microtask that continues the rest of the image
// loading algorithm. But the actual decision to reuse the image is determined
// by ResourceFetcher, and is much stricter.
// [1]:
// https://html.spec.whatwg.org/multipage/images.html#updating-the-image-data:list-of-available-images
bool CanReuseFromListOfAvailableImages(
    const Resource* resource,
    CrossOriginAttributeValue cross_origin_attribute,
    const SecurityOrigin* origin) {}

}  // namespace

class ImageLoader::Task {};

ImageLoader::ImageLoader(Element* element)
    :{}

ImageLoader::~ImageLoader() = default;

void ImageLoader::Dispose() {}

static bool ImageTypeNeedsDecode(const Image& image) {}

void ImageLoader::DispatchDecodeRequestsIfComplete() {}

void ImageLoader::DecodeRequestFinished(uint64_t request_id, bool success) {}

void ImageLoader::RejectPendingDecodes(UpdateType update_type) {}

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

void ImageLoader::SetImageForTest(ImageResourceContent* new_image) {}

bool ImageLoader::ImageIsPotentiallyAvailable() const {}

void ImageLoader::ClearImage() {}

void ImageLoader::SetImageWithoutConsideringPendingLoadEvent(
    ImageResourceContent* new_image_content) {}

static void ConfigureRequest(
    FetchParameters& params,
    Element& element,
    const ClientHintsPreferences& client_hints_preferences) {}

inline void ImageLoader::QueuePendingErrorEvent() {}

inline void ImageLoader::CrossSiteOrCSPViolationOccurred(
    AtomicString image_source_url) {}

inline void ImageLoader::ClearFailedLoadURL() {}

inline void ImageLoader::EnqueueImageLoadingMicroTask(
    UpdateFromElementBehavior update_behavior) {}

void ImageLoader::UpdateImageState(ImageResourceContent* new_image_content) {}

void ImageLoader::DoUpdateFromElement(const DOMWrapperWorld* world,
                                      UpdateFromElementBehavior update_behavior,
                                      UpdateType update_type,
                                      bool force_blocking) {}

void ImageLoader::UpdateFromElement(UpdateFromElementBehavior update_behavior,
                                    bool force_blocking) {}

KURL ImageLoader::ImageSourceToKURL(AtomicString image_source_url) const {}

bool ImageLoader::ShouldLoadImmediately(const KURL& url) const {}

void ImageLoader::ImageChanged(ImageResourceContent* content,
                               CanDeferInvalidation) {}

void ImageLoader::ImageNotifyFinished(ImageResourceContent* content) {}

LayoutImageResource* ImageLoader::GetLayoutImageResource() const {}

void ImageLoader::OnAttachLayoutTree() {}

void ImageLoader::UpdateLayoutObject() {}

ResourcePriority ImageLoader::ComputeResourcePriority() const {}

bool ImageLoader::HasPendingEvent() const {}

void ImageLoader::DispatchPendingLoadEvent(
    std::unique_ptr<IncrementLoadEventDelayCount> count) {}

void ImageLoader::DispatchPendingErrorEvent(
    std::unique_ptr<IncrementLoadEventDelayCount> count) {}

bool ImageLoader::GetImageAnimationPolicy(
    mojom::blink::ImageAnimationPolicy& policy) {}

ScriptPromise<IDLUndefined> ImageLoader::Decode(
    ScriptState* script_state,
    ExceptionState& exception_state) {}

void ImageLoader::LoadDeferredImage(bool force_blocking,
                                    bool update_from_microtask) {}

void ImageLoader::ElementDidMoveToNewDocument() {}

// Indicates the next available id that we can use to uniquely identify a decode
// request.
uint64_t ImageLoader::DecodeRequest::s_next_request_id_ =;

ImageLoader::DecodeRequest::DecodeRequest(
    ImageLoader* loader,
    ScriptPromiseResolver<IDLUndefined>* resolver)
    :{}

void ImageLoader::DecodeRequest::Resolve() {}

void ImageLoader::DecodeRequest::Reject() {}

void ImageLoader::DecodeRequest::ProcessForTask() {}

void ImageLoader::DecodeRequest::NotifyDecodeDispatched() {}

void ImageLoader::DecodeRequest::Trace(Visitor* visitor) const {}

}  // namespace blink