mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-25 05:55:13 +00:00
CSSFontFaceRule now stores its values as a CSSFontFaceDescriptors, with a ParsedFontFace produced on request. This is exposed via the `style` attribute, so we pass a lot of tests that try to read values from that. We have one test regression, which we passed by mistake before: The test wanted to ensure we don't allow `@font-face` nested inside other rules. We passed it just because we discarded any `@font-face` without a `font-family`. What we're supposed to do is 1) keep at-rules with missing required descriptors and just not use them, and 2) reject certain ones when nested. We may want to cache the ParsedFontFace in the future, but I didn't here because 1) it's called rarely, and 2) that would mean knowing to invalidate it when the CSSFontFaceDescriptors changes, which isn't obvious to me right now.
41 lines
1.1 KiB
C++
41 lines
1.1 KiB
C++
/*
|
|
* Copyright (c) 2022-2025, Sam Atkins <sam@ladybird.org>
|
|
* Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/CSS/CSSFontFaceDescriptors.h>
|
|
#include <LibWeb/CSS/CSSRule.h>
|
|
#include <LibWeb/CSS/ParsedFontFace.h>
|
|
|
|
namespace Web::CSS {
|
|
|
|
class CSSFontFaceRule final : public CSSRule {
|
|
WEB_PLATFORM_OBJECT(CSSFontFaceRule, CSSRule);
|
|
GC_DECLARE_ALLOCATOR(CSSFontFaceRule);
|
|
|
|
public:
|
|
[[nodiscard]] static GC::Ref<CSSFontFaceRule> create(JS::Realm&, GC::Ref<CSSFontFaceDescriptors>);
|
|
|
|
virtual ~CSSFontFaceRule() override = default;
|
|
|
|
ParsedFontFace font_face() const;
|
|
CSSStyleDeclaration* style() { return m_style; }
|
|
|
|
private:
|
|
CSSFontFaceRule(JS::Realm&, GC::Ref<CSSFontFaceDescriptors>);
|
|
|
|
virtual void initialize(JS::Realm&) override;
|
|
virtual String serialized() const override;
|
|
virtual void visit_edges(Visitor&) override;
|
|
|
|
GC::Ref<CSSFontFaceDescriptors> m_style;
|
|
};
|
|
|
|
template<>
|
|
inline bool CSSRule::fast_is<CSSFontFaceRule>() const { return type() == CSSRule::Type::FontFace; }
|
|
|
|
}
|