#ifdef UNSAFE_BUFFERS_BUILD
#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 {
bool CanReuseFromListOfAvailableImages(
const Resource* resource,
CrossOriginAttributeValue cross_origin_attribute,
const SecurityOrigin* origin) { … }
}
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() { … }
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 { … }
}