mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-19 02:10:26 +00:00
This was just added to the spec and doesn't yet have WPT coverage, but it's also pretty trivial.
112 lines
2.8 KiB
C++
112 lines
2.8 KiB
C++
/*
|
|
* Copyright (c) 2021-2026, Sam Atkins <sam@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibJS/Runtime/Realm.h>
|
|
#include <LibWeb/CSS/Serialize.h>
|
|
#include <LibWeb/CSS/Supports.h>
|
|
#include <LibWeb/Dump.h>
|
|
|
|
namespace Web::CSS {
|
|
|
|
Supports::Supports(NonnullOwnPtr<BooleanExpression>&& condition)
|
|
: m_condition(move(condition))
|
|
{
|
|
m_matches = m_condition->evaluate_to_boolean(nullptr);
|
|
}
|
|
|
|
MatchResult Supports::Declaration::evaluate(DOM::Document const*) const
|
|
{
|
|
return as_match_result(m_matches);
|
|
}
|
|
|
|
String Supports::Declaration::to_string() const
|
|
{
|
|
return m_declaration;
|
|
}
|
|
|
|
void Supports::Declaration::dump(StringBuilder& builder, int indent_levels) const
|
|
{
|
|
indent(builder, indent_levels);
|
|
builder.appendff("Declaration: `{}`, matches={}\n", m_declaration, m_matches);
|
|
}
|
|
|
|
MatchResult Supports::Selector::evaluate(DOM::Document const*) const
|
|
{
|
|
return as_match_result(m_matches);
|
|
}
|
|
|
|
String Supports::Selector::to_string() const
|
|
{
|
|
return MUST(String::formatted("selector({})", m_selector));
|
|
}
|
|
|
|
void Supports::Selector::dump(StringBuilder& builder, int indent_levels) const
|
|
{
|
|
indent(builder, indent_levels);
|
|
builder.appendff("Selector: `{}` matches={}\n", m_selector, m_matches);
|
|
}
|
|
|
|
MatchResult Supports::FontTech::evaluate(DOM::Document const*) const
|
|
{
|
|
return as_match_result(m_matches);
|
|
}
|
|
|
|
String Supports::FontTech::to_string() const
|
|
{
|
|
return MUST(String::formatted("font-tech({})", m_tech));
|
|
}
|
|
|
|
void Supports::FontTech::dump(StringBuilder& builder, int indent_levels) const
|
|
{
|
|
indent(builder, indent_levels);
|
|
builder.appendff("FontTech: `{}` matches={}\n", m_tech, m_matches);
|
|
}
|
|
|
|
MatchResult Supports::FontFormat::evaluate(DOM::Document const*) const
|
|
{
|
|
return as_match_result(m_matches);
|
|
}
|
|
|
|
String Supports::FontFormat::to_string() const
|
|
{
|
|
return MUST(String::formatted("font-format({})", m_format));
|
|
}
|
|
|
|
void Supports::FontFormat::dump(StringBuilder& builder, int indent_levels) const
|
|
{
|
|
indent(builder, indent_levels);
|
|
builder.appendff("FontFormat: `{}` matches={}\n", m_format, m_matches);
|
|
}
|
|
|
|
MatchResult Supports::Env::evaluate(DOM::Document const*) const
|
|
{
|
|
return as_match_result(m_matches);
|
|
}
|
|
|
|
String Supports::Env::to_string() const
|
|
{
|
|
return MUST(String::formatted("font-format({})", serialize_an_identifier(m_variable_name)));
|
|
}
|
|
|
|
void Supports::Env::dump(StringBuilder& builder, int indent_levels) const
|
|
{
|
|
indent(builder, indent_levels);
|
|
builder.appendff("Env: `{}` matches={}\n", m_variable_name, m_matches);
|
|
}
|
|
|
|
String Supports::to_string() const
|
|
{
|
|
return m_condition->to_string();
|
|
}
|
|
|
|
void Supports::dump(StringBuilder& builder, int indent_levels) const
|
|
{
|
|
dump_indent(builder, indent_levels);
|
|
builder.appendff("Supports condition: (matches = {})\n", m_matches);
|
|
m_condition->dump(builder, indent_levels + 1);
|
|
}
|
|
|
|
}
|