/* * 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 construct_impl(JS::Realm&, Vector> const& initial_faces); [[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 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); GC::Ref ready() const; Bindings::FontFaceSetLoadStatus status() const { return m_status; } void resolve_ready_promise(); private: FontFaceSet(JS::Realm&, GC::Ref ready_promise, GC::Ref set_entries); 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::Loading }; }; }