mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-18 18:00:31 +00:00
No parsing yet, just CSSContainerRule and the supporting ContainerQuery class. CSSContainerRule is unusual in how it matches, because instead of it either matching or not matching globally, it instead is matched against a specific element. But also, some at-rules inside it always apply, as if they were written outside it. This doesn't fit well with how CSSConditionRule is implemented, and will likely require some rework later. For now, `condition_matches()` always returns false, and `for_each_effective_rule()` is overridden to always process those global at-rules and nothing else.
37 lines
920 B
C++
37 lines
920 B
C++
/*
|
|
* Copyright (c) 2026, Sam Atkins <sam@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include "ContainerQuery.h"
|
|
#include <AK/NonnullRefPtr.h>
|
|
#include <LibWeb/CSS/BooleanExpression.h>
|
|
#include <LibWeb/Dump.h>
|
|
|
|
namespace Web::CSS {
|
|
|
|
NonnullRefPtr<ContainerQuery> ContainerQuery::create(NonnullOwnPtr<BooleanExpression>&& condition)
|
|
{
|
|
return adopt_ref(*new ContainerQuery(move(condition)));
|
|
}
|
|
|
|
ContainerQuery::ContainerQuery(NonnullOwnPtr<BooleanExpression>&& condition)
|
|
: m_condition(move(condition))
|
|
, m_matches(m_condition->evaluate_to_boolean(nullptr))
|
|
{
|
|
}
|
|
|
|
String ContainerQuery::to_string() const
|
|
{
|
|
return m_condition->to_string();
|
|
}
|
|
|
|
void ContainerQuery::dump(StringBuilder& builder, int indent_levels) const
|
|
{
|
|
dump_indent(builder, indent_levels);
|
|
builder.appendff("Container query: (matches = {})\n", m_matches);
|
|
m_condition->dump(builder, indent_levels + 1);
|
|
}
|
|
|
|
}
|