Luce packages
LuceLuce BaseLuciaOS

dymokomi/luce-browser-engine

Source of release 0.6.1

0.6.1 / src / web / css / style_values / calculated_style_value_2.lucb

#==============================================================================================
#
#   calculated_style_value_2 - CalculatedStyleValue: serializing calculation trees and the
#                              CalculationNode base class
#
#   DESCRIPTION:
#       Port of LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp (lines 229-597) and the inline
#       members of CalculatedStyleValue.h they belong with: "serialize a math function", "sort a
#       calculation's children", "serialize a calculation tree", CalculationNode::from_style_value,
#       the CalculationNode base class (its constructor, type tests, name() and its pure virtuals).
#
#       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: Serialization ===========================================================================

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:237 Web::CSS::serialize_a_math_function.
# https://drafts.csswg.org/css-values-4/#serialize-a-math-function
func css_serialize_a_math_function(builder: ak.StringBuilder*, fn: CssCalculationNode*, context: CssCalculationContext, serialization_mode: css_syntax.SerializationMode):
    # To serialize a math function fn:

    # 1. If the root of the calculation tree fn represents is a numeric value (number, percentage, or dimension), and
    #    the serialization being produced is of a computed value or later, then clamp the value to the range allowed
    #    for its context (if necessary), then serialize the value as normal and return the result.
    if css_calculation_node_type(fn) == CssCalculationNodeType.numeric and serialization_mode == css_syntax.SerializationMode.resolved_value:
        let clamped_value = css_clamp_and_censor_numeric_value((CssNumericCalculationNode*)fn, context)
        css_numeric_value_serialize(&clamped_value, builder, serialization_mode)
        return

    # 2. If fn represents an infinite or NaN value:
    if css_calculation_node_type(fn) == CssCalculationNodeType.numeric:
        let numeric_node = (CssNumericCalculationNode*)fn
        if let infinite_or_nan = css_numeric_calculation_node_infinite_or_nan_value(numeric_node):
            # 1. Let s be the string "calc(".
            ak.string_builder_append(builder, "calc(")

            # 2. Serialize the keyword infinity, -infinity, or NaN, as appropriate to represent the value, and append it to s.
            match infinite_or_nan:
                .infinity: ak.string_builder_append(builder, "infinity")
                .negative_infinity: ak.string_builder_append(builder, "-infinity")
                .na_n: ak.string_builder_append(builder, "NaN")
                _: trap("VERIFY_NOT_REACHED")

            # 3. If fn’s type is anything other than «[ ]» (empty, representing a <number>), append " * " to s.
            #    Create a numeric value in the canonical unit for fn’s type (such as px for <length>), with a value of 1.
            #    Serialize this numeric value and append it to s.
            match numeric_node.m_value:
                .css_angle(_): ak.string_builder_append(builder, " * 1deg")
                .css_flex(_): ak.string_builder_append(builder, " * 1fr")
                .css_frequency(_): ak.string_builder_append(builder, " * 1hz")
                .css_length(_): ak.string_builder_append(builder, " * 1px")
                .number(_): _ = 0
                .css_percentage(_): ak.string_builder_append(builder, " * 1%")
                .css_resolution(_): ak.string_builder_append(builder, " * 1dppx")
                .css_time(_): ak.string_builder_append(builder, " * 1s")

            # 4. Append ")" to s, then return it.
            ak.string_builder_append_u8(builder, ')')
            return

    # AD-HOC: We serialize random() directly since it has abnormal children (e.g. m_random_value_sharing which is not a
    #         calculation node and m_step which is nullable).
    if css_calculation_node_type(fn) == CssCalculationNodeType.random:
        css_random_calculation_node_serialize(as_css_random_calculation_node(fn), builder, context, serialization_mode)
        return

    # 3. If the calculation tree’s root node is a numeric value, or a calc-operator node, let s be a string initially
    #    containing "calc(".
    #    Otherwise, let s be a string initially containing the name of the root node, lowercased (such as "sin" or
    #    "max"), followed by a "(" (open parenthesis).
    if css_calculation_node_type(fn) == CssCalculationNodeType.numeric or css_calculation_node_is_calc_operator_node(fn):
        ak.string_builder_append(builder, "calc(")
    else:
        css_appendff(builder, "{}(", [ak.arg_string_view(css_calculation_node_name(fn))])

    # 4. For each child of the root node, serialize the calculation tree.
    #    If a result of this serialization starts with a "(" (open parenthesis) and ends with a ")" (close parenthesis),
    #    remove those characters from the result.
    #    Concatenate all of the results using ", " (comma followed by space), then append the result to s.

    # Spec issue: https://github.com/w3c/csswg-drafts/issues/11783
    #             The three AD-HOCs in this step are mentioned there.
    # AD-HOC: Numeric nodes have no children and should serialize directly.
    # AD-HOC: calc-operator nodes should also serialize directly, instead of separating their children by commas.#
    if css_calculation_node_type(fn) == CssCalculationNodeType.numeric or css_calculation_node_is_calc_operator_node(fn):
        css_serialize_a_calculation_tree(builder, fn, context, serialization_mode, CssEmitOuterParentheses.no)
    else:
        var first = true
        # AD-HOC: For `clamp()`, the first child is a <rounding-strategy>, which is incompatible with "serialize a calculation tree".
        #         So, we serialize it directly first, and hope for the best.
        if css_calculation_node_type(fn) == CssCalculationNodeType.round:
            let rounding_strategy = css_round_calculation_node_rounding_strategy((CssRoundCalculationNode*)fn)
            ak.string_builder_append_string_view(builder, css_data.to_string_rounding_strategy(rounding_strategy))
            first = false
        let children = css_calculation_node_children(fn)
        for child in ak.vector_span_const(&children):
            if not first:
                ak.string_builder_append(builder, ", ")
            first = false
            css_serialize_a_calculation_tree(builder, child, context, serialization_mode, CssEmitOuterParentheses.no)

    # 5. Append ")" (close parenthesis) to s.
    ak.string_builder_append_u8(builder, ')')

    # 6. Return s.

## Whether `node` is a numeric node holding a number (sort_a_calculations_children's first predicate).
func css_is_numeric_number_node(node: CssCalculationNode*) -> bool:
    if css_calculation_node_type(node) != CssCalculationNodeType.numeric:
        return false
    return css_numeric_value_is_number(&((CssNumericCalculationNode*)node).m_value)

## Whether `node` is a numeric node holding a percentage (sort_a_calculations_children's second predicate).
func css_is_numeric_percentage_node(node: CssCalculationNode*) -> bool:
    if css_calculation_node_type(node) != CssCalculationNodeType.numeric:
        return false
    return css_numeric_value_is_percentage(&((CssNumericCalculationNode*)node).m_value)

## Whether `node` is a numeric node holding a dimension (sort_a_calculations_children's `next_dimension_index`
## predicate).
func css_is_numeric_dimension_node(node: CssCalculationNode*) -> bool:
    if css_calculation_node_type(node) != CssCalculationNodeType.numeric:
        return false
    match ((CssNumericCalculationNode*)node).m_value:
        .number(_): return false
        .css_percentage(_): return false
        _: return true

## `nodes.find_first_index_if(predicate)`.
func css_find_first_node_index(nodes: const ak.Vector[CssCalculationNode*]*, predicate: func(CssCalculationNode*) -> bool) -> usize?:
    for (index, node) in ak.vector_span_const(nodes).indexed():
        if predicate(node):
            return index
    return none

## sort_a_calculations_children's comparator: the dimensions' unit names, ordered.
func css_sort_by_unit_less_than(context: void*?, a: const (CssCalculationNode*)*, b: const (CssCalculationNode*)*) -> bool:
    _ = context
    # get_unit: the unit name of a dimension node.
    let a_unit = css_numeric_value_dimension_unit_name(&((CssNumericCalculationNode*)*a).m_value)
    let b_unit = css_numeric_value_dimension_unit_name(&((CssNumericCalculationNode*)*b).m_value)
    # NOTE: Our unit name strings are always lowercase, so we don't have to do anything special for a case-insensitive match.
    return ak.fly_string_cmp(&a_unit, &b_unit) < 0

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:345 Web::CSS::sort_a_calculations_children.
# https://drafts.csswg.org/css-values-4/#sort-a-calculations-children
func css_sort_a_calculations_children(nodes_: ak.Vector[CssCalculationNode*]) -> ak.Vector[CssCalculationNode*]:
    var nodes = ak.vector_clone(&nodes_)

    # 1. Let ret be an empty list.
    var ret = ak.Vector[CssCalculationNode*]()

    # 2. If nodes contains a number, remove it from nodes and append it to ret.
    if let index_of_number = css_find_first_node_index(&nodes, css_is_numeric_number_node):
        ak.vector_append_t(&ret, ak.vector_take(&nodes, index_of_number))

    # 3. If nodes contains a percentage, remove it from nodes and append it to ret.
    if let index_of_percentage = css_find_first_node_index(&nodes, css_is_numeric_percentage_node):
        ak.vector_append_t(&ret, ak.vector_take(&nodes, index_of_percentage))

    # 4. If nodes contains any dimensions, remove them from nodes, sort them by their units, ordered ASCII
    #    case-insensitively, and append them to ret.
    var dimensions = ak.Vector[CssCalculationNode*]()
    ak.vector_ensure_capacity(&dimensions, ak.vector_size(&nodes))

    while let index_of_dimension = css_find_first_node_index(&nodes, css_is_numeric_dimension_node):
        ak.vector_append_t(&dimensions, ak.vector_take(&nodes, index_of_dimension))

    ak.quick_sort_t_collection_t_less_than(ak.vector_span(&dimensions), ak.Function2[const (CssCalculationNode*)*, const (CssCalculationNode*)*, bool](call = css_sort_by_unit_less_than, context = none))
    ak.vector_extend_2(&ret, &dimensions)

    # 5. If nodes still contains any items, append them to ret in the same order.
    if not ak.vector_is_empty(&nodes):
        ak.vector_extend_2(&ret, &nodes)

    # 6. Return ret.
    return ret

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:415 Web::CSS::serialize_a_calculation_tree.
# https://drafts.csswg.org/css-values-4/#serialize-a-calculation-tree
func css_serialize_a_calculation_tree(builder: ak.StringBuilder*, root: CssCalculationNode*, context: CssCalculationContext, serialization_mode: css_syntax.SerializationMode, emit_outer_parentheses: CssEmitOuterParentheses = CssEmitOuterParentheses.yes):
    # 1. Let root be the root node of the calculation tree.
    # NOTE: Already the case.

    # 2. If root is a numeric value, or a non-math function, serialize root per the normal rules for it and return the result.
    if css_calculation_node_type(root) == CssCalculationNodeType.numeric:
        css_numeric_calculation_node_serialize_value((CssNumericCalculationNode*)root, builder)
        return

    if css_calculation_node_type(root) == CssCalculationNodeType.non_math_function:
        css_style_value_serialize(as_css_non_math_function_calculation_node(root).m_function.css_style_value(), builder, serialization_mode)
        return

    # 3. If root is anything but a Sum, Negate, Product, or Invert node, serialize a math function for the function
    #    corresponding to the node type, treating the node’s children as the function’s comma-separated calculation
    #    arguments, and return the result.
    let root_type = css_calculation_node_type(root)
    if not (root_type == CssCalculationNodeType.sum or root_type == CssCalculationNodeType.product or root_type == CssCalculationNodeType.negate or root_type == CssCalculationNodeType.invert):
        css_serialize_a_math_function(builder, root, context, serialization_mode)
        return

    # 4. If root is a Negate node, let s be a string initially containing "(-1 * ".
    if root_type == CssCalculationNodeType.negate:
        if emit_outer_parentheses == CssEmitOuterParentheses.yes:
            ak.string_builder_append_u8(builder, '(')
        ak.string_builder_append(builder, "-1 * ")

        # Serialize root’s child, and append it to s.
        let children = css_calculation_node_children(root)
        css_serialize_a_calculation_tree(builder, *ak.vector_first_const(&children), context, serialization_mode)

        # Append ")" to s, then return it.
        if emit_outer_parentheses == CssEmitOuterParentheses.yes:
            ak.string_builder_append_u8(builder, ')')
        return

    # 5. If root is an Invert node, let s be a string initially containing "(1 / ".
    if root_type == CssCalculationNodeType.invert:
        if emit_outer_parentheses == CssEmitOuterParentheses.yes:
            ak.string_builder_append_u8(builder, '(')
        ak.string_builder_append(builder, "1 / ")

        # Serialize root’s child, and append it to s.
        let children = css_calculation_node_children(root)
        css_serialize_a_calculation_tree(builder, *ak.vector_first_const(&children), context, serialization_mode)

        # Append ")" to s, then return it.
        if emit_outer_parentheses == CssEmitOuterParentheses.yes:
            ak.string_builder_append_u8(builder, ')')
        return

    # 6. If root is a Sum node, let s be a string initially containing "(".
    if root_type == CssCalculationNodeType.sum:
        if emit_outer_parentheses == CssEmitOuterParentheses.yes:
            ak.string_builder_append_u8(builder, '(')

        let sorted_children = css_sort_a_calculations_children(css_calculation_node_children(root))

        # Serialize root’s first child, and append it to s.
        css_serialize_a_calculation_tree(builder, *ak.vector_first_const(&sorted_children), context, serialization_mode)

        # For each child of root beyond the first:
        for i in 1..<ak.vector_size(&sorted_children):
            let child = *ak.vector_at_const(&sorted_children, i)

            # 1. If child is a Negate node, append " - " to s, then serialize the Negate’s child and append the
            #    result to s.
            if css_calculation_node_type(child) == CssCalculationNodeType.negate:
                ak.string_builder_append(builder, " - ")
                css_serialize_a_calculation_tree(builder, css_negate_calculation_node_child((CssNegateCalculationNode*)child), context, serialization_mode)

            # 2. If child is a negative numeric value, append " - " to s, then serialize the negation of child as
            #    normal and append the result to s.
            elif css_calculation_node_type(child) == CssCalculationNodeType.numeric and css_numeric_calculation_node_is_negative((CssNumericCalculationNode*)child):
                let numeric_node = (CssNumericCalculationNode*)child
                ak.string_builder_append(builder, " - ")
                css_serialize_a_calculation_tree(builder, css_numeric_calculation_node_negated(numeric_node, context).css_calculation_node(), context, serialization_mode)

            # 3. Otherwise, append " + " to s, then serialize child and append the result to s.
            else:
                ak.string_builder_append(builder, " + ")
                css_serialize_a_calculation_tree(builder, child, context, serialization_mode)

        # Finally, append ")" to s and return it.
        if emit_outer_parentheses == CssEmitOuterParentheses.yes:
            ak.string_builder_append_u8(builder, ')')
        return

    # 7. If root is a Product node, let s be a string initially containing "(".
    if root_type == CssCalculationNodeType.product:
        if emit_outer_parentheses == CssEmitOuterParentheses.yes:
            ak.string_builder_append_u8(builder, '(')

        let sorted_children = css_sort_a_calculations_children(css_calculation_node_children(root))

        # Serialize root’s first child, and append it to s.
        css_serialize_a_calculation_tree(builder, *ak.vector_first_const(&sorted_children), context, serialization_mode)

        # For each child of root beyond the first:
        for i in 1..<ak.vector_size(&sorted_children):
            let child = *ak.vector_at_const(&sorted_children, i)

            # 1. If child is an Invert node, append " / " to s, then serialize the Invert’s child and append the result to s.
            if css_calculation_node_type(child) == CssCalculationNodeType.invert:
                ak.string_builder_append(builder, " / ")
                css_serialize_a_calculation_tree(builder, css_invert_calculation_node_child((CssInvertCalculationNode*)child), context, serialization_mode)

            # 2. Otherwise, append " * " to s, then serialize child and append the result to s.
            else:
                ak.string_builder_append(builder, " * ")
                css_serialize_a_calculation_tree(builder, child, context, serialization_mode)

        # Finally, append ")" to s and return it.
        if emit_outer_parentheses == CssEmitOuterParentheses.yes:
            ak.string_builder_append_u8(builder, ')')
        return

    trap("VERIFY_NOT_REACHED")

# mark: CalculationNode =========================================================================

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:547 Web::CSS::CalculationNode::from_style_value.
pub func css_calculation_node_from_style_value(style_value: CssStyleValue*, calculation_context: CssCalculationContext) -> CssCalculationNode*:
    match css_style_value_type(style_value):
        .angle:
            return css_numeric_calculation_node_create(CssCalculationNodeNumericValue.css_angle(css_angle_style_value_angle(css_style_value_as_angle(style_value))), calculation_context).css_calculation_node()
        .frequency:
            return css_numeric_calculation_node_create(CssCalculationNodeNumericValue.css_frequency(css_frequency_style_value_frequency(css_style_value_as_frequency(style_value))), calculation_context).css_calculation_node()
        .integer:
            return css_numeric_calculation_node_create(CssCalculationNodeNumericValue.number(css_syntax.number_create(css_syntax.NumberType.number, f64(css_integer_style_value_integer(css_style_value_as_integer(style_value))))), calculation_context).css_calculation_node()
        .length:
            return css_numeric_calculation_node_create(CssCalculationNodeNumericValue.css_length(css_length_style_value_length(css_style_value_as_length(style_value))), calculation_context).css_calculation_node()
        .number:
            return css_numeric_calculation_node_create(CssCalculationNodeNumericValue.number(css_syntax.number_create(css_syntax.NumberType.number, css_number_style_value_number(css_style_value_as_number(style_value)))), calculation_context).css_calculation_node()
        .percentage:
            return css_numeric_calculation_node_create(CssCalculationNodeNumericValue.css_percentage(css_percentage_style_value_percentage(css_style_value_as_percentage(style_value))), calculation_context).css_calculation_node()
        .time:
            return css_numeric_calculation_node_create(CssCalculationNodeNumericValue.css_time(css_time_style_value_time(css_style_value_as_time(style_value))), calculation_context).css_calculation_node()
        .calculated:
            return css_calculated_style_value_calculation(css_style_value_as_calculated(style_value))
        _:
            trap("VERIFY_NOT_REACHED")

## Install the vtable and class id of the most-derived node class (the C++ vptr after the base constructor).
func css_calculation_node_set_class(this: CssCalculationNode*, vtable: const CssCalculationNodeVTable*, info: const ak.ClassInfo*):
    this.vtable = vtable
    this.class_id = info.first_id

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:571 Web::CSS::CalculationNode::CalculationNode.
pub func css_calculation_node_construct(this: CssCalculationNode*, type_: CssCalculationNodeType, numeric_type: CssNumericType?):
    css_calculation_node_set_class(this, &css_calculation_node_vtable, &css_calculation_node_class)
    this.m_type = type_
    this.m_numeric_type = numeric_type

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.h:195 Web::CSS::CalculationNode::type.
pub func css_calculation_node_type(this: CssCalculationNode*) -> CssCalculationNodeType:
    return this.m_type

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.h:198 Web::CSS::CalculationNode::is_operator_node.
# https://www.w3.org/TR/css-values-4/#calculation-tree-operator-nodes
pub func css_calculation_node_is_operator_node(this: CssCalculationNode*) -> bool:
    return css_calculation_node_is_calc_operator_node(this) or css_calculation_node_is_math_function_node(this)

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.h:203 Web::CSS::CalculationNode::is_math_function_node.
pub func css_calculation_node_is_math_function_node(this: CssCalculationNode*) -> bool:
    match this.m_type:
        .min, .max, .clamp, .abs, .sign, .sin, .cos, .tan, .asin, .acos, .atan, .atan2, .pow, .sqrt, .hypot, .log, .exp, .round, .mod, .rem, .random:
            return true
        _:
            return false

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.h:235 Web::CSS::CalculationNode::is_calc_operator_node.
# https://www.w3.org/TR/css-values-4/#calculation-tree-calc-operator-nodes
pub func css_calculation_node_is_calc_operator_node(this: CssCalculationNode*) -> bool:
    return this.m_type == CssCalculationNodeType.sum or this.m_type == CssCalculationNodeType.product or this.m_type == CssCalculationNodeType.negate or this.m_type == CssCalculationNodeType.invert

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp:579 Web::CSS::CalculationNode::name.
pub func css_calculation_node_name(this: CssCalculationNode*) -> ak.StringView:
    match this.m_type:
        .min: return ak.sv("min")
        .max: return ak.sv("max")
        .clamp: return ak.sv("clamp")
        .abs: return ak.sv("abs")
        .sign: return ak.sv("sign")
        .sin: return ak.sv("sin")
        .cos: return ak.sv("cos")
        .tan: return ak.sv("tan")
        .asin: return ak.sv("asin")
        .acos: return ak.sv("acos")
        .atan: return ak.sv("atan")
        .atan2: return ak.sv("atan2")
        .pow: return ak.sv("pow")
        .sqrt: return ak.sv("sqrt")
        .hypot: return ak.sv("hypot")
        .log: return ak.sv("log")
        .exp: return ak.sv("exp")
        .random: return ak.sv("random")
        .round: return ak.sv("round")
        .mod: return ak.sv("mod")
        .rem: return ak.sv("rem")
        .numeric, .sum, .product, .negate, .invert, .non_math_function: return ak.sv("calc")
        _: trap("VERIFY_NOT_REACHED")

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.h:243 Web::CSS::CalculationNode::numeric_type.
pub func css_calculation_node_numeric_type(this: CssCalculationNode*) -> CssNumericType?:
    return this.m_numeric_type

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.h:241 Web::CSS::CalculationNode::children (virtual).
pub func css_calculation_node_children_impl(this: CssCalculationNode*) -> ak.Vector[CssCalculationNode*]:
    _ = this
    trap("pure virtual: Web::CSS::CalculationNode::children")

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.h:244 Web::CSS::CalculationNode::contains_percentage (virtual).
pub func css_calculation_node_contains_percentage_impl(this: CssCalculationNode*) -> bool:
    _ = this
    trap("pure virtual: Web::CSS::CalculationNode::contains_percentage")

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.h:245 Web::CSS::CalculationNode::with_simplified_children (virtual).
pub func css_calculation_node_with_simplified_children_impl(this: CssCalculationNode*, arg0: CssCalculationContext, arg1: CssCalculationResolutionContext) -> CssCalculationNode*:
    _ = this
    _ = arg0
    _ = arg1
    trap("pure virtual: Web::CSS::CalculationNode::with_simplified_children")

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.h:247 Web::CSS::CalculationNode::run_operation_if_possible (virtual).
# Step 4 of simplify_a_calculation_tree(). Only valid for math-function nodes.
pub func css_calculation_node_run_operation_if_possible_impl(this: CssCalculationNode*, arg0: CssCalculationContext, arg1: CssCalculationResolutionContext) -> CssCalculatedStyleValueCalculationResult?:
    _ = this
    _ = arg0
    _ = arg1
    trap("VERIFY_NOT_REACHED")

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.h:249 Web::CSS::CalculationNode::dump (virtual).
pub func css_calculation_node_dump_impl(this: CssCalculationNode*, arg0: ak.StringBuilder*, indent: i32):
    _ = this
    _ = arg0
    _ = indent
    trap("pure virtual: Web::CSS::CalculationNode::dump")

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.h:250 Web::CSS::CalculationNode::equals (virtual).
pub func css_calculation_node_equals_impl(this: CssCalculationNode*, arg0: CssCalculationNode*) -> bool:
    _ = this
    _ = arg0
    trap("pure virtual: Web::CSS::CalculationNode::equals")

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.h:251 Web::CSS::CalculationNode::is_computationally_independent (virtual).
pub func css_calculation_node_is_computationally_independent_impl(this: CssCalculationNode*) -> bool:
    _ = this
    trap("pure virtual: Web::CSS::CalculationNode::is_computationally_independent")

## Ported from Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.h:252 Web::CSS::CalculationNode::reify (virtual).
pub func css_calculation_node_reify_impl(this: CssCalculationNode*, arg0: Realm*) -> CssNumericValue*?:
    _ = this
    _ = arg0
    return none