/* * 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); JS_DECLARE_ALLOCATOR(FontFaceSet); public: [[nodiscard]] static JS::NonnullGCPtr construct_impl(JS::Realm&, Vector> const& initial_faces); [[nodiscard]] static JS::NonnullGCPtr create(JS::Realm&); virtual ~FontFaceSet() override = default; JS::NonnullGCPtr set_entries() const { return m_set_entries; } JS::NonnullGCPtr add(JS::Handle); bool delete_(JS::Handle); 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); JS::NonnullGCPtr ready() const; Bindings::FontFaceSetLoadStatus status() const { return m_status; } private: FontFaceSet(JS::Realm&, JS::NonnullGCPtr ready_promise, JS::NonnullGCPtr set_entries); virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; JS::NonnullGCPtr m_set_entries; JS::GCPtr m_ready_promise; // [[ReadyPromise]] Bindings::FontFaceSetLoadStatus m_status { Bindings::FontFaceSetLoadStatus::Loading }; }; }