Luce packages
LuceLuce BaseLuciaOS

dymokomi/luce-browser-engine

Source of release 0.6.0

0.6.0 / src / web / css / style_values / calculated_style_value_5.lucb

#==============================================================================================
#
#   calculated_style_value_5 - CalculatedStyleValue: cos(), tan(), the inverse trigonometric
#                              functions, atan2(), pow() and sqrt()
#
#   DESCRIPTION:
#       Port of LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp (lines 1638-2124) and the inline
#       members of CalculatedStyleValue.h they belong with: the Cos, Tan, Asin, Acos, Atan, Atan2,
#       Pow and Sqrt nodes and run_asin_acos_or_atan_operation_if_possible.
#
#       Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org>
#       Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
#       Copyright (c) 2021-2025, Sam Atkins <sam@ladybird.org>
#       Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
#       SPDX-License-Identifier: BSD-2-Clause
#
#==============================================================================================

# mark: CosCalculationNode =================================================================

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1636 Web::CSS::CosCalculationNode::create.
pub func css_cos_calculation_node_create(value: CssCalculationNode*) -> CssCosCalculationNode*:
    let this = &(new CssCosCalculationNode[1] --- else trap("out of memory"))[0]
    css_cos_calculation_node_construct(this, value)
    return this

## css_cos_calculation_node_create as a CssCreateFromChild.
func css_cos_calculation_node_create_node(value: CssCalculationNode*) -> CssCalculationNode*:
    return css_cos_calculation_node_create(value).css_calculation_node()

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1641 Web::CSS::CosCalculationNode::CosCalculationNode.
pub func css_cos_calculation_node_construct(this: CssCosCalculationNode*, value: CssCalculationNode*):
    # https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
    # «[ ]» (empty map).
    css_calculation_node_construct(this.css_calculation_node(), .cos, CssNumericType())
    css_calculation_node_set_class(this.css_calculation_node(), (const CssCalculationNodeVTable*)&css_cos_calculation_node_vtable, &css_cos_calculation_node_class)
    this.m_value = value

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1651 Web::CSS::CosCalculationNode::contains_percentage (override).
pub func css_cos_calculation_node_contains_percentage_impl(base: CssCalculationNode*) -> bool:
    let this = (CssCosCalculationNode*)base
    return css_calculation_node_contains_percentage(this.m_value)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1656 Web::CSS::CosCalculationNode::with_simplified_children (override).
pub func css_cos_calculation_node_with_simplified_children_impl(base: CssCalculationNode*, context: CssCalculationContext, resolution_context: CssCalculationResolutionContext) -> CssCalculationNode*:
    let this = (CssCosCalculationNode*)base
    return css_simplify_child(base, css_cos_calculation_node_create_node, this.m_value, context, resolution_context)

# https://drafts.csswg.org/css-values-4/#funcdef-cos
## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1662 Web::CSS::CosCalculationNode::run_operation_if_possible (override).
pub func css_cos_calculation_node_run_operation_if_possible_impl(base: CssCalculationNode*, arg0: CssCalculationContext, arg1: CssCalculationResolutionContext) -> CssCalculatedStyleValueCalculationResult?:
    _ = arg0
    _ = arg1
    let this = (CssCosCalculationNode*)base
    return css_run_sin_cos_or_tan_operation_if_possible(this.m_value, .cos)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1667 Web::CSS::CosCalculationNode::dump (override).
pub func css_cos_calculation_node_dump_impl(base: CssCalculationNode*, builder: ak.StringBuilder*, indent: i32):
    let this = (CssCosCalculationNode*)base
    css_appendff(builder, "{: >{}}COS:\n", [ak.arg_str(""), ak.arg_i64((i64)indent)])
    css_calculation_node_dump(this.m_value, builder, indent + 2)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1673 Web::CSS::CosCalculationNode::equals (override).
pub func css_cos_calculation_node_equals_impl(base: CssCalculationNode*, other: CssCalculationNode*) -> bool:
    let this = (CssCosCalculationNode*)base
    if base == other:
        return true
    if css_calculation_node_type(base) != css_calculation_node_type(other):
        return false
    return css_calculation_node_equals(this.m_value, ((CssCosCalculationNode*)other).m_value)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1682 Web::CSS::CosCalculationNode::is_computationally_independent (override).
pub func css_cos_calculation_node_is_computationally_independent_impl(base: CssCalculationNode*) -> bool:
    let this = (CssCosCalculationNode*)base
    return css_calculation_node_is_computationally_independent(this.m_value)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.h:513 Web::CSS::CosCalculationNode::children (override).
pub func css_cos_calculation_node_children_impl(base: CssCalculationNode*) -> ak.Vector[CssCalculationNode*]:
    let this = (CssCosCalculationNode*)base
    var children = ak.Vector[CssCalculationNode*]()
    ak.vector_append_t(&children, this.m_value)
    return children

# mark: TanCalculationNode =================================================================

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1687 Web::CSS::TanCalculationNode::create.
pub func css_tan_calculation_node_create(value: CssCalculationNode*) -> CssTanCalculationNode*:
    let this = &(new CssTanCalculationNode[1] --- else trap("out of memory"))[0]
    css_tan_calculation_node_construct(this, value)
    return this

## css_tan_calculation_node_create as a CssCreateFromChild.
func css_tan_calculation_node_create_node(value: CssCalculationNode*) -> CssCalculationNode*:
    return css_tan_calculation_node_create(value).css_calculation_node()

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1692 Web::CSS::TanCalculationNode::TanCalculationNode.
pub func css_tan_calculation_node_construct(this: CssTanCalculationNode*, value: CssCalculationNode*):
    # https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
    # «[ ]» (empty map).
    css_calculation_node_construct(this.css_calculation_node(), .tan, CssNumericType())
    css_calculation_node_set_class(this.css_calculation_node(), (const CssCalculationNodeVTable*)&css_tan_calculation_node_vtable, &css_tan_calculation_node_class)
    this.m_value = value

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1702 Web::CSS::TanCalculationNode::contains_percentage (override).
pub func css_tan_calculation_node_contains_percentage_impl(base: CssCalculationNode*) -> bool:
    let this = (CssTanCalculationNode*)base
    return css_calculation_node_contains_percentage(this.m_value)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1707 Web::CSS::TanCalculationNode::with_simplified_children (override).
pub func css_tan_calculation_node_with_simplified_children_impl(base: CssCalculationNode*, context: CssCalculationContext, resolution_context: CssCalculationResolutionContext) -> CssCalculationNode*:
    let this = (CssTanCalculationNode*)base
    return css_simplify_child(base, css_tan_calculation_node_create_node, this.m_value, context, resolution_context)

# https://drafts.csswg.org/css-values-4/#funcdef-tan
## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1713 Web::CSS::TanCalculationNode::run_operation_if_possible (override).
pub func css_tan_calculation_node_run_operation_if_possible_impl(base: CssCalculationNode*, arg0: CssCalculationContext, arg1: CssCalculationResolutionContext) -> CssCalculatedStyleValueCalculationResult?:
    _ = arg0
    _ = arg1
    let this = (CssTanCalculationNode*)base
    return css_run_sin_cos_or_tan_operation_if_possible(this.m_value, .tan)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1718 Web::CSS::TanCalculationNode::dump (override).
pub func css_tan_calculation_node_dump_impl(base: CssCalculationNode*, builder: ak.StringBuilder*, indent: i32):
    let this = (CssTanCalculationNode*)base
    css_appendff(builder, "{: >{}}TAN:\n", [ak.arg_str(""), ak.arg_i64((i64)indent)])
    css_calculation_node_dump(this.m_value, builder, indent + 2)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1724 Web::CSS::TanCalculationNode::equals (override).
pub func css_tan_calculation_node_equals_impl(base: CssCalculationNode*, other: CssCalculationNode*) -> bool:
    let this = (CssTanCalculationNode*)base
    if base == other:
        return true
    if css_calculation_node_type(base) != css_calculation_node_type(other):
        return false
    return css_calculation_node_equals(this.m_value, ((CssTanCalculationNode*)other).m_value)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1733 Web::CSS::TanCalculationNode::is_computationally_independent (override).
pub func css_tan_calculation_node_is_computationally_independent_impl(base: CssCalculationNode*) -> bool:
    let this = (CssTanCalculationNode*)base
    return css_calculation_node_is_computationally_independent(this.m_value)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.h:533 Web::CSS::TanCalculationNode::children (override).
pub func css_tan_calculation_node_children_impl(base: CssCalculationNode*) -> ak.Vector[CssCalculationNode*]:
    let this = (CssTanCalculationNode*)base
    var children = ak.Vector[CssCalculationNode*]()
    ak.vector_append_t(&children, this.m_value)
    return children

# mark: AsinCalculationNode ================================================================

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1738 Web::CSS::AsinCalculationNode::create.
pub func css_asin_calculation_node_create(value: CssCalculationNode*) -> CssAsinCalculationNode*:
    let this = &(new CssAsinCalculationNode[1] --- else trap("out of memory"))[0]
    css_asin_calculation_node_construct(this, value)
    return this

## css_asin_calculation_node_create as a CssCreateFromChild.
func css_asin_calculation_node_create_node(value: CssCalculationNode*) -> CssCalculationNode*:
    return css_asin_calculation_node_create(value).css_calculation_node()

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1743 Web::CSS::AsinCalculationNode::AsinCalculationNode.
pub func css_asin_calculation_node_construct(this: CssAsinCalculationNode*, value: CssCalculationNode*):
    # https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
    # «[ "angle" → 1 ]».
    css_calculation_node_construct(this.css_calculation_node(), .asin, css_numeric_type_new(.angle, 1))
    css_calculation_node_set_class(this.css_calculation_node(), (const CssCalculationNodeVTable*)&css_asin_calculation_node_vtable, &css_asin_calculation_node_class)
    this.m_value = value

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1753 Web::CSS::AsinCalculationNode::contains_percentage (override).
pub func css_asin_calculation_node_contains_percentage_impl(base: CssCalculationNode*) -> bool:
    let this = (CssAsinCalculationNode*)base
    return css_calculation_node_contains_percentage(this.m_value)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1758 Web::CSS::AsinCalculationNode::with_simplified_children (override).
pub func css_asin_calculation_node_with_simplified_children_impl(base: CssCalculationNode*, context: CssCalculationContext, resolution_context: CssCalculationResolutionContext) -> CssCalculationNode*:
    let this = (CssAsinCalculationNode*)base
    return css_simplify_child(base, css_asin_calculation_node_create_node, this.m_value, context, resolution_context)

## run_asin_acos_or_atan_operation_if_possible's `normalize_angle` lambda.
func css_normalize_angle(radians: f64, min_degrees: f64, max_degrees: f64) -> f64:
    var degrees = ak.to_degrees_f64(radians)
    while degrees < min_degrees:
        degrees += 360.0
    while degrees > max_degrees:
        degrees -= 360.0
    return degrees

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1768 Web::CSS::run_asin_acos_or_atan_operation_if_possible.
func css_run_asin_acos_or_atan_operation_if_possible(child: CssCalculationNode*, trig_function: CssAsinAcosOrAtan) -> CssCalculatedStyleValueCalculationResult?:
    # The asin(A), acos(A), and atan(A) functions are the "arc" or "inverse" trigonometric functions, representing
    # the inverse function to their corresponding "normal" trig functions. All of them contain a single calculation
    # which must resolve to a <number>, and compute their corresponding function, interpreting their result as a
    # number of radians, representing an <angle> with the return type made consistent with the input calculation’s
    # type. The angle returned by asin() must be normalized to the range [-90deg, 90deg]; the angle returned by acos()
    # to the range [0deg, 180deg]; and the angle returned by atan() to the range [-90deg, 90deg].
    let number = css_try_get_number(child) else return none

    var result = 0.0
    match trig_function:
        .asin: result = css_normalize_angle(math.asin(number), -90.0, 90.0)
        .acos: result = css_normalize_angle(math.acos(number), 0.0, 180.0)
        .atan: result = css_normalize_angle(math.atan(number), -90.0, 90.0)
        _: _ = 0

    let angle_type = css_numeric_type_new(.angle, 1)
    return css_calculated_style_value_calculation_result_new(result, css_numeric_type_made_consistent_with(&angle_type, css_calculation_node_numeric_type(child) else trap("VERIFY: has_value")))

# https://drafts.csswg.org/css-values-4/#funcdef-asin
## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1808 Web::CSS::AsinCalculationNode::run_operation_if_possible (override).
pub func css_asin_calculation_node_run_operation_if_possible_impl(base: CssCalculationNode*, arg0: CssCalculationContext, arg1: CssCalculationResolutionContext) -> CssCalculatedStyleValueCalculationResult?:
    _ = arg0
    _ = arg1
    let this = (CssAsinCalculationNode*)base
    return css_run_asin_acos_or_atan_operation_if_possible(this.m_value, .asin)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1813 Web::CSS::AsinCalculationNode::dump (override).
pub func css_asin_calculation_node_dump_impl(base: CssCalculationNode*, builder: ak.StringBuilder*, indent: i32):
    let this = (CssAsinCalculationNode*)base
    css_appendff(builder, "{: >{}}ASIN:\n", [ak.arg_str(""), ak.arg_i64((i64)indent)])
    css_calculation_node_dump(this.m_value, builder, indent + 2)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1819 Web::CSS::AsinCalculationNode::equals (override).
pub func css_asin_calculation_node_equals_impl(base: CssCalculationNode*, other: CssCalculationNode*) -> bool:
    let this = (CssAsinCalculationNode*)base
    if base == other:
        return true
    if css_calculation_node_type(base) != css_calculation_node_type(other):
        return false
    return css_calculation_node_equals(this.m_value, ((CssAsinCalculationNode*)other).m_value)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1828 Web::CSS::AsinCalculationNode::is_computationally_independent (override).
pub func css_asin_calculation_node_is_computationally_independent_impl(base: CssCalculationNode*) -> bool:
    let this = (CssAsinCalculationNode*)base
    return css_calculation_node_is_computationally_independent(this.m_value)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.h:553 Web::CSS::AsinCalculationNode::children (override).
pub func css_asin_calculation_node_children_impl(base: CssCalculationNode*) -> ak.Vector[CssCalculationNode*]:
    let this = (CssAsinCalculationNode*)base
    var children = ak.Vector[CssCalculationNode*]()
    ak.vector_append_t(&children, this.m_value)
    return children

# mark: AcosCalculationNode ================================================================

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1833 Web::CSS::AcosCalculationNode::create.
pub func css_acos_calculation_node_create(value: CssCalculationNode*) -> CssAcosCalculationNode*:
    let this = &(new CssAcosCalculationNode[1] --- else trap("out of memory"))[0]
    css_acos_calculation_node_construct(this, value)
    return this

## css_acos_calculation_node_create as a CssCreateFromChild.
func css_acos_calculation_node_create_node(value: CssCalculationNode*) -> CssCalculationNode*:
    return css_acos_calculation_node_create(value).css_calculation_node()

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1838 Web::CSS::AcosCalculationNode::AcosCalculationNode.
pub func css_acos_calculation_node_construct(this: CssAcosCalculationNode*, value: CssCalculationNode*):
    # https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
    # «[ "angle" → 1 ]».
    css_calculation_node_construct(this.css_calculation_node(), .acos, css_numeric_type_new(.angle, 1))
    css_calculation_node_set_class(this.css_calculation_node(), (const CssCalculationNodeVTable*)&css_acos_calculation_node_vtable, &css_acos_calculation_node_class)
    this.m_value = value

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1848 Web::CSS::AcosCalculationNode::contains_percentage (override).
pub func css_acos_calculation_node_contains_percentage_impl(base: CssCalculationNode*) -> bool:
    let this = (CssAcosCalculationNode*)base
    return css_calculation_node_contains_percentage(this.m_value)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1853 Web::CSS::AcosCalculationNode::with_simplified_children (override).
pub func css_acos_calculation_node_with_simplified_children_impl(base: CssCalculationNode*, context: CssCalculationContext, resolution_context: CssCalculationResolutionContext) -> CssCalculationNode*:
    let this = (CssAcosCalculationNode*)base
    return css_simplify_child(base, css_acos_calculation_node_create_node, this.m_value, context, resolution_context)

# https://drafts.csswg.org/css-values-4/#funcdef-acos
## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1859 Web::CSS::AcosCalculationNode::run_operation_if_possible (override).
pub func css_acos_calculation_node_run_operation_if_possible_impl(base: CssCalculationNode*, arg0: CssCalculationContext, arg1: CssCalculationResolutionContext) -> CssCalculatedStyleValueCalculationResult?:
    _ = arg0
    _ = arg1
    let this = (CssAcosCalculationNode*)base
    return css_run_asin_acos_or_atan_operation_if_possible(this.m_value, .acos)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1864 Web::CSS::AcosCalculationNode::dump (override).
pub func css_acos_calculation_node_dump_impl(base: CssCalculationNode*, builder: ak.StringBuilder*, indent: i32):
    let this = (CssAcosCalculationNode*)base
    css_appendff(builder, "{: >{}}ACOS:\n", [ak.arg_str(""), ak.arg_i64((i64)indent)])
    css_calculation_node_dump(this.m_value, builder, indent + 2)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1870 Web::CSS::AcosCalculationNode::equals (override).
pub func css_acos_calculation_node_equals_impl(base: CssCalculationNode*, other: CssCalculationNode*) -> bool:
    let this = (CssAcosCalculationNode*)base
    if base == other:
        return true
    if css_calculation_node_type(base) != css_calculation_node_type(other):
        return false
    return css_calculation_node_equals(this.m_value, ((CssAcosCalculationNode*)other).m_value)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1879 Web::CSS::AcosCalculationNode::is_computationally_independent (override).
pub func css_acos_calculation_node_is_computationally_independent_impl(base: CssCalculationNode*) -> bool:
    let this = (CssAcosCalculationNode*)base
    return css_calculation_node_is_computationally_independent(this.m_value)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.h:573 Web::CSS::AcosCalculationNode::children (override).
pub func css_acos_calculation_node_children_impl(base: CssCalculationNode*) -> ak.Vector[CssCalculationNode*]:
    let this = (CssAcosCalculationNode*)base
    var children = ak.Vector[CssCalculationNode*]()
    ak.vector_append_t(&children, this.m_value)
    return children

# mark: AtanCalculationNode ================================================================

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1884 Web::CSS::AtanCalculationNode::create.
pub func css_atan_calculation_node_create(value: CssCalculationNode*) -> CssAtanCalculationNode*:
    let this = &(new CssAtanCalculationNode[1] --- else trap("out of memory"))[0]
    css_atan_calculation_node_construct(this, value)
    return this

## css_atan_calculation_node_create as a CssCreateFromChild.
func css_atan_calculation_node_create_node(value: CssCalculationNode*) -> CssCalculationNode*:
    return css_atan_calculation_node_create(value).css_calculation_node()

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1889 Web::CSS::AtanCalculationNode::AtanCalculationNode.
pub func css_atan_calculation_node_construct(this: CssAtanCalculationNode*, value: CssCalculationNode*):
    # https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
    # «[ "angle" → 1 ]».
    css_calculation_node_construct(this.css_calculation_node(), .atan, css_numeric_type_new(.angle, 1))
    css_calculation_node_set_class(this.css_calculation_node(), (const CssCalculationNodeVTable*)&css_atan_calculation_node_vtable, &css_atan_calculation_node_class)
    this.m_value = value

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1899 Web::CSS::AtanCalculationNode::contains_percentage (override).
pub func css_atan_calculation_node_contains_percentage_impl(base: CssCalculationNode*) -> bool:
    let this = (CssAtanCalculationNode*)base
    return css_calculation_node_contains_percentage(this.m_value)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1904 Web::CSS::AtanCalculationNode::with_simplified_children (override).
pub func css_atan_calculation_node_with_simplified_children_impl(base: CssCalculationNode*, context: CssCalculationContext, resolution_context: CssCalculationResolutionContext) -> CssCalculationNode*:
    let this = (CssAtanCalculationNode*)base
    return css_simplify_child(base, css_atan_calculation_node_create_node, this.m_value, context, resolution_context)

# https://drafts.csswg.org/css-values-4/#funcdef-atan
## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1910 Web::CSS::AtanCalculationNode::run_operation_if_possible (override).
pub func css_atan_calculation_node_run_operation_if_possible_impl(base: CssCalculationNode*, arg0: CssCalculationContext, arg1: CssCalculationResolutionContext) -> CssCalculatedStyleValueCalculationResult?:
    _ = arg0
    _ = arg1
    let this = (CssAtanCalculationNode*)base
    return css_run_asin_acos_or_atan_operation_if_possible(this.m_value, .atan)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1915 Web::CSS::AtanCalculationNode::dump (override).
pub func css_atan_calculation_node_dump_impl(base: CssCalculationNode*, builder: ak.StringBuilder*, indent: i32):
    let this = (CssAtanCalculationNode*)base
    css_appendff(builder, "{: >{}}ATAN:\n", [ak.arg_str(""), ak.arg_i64((i64)indent)])
    css_calculation_node_dump(this.m_value, builder, indent + 2)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1921 Web::CSS::AtanCalculationNode::equals (override).
pub func css_atan_calculation_node_equals_impl(base: CssCalculationNode*, other: CssCalculationNode*) -> bool:
    let this = (CssAtanCalculationNode*)base
    if base == other:
        return true
    if css_calculation_node_type(base) != css_calculation_node_type(other):
        return false
    return css_calculation_node_equals(this.m_value, ((CssAtanCalculationNode*)other).m_value)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1930 Web::CSS::AtanCalculationNode::is_computationally_independent (override).
pub func css_atan_calculation_node_is_computationally_independent_impl(base: CssCalculationNode*) -> bool:
    let this = (CssAtanCalculationNode*)base
    return css_calculation_node_is_computationally_independent(this.m_value)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.h:593 Web::CSS::AtanCalculationNode::children (override).
pub func css_atan_calculation_node_children_impl(base: CssCalculationNode*) -> ak.Vector[CssCalculationNode*]:
    let this = (CssAtanCalculationNode*)base
    var children = ak.Vector[CssCalculationNode*]()
    ak.vector_append_t(&children, this.m_value)
    return children

# mark: Atan2CalculationNode ===============================================================

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1935 Web::CSS::Atan2CalculationNode::create.
pub func css_atan2_calculation_node_create(y: CssCalculationNode*, x: CssCalculationNode*) -> CssAtan2CalculationNode*:
    let this = &(new CssAtan2CalculationNode[1] --- else trap("out of memory"))[0]
    css_atan2_calculation_node_construct(this, y, x)
    return this

## css_atan2_calculation_node_create as a CssCreateFromTwoChildren.
func css_atan2_calculation_node_create_node(y: CssCalculationNode*, x: CssCalculationNode*) -> CssCalculationNode*:
    return css_atan2_calculation_node_create(y, x).css_calculation_node()

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1940 Web::CSS::Atan2CalculationNode::Atan2CalculationNode.
pub func css_atan2_calculation_node_construct(this: CssAtan2CalculationNode*, y: CssCalculationNode*, x: CssCalculationNode*):
    # https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
    # «[ "angle" → 1 ]».
    css_calculation_node_construct(this.css_calculation_node(), .atan2, css_numeric_type_new(.angle, 1))
    css_calculation_node_set_class(this.css_calculation_node(), (const CssCalculationNodeVTable*)&css_atan2_calculation_node_vtable, &css_atan2_calculation_node_class)
    this.m_y = y
    this.m_x = x

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1951 Web::CSS::Atan2CalculationNode::contains_percentage (override).
pub func css_atan2_calculation_node_contains_percentage_impl(base: CssCalculationNode*) -> bool:
    let this = (CssAtan2CalculationNode*)base
    return css_calculation_node_contains_percentage(this.m_y) or css_calculation_node_contains_percentage(this.m_x)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1956 Web::CSS::Atan2CalculationNode::with_simplified_children (override).
pub func css_atan2_calculation_node_with_simplified_children_impl(base: CssCalculationNode*, context: CssCalculationContext, resolution_context: CssCalculationResolutionContext) -> CssCalculationNode*:
    let this = (CssAtan2CalculationNode*)base
    return css_simplify_2_children(base, css_atan2_calculation_node_create_node, this.m_y, this.m_x, context, resolution_context)

# https://drafts.csswg.org/css-values-4/#funcdef-atan2
## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1962 Web::CSS::Atan2CalculationNode::run_operation_if_possible (override).
pub func css_atan2_calculation_node_run_operation_if_possible_impl(base: CssCalculationNode*, context: CssCalculationContext, resolution_context: CssCalculationResolutionContext) -> CssCalculatedStyleValueCalculationResult?:
    let this = (CssAtan2CalculationNode*)base
    # The atan2(A, B) function contains two comma-separated calculations, A and B. A and B can resolve to any <number>,
    # <dimension>, or <percentage>, but must have a consistent type or else the function is invalid. The function
    # returns the <angle> between the positive X-axis and the point (B,A), with the return type made consistent with the
    # input calculation’s type. The returned angle must be normalized to the interval (-180deg, 180deg] (that is,
    # greater than -180deg, and less than or equal to 180deg).
    let x_value = css_try_get_value_with_canonical_unit(this.m_x, context, resolution_context) else return none
    let y_value = css_try_get_value_with_canonical_unit(this.m_y, context, resolution_context) else return none

    let x_type = x_value.m_type else trap("VERIFY: has_value")
    let input_consistent_type = css_numeric_type_consistent_type(&x_type, y_value.m_type else trap("VERIFY: has_value")) else return none

    var degrees = ak.to_degrees_f64(math.atan2(y_value.m_value, x_value.m_value))
    while degrees <= -180.0:
        degrees += 360.0
    while degrees > 180.0:
        degrees -= 360.0

    let angle_type = css_numeric_type_new(.angle, 1)
    return css_calculated_style_value_calculation_result_new(degrees, css_numeric_type_made_consistent_with(&angle_type, input_consistent_type))

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1989 Web::CSS::Atan2CalculationNode::dump (override).
pub func css_atan2_calculation_node_dump_impl(base: CssCalculationNode*, builder: ak.StringBuilder*, indent: i32):
    let this = (CssAtan2CalculationNode*)base
    css_appendff(builder, "{: >{}}ATAN2:\n", [ak.arg_str(""), ak.arg_i64((i64)indent)])
    css_calculation_node_dump(this.m_x, builder, indent + 2)
    css_calculation_node_dump(this.m_y, builder, indent + 2)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:1996 Web::CSS::Atan2CalculationNode::equals (override).
pub func css_atan2_calculation_node_equals_impl(base: CssCalculationNode*, other: CssCalculationNode*) -> bool:
    let this = (CssAtan2CalculationNode*)base
    if base == other:
        return true
    if css_calculation_node_type(base) != css_calculation_node_type(other):
        return false
    return css_calculation_node_equals(this.m_x, ((CssAtan2CalculationNode*)other).m_x) and css_calculation_node_equals(this.m_y, ((CssAtan2CalculationNode*)other).m_y)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:2006 Web::CSS::Atan2CalculationNode::is_computationally_independent (override).
pub func css_atan2_calculation_node_is_computationally_independent_impl(base: CssCalculationNode*) -> bool:
    let this = (CssAtan2CalculationNode*)base
    return css_calculation_node_is_computationally_independent(this.m_x) and css_calculation_node_is_computationally_independent(this.m_y)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.h:613 Web::CSS::Atan2CalculationNode::children (override).
pub func css_atan2_calculation_node_children_impl(base: CssCalculationNode*) -> ak.Vector[CssCalculationNode*]:
    let this = (CssAtan2CalculationNode*)base
    var children = ak.Vector[CssCalculationNode*]()
    ak.vector_append_t(&children, this.m_y)
    ak.vector_append_t(&children, this.m_x)
    return children

# mark: PowCalculationNode =================================================================

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:2011 Web::CSS::PowCalculationNode::create.
pub func css_pow_calculation_node_create(x: CssCalculationNode*, y: CssCalculationNode*) -> CssPowCalculationNode*:
    let this = &(new CssPowCalculationNode[1] --- else trap("out of memory"))[0]
    css_pow_calculation_node_construct(this, x, y)
    return this

## css_pow_calculation_node_create as a CssCreateFromTwoChildren.
func css_pow_calculation_node_create_node(x: CssCalculationNode*, y: CssCalculationNode*) -> CssCalculationNode*:
    return css_pow_calculation_node_create(x, y).css_calculation_node()

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:2016 Web::CSS::PowCalculationNode::PowCalculationNode.
pub func css_pow_calculation_node_construct(this: CssPowCalculationNode*, x: CssCalculationNode*, y: CssCalculationNode*):
    # https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
    # «[ ]» (empty map).
    css_calculation_node_construct(this.css_calculation_node(), .pow, CssNumericType())
    css_calculation_node_set_class(this.css_calculation_node(), (const CssCalculationNodeVTable*)&css_pow_calculation_node_vtable, &css_pow_calculation_node_class)
    this.m_x = x
    this.m_y = y

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.h:630 Web::CSS::PowCalculationNode::contains_percentage (override).
pub func css_pow_calculation_node_contains_percentage_impl(base: CssCalculationNode*) -> bool:
    _ = base
    return false

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:2027 Web::CSS::PowCalculationNode::with_simplified_children (override).
pub func css_pow_calculation_node_with_simplified_children_impl(base: CssCalculationNode*, context: CssCalculationContext, resolution_context: CssCalculationResolutionContext) -> CssCalculationNode*:
    let this = (CssPowCalculationNode*)base
    return css_simplify_2_children(base, css_pow_calculation_node_create_node, this.m_x, this.m_y, context, resolution_context)

# https://drafts.csswg.org/css-values-4/#funcdef-pow
## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:2033 Web::CSS::PowCalculationNode::run_operation_if_possible (override).
pub func css_pow_calculation_node_run_operation_if_possible_impl(base: CssCalculationNode*, arg0: CssCalculationContext, arg1: CssCalculationResolutionContext) -> CssCalculatedStyleValueCalculationResult?:
    _ = arg0
    _ = arg1
    let this = (CssPowCalculationNode*)base
    # The pow(A, B) function contains two comma-separated calculations A and B, both of which must resolve to <number>s,
    # and returns the result of raising A to the power of B, returning the value as a <number>. The input calculations
    # must have a consistent type or else the function is invalid; the result’s type will be the consistent type.
    let a = css_try_get_number(this.m_x)
    let b = css_try_get_number(this.m_y)
    if a == none or b == none:
        return none

    let x_type = css_calculation_node_numeric_type(this.m_x) else trap("VERIFY: has_value")
    let consistent_type = css_numeric_type_consistent_type(&x_type, css_calculation_node_numeric_type(this.m_y) else trap("VERIFY: has_value")) else return none

    return css_calculated_style_value_calculation_result_new(math.pow(a else trap("unreachable"), b else trap("unreachable")), consistent_type)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:2050 Web::CSS::PowCalculationNode::dump (override).
pub func css_pow_calculation_node_dump_impl(base: CssCalculationNode*, builder: ak.StringBuilder*, indent: i32):
    let this = (CssPowCalculationNode*)base
    css_appendff(builder, "{: >{}}POW:\n", [ak.arg_str(""), ak.arg_i64((i64)indent)])
    css_calculation_node_dump(this.m_x, builder, indent + 2)
    css_calculation_node_dump(this.m_y, builder, indent + 2)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:2057 Web::CSS::PowCalculationNode::equals (override).
pub func css_pow_calculation_node_equals_impl(base: CssCalculationNode*, other: CssCalculationNode*) -> bool:
    let this = (CssPowCalculationNode*)base
    if base == other:
        return true
    if css_calculation_node_type(base) != css_calculation_node_type(other):
        return false
    return css_calculation_node_equals(this.m_x, ((CssPowCalculationNode*)other).m_x) and css_calculation_node_equals(this.m_y, ((CssPowCalculationNode*)other).m_y)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:2067 Web::CSS::PowCalculationNode::is_computationally_independent (override).
pub func css_pow_calculation_node_is_computationally_independent_impl(base: CssCalculationNode*) -> bool:
    let this = (CssPowCalculationNode*)base
    return css_calculation_node_is_computationally_independent(this.m_x) and css_calculation_node_is_computationally_independent(this.m_y)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.h:634 Web::CSS::PowCalculationNode::children (override).
pub func css_pow_calculation_node_children_impl(base: CssCalculationNode*) -> ak.Vector[CssCalculationNode*]:
    let this = (CssPowCalculationNode*)base
    var children = ak.Vector[CssCalculationNode*]()
    ak.vector_append_t(&children, this.m_x)
    ak.vector_append_t(&children, this.m_y)
    return children

# mark: SqrtCalculationNode ================================================================

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:2072 Web::CSS::SqrtCalculationNode::create.
pub func css_sqrt_calculation_node_create(value: CssCalculationNode*) -> CssSqrtCalculationNode*:
    let this = &(new CssSqrtCalculationNode[1] --- else trap("out of memory"))[0]
    css_sqrt_calculation_node_construct(this, value)
    return this

## css_sqrt_calculation_node_create as a CssCreateFromChild.
func css_sqrt_calculation_node_create_node(value: CssCalculationNode*) -> CssCalculationNode*:
    return css_sqrt_calculation_node_create(value).css_calculation_node()

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:2077 Web::CSS::SqrtCalculationNode::SqrtCalculationNode.
pub func css_sqrt_calculation_node_construct(this: CssSqrtCalculationNode*, value: CssCalculationNode*):
    # https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
    # «[ ]» (empty map).
    css_calculation_node_construct(this.css_calculation_node(), .sqrt, CssNumericType())
    css_calculation_node_set_class(this.css_calculation_node(), (const CssCalculationNodeVTable*)&css_sqrt_calculation_node_vtable, &css_sqrt_calculation_node_class)
    this.m_value = value

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.h:651 Web::CSS::SqrtCalculationNode::contains_percentage (override).
pub func css_sqrt_calculation_node_contains_percentage_impl(base: CssCalculationNode*) -> bool:
    _ = base
    return false

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:2087 Web::CSS::SqrtCalculationNode::with_simplified_children (override).
pub func css_sqrt_calculation_node_with_simplified_children_impl(base: CssCalculationNode*, context: CssCalculationContext, resolution_context: CssCalculationResolutionContext) -> CssCalculationNode*:
    let this = (CssSqrtCalculationNode*)base
    return css_simplify_child(base, css_sqrt_calculation_node_create_node, this.m_value, context, resolution_context)

# https://drafts.csswg.org/css-values-4/#funcdef-sqrt
## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:2093 Web::CSS::SqrtCalculationNode::run_operation_if_possible (override).
pub func css_sqrt_calculation_node_run_operation_if_possible_impl(base: CssCalculationNode*, arg0: CssCalculationContext, arg1: CssCalculationResolutionContext) -> CssCalculatedStyleValueCalculationResult?:
    _ = arg0
    _ = arg1
    let this = (CssSqrtCalculationNode*)base
    # The sqrt(A) function contains a single calculation which must resolve to a <number>, and returns the square root
    # of the value as a <number>, with the return type made consistent with the input calculation’s type.
    # (sqrt(X) and pow(X, .5) are basically equivalent, differing only in some error-handling; sqrt() is a common enough
    # function that it is provided as a convenience.)
    let number = css_try_get_number(this.m_value) else return none

    let empty_type = CssNumericType()
    let consistent_type = css_numeric_type_made_consistent_with(&empty_type, css_calculation_node_numeric_type(this.m_value) else trap("VERIFY: has_value")) else return none

    return css_calculated_style_value_calculation_result_new(math.sqrt(number), consistent_type)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:2110 Web::CSS::SqrtCalculationNode::dump (override).
pub func css_sqrt_calculation_node_dump_impl(base: CssCalculationNode*, builder: ak.StringBuilder*, indent: i32):
    let this = (CssSqrtCalculationNode*)base
    css_appendff(builder, "{: >{}}SQRT:\n", [ak.arg_str(""), ak.arg_i64((i64)indent)])
    css_calculation_node_dump(this.m_value, builder, indent + 2)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:2116 Web::CSS::SqrtCalculationNode::equals (override).
pub func css_sqrt_calculation_node_equals_impl(base: CssCalculationNode*, other: CssCalculationNode*) -> bool:
    let this = (CssSqrtCalculationNode*)base
    if base == other:
        return true
    if css_calculation_node_type(base) != css_calculation_node_type(other):
        return false
    return css_calculation_node_equals(this.m_value, ((CssSqrtCalculationNode*)other).m_value)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:2125 Web::CSS::SqrtCalculationNode::is_computationally_independent (override).
pub func css_sqrt_calculation_node_is_computationally_independent_impl(base: CssCalculationNode*) -> bool:
    let this = (CssSqrtCalculationNode*)base
    return css_calculation_node_is_computationally_independent(this.m_value)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.h:655 Web::CSS::SqrtCalculationNode::children (override).
pub func css_sqrt_calculation_node_children_impl(base: CssCalculationNode*) -> ak.Vector[CssCalculationNode*]:
    let this = (CssSqrtCalculationNode*)base
    var children = ak.Vector[CssCalculationNode*]()
    ak.vector_append_t(&children, this.m_value)
    return children