mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 11:36:10 +00:00
We now don't absolutize the URL during parsing, keeping it as a CSS::URL object which we then pass to the "fetch an external image for a stylesheet" algorithm. Our version of this algorithm is a bit ad-hoc, in order to make use of SharedResourceRequest. To try and reduce duplication, I've pulled all of fetch_a_style_resource() into a static function, apart from the "actually do the fetch" step.
33 lines
1.1 KiB
C++
33 lines
1.1 KiB
C++
/*
|
|
* Copyright (c) 2024-2025, Sam Atkins <sam@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibURL/URL.h>
|
|
#include <LibWeb/CSS/URL.h>
|
|
#include <LibWeb/Fetch/Infrastructure/FetchAlgorithms.h>
|
|
#include <LibWeb/Fetch/Infrastructure/HTTP/Requests.h>
|
|
#include <LibWeb/Forward.h>
|
|
|
|
namespace Web::CSS {
|
|
|
|
enum class CorsMode {
|
|
NoCors,
|
|
Cors,
|
|
};
|
|
|
|
using StyleResourceURL = Variant<::URL::URL, CSS::URL>;
|
|
|
|
// AD-HOC: See comment inside fetch_a_style_resource() implementation.
|
|
using StyleSheetOrDocument = Variant<GC::Ref<CSSStyleSheet>, GC::Ref<DOM::Document>>;
|
|
|
|
// https://drafts.csswg.org/css-values-4/#fetch-a-style-resource
|
|
void fetch_a_style_resource(StyleResourceURL const& url, StyleSheetOrDocument, Fetch::Infrastructure::Request::Destination, CorsMode, Fetch::Infrastructure::FetchAlgorithms::ProcessResponseConsumeBodyFunction process_response);
|
|
|
|
// https://drafts.csswg.org/css-images-4/#fetch-an-external-image-for-a-stylesheet
|
|
GC::Ptr<HTML::SharedResourceRequest> fetch_an_external_image_for_a_stylesheet(StyleResourceURL const&, StyleSheetOrDocument);
|
|
|
|
}
|