LibWeb/CSS: Use CSS::URL for font-fetching

ParsedFontFace and FontLoader now both keep track of which
CSSStyleSheet (if any) was the source of the font-face, so the URLs can
be completed correctly.
This commit is contained in:
Sam Atkins 2025-05-02 12:07:22 +01:00
commit 9e2e796f2d
Notes: github-actions[bot] 2025-05-03 11:02:47 +00:00
9 changed files with 38 additions and 31 deletions

View file

@ -34,11 +34,11 @@ String FontSourceStyleValue::to_string(SerializationMode) const
builder.append(')');
return builder.to_string_without_validation();
},
[this](::URL::URL const& url) {
[this](URL const& url) {
// <url> [ format(<font-format>)]? [ tech( <font-tech>#)]?
// FIXME: tech()
StringBuilder builder;
serialize_a_url(builder, url.to_string());
builder.append(url.to_string());
if (m_format.has_value()) {
builder.append(" format("sv);
@ -59,8 +59,8 @@ bool FontSourceStyleValue::properties_equal(FontSourceStyleValue const& other) c
}
return false;
},
[&other](::URL::URL const& url) {
if (auto* other_url = other.m_source.get_pointer<::URL::URL>()) {
[&other](URL const& url) {
if (auto* other_url = other.m_source.get_pointer<URL>()) {
return url == *other_url;
}
return false;

View file

@ -8,6 +8,7 @@
#include <AK/FlyString.h>
#include <LibWeb/CSS/CSSStyleValue.h>
#include <LibWeb/CSS/URL.h>
namespace Web::CSS {
@ -16,7 +17,7 @@ public:
struct Local {
NonnullRefPtr<CSSStyleValue const> name;
};
using Source = Variant<Local, ::URL::URL>;
using Source = Variant<Local, URL>;
static ValueComparingNonnullRefPtr<FontSourceStyleValue const> create(Source source, Optional<FlyString> format)
{