/* * Copyright (c) 2024, Andrew Kaster * Copyright (c) 2024, Jamie Mansfield * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include namespace Web::CSS { class FontFaceSet final : public DOM::EventTarget { WEB_PLATFORM_OBJECT(FontFaceSet, DOM::EventTarget); GC_DECLARE_ALLOCATOR(FontFaceSet); public: [[nodiscard]] static GC::Ref create(JS::Realm&); virtual ~FontFaceSet() override = default; GC::Ref set_entries() const { return m_set_entries; } WebIDL::ExceptionOr> add(GC::Root); bool delete_(GC::Root); void clear(); void add_css_connected_font(GC::Ref); void set_onloading(WebIDL::CallbackType*); WebIDL::CallbackType* onloading(); void set_onloadingdone(WebIDL::CallbackType*); WebIDL::CallbackType* onloadingdone(); void set_onloadingerror(WebIDL::CallbackType*); WebIDL::CallbackType* onloadingerror(); JS::ThrowCompletionOr> load(String const& font, String const& text); WebIDL::ExceptionOr check(String const& font, String const& text); Vector>& loading_fonts() { return m_loading_fonts; } Vector>& loaded_fonts() { return m_loaded_fonts; } Vector>& failed_fonts() { return m_failed_fonts; } GC::Ref ready() const; Bindings::FontFaceSetLoadStatus status() const { return m_status; } void on_set_modified_from_js(Badge) { } void fire_a_font_load_event(FlyString name, Vector> = {}); void set_is_pending_on_the_environment(bool); void switch_to_loading(); void switch_to_loaded(); private: explicit FontFaceSet(JS::Realm&); virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; GC::Ref m_set_entries; GC::Ref m_ready_promise; // [[ReadyPromise]] Vector> m_loading_fonts {}; // [[LoadingFonts]] Vector> m_loaded_fonts {}; // [[LoadedFonts]] Vector> m_failed_fonts {}; // [[FailedFonts]] Bindings::FontFaceSetLoadStatus m_status { Bindings::FontFaceSetLoadStatus::Loaded }; bool m_is_pending_on_the_environment { true }; // https://drafts.csswg.org/css-font-loading/#fontfaceset-stuck-on-the-environment bool m_is_stuck_on_the_environment { false }; }; }