Luce packages
LuceLuce BaseLuciaOS

dymokomi/luce-browser-engine

Source of release 0.6.0

0.6.0 / src / web / css / computed_properties_4.lucb

#==============================================================================================
#
#   computed_properties_4 - ComputedProperties: fonts, grid, tables, writing, containment
#
#   DESCRIPTION:
#       Port of LibWeb/CSS/ComputedProperties.cpp (lines 1400-1898): text-wrap-mode,
#       box-sizing, vertical-align, the font feature readers (kerning, language override, the
#       font-variant-* longhands, feature and variation settings), the grid readers, the table
#       readers, object-fit and -position, direction, unicode-bidi, writing-mode, user-select,
#       isolation, touch-action, contain and container-type.
#
#       Copyright (c) 2018-2025, Andreas Kling <andreas@ladybird.org>
#       Copyright (c) 2021-2025, Sam Atkins <sam@ladybird.org>
#       SPDX-License-Identifier: BSD-2-Clause
#
#==============================================================================================

# mark: Text wrap, box sizing, vertical-align ===================================================

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1400 Web::CSS::ComputedProperties::text_wrap_mode.
pub func css_computed_properties_text_wrap_mode(this: CssComputedProperties*) -> css_data.TextWrapMode:
    let value = css_computed_properties_property(this, css_data.PropertyId.text_wrap_mode)
    return css_data.keyword_to_text_wrap_mode(css_style_value_to_keyword(value)) else trap("VERIFY: Optional::release_value()")

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1406 Web::CSS::ComputedProperties::box_sizing.
pub func css_computed_properties_box_sizing(this: CssComputedProperties*) -> css_data.BoxSizing:
    let value = css_computed_properties_property(this, css_data.PropertyId.box_sizing)
    return css_data.keyword_to_box_sizing(css_style_value_to_keyword(value)) else trap("VERIFY: Optional::release_value()")

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1412 Web::CSS::ComputedProperties::vertical_align.
pub func css_computed_properties_vertical_align(this: CssComputedProperties*) -> VerticalAlignOrCssLengthPercentage:
    let value = css_computed_properties_property(this, css_data.PropertyId.vertical_align)

    if css_style_value_is_keyword(value):
        return VerticalAlignOrCssLengthPercentage.vertical_align(css_data.keyword_to_vertical_align(css_style_value_to_keyword(value)) else trap("VERIFY: Optional::release_value()"))

    return VerticalAlignOrCssLengthPercentage.css_length_percentage(css_length_percentage_from_style_value(value))

# mark: Fonts ===================================================================================

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1422 Web::CSS::ComputedProperties::font_kerning.
pub func css_computed_properties_font_kerning(this: CssComputedProperties*) -> css_data.FontKerning:
    let value = css_computed_properties_property(this, css_data.PropertyId.font_kerning)
    return css_data.keyword_to_font_kerning(css_style_value_to_keyword(value)) else trap("VERIFY: Optional::release_value()")

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1428 Web::CSS::ComputedProperties::font_language_override.
pub func css_computed_properties_font_language_override(this: CssComputedProperties*) -> ak.FlyString?:
    let value = css_computed_properties_property(this, css_data.PropertyId.font_language_override)
    if css_style_value_is_string(value):
        return css_string_style_value_string_value(css_style_value_as_string(value))
    return none

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1436 Web::CSS::ComputedProperties::font_feature_data.
pub func css_computed_properties_font_feature_data(this: CssComputedProperties*) -> CssFontFeatureData:
    return CssFontFeatureData(
        font_variant_alternates = css_computed_properties_font_variant_alternates(this),
        font_variant_caps = css_computed_properties_font_variant_caps(this),
        font_variant_east_asian = css_computed_properties_font_variant_east_asian(this),
        font_variant_emoji = css_computed_properties_font_variant_emoji(this),
        font_variant_ligatures = css_computed_properties_font_variant_ligatures(this),
        font_variant_numeric = css_computed_properties_font_variant_numeric(this),
        font_variant_position = css_computed_properties_font_variant_position(this),
        font_feature_settings = css_computed_properties_font_feature_settings(this),
        font_kerning = css_computed_properties_font_kerning(this),
        text_rendering = css_computed_properties_text_rendering(this))

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1452 Web::CSS::ComputedProperties::font_variant_alternates.
pub func css_computed_properties_font_variant_alternates(this: CssComputedProperties*) -> CssFontVariantAlternates?:
    let value = css_computed_properties_property(this, css_data.PropertyId.font_variant_alternates)

    # normal
    if css_style_value_is_keyword(value):
        assert(css_style_value_to_keyword(value) == css_data.Keyword.normal)
        return none

    var alternates = CssFontVariantAlternates()

    let values = css_style_value_list_values(css_style_value_as_value_list(value))
    for item in ak.vector_span_const(&values):
        # historical-forms
        if css_style_value_is_keyword(item) and css_style_value_to_keyword(item) == css_data.Keyword.historical_forms:
            alternates.historical_forms = true
            continue

        if css_style_value_is_function(item):
            let function = css_style_value_as_function(item)
            let function_type = css_font_feature_value_type_from_string(css_function_style_value_name(function)) else trap("VERIFY: Optional::release_value()")
            let names = css_style_value_list_values(css_style_value_as_value_list(css_function_style_value_value(function)))

            for name in ak.vector_span_const(&names):
                ak.vector_append_t(&alternates.font_feature_value_entries, CssFontFeatureValueKey(type_ = function_type, name = css_string_from_style_value(name)))

            continue

        trap("VERIFY_NOT_REACHED")

    return alternates

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1487 Web::CSS::ComputedProperties::font_variant_caps.
pub func css_computed_properties_font_variant_caps(this: CssComputedProperties*) -> css_data.FontVariantCaps:
    let value = css_computed_properties_property(this, css_data.PropertyId.font_variant_caps)
    return css_data.keyword_to_font_variant_caps(css_style_value_to_keyword(value)) else trap("VERIFY: Optional::release_value()")

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1493 Web::CSS::ComputedProperties::font_variant_east_asian.
pub func css_computed_properties_font_variant_east_asian(this: CssComputedProperties*) -> CssFontVariantEastAsian?:
    let value = css_computed_properties_property(this, css_data.PropertyId.font_variant_east_asian)

    if css_style_value_to_keyword(value) == css_data.Keyword.normal:
        return none

    let tuple = css_tuple_style_value_tuple(css_style_value_as_tuple(value))

    var east_asian = CssFontVariantEastAsian()

    if let variant = *ak.vector_at_const(&tuple, css_tuple_style_value_indices_font_variant_east_asian_variant):
        east_asian.variant = css_data.keyword_to_east_asian_variant(css_style_value_to_keyword(variant)) else trap("VERIFY: Optional::value()")

    if let width = *ak.vector_at_const(&tuple, css_tuple_style_value_indices_font_variant_east_asian_width):
        east_asian.width = css_data.keyword_to_east_asian_width(css_style_value_to_keyword(width)) else trap("VERIFY: Optional::value()")

    if *ak.vector_at_const(&tuple, css_tuple_style_value_indices_font_variant_east_asian_ruby) != none:
        east_asian.ruby = true

    return east_asian

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1516 Web::CSS::ComputedProperties::font_variant_emoji.
pub func css_computed_properties_font_variant_emoji(this: CssComputedProperties*) -> css_data.FontVariantEmoji:
    let value = css_computed_properties_property(this, css_data.PropertyId.font_variant_emoji)
    return css_data.keyword_to_font_variant_emoji(css_style_value_to_keyword(value)) else trap("VERIFY: Optional::release_value()")

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1522 Web::CSS::ComputedProperties::font_variant_ligatures.
pub func css_computed_properties_font_variant_ligatures(this: CssComputedProperties*) -> CssFontVariantLigatures?:
    let value = css_computed_properties_property(this, css_data.PropertyId.font_variant_ligatures)

    if css_style_value_to_keyword(value) == css_data.Keyword.normal:
        return none

    if css_style_value_to_keyword(value) == css_data.Keyword.none_:
        return CssFontVariantLigatures(none_ = true)

    let tuple = css_tuple_style_value_tuple(css_style_value_as_tuple(value))

    var ligatures = CssFontVariantLigatures()

    if let common = *ak.vector_at_const(&tuple, css_tuple_style_value_indices_font_variant_ligatures_common):
        ligatures.common = css_data.keyword_to_common_lig_value(css_style_value_to_keyword(common)) else trap("VERIFY: Optional::value()")

    if let discretionary = *ak.vector_at_const(&tuple, css_tuple_style_value_indices_font_variant_ligatures_discretionary):
        ligatures.discretionary = css_data.keyword_to_discretionary_lig_value(css_style_value_to_keyword(discretionary)) else trap("VERIFY: Optional::value()")

    if let historical = *ak.vector_at_const(&tuple, css_tuple_style_value_indices_font_variant_ligatures_historical):
        ligatures.historical = css_data.keyword_to_historical_lig_value(css_style_value_to_keyword(historical)) else trap("VERIFY: Optional::value()")

    if let contextual = *ak.vector_at_const(&tuple, css_tuple_style_value_indices_font_variant_ligatures_contextual):
        ligatures.contextual = css_data.keyword_to_contextual_alt_value(css_style_value_to_keyword(contextual)) else trap("VERIFY: Optional::value()")

    return ligatures

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1551 Web::CSS::ComputedProperties::font_variant_numeric.
pub func css_computed_properties_font_variant_numeric(this: CssComputedProperties*) -> CssFontVariantNumeric?:
    let value = css_computed_properties_property(this, css_data.PropertyId.font_variant_numeric)

    if css_style_value_to_keyword(value) == css_data.Keyword.normal:
        return none

    let tuple = css_tuple_style_value_tuple(css_style_value_as_tuple(value))

    var numeric = CssFontVariantNumeric()

    if let figure = *ak.vector_at_const(&tuple, css_tuple_style_value_indices_font_variant_numeric_figure):
        numeric.figure = css_data.keyword_to_numeric_figure_value(css_style_value_to_keyword(figure)) else trap("VERIFY: Optional::value()")

    if let spacing = *ak.vector_at_const(&tuple, css_tuple_style_value_indices_font_variant_numeric_spacing):
        numeric.spacing = css_data.keyword_to_numeric_spacing_value(css_style_value_to_keyword(spacing)) else trap("VERIFY: Optional::value()")

    if let fraction = *ak.vector_at_const(&tuple, css_tuple_style_value_indices_font_variant_numeric_fraction):
        numeric.fraction = css_data.keyword_to_numeric_fraction_value(css_style_value_to_keyword(fraction)) else trap("VERIFY: Optional::value()")

    if *ak.vector_at_const(&tuple, css_tuple_style_value_indices_font_variant_numeric_ordinal) != none:
        numeric.ordinal = true

    if *ak.vector_at_const(&tuple, css_tuple_style_value_indices_font_variant_numeric_slashed_zero) != none:
        numeric.slashed_zero = true

    return numeric

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1580 Web::CSS::ComputedProperties::font_variant_position.
pub func css_computed_properties_font_variant_position(this: CssComputedProperties*) -> css_data.FontVariantPosition:
    let value = css_computed_properties_property(this, css_data.PropertyId.font_variant_position)
    return css_data.keyword_to_font_variant_position(css_style_value_to_keyword(value)) else trap("VERIFY: Optional::release_value()")

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1586 Web::CSS::ComputedProperties::font_feature_settings.
pub func css_computed_properties_font_feature_settings(this: CssComputedProperties*) -> ak.HashMap[ak.FlyString, u8, ak.FlyStringTraits]:
    let value = css_computed_properties_property(this, css_data.PropertyId.font_feature_settings)

    if css_style_value_is_keyword(value):
        return ak.HashMap[ak.FlyString, u8, ak.FlyStringTraits]()  # normal

    if css_style_value_is_value_list(value):
        let feature_tags = css_style_value_list_values(css_style_value_as_value_list(value))
        var result: ak.HashMap[ak.FlyString, u8, ak.FlyStringTraits]
        ak.hash_map_ensure_capacity(&result, ak.vector_size(&feature_tags))
        for tag_value in ak.vector_span_const(&feature_tags):
            let feature_tag = css_style_value_as_open_type_tagged(tag_value)

            # The C++ int converts to u8 implicitly (HashMap<FlyString, u8>::set).
            _ = ak.hash_map_set(&result, css_open_type_tagged_style_value_tag(feature_tag), (u8)css_int_from_style_value(css_open_type_tagged_style_value_value(feature_tag)))
        return result

    return ak.HashMap[ak.FlyString, u8, ak.FlyStringTraits]()

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1608 Web::CSS::ComputedProperties::font_variation_settings.
pub func css_computed_properties_font_variation_settings(this: CssComputedProperties*) -> ak.HashMap[ak.FlyString, f64, ak.FlyStringTraits]:
    let value = css_computed_properties_property(this, css_data.PropertyId.font_variation_settings)

    if css_style_value_is_keyword(value):
        return ak.HashMap[ak.FlyString, f64, ak.FlyStringTraits]()  # normal

    if css_style_value_is_value_list(value):
        let axis_tags = css_style_value_list_values(css_style_value_as_value_list(value))
        var result: ak.HashMap[ak.FlyString, f64, ak.FlyStringTraits]
        ak.hash_map_ensure_capacity(&result, ak.vector_size(&axis_tags))
        for tag_value in ak.vector_span_const(&axis_tags):
            let axis_tag = css_style_value_as_open_type_tagged(tag_value)

            _ = ak.hash_map_set(&result, css_open_type_tagged_style_value_tag(axis_tag), css_number_from_style_value(css_open_type_tagged_style_value_value(axis_tag), none))
        return result

    return ak.HashMap[ak.FlyString, f64, ak.FlyStringTraits]()

# mark: Grid and tables =========================================================================

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1630 Web::CSS::ComputedProperties::grid_auto_columns.
pub func css_computed_properties_grid_auto_columns(this: CssComputedProperties*) -> CssGridTrackSizeList:
    let value = css_computed_properties_property(this, css_data.PropertyId.grid_auto_columns)
    return css_grid_track_size_list_style_value_grid_track_size_list(css_style_value_as_grid_track_size_list(value))

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1636 Web::CSS::ComputedProperties::grid_auto_rows.
pub func css_computed_properties_grid_auto_rows(this: CssComputedProperties*) -> CssGridTrackSizeList:
    let value = css_computed_properties_property(this, css_data.PropertyId.grid_auto_rows)
    return css_grid_track_size_list_style_value_grid_track_size_list(css_style_value_as_grid_track_size_list(value))

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1642 Web::CSS::ComputedProperties::grid_template_columns.
pub func css_computed_properties_grid_template_columns(this: CssComputedProperties*) -> CssGridTrackSizeList:
    let value = css_computed_properties_property(this, css_data.PropertyId.grid_template_columns)
    return css_grid_track_size_list_style_value_grid_track_size_list(css_style_value_as_grid_track_size_list(value))

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1648 Web::CSS::ComputedProperties::grid_template_rows.
pub func css_computed_properties_grid_template_rows(this: CssComputedProperties*) -> CssGridTrackSizeList:
    let value = css_computed_properties_property(this, css_data.PropertyId.grid_template_rows)
    return css_grid_track_size_list_style_value_grid_track_size_list(css_style_value_as_grid_track_size_list(value))

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1654 Web::CSS::ComputedProperties::grid_auto_flow.
pub func css_computed_properties_grid_auto_flow(this: CssComputedProperties*) -> CssGridAutoFlow:
    let value = css_computed_properties_property(this, css_data.PropertyId.grid_auto_flow)
    if not css_style_value_is_grid_auto_flow(value):
        var grid_auto_flow = CssGridAutoFlow()
        css_grid_auto_flow_init_fields(&grid_auto_flow)
        return grid_auto_flow
    let grid_auto_flow_value = css_style_value_as_grid_auto_flow(value)
    return CssGridAutoFlow(row = css_grid_auto_flow_style_value_is_row(grid_auto_flow_value), dense = css_grid_auto_flow_style_value_is_dense(grid_auto_flow_value))

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1663 Web::CSS::ComputedProperties::grid_column_end.
pub func css_computed_properties_grid_column_end(this: CssComputedProperties*) -> CssGridTrackPlacement:
    let value = css_computed_properties_property(this, css_data.PropertyId.grid_column_end)
    return css_grid_track_placement_style_value_grid_track_placement(css_style_value_as_grid_track_placement(value))

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1669 Web::CSS::ComputedProperties::grid_column_start.
pub func css_computed_properties_grid_column_start(this: CssComputedProperties*) -> CssGridTrackPlacement:
    let value = css_computed_properties_property(this, css_data.PropertyId.grid_column_start)
    return css_grid_track_placement_style_value_grid_track_placement(css_style_value_as_grid_track_placement(value))

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1675 Web::CSS::ComputedProperties::grid_row_end.
pub func css_computed_properties_grid_row_end(this: CssComputedProperties*) -> CssGridTrackPlacement:
    let value = css_computed_properties_property(this, css_data.PropertyId.grid_row_end)
    return css_grid_track_placement_style_value_grid_track_placement(css_style_value_as_grid_track_placement(value))

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1681 Web::CSS::ComputedProperties::grid_row_start.
pub func css_computed_properties_grid_row_start(this: CssComputedProperties*) -> CssGridTrackPlacement:
    let value = css_computed_properties_property(this, css_data.PropertyId.grid_row_start)
    return css_grid_track_placement_style_value_grid_track_placement(css_style_value_as_grid_track_placement(value))

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1687 Web::CSS::ComputedProperties::border_collapse.
pub func css_computed_properties_border_collapse(this: CssComputedProperties*) -> css_data.BorderCollapse:
    let value = css_computed_properties_property(this, css_data.PropertyId.border_collapse)
    return css_data.keyword_to_border_collapse(css_style_value_to_keyword(value)) else trap("VERIFY: Optional::release_value()")

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1693 Web::CSS::ComputedProperties::empty_cells.
pub func css_computed_properties_empty_cells(this: CssComputedProperties*) -> css_data.EmptyCells:
    let value = css_computed_properties_property(this, css_data.PropertyId.empty_cells)
    return css_data.keyword_to_empty_cells(css_style_value_to_keyword(value)) else trap("VERIFY: Optional::release_value()")

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1699 Web::CSS::ComputedProperties::grid_template_areas.
pub func css_computed_properties_grid_template_areas(this: CssComputedProperties*) -> CssGridTemplateAreas:
    let value = css_computed_properties_property(this, css_data.PropertyId.grid_template_areas)
    let style_value = css_style_value_as_grid_template_area(value)
    return CssGridTemplateAreas(areas = css_grid_template_area_style_value_grid_areas(style_value), row_count = css_grid_template_area_style_value_row_count(style_value), column_count = css_grid_template_area_style_value_column_count(style_value))

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1706 Web::CSS::ComputedProperties::object_fit.
pub func css_computed_properties_object_fit(this: CssComputedProperties*) -> css_data.ObjectFit:
    let value = css_computed_properties_property(this, css_data.PropertyId.object_fit)
    return css_data.keyword_to_object_fit(css_style_value_to_keyword(value)) else trap("VERIFY: Optional::release_value()")

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1712 Web::CSS::ComputedProperties::object_position.
pub func css_computed_properties_object_position(this: CssComputedProperties*) -> CssPosition:
    return css_computed_properties_position_value(this, css_data.PropertyId.object_position)

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1717 Web::CSS::ComputedProperties::table_layout.
pub func css_computed_properties_table_layout(this: CssComputedProperties*) -> css_data.TableLayout:
    let value = css_computed_properties_property(this, css_data.PropertyId.table_layout)
    return css_data.keyword_to_table_layout(css_style_value_to_keyword(value)) else trap("VERIFY: Optional::release_value()")

# mark: Writing modes, user interaction, containment ============================================

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1723 Web::CSS::ComputedProperties::direction.
pub func css_computed_properties_direction(this: CssComputedProperties*) -> css_data.Direction:
    let value = css_computed_properties_property(this, css_data.PropertyId.direction)
    return css_data.keyword_to_direction(css_style_value_to_keyword(value)) else trap("VERIFY: Optional::release_value()")

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1729 Web::CSS::ComputedProperties::unicode_bidi.
pub func css_computed_properties_unicode_bidi(this: CssComputedProperties*) -> css_data.UnicodeBidi:
    let value = css_computed_properties_property(this, css_data.PropertyId.unicode_bidi)
    return css_data.keyword_to_unicode_bidi(css_style_value_to_keyword(value)) else trap("VERIFY: Optional::release_value()")

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1735 Web::CSS::ComputedProperties::writing_mode.
pub func css_computed_properties_writing_mode(this: CssComputedProperties*) -> css_data.WritingMode:
    let value = css_computed_properties_property(this, css_data.PropertyId.writing_mode)
    return css_data.keyword_to_writing_mode(css_style_value_to_keyword(value)) else trap("VERIFY: Optional::release_value()")

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1741 Web::CSS::ComputedProperties::user_select.
pub func css_computed_properties_user_select(this: CssComputedProperties*) -> css_data.UserSelect:
    let value = css_computed_properties_property(this, css_data.PropertyId.user_select)
    return css_data.keyword_to_user_select(css_style_value_to_keyword(value)) else trap("VERIFY: Optional::release_value()")

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1747 Web::CSS::ComputedProperties::isolation.
pub func css_computed_properties_isolation(this: CssComputedProperties*) -> css_data.Isolation:
    let value = css_computed_properties_property(this, css_data.PropertyId.isolation)
    return css_data.keyword_to_isolation(css_style_value_to_keyword(value)) else trap("VERIFY: Optional::release_value()")

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1753 Web::CSS::ComputedProperties::touch_action.
pub func css_computed_properties_touch_action(this: CssComputedProperties*) -> CssTouchActionData:
    let touch_action = css_computed_properties_property(this, css_data.PropertyId.touch_action)
    if css_style_value_is_keyword(touch_action):
        match css_style_value_to_keyword(touch_action):
            .auto:
                return css_touch_action_data_new()
            .none_:
                return css_touch_action_data_none()
            .manipulation:
                var manipulation = css_touch_action_data_new()
                manipulation.allow_other = false
                return manipulation
            _:
                trap("VERIFY_NOT_REACHED")
    if css_style_value_is_value_list(touch_action):
        var touch_action_data = css_touch_action_data_none()
        let values = css_style_value_list_values(css_style_value_as_value_list(touch_action))
        for value in ak.vector_span_const(&values):
            match css_keyword_style_value_keyword(css_style_value_as_keyword(value)):
                .pan_x:
                    touch_action_data.allow_right = true
                    touch_action_data.allow_left = true
                .pan_left:
                    touch_action_data.allow_left = true
                .pan_right:
                    touch_action_data.allow_right = true
                .pan_y:
                    touch_action_data.allow_up = true
                    touch_action_data.allow_down = true
                .pan_up:
                    touch_action_data.allow_up = true
                .pan_down:
                    touch_action_data.allow_down = true
                _:
                    trap("VERIFY_NOT_REACHED")
        return touch_action_data
    return css_touch_action_data_new()

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1801 Web::CSS::ComputedProperties::contain.
pub func css_computed_properties_contain(this: CssComputedProperties*) -> CssContainment:
    var containment = CssContainment()
    let value = css_computed_properties_property(this, css_data.PropertyId.contain)

    match css_style_value_to_keyword(value):
        .none_:
            # This value indicates that the property has no effect. The element renders as normal, with no containment effects applied.
            return CssContainment()
        .strict:
            # This value computes to 'size layout paint style', and thus turns on all forms of containment for the element.
            containment.size_containment = true
            containment.layout_containment = true
            containment.paint_containment = true
            containment.style_containment = true
        .content:
            #  This value computes to 'layout paint style', and thus turns on all forms of containment except size containment for the element.
            containment.layout_containment = true
            containment.paint_containment = true
            containment.style_containment = true
        .size:
            containment.size_containment = true
        .inline_size:
            containment.inline_size_containment = true
        .layout:
            containment.layout_containment = true
        .style:
            containment.style_containment = true
        .paint:
            containment.paint_containment = true
        _:
            if css_style_value_is_value_list(value):
                let values = css_style_value_list_values(css_style_value_as_value_list(value))
                for item in ak.vector_span_const(&values):
                    match css_style_value_to_keyword(item):
                        .size:
                            containment.size_containment = true
                        .inline_size:
                            containment.inline_size_containment = true
                        .layout:
                            containment.layout_containment = true
                        .style:
                            containment.style_containment = true
                        .paint:
                            containment.paint_containment = true
                        _:
                            css_computed_properties_dbgln_unsupported(item, "contain")

    return containment

## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1869 Web::CSS::ComputedProperties::container_type.
pub func css_computed_properties_container_type(this: CssComputedProperties*) -> CssContainerType:
    var container_type = CssContainerType()

    let value = css_computed_properties_property(this, css_data.PropertyId.container_type)

    if css_style_value_to_keyword(value) == css_data.Keyword.normal:
        return container_type

    if css_style_value_is_value_list(value):
        let values = css_style_value_list_values(css_style_value_as_value_list(value))
        for item in ak.vector_span_const(&values):
            match css_style_value_to_keyword(item):
                .size:
                    container_type.is_size_container = true
                .inline_size:
                    container_type.is_inline_size_container = true
                .scroll_state:
                    container_type.is_scroll_state_container = true
                _:
                    css_computed_properties_dbgln_unsupported(item, "container-type")

    return container_type