LibWeb/CSS: Implement delete method for FontFaceSet
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run

This commit is contained in:
Kostya Farber 2024-10-03 14:49:25 +01:00 committed by Alexander Kalenik
parent d33a87c8c4
commit 09aec4be71
Notes: github-actions[bot] 2024-10-03 14:37:42 +00:00

View file

@ -97,8 +97,26 @@ FontFaceSet::add(JS::Handle<FontFace> face)
// https://drafts.csswg.org/css-font-loading/#dom-fontfaceset-delete // https://drafts.csswg.org/css-font-loading/#dom-fontfaceset-delete
bool FontFaceSet::delete_(JS::Handle<FontFace> face) bool FontFaceSet::delete_(JS::Handle<FontFace> face)
{ {
// FIXME: Do the actual spec steps // 1. If font is CSS-connected, return false and exit this algorithm immediately.
return m_set_entries->set_remove(face); if (face->is_css_connected()) {
return false;
}
// 2. Let deleted be the result of removing font from the FontFaceSets set entries.
bool deleted = m_set_entries->set_remove(face);
// 3. If font is present in the FontFaceSets [[LoadedFonts]], or [[FailedFonts]] lists, remove it.
m_loaded_fonts.remove_all_matching([face](auto const& entry) { return entry == face; });
m_failed_fonts.remove_all_matching([face](auto const& entry) { return entry == face; });
// 4. If font is present in the FontFaceSets [[LoadingFonts]] list, remove it. If font was the last item in that list (and so the list is now empty), switch the FontFaceSet to loaded.
m_loading_fonts.remove_all_matching([face](auto const& entry) { return entry == face; });
if (m_loading_fonts.is_empty()) {
m_status = Bindings::FontFaceSetLoadStatus::Loaded;
}
return deleted;
} }
// https://drafts.csswg.org/css-font-loading/#dom-fontfaceset-clear // https://drafts.csswg.org/css-font-loading/#dom-fontfaceset-clear