2021-10-08 15:40:19 +01:00
|
|
|
/*
|
2025-03-13 16:04:48 +00:00
|
|
|
* Copyright (c) 2021-2025, Sam Atkins <sam@ladybird.org>
|
2021-10-08 15:40:19 +01:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
2023-02-28 16:54:25 +00:00
|
|
|
#include <LibJS/Runtime/Realm.h>
|
2021-10-08 15:40:19 +01:00
|
|
|
#include <LibWeb/CSS/Supports.h>
|
|
|
|
|
|
|
|
namespace Web::CSS {
|
|
|
|
|
2025-03-14 10:31:27 +00:00
|
|
|
Supports::Supports(NonnullOwnPtr<BooleanExpression>&& condition)
|
2021-10-08 15:40:19 +01:00
|
|
|
: m_condition(move(condition))
|
|
|
|
{
|
2025-03-14 10:31:27 +00:00
|
|
|
m_matches = m_condition->evaluate_to_boolean(nullptr);
|
2021-10-08 15:40:19 +01:00
|
|
|
}
|
|
|
|
|
2025-03-14 10:31:27 +00:00
|
|
|
MatchResult Supports::Declaration::evaluate(HTML::Window const*) const
|
2022-02-19 17:22:05 +00:00
|
|
|
{
|
2025-03-14 10:31:27 +00:00
|
|
|
return as_match_result(m_matches);
|
2022-02-19 17:22:05 +00:00
|
|
|
}
|
|
|
|
|
2023-08-22 12:47:38 +01:00
|
|
|
String Supports::Declaration::to_string() const
|
2022-04-22 15:18:47 +01:00
|
|
|
{
|
2025-03-19 11:32:34 +00:00
|
|
|
return m_declaration;
|
2022-04-22 15:18:47 +01:00
|
|
|
}
|
|
|
|
|
2024-11-01 19:55:31 +00:00
|
|
|
void Supports::Declaration::dump(StringBuilder& builder, int indent_levels) const
|
|
|
|
{
|
|
|
|
indent(builder, indent_levels);
|
2025-03-14 10:31:27 +00:00
|
|
|
builder.appendff("Declaration: `{}`, matches={}\n", m_declaration, m_matches);
|
2024-11-01 19:55:31 +00:00
|
|
|
}
|
|
|
|
|
2025-03-14 10:31:27 +00:00
|
|
|
MatchResult Supports::Selector::evaluate(HTML::Window const*) const
|
2024-11-01 19:55:31 +00:00
|
|
|
{
|
2025-03-14 10:31:27 +00:00
|
|
|
return as_match_result(m_matches);
|
2024-11-01 19:55:31 +00:00
|
|
|
}
|
|
|
|
|
2025-03-14 10:31:27 +00:00
|
|
|
String Supports::Selector::to_string() const
|
2024-11-01 19:55:31 +00:00
|
|
|
{
|
2025-03-14 10:31:27 +00:00
|
|
|
return MUST(String::formatted("selector({})", m_selector));
|
2024-11-01 19:55:31 +00:00
|
|
|
}
|
|
|
|
|
2025-03-14 10:31:27 +00:00
|
|
|
void Supports::Selector::dump(StringBuilder& builder, int indent_levels) const
|
2024-11-01 19:55:31 +00:00
|
|
|
{
|
2025-03-14 10:31:27 +00:00
|
|
|
indent(builder, indent_levels);
|
|
|
|
builder.appendff("Selector: `{}` matches={}\n", m_selector, m_matches);
|
2024-11-01 19:55:31 +00:00
|
|
|
}
|
|
|
|
|
2025-03-14 11:36:15 +00:00
|
|
|
MatchResult Supports::FontTech::evaluate(HTML::Window 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(HTML::Window 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);
|
|
|
|
}
|
|
|
|
|
2025-03-14 10:31:27 +00:00
|
|
|
String Supports::to_string() const
|
2024-11-01 19:55:31 +00:00
|
|
|
{
|
2025-03-14 10:31:27 +00:00
|
|
|
return m_condition->to_string();
|
2024-11-01 19:55:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Supports::dump(StringBuilder& builder, int indent_levels) const
|
|
|
|
{
|
|
|
|
m_condition->dump(builder, indent_levels);
|
|
|
|
}
|
|
|
|
|
2021-10-08 15:40:19 +01:00
|
|
|
}
|