LibWeb: Add stub implementation of CSS FontFace Web API

This commit is contained in:
Andrew Kaster 2024-05-07 10:05:29 -06:00 committed by Andreas Kling
commit 2c31d7dddc
Notes: sideshowbarker 2024-07-17 03:35:16 +09:00
7 changed files with 130 additions and 0 deletions

View file

@ -0,0 +1,43 @@
/*
* Copyright (c) 2024, Andrew Kaster <akaster@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibJS/Heap/Heap.h>
#include <LibJS/Runtime/Realm.h>
#include <LibWeb/Bindings/FontFacePrototype.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/CSS/FontFace.h>
#include <LibWeb/WebIDL/Promise.h>
namespace Web::CSS {
JS_DEFINE_ALLOCATOR(FontFace);
JS::NonnullGCPtr<FontFace> FontFace::construct_impl(JS::Realm& realm, String family, FontFaceSource source, FontFaceDescriptors const& descriptors)
{
return realm.heap().allocate<FontFace>(realm, realm, move(family), move(source), descriptors);
}
FontFace::FontFace(JS::Realm& realm, String, FontFaceSource, FontFaceDescriptors const&)
: Bindings::PlatformObject(realm)
{
}
void FontFace::initialize(JS::Realm& realm)
{
Base::initialize(realm);
WEB_SET_PROTOTYPE_FOR_INTERFACE(FontFace);
}
// https://drafts.csswg.org/css-font-loading/#dom-fontface-load
JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Promise>> FontFace::load()
{
// FIXME: Do the steps
auto promise = WebIDL::create_rejected_promise(realm(), WebIDL::NotSupportedError::create(realm(), "FontFace::load is not yet implemented"_fly_string));
return verify_cast<JS::Promise>(*promise->promise());
}
}