dymokomi/luce-browser-engine
Source of release 0.6.1
0.6.1 / src / web / css / container_query.lucb
#==============================================================================================
#
# container_query - CSS::ContainerQuery: the condition of an @container rule
#
# DESCRIPTION:
# Port of LibWeb/CSS/ContainerQuery.cpp (lines 1-37) and the inline members of
# ContainerQuery.h (lines 16-30). The condition is evaluated once, with no document,
# when the query is made (container size features are not evaluated against boxes).
#
# Copyright (c) 2026, Sam Atkins <sam@ladybird.org>
# SPDX-License-Identifier: BSD-2-Clause
#
#==============================================================================================
## Ported from Libraries/LibWeb/CSS/ContainerQuery.cpp:14 Web::CSS::ContainerQuery::create.
pub func css_container_query_create(condition: CssBooleanExpression*) -> CssContainerQuery*:
let this = &(new CssContainerQuery[1] --- else trap("out of memory"))[0]
css_container_query_construct(this, condition)
return this
## Ported from Libraries/LibWeb/CSS/ContainerQuery.cpp:19 Web::CSS::ContainerQuery::ContainerQuery.
pub func css_container_query_construct(this: CssContainerQuery*, condition: CssBooleanExpression*):
this.m_condition = condition
this.m_matches = css_boolean_expression_evaluate_to_boolean(this.m_condition, none)
## Ported from Libraries/LibWeb/CSS/ContainerQuery.h:20 Web::CSS::ContainerQuery::matches.
pub func css_container_query_matches(this: const CssContainerQuery*) -> bool:
return this.m_matches
## Ported from Libraries/LibWeb/CSS/ContainerQuery.cpp:25 Web::CSS::ContainerQuery::to_string.
pub func css_container_query_to_string(this: const CssContainerQuery*) -> ak.String:
return css_boolean_expression_to_string(this.m_condition)
## Ported from Libraries/LibWeb/CSS/ContainerQuery.cpp:30 Web::CSS::ContainerQuery::dump.
pub func css_container_query_dump(this: const CssContainerQuery*, builder: ak.StringBuilder*, indent_levels: i32 = 0):
dump_indent(builder, indent_levels)
dump_appendff(builder, "Container query: (matches = {})\n", [ak.arg_bool(this.m_matches)])
css_boolean_expression_dump(this.m_condition, builder, indent_levels + 1)