2022-03-28 20:30:26 +01:00
|
|
|
/*
|
2025-04-03 12:05:49 +01:00
|
|
|
* Copyright (c) 2022-2025, Sam Atkins <sam@ladybird.org>
|
2024-10-04 13:19:50 +02:00
|
|
|
* Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
|
2022-03-28 20:30:26 +01:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2025-04-03 12:05:49 +01:00
|
|
|
#include <LibWeb/CSS/CSSFontFaceDescriptors.h>
|
2022-03-28 20:30:26 +01:00
|
|
|
#include <LibWeb/CSS/CSSRule.h>
|
2026-02-23 14:31:54 +00:00
|
|
|
#include <LibWeb/CSS/CSSStyleSheet.h>
|
2024-05-07 09:18:37 -06:00
|
|
|
#include <LibWeb/CSS/ParsedFontFace.h>
|
2022-03-28 20:30:26 +01:00
|
|
|
|
|
|
|
|
namespace Web::CSS {
|
|
|
|
|
|
2026-01-05 09:50:55 +00:00
|
|
|
class FontFace;
|
|
|
|
|
|
2026-02-23 14:31:54 +00:00
|
|
|
class CSSFontFaceRule final
|
|
|
|
|
: public CSSRule
|
|
|
|
|
, public CSSStyleSheet::Subresource {
|
2022-08-28 13:42:07 +02:00
|
|
|
WEB_PLATFORM_OBJECT(CSSFontFaceRule, CSSRule);
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_DECLARE_ALLOCATOR(CSSFontFaceRule);
|
2022-03-28 20:30:26 +01:00
|
|
|
|
|
|
|
|
public:
|
2025-04-03 12:05:49 +01:00
|
|
|
[[nodiscard]] static GC::Ref<CSSFontFaceRule> create(JS::Realm&, GC::Ref<CSSFontFaceDescriptors>);
|
2022-03-28 20:30:26 +01:00
|
|
|
|
|
|
|
|
virtual ~CSSFontFaceRule() override = default;
|
|
|
|
|
|
2025-04-03 12:15:11 +01:00
|
|
|
bool is_valid() const;
|
2025-04-03 12:05:49 +01:00
|
|
|
ParsedFontFace font_face() const;
|
2025-05-08 14:37:25 +01:00
|
|
|
GC::Ref<CSSStyleDeclaration> style() { return m_style; }
|
2026-01-05 09:30:38 +00:00
|
|
|
GC::Ref<CSSFontFaceDescriptors> descriptors() { return m_style; }
|
2025-05-08 14:37:25 +01:00
|
|
|
GC::Ref<CSSFontFaceDescriptors const> descriptors() const { return m_style; }
|
2022-03-28 20:30:26 +01:00
|
|
|
|
2026-01-05 09:50:55 +00:00
|
|
|
GC::Ptr<FontFace> css_connected_font_face() const { return m_css_connected_font_face; }
|
|
|
|
|
void set_css_connected_font_face(GC::Ptr<FontFace> font_face) { m_css_connected_font_face = font_face; }
|
2026-01-10 16:23:23 +13:00
|
|
|
void handle_descriptor_change(FlyString const& property);
|
2026-01-05 10:08:52 +00:00
|
|
|
void disconnect_font_face();
|
2026-01-05 09:50:55 +00:00
|
|
|
|
2022-03-28 20:30:26 +01:00
|
|
|
private:
|
2025-04-03 12:05:49 +01:00
|
|
|
CSSFontFaceRule(JS::Realm&, GC::Ref<CSSFontFaceDescriptors>);
|
2022-08-28 13:42:07 +02:00
|
|
|
|
2023-08-07 08:41:28 +02:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2023-11-20 23:16:39 +13:00
|
|
|
virtual String serialized() const override;
|
2025-04-03 12:05:49 +01:00
|
|
|
virtual void visit_edges(Visitor&) override;
|
2025-12-04 12:03:01 +00:00
|
|
|
virtual void dump(StringBuilder&, int indent_levels) const override;
|
2022-03-28 20:30:26 +01:00
|
|
|
|
2026-01-10 16:23:23 +13:00
|
|
|
void handle_src_descriptor_change();
|
|
|
|
|
|
2026-02-23 14:31:54 +00:00
|
|
|
virtual void set_parent_style_sheet(CSSStyleSheet*) override;
|
|
|
|
|
|
|
|
|
|
GC::Ptr<CSSStyleSheet> parent_style_sheet_for_subresource() override { return parent_style_sheet(); }
|
|
|
|
|
|
2025-04-03 12:05:49 +01:00
|
|
|
GC::Ref<CSSFontFaceDescriptors> m_style;
|
2026-01-05 09:50:55 +00:00
|
|
|
GC::Ptr<FontFace> m_css_connected_font_face;
|
2022-03-28 20:30:26 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template<>
|
|
|
|
|
inline bool CSSRule::fast_is<CSSFontFaceRule>() const { return type() == CSSRule::Type::FontFace; }
|
|
|
|
|
|
|
|
|
|
}
|