LibWeb: Support <custom-ident> in FontFaceSet::load()

This exposed a false positive in our test suite which has been fixed and
made more robust
This commit is contained in:
Callum Law
2026-01-08 23:27:38 +13:00
committed by Sam Atkins
parent 9b20fe6902
commit e114c7341e
Notes: github-actions[bot] 2026-01-13 10:41:47 +00:00
3 changed files with 24 additions and 7 deletions

View File

@@ -15,6 +15,7 @@
#include <LibWeb/CSS/FontFaceSet.h>
#include <LibWeb/CSS/Parser/Parser.h>
#include <LibWeb/CSS/PropertyID.h>
#include <LibWeb/CSS/StyleValues/CustomIdentStyleValue.h>
#include <LibWeb/CSS/StyleValues/KeywordStyleValue.h>
#include <LibWeb/CSS/StyleValues/ShorthandStyleValue.h>
#include <LibWeb/CSS/StyleValues/StringStyleValue.h>
@@ -229,14 +230,22 @@ static WebIDL::ExceptionOr<GC::Ref<JS::Set>> find_matching_font_faces(JS::Realm&
// that this may be more than just a single font face.
for (auto const& font_family : font_family_list.values()) {
// FIXME: The matching below is super basic. We currently just match font family names by their string value.
if (!font_family->is_string())
continue;
auto maybe_font_family_name = [&]() -> Optional<FlyString> {
if (font_family->is_string())
return font_family->as_string().string_value();
auto const& font_family_name = font_family->as_string().string_value();
if (font_family->is_custom_ident())
return font_family->as_custom_ident().custom_ident();
return {};
}();
if (!maybe_font_family_name.has_value())
continue;
for (auto font_face_value : *available_font_faces) {
auto& font_face = as<FontFace>(font_face_value.key.as_object());
if (font_face.family() != font_family_name)
if (font_face.family() != maybe_font_family_name.value())
continue;
matched_font_faces->set_add(font_face_value.key);