FontFace.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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/FontFacePrototype.h>
  9. #include <LibWeb/Bindings/Intrinsics.h>
  10. #include <LibWeb/CSS/FontFace.h>
  11. #include <LibWeb/WebIDL/Promise.h>
  12. namespace Web::CSS {
  13. JS_DEFINE_ALLOCATOR(FontFace);
  14. JS::NonnullGCPtr<FontFace> FontFace::construct_impl(JS::Realm& realm, String family, FontFaceSource source, FontFaceDescriptors const& descriptors)
  15. {
  16. return realm.heap().allocate<FontFace>(realm, realm, move(family), move(source), descriptors);
  17. }
  18. FontFace::FontFace(JS::Realm& realm, String, FontFaceSource, FontFaceDescriptors const&)
  19. : Bindings::PlatformObject(realm)
  20. {
  21. }
  22. void FontFace::initialize(JS::Realm& realm)
  23. {
  24. Base::initialize(realm);
  25. WEB_SET_PROTOTYPE_FOR_INTERFACE(FontFace);
  26. }
  27. // https://drafts.csswg.org/css-font-loading/#dom-fontface-load
  28. JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Promise>> FontFace::load()
  29. {
  30. // FIXME: Do the steps
  31. auto promise = WebIDL::create_rejected_promise(realm(), WebIDL::NotSupportedError::create(realm(), "FontFace::load is not yet implemented"_fly_string));
  32. return verify_cast<JS::Promise>(*promise->promise());
  33. }
  34. }