dymokomi/luce-browser-engine
Source of release 0.6.1
0.6.1 / src / web / css / interpolation_6.lucb
#==============================================================================================
#
# interpolation_6 - CSS interpolation: composition (add and accumulate)
#
# DESCRIPTION:
# Port of Libraries/LibWeb/CSS/Interpolation.cpp (lines 2253-2677), by region p4a: the
# composition of an animated value onto an underlying value for the add and accumulate
# composite operations: grid track lists, mixed numeric values (a calc() sum), and
# composite_value by type (dimensions, basic shapes, border image slices and radii,
# edges, flex, functions, integers, numbers, OpenType tags, percentages, positions,
# radial sizes, value lists and filter value lists).
#
# Copyright (c) 2025-2026, Tim Ledbetter <tim.ledbetter@ladybird.org>
# Copyright (c) 2021-2025, Sam Atkins <sam@ladybird.org>
# SPDX-License-Identifier: BSD-2-Clause
#
#==============================================================================================
# mark: Grid track lists and mixed values =======================================================
## composite_grid_track_size_list's `composite_grid_size` lambda.
func css_composite_grid_size(property_id: css_data.PropertyId, underlying_grid_size: CssGridSize, animated_grid_size: CssGridSize, composite_operation: BindCompositeOperation) -> CssGridSize?:
if let composited_value = css_composite_value(property_id, css_grid_size_style_value(&underlying_grid_size), css_grid_size_style_value(&animated_grid_size), composite_operation):
return css_grid_size_new(composited_value)
return none
## Ported from Libraries/LibWeb/CSS/Interpolation.cpp:2259 Web::CSS::composite_grid_track_size_list.
func css_composite_grid_track_size_list(property_id: css_data.PropertyId, calculation_context: const CssCalculationContext*, underlying: const CssGridTrackSizeList*, animated: const CssGridTrackSizeList*, composite_operation: BindCompositeOperation) -> CssGridTrackSizeList?:
let expanded_underlying = css_expand_grid_tracks_and_lines(underlying)
let expanded_animated = css_expand_grid_tracks_and_lines(animated)
if ak.vector_size(&expanded_underlying.tracks) != ak.vector_size(&expanded_animated.tracks):
return none
var result = CssGridTrackSizeList()
for i in 0..<ak.vector_size(&expanded_underlying.tracks):
let underlying_track = *ak.vector_at_const(&expanded_underlying.tracks, i)
let animated_track = *ak.vector_at_const(&expanded_animated.tracks, i)
let composited_line_names = *ak.vector_at_const(&expanded_animated.line_names, i)
if css_explicit_grid_track_is_repeat(&underlying_track) or css_explicit_grid_track_is_repeat(&animated_track):
if not css_explicit_grid_track_is_repeat(&underlying_track) or not css_explicit_grid_track_is_repeat(&animated_track):
return none
let underlying_repeat = css_explicit_grid_track_repeat(&underlying_track)
let animated_repeat = css_explicit_grid_track_repeat(&animated_track)
if not css_grid_repeat_is_fixed(&underlying_repeat) or not css_grid_repeat_is_fixed(&animated_repeat):
return none
let underlying_repeat_list = css_grid_repeat_grid_track_size_list(&underlying_repeat)
let animated_repeat_list = css_grid_repeat_grid_track_size_list(&animated_repeat)
let underlying_repeat_tracks = css_grid_track_size_list_track_list(&underlying_repeat_list)
let animated_repeat_tracks = css_grid_track_size_list_track_list(&animated_repeat_list)
if css_grid_repeat_repeat_count(&underlying_repeat) != css_grid_repeat_repeat_count(&animated_repeat) or ak.vector_size(&underlying_repeat_tracks) != ak.vector_size(&animated_repeat_tracks):
return none
let composited_repeat_grid_tracks = css_composite_grid_track_size_list(property_id, calculation_context, &underlying_repeat_list, &animated_repeat_list, composite_operation) else return none
var repeat: CssGridRepeat = ---
css_grid_repeat_construct_css_grid_repeat_type(&repeat, css_grid_repeat_type(&underlying_repeat), composited_repeat_grid_tracks, css_integer_style_value_create((i32)css_grid_repeat_repeat_count(&underlying_repeat)).css_style_value())
css_append_grid_track_with_line_names(&result, css_explicit_grid_track_new(.css_grid_repeat(repeat)), composited_line_names)
continue
if css_explicit_grid_track_is_minmax(&underlying_track) and css_explicit_grid_track_is_minmax(&animated_track):
let underlying_minmax = css_explicit_grid_track_minmax(&underlying_track)
let animated_minmax = css_explicit_grid_track_minmax(&animated_track)
let composited_min = css_composite_grid_size(property_id, css_grid_min_max_min_grid_size(&underlying_minmax), css_grid_min_max_min_grid_size(&animated_minmax), composite_operation)
let composited_max = css_composite_grid_size(property_id, css_grid_min_max_max_grid_size(&underlying_minmax), css_grid_min_max_max_grid_size(&animated_minmax), composite_operation)
var minmax: CssGridMinMax = ---
css_grid_min_max_construct(&minmax, composited_min else css_grid_min_max_min_grid_size(&animated_minmax), composited_max else css_grid_min_max_max_grid_size(&animated_minmax))
css_append_grid_track_with_line_names(&result, css_explicit_grid_track_new(.css_grid_min_max(minmax)), composited_line_names)
continue
if css_explicit_grid_track_is_default(&underlying_track) and css_explicit_grid_track_is_default(&animated_track):
let underlying_grid_size = css_explicit_grid_track_grid_size(&underlying_track)
let animated_grid_size = css_explicit_grid_track_grid_size(&animated_track)
if let composited_grid_size_result = css_composite_grid_size(property_id, underlying_grid_size, animated_grid_size, composite_operation):
css_append_grid_track_with_line_names(&result, css_explicit_grid_track_new(.css_grid_size(composited_grid_size_result)), composited_line_names)
continue
css_append_grid_track_with_line_names(&result, animated_track, composited_line_names)
return result
## Ported from Libraries/LibWeb/CSS/Interpolation.cpp:2326 Web::CSS::composite_mixed_value.
func css_composite_mixed_value(underlying_value: CssStyleValue*, animated_value: CssStyleValue*, calculation_context: const CssCalculationContext*) -> CssStyleValue*?:
# https://drafts.csswg.org/css-values-4/#combine-mixed
# Addition of <percentage> is defined the same as interpolation except by adding each component rather than interpolating it.
let underlying_value_type = css_get_value_type_of_numeric_style_value(underlying_value, calculation_context)
let animated_value_type = css_get_value_type_of_numeric_style_value(animated_value, calculation_context)
if underlying_value_type != none and underlying_value_type == animated_value_type:
# The computed value of a percentage-dimension mix is defined as
# FIXME: a computed dimension if the percentage component is zero or is defined specifically to compute to a dimension value
# a computed percentage if the dimension component is zero
# a computed calc() expression otherwise
let from_dimension_value = as_if_css_dimension_style_value(underlying_value)
let to_dimension_value = as_if_css_dimension_style_value(animated_value)
if from_dimension_value != none and css_style_value_type(animated_value) == CssStyleValueType.percentage:
let dimension_component = css_dimension_style_value_raw_value(from_dimension_value else trap("unreachable: checked above"))
let percentage_component = css_dimension_style_value_raw_value(css_style_value_as_percentage(animated_value).css_dimension_style_value())
if dimension_component == 0.0:
return css_percentage_style_value_create(css_percentage_new(percentage_component)).css_style_value()
elif to_dimension_value != none and css_style_value_type(underlying_value) == CssStyleValueType.percentage:
let dimension_component = css_dimension_style_value_raw_value(to_dimension_value else trap("unreachable: checked above"))
let percentage_component = css_dimension_style_value_raw_value(css_style_value_as_percentage(underlying_value).css_dimension_style_value())
if dimension_component == 0.0:
return css_percentage_style_value_create(css_percentage_new(percentage_component)).css_style_value()
let underlying_node = css_calculation_node_from_style_value(underlying_value, *calculation_context)
let animated_node = css_calculation_node_from_style_value(animated_value, *calculation_context)
return css_interpolation_calculated_sum(underlying_node, animated_node, underlying_node, animated_node, calculation_context)
return none
# mark: composite_value =========================================================================
## composite_value's `composite_dimension_value` lambda (composite_raw_values over the dimensions' raw values).
func css_composite_dimension_value(underlying_value: CssStyleValue*, animated_value: CssStyleValue*) -> f64?:
let underlying_dimension = as_css_dimension_style_value(underlying_value)
let animated_dimension = as_css_dimension_style_value(animated_value)
return css_dimension_style_value_raw_value(underlying_dimension) + css_dimension_style_value_raw_value(animated_dimension)
## composite_value's position-with-default of a circle or ellipse: the position, or the computed center.
func css_composite_position_with_default(position: CssStyleValue*?) -> CssStyleValue*:
if let value = position:
return value
return css_position_style_value_create_computed_center().css_style_value()
## composite_value's composition of a circle's or an ellipse's optional positions: none when neither has one, the
## composited position, or a failure.
func css_composite_optional_position(property_id: css_data.PropertyId, underlying_position: CssStyleValue*?, animated_position: CssStyleValue*?, composite_operation: BindCompositeOperation) -> CssInterpolatedOptionalPosition:
if underlying_position == none and animated_position == none:
return CssInterpolatedOptionalPosition.position(none)
let underlying_position_with_default = css_composite_position_with_default(underlying_position)
let animated_position_with_default = css_composite_position_with_default(animated_position)
let composited_position = css_composite_value(property_id, underlying_position_with_default, animated_position_with_default, composite_operation)
if composited_position == none:
return CssInterpolatedOptionalPosition.failed
return CssInterpolatedOptionalPosition.position(composited_position)
## composite_value's `case StyleValue::Type::BasicShape`.
func css_composite_basic_shape(property_id: css_data.PropertyId, underlying_value: CssStyleValue*, animated_value: CssStyleValue*, composite_operation: BindCompositeOperation) -> CssStyleValue*?:
let underlying_basic_shape = css_basic_shape_style_value_basic_shape(css_style_value_as_basic_shape(underlying_value))
let animated_basic_shape = css_basic_shape_style_value_basic_shape(css_style_value_as_basic_shape(animated_value))
if css_basic_shape_index(&underlying_basic_shape) != css_basic_shape_index(&animated_basic_shape):
return none
match underlying_basic_shape:
.css_inset(underlying_inset):
let animated_inset = match animated_basic_shape:
.css_inset(value) => value
_ => trap("VERIFY: Variant::get<Inset>()")
let composited_top = css_composite_value(property_id, underlying_inset.top, animated_inset.top, composite_operation)
let composited_right = css_composite_value(property_id, underlying_inset.right, animated_inset.right, composite_operation)
let composited_bottom = css_composite_value(property_id, underlying_inset.bottom, animated_inset.bottom, composite_operation)
let composited_left = css_composite_value(property_id, underlying_inset.left, animated_inset.left, composite_operation)
let composited_border_radius = css_composite_value(property_id, underlying_inset.border_radius, animated_inset.border_radius, composite_operation)
let top = composited_top else return none
let right = composited_right else return none
let bottom = composited_bottom else return none
let left = composited_left else return none
let border_radius = composited_border_radius else return none
return css_basic_shape_style_value_create(CssBasicShape.css_inset(CssInset(top = top, right = right, bottom = bottom, left = left, border_radius = border_radius))).css_style_value()
.css_circle(underlying_circle):
let animated_circle = match animated_basic_shape:
.css_circle(value) => value
_ => trap("VERIFY: Variant::get<Circle>()")
let composited_radius = css_composite_value(property_id, underlying_circle.radius, animated_circle.radius, composite_operation) else return none
match css_composite_optional_position(property_id, underlying_circle.position, animated_circle.position, composite_operation):
.failed:
return none
.position(composited_position):
return css_basic_shape_style_value_create(CssBasicShape.css_circle(CssCircle(radius = composited_radius, position = composited_position))).css_style_value()
.css_ellipse(underlying_ellipse):
let animated_ellipse = match animated_basic_shape:
.css_ellipse(value) => value
_ => trap("VERIFY: Variant::get<Ellipse>()")
let composited_radius = css_composite_value(property_id, underlying_ellipse.radius, animated_ellipse.radius, composite_operation) else return none
match css_composite_optional_position(property_id, underlying_ellipse.position, animated_ellipse.position, composite_operation):
.failed:
return none
.position(composited_position):
return css_basic_shape_style_value_create(CssBasicShape.css_ellipse(CssEllipse(radius = composited_radius, position = composited_position))).css_style_value()
.css_polygon(underlying_polygon):
let animated_polygon = match animated_basic_shape:
.css_polygon(value) => value
_ => trap("VERIFY: Variant::get<Polygon>()")
if underlying_polygon.fill_rule != animated_polygon.fill_rule:
return none
if ak.vector_size(&underlying_polygon.points) != ak.vector_size(&animated_polygon.points):
return none
var composited_points: ak.Vector[CssPolygonPoint]
ak.vector_ensure_capacity(&composited_points, ak.vector_size(&underlying_polygon.points))
for i in 0..<ak.vector_size(&underlying_polygon.points):
let underlying_point = ak.vector_at_const(&underlying_polygon.points, i)
let animated_point = ak.vector_at_const(&animated_polygon.points, i)
let composited_point_x = css_composite_value(property_id, underlying_point.x, animated_point.x, composite_operation)
let composited_point_y = css_composite_value(property_id, underlying_point.y, animated_point.y, composite_operation)
let x = composited_point_x else return none
let y = composited_point_y else return none
ak.vector_append_t(&composited_points, CssPolygonPoint(x = x, y = y))
return css_basic_shape_style_value_create(CssBasicShape.css_polygon(CssPolygon(fill_rule = underlying_polygon.fill_rule, points = composited_points))).css_style_value()
.css_xywh(xywh):
# xywh() should have been absolutized into inset() before now
_ = xywh
trap("VERIFY_NOT_REACHED")
.css_rect(rect):
# rect() should have been absolutized into inset() before now
_ = rect
trap("VERIFY_NOT_REACHED")
.css_path(path):
# FIXME: Implement composition for path()
_ = path
return none
## composite_value's `case StyleValue::Type::RadialSize`.
func css_composite_radial_size(property_id: css_data.PropertyId, underlying_value: CssStyleValue*, animated_value: CssStyleValue*, composite_operation: BindCompositeOperation) -> CssStyleValue*?:
let underlying_components = css_radial_size_style_value_components(css_style_value_as_radial_size(underlying_value))
let animated_components = css_radial_size_style_value_components(css_style_value_as_radial_size(animated_value))
# https://drafts.csswg.org/css-images-4/#interpolating-gradients
# https://drafts.csswg.org/css-shapes-1/#basic-shape-interpolation
# FIXME: Radial extents should disallow composition for basic-shape values but should be converted into their
# equivalent length-percentage values for radial gradients
if css_radial_size_has_radial_extent(&underlying_components) or css_radial_size_has_radial_extent(&animated_components):
return none
if ak.vector_size(&underlying_components) == 1 and ak.vector_size(&animated_components) == 1:
let underlying_component = css_radial_size_component_value(ak.vector_at_const(&underlying_components, 0))
let animated_component = css_radial_size_component_value(ak.vector_at_const(&animated_components, 0))
let interpolated_value = css_composite_value(property_id, underlying_component, animated_component, composite_operation) else return none
var components: ak.Vector[CssRadialSizeStyleValueComponent]
ak.vector_append_t(&components, CssRadialSizeStyleValueComponent.css_style_value(interpolated_value))
return css_radial_size_style_value_create(components).css_style_value()
let underlying_horizontal_component = css_radial_size_component_value(ak.vector_at_const(&underlying_components, 0))
let underlying_vertical_component = css_radial_size_component_value(ak.vector_at_const(&underlying_components, 1)) if ak.vector_size(&underlying_components) > 1 else underlying_horizontal_component
let animated_horizontal_component = css_radial_size_component_value(ak.vector_at_const(&animated_components, 0))
let animated_vertical_component = css_radial_size_component_value(ak.vector_at_const(&animated_components, 1)) if ak.vector_size(&animated_components) > 1 else animated_horizontal_component
let composited_horizontal = css_composite_value(property_id, underlying_horizontal_component, animated_horizontal_component, composite_operation)
let composited_vertical = css_composite_value(property_id, underlying_vertical_component, animated_vertical_component, composite_operation)
let horizontal = composited_horizontal else return none
let vertical = composited_vertical else return none
var components: ak.Vector[CssRadialSizeStyleValueComponent]
ak.vector_append_t(&components, CssRadialSizeStyleValueComponent.css_style_value(horizontal))
ak.vector_append_t(&components, CssRadialSizeStyleValueComponent.css_style_value(vertical))
return css_radial_size_style_value_create(components).css_style_value()
## Ported from Libraries/LibWeb/CSS/Interpolation.cpp:2362 Web::CSS::composite_value.
pub func css_composite_value(property_id: css_data.PropertyId, underlying_value: CssStyleValue*, animated_value: CssStyleValue*, composite_operation: BindCompositeOperation) -> CssStyleValue*?:
let calculation_context = css_calculation_context_for_property(css_property_name_and_id_from_id(property_id))
if composite_operation == BindCompositeOperation.replace:
return none
if css_style_value_type(underlying_value) != css_style_value_type(animated_value) or css_style_value_is_calculated(underlying_value) or css_style_value_is_calculated(animated_value):
return css_composite_mixed_value(underlying_value, animated_value, &calculation_context)
match css_style_value_type(underlying_value):
.angle:
let result = css_composite_dimension_value(underlying_value, animated_value) else return none
let underlying_angle = css_angle_style_value_angle(css_style_value_as_angle(underlying_value))
let animated_angle = css_angle_style_value_angle(css_style_value_as_angle(animated_value))
assert(css_angle_unit(&underlying_angle) == css_angle_unit(&animated_angle))
return css_angle_style_value_create(css_angle_new(result, css_angle_unit(&underlying_angle))).css_style_value()
.basic_shape:
return css_composite_basic_shape(property_id, underlying_value, animated_value, composite_operation)
.border_image_slice:
let underlying_border_image_slice_value = css_style_value_as_border_image_slice(underlying_value)
let animated_border_image_slice_value = css_style_value_as_border_image_slice(animated_value)
if css_border_image_slice_style_value_fill(underlying_border_image_slice_value) != css_border_image_slice_style_value_fill(animated_border_image_slice_value):
return none
let composited_top = css_composite_value(property_id, css_border_image_slice_style_value_top(underlying_border_image_slice_value), css_border_image_slice_style_value_top(animated_border_image_slice_value), composite_operation)
let composited_right = css_composite_value(property_id, css_border_image_slice_style_value_right(underlying_border_image_slice_value), css_border_image_slice_style_value_right(animated_border_image_slice_value), composite_operation)
let composited_bottom = css_composite_value(property_id, css_border_image_slice_style_value_bottom(underlying_border_image_slice_value), css_border_image_slice_style_value_bottom(animated_border_image_slice_value), composite_operation)
let composited_left = css_composite_value(property_id, css_border_image_slice_style_value_left(underlying_border_image_slice_value), css_border_image_slice_style_value_left(animated_border_image_slice_value), composite_operation)
let top = composited_top else return none
let right = composited_right else return none
let bottom = composited_bottom else return none
let left = composited_left else return none
return css_border_image_slice_style_value_create(top, right, bottom, left, css_border_image_slice_style_value_fill(underlying_border_image_slice_value)).css_style_value()
.border_radius:
let composited_horizontal_radius = css_composite_value(property_id, css_border_radius_style_value_horizontal_radius(css_style_value_as_border_radius(underlying_value)), css_border_radius_style_value_horizontal_radius(css_style_value_as_border_radius(animated_value)), composite_operation)
let composited_vertical_radius = css_composite_value(property_id, css_border_radius_style_value_vertical_radius(css_style_value_as_border_radius(underlying_value)), css_border_radius_style_value_vertical_radius(css_style_value_as_border_radius(animated_value)), composite_operation)
let horizontal = composited_horizontal_radius else return none
let vertical = composited_vertical_radius else return none
return css_border_radius_style_value_create(horizontal, vertical).css_style_value()
.border_radius_rect:
let underlying_rect = css_style_value_as_border_radius_rect(underlying_value)
let animated_rect = css_style_value_as_border_radius_rect(animated_value)
let composited_top_left = css_composite_value(property_id, css_border_radius_rect_style_value_top_left(underlying_rect), css_border_radius_rect_style_value_top_left(animated_rect), composite_operation)
let composited_top_right = css_composite_value(property_id, css_border_radius_rect_style_value_top_right(underlying_rect), css_border_radius_rect_style_value_top_right(animated_rect), composite_operation)
let composited_bottom_right = css_composite_value(property_id, css_border_radius_rect_style_value_bottom_right(underlying_rect), css_border_radius_rect_style_value_bottom_right(animated_rect), composite_operation)
let composited_bottom_left = css_composite_value(property_id, css_border_radius_rect_style_value_bottom_left(underlying_rect), css_border_radius_rect_style_value_bottom_left(animated_rect), composite_operation)
let top_left = composited_top_left else return none
let top_right = composited_top_right else return none
let bottom_right = composited_bottom_right else return none
let bottom_left = composited_bottom_left else return none
return css_border_radius_rect_style_value_create(top_left, top_right, bottom_right, bottom_left).css_style_value()
.edge:
let underlying_offset = css_edge_style_value_offset(css_style_value_as_edge(underlying_value))
let animated_offset = css_edge_style_value_offset(css_style_value_as_edge(animated_value))
if let composited_value = css_composite_value(property_id, underlying_offset, animated_offset, composite_operation):
return css_edge_style_value_create(none, composited_value).css_style_value()
return none
.flex:
let underlying_flex = css_flex_style_value_flex(css_style_value_as_flex(underlying_value))
let animated_flex = css_flex_style_value_flex(css_style_value_as_flex(animated_value))
let result = css_flex_to_fr(&underlying_flex) + css_flex_to_fr(&animated_flex)
return css_flex_style_value_create(css_flex_make_fr(result)).css_style_value()
.function:
let underlying_function = css_style_value_as_function(underlying_value)
let animated_function = css_style_value_as_function(animated_value)
let underlying_name = css_function_style_value_name(underlying_function)
let animated_name = css_function_style_value_name(animated_function)
if not ak.fly_string_eq_fly_string(&underlying_name, &animated_name):
return none
let composited_value = css_composite_value(property_id, css_function_style_value_value(underlying_function), css_function_style_value_value(animated_function), composite_operation) else return none
return css_function_style_value_create(underlying_name, composited_value).css_style_value()
.grid_track_size_list:
let underlying_list = css_grid_track_size_list_style_value_grid_track_size_list(css_style_value_as_grid_track_size_list(underlying_value))
let animated_list = css_grid_track_size_list_style_value_grid_track_size_list(css_style_value_as_grid_track_size_list(animated_value))
let composited_list = css_composite_grid_track_size_list(property_id, &calculation_context, &underlying_list, &animated_list, composite_operation) else return none
return css_grid_track_size_list_style_value_create(composited_list).css_style_value()
.integer:
let result = css_integer_style_value_integer(css_style_value_as_integer(underlying_value)) + css_integer_style_value_integer(css_style_value_as_integer(animated_value))
return css_integer_style_value_create(result).css_style_value()
.length:
let result = css_composite_dimension_value(underlying_value, animated_value) else return none
let underlying_length = css_length_style_value_length(css_style_value_as_length(underlying_value))
let animated_length = css_length_style_value_length(css_style_value_as_length(animated_value))
assert(css_length_unit(&underlying_length) == css_length_unit(&animated_length))
return css_length_style_value_create(css_length_new(result, css_length_unit(&underlying_length))).css_style_value()
.number:
let result = css_number_style_value_number(css_style_value_as_number(underlying_value)) + css_number_style_value_number(css_style_value_as_number(animated_value))
return css_number_style_value_create(result).css_style_value()
.open_type_tagged:
let underlying_open_type_tagged = css_style_value_as_open_type_tagged(underlying_value)
let animated_open_type_tagged = css_style_value_as_open_type_tagged(animated_value)
let underlying_tag = css_open_type_tagged_style_value_tag(underlying_open_type_tagged)
let animated_tag = css_open_type_tagged_style_value_tag(animated_open_type_tagged)
if not ak.fly_string_eq_fly_string(&underlying_tag, &animated_tag):
return none
let composited_value = css_composite_value(property_id, css_open_type_tagged_style_value_value(underlying_open_type_tagged), css_open_type_tagged_style_value_value(animated_open_type_tagged), composite_operation) else return none
return css_open_type_tagged_style_value_create(CssOpenTypeTaggedStyleValueMode.font_variation_settings, underlying_tag, composited_value).css_style_value()
.percentage:
let underlying_percentage = css_percentage_style_value_percentage(css_style_value_as_percentage(underlying_value))
let animated_percentage = css_percentage_style_value_percentage(css_style_value_as_percentage(animated_value))
let result = css_percentage_value(&underlying_percentage) + css_percentage_value(&animated_percentage)
return css_percentage_style_value_create(css_percentage_new(result)).css_style_value()
.position:
let underlying_position = css_style_value_as_position(underlying_value)
let animated_position = css_style_value_as_position(animated_value)
let composited_edge_x = css_composite_value(property_id, css_position_style_value_edge_x(underlying_position).css_style_value(), css_position_style_value_edge_x(animated_position).css_style_value(), composite_operation)
let composited_edge_y = css_composite_value(property_id, css_position_style_value_edge_y(underlying_position).css_style_value(), css_position_style_value_edge_y(animated_position).css_style_value(), composite_operation)
let edge_x = composited_edge_x else return none
let edge_y = composited_edge_y else return none
return css_position_style_value_create(css_style_value_as_edge(edge_x), css_style_value_as_edge(edge_y)).css_style_value()
.radial_size:
return css_composite_radial_size(property_id, underlying_value, animated_value, composite_operation)
.ratio:
# https://drafts.csswg.org/css-values/#combine-ratio
# Addition of <ratio>s is not possible.
return none
.value_list:
let underlying_list = css_style_value_as_value_list(underlying_value)
let animated_list = css_style_value_as_value_list(animated_value)
if css_style_value_list_size(underlying_list) != css_style_value_list_size(animated_list) or css_style_value_list_separator(underlying_list) != css_style_value_list_separator(animated_list):
return none
let underlying_values = css_style_value_list_values(underlying_list)
let animated_values = css_style_value_list_values(animated_list)
var values: ak.Vector[CssStyleValue*]
ak.vector_ensure_capacity(&values, css_style_value_list_size(underlying_list))
for i in 0..<css_style_value_list_size(underlying_list):
let composited_value = css_composite_value(property_id, *ak.vector_at_const(&underlying_values, i), *ak.vector_at_const(&animated_values, i), composite_operation) else return none
ak.vector_append_t(&values, composited_value)
return css_style_value_list_create(values, css_style_value_list_separator(underlying_list)).css_style_value()
.filter_value_list:
let underlying_list = css_style_value_as_filter_value_list(underlying_value)
let animated_list = css_style_value_as_filter_value_list(animated_value)
# https://drafts.fxtf.org/filter-effects/#addition
# Given two filter values representing an base value (base filter list) and a value to add (added filter list),
# returns the concatenation of the the two lists: ‘base filter list added filter list’.
if composite_operation == BindCompositeOperation.add:
var result = ak.vector_clone(&underlying_list.m_filter_value_list)
for filter_value in ak.vector_span_const(&animated_list.m_filter_value_list):
ak.vector_append_t(&result, filter_value)
return css_filter_value_list_style_value_create(result).css_style_value()
assert(composite_operation == BindCompositeOperation.accumulate)
let result = css_accumulate_filter_function(underlying_list, animated_list)
if ak.vector_is_empty(&result):
return none
return css_filter_value_list_style_value_create(result).css_style_value()
_:
# FIXME: Implement compositing for missing types
return none