mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-06-28 04:00:33 +00:00
A given element may be a container in different ways, depending on its `container-type` property. For a container query to match an element, that element must have the required container type for each feature that the query checks. This commit implement a step to collect those required types, so that we can quickly eliminate potential container elements that lack a required containment type.
44 lines
1.1 KiB
C++
44 lines
1.1 KiB
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({}))
|
|
{
|
|
}
|
|
|
|
ContainerQueryFeatureRequirements ContainerQuery::collect_feature_requirements() const
|
|
{
|
|
ContainerQueryFeatureRequirements requirements;
|
|
m_condition->collect_container_query_feature_requirements(requirements);
|
|
return requirements;
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
}
|