mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-12 12:32:21 +00:00
LibWeb: Support loading FontFaces constructed with binary data
This commit is contained in:
parent
452ffa56dc
commit
60b3436ea3
Notes:
sideshowbarker
2024-07-18 05:01:22 +09:00
Author: https://github.com/ADKaster
Commit: 60b3436ea3
Pull-request: https://github.com/SerenityOS/serenity/pull/24319
8 changed files with 245 additions and 13 deletions
|
@ -6,7 +6,11 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibGfx/Font/VectorFont.h>
|
||||
#include <LibURL/URL.h>
|
||||
#include <LibWeb/Bindings/FontFacePrototype.h>
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
#include <LibWeb/CSS/ParsedFontFace.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
|
@ -28,7 +32,7 @@ class FontFace final : public Bindings::PlatformObject {
|
|||
JS_DECLARE_ALLOCATOR(FontFace);
|
||||
|
||||
public:
|
||||
using FontFaceSource = Variant<String, JS::Handle<JS::ArrayBuffer>, JS::Handle<WebIDL::ArrayBufferView>>;
|
||||
using FontFaceSource = Variant<String, JS::Handle<WebIDL::BufferSource>>;
|
||||
|
||||
[[nodiscard]] static JS::NonnullGCPtr<FontFace> construct_impl(JS::Realm&, String family, FontFaceSource source, FontFaceDescriptors const& descriptors);
|
||||
virtual ~FontFace() override = default;
|
||||
|
@ -66,12 +70,16 @@ public:
|
|||
String line_gap_override() const { return m_line_gap_override; }
|
||||
WebIDL::ExceptionOr<void> set_line_gap_override(String const&);
|
||||
|
||||
Bindings::FontFaceLoadStatus status() const { return m_status; }
|
||||
|
||||
JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Promise>> load();
|
||||
JS::NonnullGCPtr<JS::Promise> loaded() const;
|
||||
|
||||
private:
|
||||
FontFace(JS::Realm&, String family, FontFaceSource source, FontFaceDescriptors const& descriptors);
|
||||
FontFace(JS::Realm&, JS::NonnullGCPtr<WebIDL::Promise> font_status_promise, Vector<ParsedFontFace::Source> urls, ByteBuffer data, String family, FontFaceDescriptors const& descriptors);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
|
||||
// FIXME: Should we be storing StyleValues instead?
|
||||
String m_family;
|
||||
|
@ -86,6 +94,16 @@ private:
|
|||
String m_descent_override;
|
||||
String m_line_gap_override;
|
||||
|
||||
// https://drafts.csswg.org/css-font-loading/#dom-fontface-status
|
||||
Bindings::FontFaceLoadStatus m_status { Bindings::FontFaceLoadStatus::Unloaded };
|
||||
|
||||
JS::NonnullGCPtr<WebIDL::Promise> m_font_status_promise; // [[FontStatusPromise]]
|
||||
Vector<ParsedFontFace::Source> m_urls; // [[Urls]]
|
||||
ByteBuffer m_binary_data; // [[Data]]
|
||||
|
||||
RefPtr<Gfx::VectorFont> m_parsed_font;
|
||||
RefPtr<Core::Promise<NonnullRefPtr<Gfx::VectorFont>>> m_font_load_promise;
|
||||
|
||||
// https://drafts.csswg.org/css-font-loading/#css-connected
|
||||
bool m_is_css_connected { false };
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue