FontFaceSet.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright (c) 2024, Andrew Kaster <akaster@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibJS/Heap/Heap.h>
  7. #include <LibJS/Runtime/Realm.h>
  8. #include <LibWeb/Bindings/FontFaceSetPrototype.h>
  9. #include <LibWeb/Bindings/Intrinsics.h>
  10. #include <LibWeb/CSS/FontFaceSet.h>
  11. #include <LibWeb/WebIDL/Promise.h>
  12. namespace Web::CSS {
  13. JS_DEFINE_ALLOCATOR(FontFaceSet);
  14. JS::NonnullGCPtr<FontFaceSet> FontFaceSet::construct_impl(JS::Realm& realm, Vector<JS::Handle<FontFace>> initial_faces)
  15. {
  16. return realm.heap().allocate<FontFaceSet>(realm, realm, move(initial_faces));
  17. }
  18. JS::NonnullGCPtr<FontFaceSet> FontFaceSet::create(JS::Realm& realm)
  19. {
  20. return construct_impl(realm, {});
  21. }
  22. FontFaceSet::FontFaceSet(JS::Realm& realm, Vector<JS::Handle<FontFace>>)
  23. : Bindings::PlatformObject(realm)
  24. {
  25. }
  26. void FontFaceSet::initialize(JS::Realm& realm)
  27. {
  28. Base::initialize(realm);
  29. WEB_SET_PROTOTYPE_FOR_INTERFACE(FontFaceSet);
  30. }
  31. // https://drafts.csswg.org/css-font-loading/#dom-fontfaceset-add
  32. JS::NonnullGCPtr<FontFaceSet> FontFaceSet::add(JS::Handle<FontFace>)
  33. {
  34. // FIXME: Do the steps
  35. return *this;
  36. }
  37. // https://drafts.csswg.org/css-font-loading/#dom-fontfaceset-load
  38. JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Promise>> FontFaceSet::load(String const&, String const&)
  39. {
  40. // FIXME: Do the steps
  41. auto promise = WebIDL::create_rejected_promise(realm(), WebIDL::NotSupportedError::create(realm(), "FontFaceSet::load is not yet implemented"_fly_string));
  42. return verify_cast<JS::Promise>(*promise->promise());
  43. }
  44. }