mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-13 03:29:49 +00:00
LibWeb/CSS: Implement @supports font-format()
and font-tech()
These let authors query whether we support font formats and features.
This commit is contained in:
parent
adfe8a9dcb
commit
b6fb4baeb7
Notes:
github-actions[bot]
2025-03-17 10:01:17 +00:00
Author: https://github.com/AtkinsSJ
Commit: b6fb4baeb7
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3941
6 changed files with 242 additions and 2 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/FlyString.h>
|
||||
#include <AK/NonnullOwnPtr.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/String.h>
|
||||
|
@ -60,6 +61,50 @@ public:
|
|||
bool m_matches;
|
||||
};
|
||||
|
||||
class FontTech final : public BooleanExpression {
|
||||
public:
|
||||
static NonnullOwnPtr<FontTech> create(FlyString tech, bool matches)
|
||||
{
|
||||
return adopt_own(*new FontTech(move(tech), matches));
|
||||
}
|
||||
virtual ~FontTech() override = default;
|
||||
|
||||
virtual MatchResult evaluate(HTML::Window const*) const override;
|
||||
virtual String to_string() const override;
|
||||
virtual void dump(StringBuilder&, int indent_levels = 0) const override;
|
||||
|
||||
private:
|
||||
FontTech(FlyString tech, bool matches)
|
||||
: m_tech(move(tech))
|
||||
, m_matches(matches)
|
||||
{
|
||||
}
|
||||
FlyString m_tech;
|
||||
bool m_matches;
|
||||
};
|
||||
|
||||
class FontFormat final : public BooleanExpression {
|
||||
public:
|
||||
static NonnullOwnPtr<FontFormat> create(FlyString format, bool matches)
|
||||
{
|
||||
return adopt_own(*new FontFormat(move(format), matches));
|
||||
}
|
||||
virtual ~FontFormat() override = default;
|
||||
|
||||
virtual MatchResult evaluate(HTML::Window const*) const override;
|
||||
virtual String to_string() const override;
|
||||
virtual void dump(StringBuilder&, int indent_levels = 0) const override;
|
||||
|
||||
private:
|
||||
FontFormat(FlyString format, bool matches)
|
||||
: m_format(move(format))
|
||||
, m_matches(matches)
|
||||
{
|
||||
}
|
||||
FlyString m_format;
|
||||
bool m_matches;
|
||||
};
|
||||
|
||||
static NonnullRefPtr<Supports> create(NonnullOwnPtr<BooleanExpression>&& condition)
|
||||
{
|
||||
return adopt_ref(*new Supports(move(condition)));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue