dymokomi/luce-browser-engine
Source of release 0.6.1
0.6.1 / src / web / css / computed_properties_5.lucb
#==============================================================================================
#
# computed_properties_5 - ComputedProperties: animations, transitions, quotes, counters, fonts
#
# DESCRIPTION:
# Port of LibWeb/CSS/ComputedProperties.cpp (lines 1900-2355): mix-blend-mode,
# view-transition-name, the animation and transition definitions (coordinated value
# lists over the animation-* and transition-* longhands), mask-type, quotes, the counter
# properties, the scrollbar readers, resize, shape-rendering, paint-order, will-change,
# the cached computed font list and first available font, and the math and font readers.
#
# 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: Blending and view transitions ===========================================================
## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1901 Web::CSS::ComputedProperties::mix_blend_mode.
pub func css_computed_properties_mix_blend_mode(this: CssComputedProperties*) -> css_data.MixBlendMode:
let value = css_computed_properties_property(this, css_data.PropertyId.mix_blend_mode)
return css_data.keyword_to_mix_blend_mode(css_style_value_to_keyword(value)) else trap("VERIFY: Optional::release_value()")
## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1907 Web::CSS::ComputedProperties::view_transition_name.
pub func css_computed_properties_view_transition_name(this: CssComputedProperties*) -> ak.FlyString?:
let value = css_computed_properties_property(this, css_data.PropertyId.view_transition_name)
if css_style_value_is_custom_ident(value):
return css_custom_ident_style_value_custom_ident(css_style_value_as_custom_ident(value))
return none
# mark: Animations and transitions ==============================================================
## The `duration` lambda of ComputedProperties::animations.
# https://drafts.csswg.org/css-animations-2/#animation-duration
func css_computed_properties_animation_duration(animation_duration_style_value: CssStyleValue*) -> F64OrString:
# auto
if css_style_value_to_keyword(animation_duration_style_value) == css_data.Keyword.auto:
# For time-driven animations, equivalent to 0s.
return F64OrString.f64_(0.0)
# FIXME: For scroll-driven animations, equivalent to the duration necessary to fill the timeline in
# consideration of animation-range, animation-delay, and animation-iteration-count. See
# Scroll-driven Animations § 4.1 Finite Timeline Calculations.
# <time [0s,∞]>
# FIXME: For scroll-driven animations, treated as auto.
# For time-driven animations, specifies the length of time that an animation takes to complete one cycle.
# A negative <time> is invalid.
let time = css_time_from_style_value(animation_duration_style_value, none)
return F64OrString.f64_(css_time_to_milliseconds(&time))
## The `iteration_count` lambda of ComputedProperties::animations.
func css_computed_properties_animation_iteration_count(animation_iteration_count_style_value: CssStyleValue*) -> f64:
if css_style_value_to_keyword(animation_iteration_count_style_value) == css_data.Keyword.infinite:
return ak.infinity_f64
return css_number_from_style_value(animation_iteration_count_style_value, none)
## The `timeline` lambda of ComputedProperties::animations.
# https://drafts.csswg.org/css-animations-2/#animation-timeline
func css_computed_properties_animation_timeline(abstract_element: DomAbstractElement, animation_timeline_style_value: CssStyleValue*) -> AnimationsAnimationTimeline*?:
let document_timeline = dom_document_timeline(dom_abstract_element_document(&abstract_element)).animations_animation_timeline()
# auto
# The animation’s timeline is a DocumentTimeline, more specifically the default document timeline.
if css_style_value_to_keyword(animation_timeline_style_value) == css_data.Keyword.auto:
return document_timeline
# none
# The animation is not associated with a timeline.
if css_style_value_to_keyword(animation_timeline_style_value) == css_data.Keyword.none_:
return none
# <dashed-ident>
# FIXME: If a named scroll progress timeline or view progress timeline is in scope on this element, use the
# referenced timeline as defined in Scroll-driven Animations § Declaring a Named Timeline’s Scope:
# the timeline-scope property. Otherwise the animation is not associated with a timeline.
# <scroll()>
# Use the scroll progress timeline indicated by the given scroll() function. See Scroll-driven Animations
# § 2.2.1 The scroll() notation.
if css_style_value_is_function(animation_timeline_style_value):
let function = css_style_value_as_function(animation_timeline_style_value)
let function_name = css_function_style_value_name(function)
if ak.fly_string_eq_string_view(&function_name, ak.sv("scroll")):
let arguments = css_tuple_style_value_tuple(css_style_value_as_tuple(css_function_style_value_value(function)))
var scroller = css_data.Scroller.nearest
if let scroller_value = *ak.vector_at_const(&arguments, css_tuple_style_value_indices_scroll_function_scroller):
scroller = css_data.keyword_to_scroller(css_style_value_to_keyword(scroller_value)) else trap("VERIFY: Optional::value()")
var axis = BindScrollAxis.block
if let axis_value = *ak.vector_at_const(&arguments, css_tuple_style_value_indices_scroll_function_axis):
axis = animations_css_axis_to_bindings_scroll_axis(css_data.keyword_to_axis(css_style_value_to_keyword(axis_value)) else trap("VERIFY: Optional::value()"))
let source = AnimationsScrollTimelineAnonymousSource(scroller = scroller, target = abstract_element)
var element_reference = abstract_element
let element = dom_abstract_element_element(&element_reference)
return animations_scroll_timeline_create(bind_platform_object_realm(element.bind_platform_object()), dom_abstract_element_document(&abstract_element), AnimationsScrollTimelineSource.anonymous_source(source), axis).animations_animation_timeline()
# <view()>
# FIXME: Use the view progress timeline indicated by the given view() function. See Scroll-driven
# Animations § 3.3.1 The view() notation.
# FIXME: We fall back to document timeline for now as though we don't support the `animation-timeline`
# property at all
return document_timeline
## The entry `property_id` of a coordinated value list, by value (C++ `.get(id).value()`).
func css_computed_properties_coordinated_list(list: const ak.HashMap[css_data.PropertyId, ak.Vector[CssStyleValue*], css_data.PropertyIdTraits]*, property_id: css_data.PropertyId) -> ak.Vector[CssStyleValue*]:
return *(ak.hash_map_get_k_const(list, property_id) else trap("VERIFY: Optional::value() of a coordinated value list entry"))
## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:1915 Web::CSS::ComputedProperties::animations.
pub func css_computed_properties_animations(this: CssComputedProperties*, abstract_element: DomAbstractElement) -> ak.Vector[CssComputedPropertiesAnimationProperties]:
let animation_name_values = css_style_value_list_values(css_style_value_as_value_list(css_computed_properties_property(this, css_data.PropertyId.animation_name)))
# OPTIMIZATION: If all animation names are 'none', there are no animations to process
var all_none = true
for value in ak.vector_span_const(&animation_name_values):
if css_style_value_to_keyword(value) != css_data.Keyword.none_:
all_none = false
break
if all_none:
return ak.Vector[CssComputedPropertiesAnimationProperties]()
# CSS Animations are defined by binding keyframes to an element using the animation-* properties. These list-valued
# properties, which are all longhands of the animation shorthand, form a coordinating list property group with
# animation-name as the coordinating list base property and each item in the coordinated value list defining the
# properties of a single animation effect.
var property_ids: ak.Vector[css_data.PropertyId]
ak.vector_append_t(&property_ids, css_data.PropertyId.animation_duration)
ak.vector_append_t(&property_ids, css_data.PropertyId.animation_timing_function)
ak.vector_append_t(&property_ids, css_data.PropertyId.animation_iteration_count)
ak.vector_append_t(&property_ids, css_data.PropertyId.animation_direction)
ak.vector_append_t(&property_ids, css_data.PropertyId.animation_play_state)
ak.vector_append_t(&property_ids, css_data.PropertyId.animation_delay)
ak.vector_append_t(&property_ids, css_data.PropertyId.animation_fill_mode)
ak.vector_append_t(&property_ids, css_data.PropertyId.animation_composition)
ak.vector_append_t(&property_ids, css_data.PropertyId.animation_name)
ak.vector_append_t(&property_ids, css_data.PropertyId.animation_timeline)
let coordinated_properties = css_computed_properties_assemble_coordinated_value_list(this, css_data.PropertyId.animation_name, property_ids)
let names = css_computed_properties_coordinated_list(&coordinated_properties, css_data.PropertyId.animation_name)
let durations = css_computed_properties_coordinated_list(&coordinated_properties, css_data.PropertyId.animation_duration)
let timing_functions = css_computed_properties_coordinated_list(&coordinated_properties, css_data.PropertyId.animation_timing_function)
let iteration_counts = css_computed_properties_coordinated_list(&coordinated_properties, css_data.PropertyId.animation_iteration_count)
let directions = css_computed_properties_coordinated_list(&coordinated_properties, css_data.PropertyId.animation_direction)
let play_states = css_computed_properties_coordinated_list(&coordinated_properties, css_data.PropertyId.animation_play_state)
let delays = css_computed_properties_coordinated_list(&coordinated_properties, css_data.PropertyId.animation_delay)
let fill_modes = css_computed_properties_coordinated_list(&coordinated_properties, css_data.PropertyId.animation_fill_mode)
let compositions = css_computed_properties_coordinated_list(&coordinated_properties, css_data.PropertyId.animation_composition)
let timelines = css_computed_properties_coordinated_list(&coordinated_properties, css_data.PropertyId.animation_timeline)
var animations: ak.Vector[CssComputedPropertiesAnimationProperties]
for i in 0..<ak.vector_size(&names):
# https://drafts.csswg.org/css-animations-1/#propdef-animation-name
# none: No keyframes are specified at all, so there will be no animation. Any other animations properties
# specified for this animation have no effect.
if css_style_value_to_keyword(*ak.vector_at_const(&names, i)) == css_data.Keyword.none_:
continue
let animation_name_style_value = *ak.vector_at_const(&names, i)
let animation_duration_style_value = *ak.vector_at_const(&durations, i)
let animation_timing_function_style_value = *ak.vector_at_const(&timing_functions, i)
let animation_iteration_count_style_value = *ak.vector_at_const(&iteration_counts, i)
let animation_direction_style_value = *ak.vector_at_const(&directions, i)
let animation_play_state_style_value = *ak.vector_at_const(&play_states, i)
let animation_delay_style_value = *ak.vector_at_const(&delays, i)
let animation_fill_mode_style_value = *ak.vector_at_const(&fill_modes, i)
let animation_composition_style_value = *ak.vector_at_const(&compositions, i)
let animation_timeline_style_value = *ak.vector_at_const(&timelines, i)
let duration = css_computed_properties_animation_duration(animation_duration_style_value)
let timing_function = css_easing_function_from_style_value(animation_timing_function_style_value)
let iteration_count = css_computed_properties_animation_iteration_count(animation_iteration_count_style_value)
let direction = css_data.keyword_to_animation_direction(css_style_value_to_keyword(animation_direction_style_value)) else trap("VERIFY: Optional::value()")
let play_state = css_data.keyword_to_animation_play_state(css_style_value_to_keyword(animation_play_state_style_value)) else trap("VERIFY: Optional::value()")
let delay_time = css_time_from_style_value(animation_delay_style_value, none)
let delay = css_time_to_milliseconds(&delay_time)
let fill_mode = css_data.keyword_to_animation_fill_mode(css_style_value_to_keyword(animation_fill_mode_style_value)) else trap("VERIFY: Optional::value()")
let composition = css_data.keyword_to_animation_composition(css_style_value_to_keyword(animation_composition_style_value)) else trap("VERIFY: Optional::value()")
let name = css_string_from_style_value(animation_name_style_value)
let timeline = css_computed_properties_animation_timeline(abstract_element, animation_timeline_style_value)
ak.vector_append_t(&animations, CssComputedPropertiesAnimationProperties(
duration = duration,
timing_function = timing_function,
iteration_count = iteration_count,
direction = direction,
play_state = play_state,
delay = delay,
fill_mode = fill_mode,
composition = composition,
name = name,
timeline = timeline))
return animations
## The `append_property_mapping_logical_aliases` lambda of ComputedProperties::transitions.
func css_computed_properties_append_property_mapping_logical_aliases(this: CssComputedProperties*, properties: ak.Vector[css_data.PropertyId]*, property_id: css_data.PropertyId):
if css_data.property_is_logical_alias(property_id):
ak.vector_append_t(properties, css_data.map_logical_alias_to_physical_property(property_id, css_data.LogicalAliasMappingContext(writing_mode = css_computed_properties_writing_mode(this), direction = css_computed_properties_direction(this))))
elif property_id != css_data.PropertyId.custom:
ak.vector_append_t(properties, property_id)
## The `properties` lambda of ComputedProperties::transitions: the longhands one transition-property entry names.
func css_computed_properties_transition_properties(this: CssComputedProperties*, property_value: CssStyleValue*) -> ak.Vector[css_data.PropertyId]:
if css_style_value_is_keyword(property_value) and css_style_value_to_keyword(property_value) == css_data.Keyword.none_:
return ak.Vector[css_data.PropertyId]()
let custom_ident = css_custom_ident_style_value_custom_ident(css_style_value_as_custom_ident(property_value))
let transition_property = css_data.property_id_from_string(ak.fly_string_bytes_as_string_view(&custom_ident)) else return ak.Vector[css_data.PropertyId]()
var properties: ak.Vector[css_data.PropertyId]
if css_data.property_is_shorthand(transition_property):
let expanded_longhands = css_data.expanded_longhands_for_shorthand(transition_property)
ak.vector_ensure_capacity(&properties, ak.vector_size(&expanded_longhands))
let longhands = css_data.expanded_longhands_for_shorthand(transition_property)
for prop in ak.vector_span_const(&longhands):
css_computed_properties_append_property_mapping_logical_aliases(this, &properties, prop)
else:
css_computed_properties_append_property_mapping_logical_aliases(this, &properties, transition_property)
return properties
## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:2062 Web::CSS::ComputedProperties::transitions.
pub func css_computed_properties_transitions(this: CssComputedProperties*) -> ak.Vector[CssTransitionProperties]:
var property_ids: ak.Vector[css_data.PropertyId]
ak.vector_append_t(&property_ids, css_data.PropertyId.transition_property)
ak.vector_append_t(&property_ids, css_data.PropertyId.transition_duration)
ak.vector_append_t(&property_ids, css_data.PropertyId.transition_timing_function)
ak.vector_append_t(&property_ids, css_data.PropertyId.transition_delay)
ak.vector_append_t(&property_ids, css_data.PropertyId.transition_behavior)
let coordinated_properties = css_computed_properties_assemble_coordinated_value_list(this, css_data.PropertyId.transition_property, property_ids)
let property_values = css_computed_properties_coordinated_list(&coordinated_properties, css_data.PropertyId.transition_property)
let duration_values = css_computed_properties_coordinated_list(&coordinated_properties, css_data.PropertyId.transition_duration)
let timing_function_values = css_computed_properties_coordinated_list(&coordinated_properties, css_data.PropertyId.transition_timing_function)
let delay_values = css_computed_properties_coordinated_list(&coordinated_properties, css_data.PropertyId.transition_delay)
let behavior_values = css_computed_properties_coordinated_list(&coordinated_properties, css_data.PropertyId.transition_behavior)
var transitions: ak.Vector[CssTransitionProperties]
ak.vector_ensure_capacity(&transitions, ak.vector_size(&property_values))
for i in 0..<ak.vector_size(&property_values):
let properties = css_computed_properties_transition_properties(this, *ak.vector_at_const(&property_values, i))
let duration = css_time_from_style_value(*ak.vector_at_const(&duration_values, i), none)
let delay = css_time_from_style_value(*ak.vector_at_const(&delay_values, i), none)
ak.vector_append_t(&transitions, CssTransitionProperties(
properties = properties,
duration = css_time_to_milliseconds(&duration),
timing_function = css_easing_function_from_style_value(*ak.vector_at_const(&timing_function_values, i)),
delay = css_time_to_milliseconds(&delay),
transition_behavior = css_data.keyword_to_transition_behavior(css_style_value_to_keyword(*ak.vector_at_const(&behavior_values, i))) else trap("VERIFY: Optional::value()")))
return transitions
# mark: Masks, quotes, counters, scrollbars =====================================================
## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:2124 Web::CSS::ComputedProperties::mask_type.
pub func css_computed_properties_mask_type(this: CssComputedProperties*) -> css_data.MaskType:
let value = css_computed_properties_property(this, css_data.PropertyId.mask_type)
return css_data.keyword_to_mask_type(css_style_value_to_keyword(value)) else trap("VERIFY: Optional::release_value()")
## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:2130 Web::CSS::ComputedProperties::quotes.
pub func css_computed_properties_quotes(this: CssComputedProperties*) -> CssQuotesData:
let value = css_computed_properties_property(this, css_data.PropertyId.quotes)
if css_style_value_is_keyword(value):
match css_style_value_to_keyword(value):
.auto:
return CssQuotesData(type_ = CssQuotesDataType.auto)
.none_:
return CssQuotesData(type_ = CssQuotesDataType.none_)
_:
_ = value
if css_style_value_is_value_list(value):
let value_list = css_style_value_as_value_list(value)
var quotes_data = CssQuotesData(type_ = CssQuotesDataType.specified)
assert(css_style_value_list_size(value_list) % 2 == 0)
var i: u32 = 0
while (usize)i < css_style_value_list_size(value_list):
ak.vector_append_t("es_data.strings, [
css_string_style_value_string_value(css_style_value_as_string(css_style_value_list_value_at(value_list, (usize)i, false))),
css_string_style_value_string_value(css_style_value_as_string(css_style_value_list_value_at(value_list, (usize)(i + 1), false)))])
i += 2
return quotes_data
return css_initial_values_quotes()
## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:2158 Web::CSS::ComputedProperties::counter_data.
pub func css_computed_properties_counter_data(this: CssComputedProperties*, property_id: css_data.PropertyId) -> ak.Vector[CssCounterData]:
let value = css_computed_properties_property(this, property_id)
if css_style_value_is_counter_definitions(value):
let counter_definitions = css_counter_definitions_style_value_counter_definitions(css_style_value_as_counter_definitions(value))
var result: ak.Vector[CssCounterData]
for counter in ak.vector_span_const(&counter_definitions):
var data = CssCounterData(
name = counter.name,
is_reversed = counter.is_reversed,
value = none)
if let counter_value = counter.value:
data.value = ak.clamp_to_i32_i32(css_int_from_style_value(counter_value))
ak.vector_append_t(&result, data)
return result
if css_style_value_to_keyword(value) == css_data.Keyword.none_:
return ak.Vector[CssCounterData]()
let name = css_data.string_from_property_id(property_id)
let text = css_style_value_to_string(value, css_syntax.SerializationMode.normal)
ak.dbgln(f"Unhandled type for {ak.string_view_text(ak.fly_string_bytes_as_string_view(&name))} value: '{ak.string_view_text(ak.string_bytes_as_string_view(&text))}'")
return ak.Vector[CssCounterData]()
## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:2187 Web::CSS::ComputedProperties::scrollbar_color.
pub func css_computed_properties_scrollbar_color(this: CssComputedProperties*, layout_node: LayoutNodeWithStyle*) -> CssScrollbarColorData:
let value = css_computed_properties_property(this, css_data.PropertyId.scrollbar_color)
if css_style_value_is_keyword(value) and css_keyword_style_value_keyword(css_style_value_as_keyword(value)) == css_data.Keyword.auto:
return css_initial_values_scrollbar_color()
if css_style_value_is_scrollbar_color(value):
let scrollbar_color_value = css_style_value_as_scrollbar_color(value)
let thumb_color = css_style_value_to_color(css_scrollbar_color_style_value_thumb_color(scrollbar_color_value), css_color_resolution_context_for_layout_node_with_style(layout_node)) else trap("VERIFY: Optional::value() of to_color()")
let track_color = css_style_value_to_color(css_scrollbar_color_style_value_track_color(scrollbar_color_value), css_color_resolution_context_for_layout_node_with_style(layout_node)) else trap("VERIFY: Optional::value() of to_color()")
return CssScrollbarColorData(thumb_color = thumb_color, track_color = track_color)
var scrollbar_color: CssScrollbarColorData = ---
css_scrollbar_color_data_init_fields(&scrollbar_color)
return scrollbar_color
## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:2203 Web::CSS::ComputedProperties::scrollbar_width.
pub func css_computed_properties_scrollbar_width(this: CssComputedProperties*) -> css_data.ScrollbarWidth:
let value = css_computed_properties_property(this, css_data.PropertyId.scrollbar_width)
return css_data.keyword_to_scrollbar_width(css_style_value_to_keyword(value)) else trap("VERIFY: Optional::release_value()")
## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:2209 Web::CSS::ComputedProperties::resize.
pub func css_computed_properties_resize(this: CssComputedProperties*) -> css_data.Resize:
let value = css_computed_properties_property(this, css_data.PropertyId.resize)
return css_data.keyword_to_resize(css_style_value_to_keyword(value)) else trap("VERIFY: Optional::release_value()")
## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:2215 Web::CSS::ComputedProperties::shape_rendering.
pub func css_computed_properties_shape_rendering(this: CssComputedProperties*) -> css_data.ShapeRendering:
let value = css_computed_properties_property(this, css_data.PropertyId.shape_rendering)
return css_data.keyword_to_shape_rendering(css_style_value_to_keyword(value)) else trap("VERIFY: Optional::release_value()")
## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:2221 Web::CSS::ComputedProperties::paint_order.
pub func css_computed_properties_paint_order(this: CssComputedProperties*) -> css_data.PaintOrder[3]:
let value = css_computed_properties_property(this, css_data.PropertyId.paint_order)
if css_style_value_is_keyword(value):
let keyword = css_keyword_style_value_keyword(css_style_value_as_keyword(value))
if keyword == css_data.Keyword.normal:
return css_initial_values_paint_order()
let paint_order_keyword = css_data.keyword_to_paint_order(keyword) else trap("VERIFY: paint_order_keyword.has_value()")
match paint_order_keyword:
.fill:
return css_initial_values_paint_order()
.stroke:
return [css_data.PaintOrder.stroke, css_data.PaintOrder.fill, css_data.PaintOrder.markers]
.markers:
return [css_data.PaintOrder.markers, css_data.PaintOrder.fill, css_data.PaintOrder.stroke]
_:
trap("VERIFY_NOT_REACHED")
assert(css_style_value_is_value_list(value))
let value_list = css_style_value_as_value_list(value)
# The list must contain 2 values at this point, since the third value is omitted during parsing due to the
# shortest-serialization principle.
assert(css_style_value_list_size(value_list) == 2)
var paint_order_list: css_data.PaintOrder[3]
# We use the sum of the keyword values to infer what the missing keyword is. Since each keyword can only appear in
# the list once, the sum of their values will always be 3.
var sum: i32 = 0
for i in 0..<2:
let keyword = css_keyword_style_value_keyword(css_style_value_as_keyword(css_style_value_list_value_at(value_list, (usize)i, false)))
let paint_order_keyword = css_data.keyword_to_paint_order(keyword) else trap("VERIFY: paint_order_keyword.has_value()")
sum += (i32)paint_order_keyword
paint_order_list[i] = paint_order_keyword
assert(sum <= 3)
paint_order_list[2] = (css_data.PaintOrder)(3 - sum)
return paint_order_list
## The `to_will_change_entry` lambda of ComputedProperties::will_change.
func css_computed_properties_to_will_change_entry(value: CssStyleValue*) -> CssWillChangeWillChangeEntry?:
if css_style_value_is_keyword(value):
match css_keyword_style_value_keyword(css_style_value_as_keyword(value)):
.contents:
return CssWillChangeWillChangeEntry.css_will_change_type(CssWillChangeType.contents)
.scroll_position:
return CssWillChangeWillChangeEntry.css_will_change_type(CssWillChangeType.scroll_position)
_:
trap("VERIFY_NOT_REACHED")
assert(css_style_value_is_custom_ident(value))
let custom_ident = css_custom_ident_style_value_custom_ident(css_style_value_as_custom_ident(value))
let property_id = css_data.property_id_from_string(ak.fly_string_bytes_as_string_view(&custom_ident)) else return none
return CssWillChangeWillChangeEntry.property_id(property_id)
## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:2262 Web::CSS::ComputedProperties::will_change.
pub func css_computed_properties_will_change(this: CssComputedProperties*) -> CssWillChange:
let value = css_computed_properties_property(this, css_data.PropertyId.will_change)
if css_style_value_to_keyword(value) == css_data.Keyword.auto:
return css_will_change_make_auto()
let value_list = css_style_value_list_values(css_style_value_as_value_list(value))
var will_change_entries: ak.Vector[CssWillChangeWillChangeEntry]
for style_value in ak.vector_span_const(&value_list):
if let entry = css_computed_properties_to_will_change_entry(style_value):
ak.vector_append_t(&will_change_entries, entry)
var will_change: CssWillChange = ---
css_will_change_construct_vector(&will_change, will_change_entries)
return will_change
# mark: Fonts and math ==========================================================================
## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:2298 Web::CSS::ComputedProperties::computed_font_list.
pub func css_computed_properties_computed_font_list(this: CssComputedProperties*, font_computer: CssFontComputer*) -> const web_fonts.FontCascadeList*:
if this.m_cached_computed_font_list == none:
this.m_cached_computed_font_list = css_font_computer_compute_font_for_style_values(font_computer, css_computed_properties_property(this, css_data.PropertyId.font_family), css_computed_properties_font_size(this), css_computed_properties_font_slope(this), css_computed_properties_font_weight(this), css_computed_properties_font_width(this), css_computed_properties_font_optical_sizing(this), css_computed_properties_font_variation_settings(this), css_computed_properties_font_feature_data(this))
assert(not web_fonts.font_cascade_list_is_empty(this.m_cached_computed_font_list else trap("VERIFY: a computed font list")))
return this.m_cached_computed_font_list else trap("VERIFY: a computed font list")
## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:2308 Web::CSS::ComputedProperties::first_available_computed_font.
pub func css_computed_properties_first_available_computed_font(this: CssComputedProperties*, font_computer: CssFontComputer*) -> const web_fonts.Font*:
if this.m_cached_first_available_computed_font == none:
# https://drafts.csswg.org/css-fonts/#first-available-font
# First font for which the character U+0020 (space) is not excluded by a unicode-range
this.m_cached_first_available_computed_font = web_fonts.font_cascade_list_font_for_code_point(css_computed_properties_computed_font_list(this, font_computer), (u32)' ')
return this.m_cached_first_available_computed_font else trap("VERIFY: a first available font")
## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:2319 Web::CSS::ComputedProperties::math_style.
pub func css_computed_properties_math_style(this: CssComputedProperties*) -> css_data.MathStyle:
return css_data.keyword_to_math_style(css_style_value_to_keyword(css_computed_properties_property(this, css_data.PropertyId.math_style))) else trap("VERIFY: Optional::value()")
## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:2324 Web::CSS::ComputedProperties::math_depth.
pub func css_computed_properties_math_depth(this: CssComputedProperties*) -> i32:
return css_integer_style_value_integer(css_style_value_as_integer(css_computed_properties_property(this, css_data.PropertyId.math_depth)))
## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:2329 Web::CSS::ComputedProperties::font_size.
pub func css_computed_properties_font_size(this: CssComputedProperties*) -> gfx.CssPixels:
let length = css_length_style_value_length(css_style_value_as_length(css_computed_properties_property(this, css_data.PropertyId.font_size)))
return css_length_absolute_length_to_px(&length)
## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:2334 Web::CSS::ComputedProperties::font_weight.
pub func css_computed_properties_font_weight(this: CssComputedProperties*) -> f64:
return css_number_style_value_number(css_style_value_as_number(css_computed_properties_property(this, css_data.PropertyId.font_weight)))
## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:2339 Web::CSS::ComputedProperties::font_width.
pub func css_computed_properties_font_width(this: CssComputedProperties*) -> CssPercentage:
return css_percentage_style_value_percentage(css_style_value_as_percentage(css_computed_properties_property(this, css_data.PropertyId.font_width)))
## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:2344 Web::CSS::ComputedProperties::font_slope.
pub func css_computed_properties_font_slope(this: CssComputedProperties*) -> i32:
return css_font_style_style_value_to_font_slope(css_style_value_as_font_style(css_computed_properties_property(this, css_data.PropertyId.font_style)))
## Ported from Libraries/LibWeb/CSS/ComputedProperties.cpp:2349 Web::CSS::ComputedProperties::font_optical_sizing.
pub func css_computed_properties_font_optical_sizing(this: CssComputedProperties*) -> css_data.FontOpticalSizing:
let value = css_computed_properties_property(this, css_data.PropertyId.font_optical_sizing)
return css_data.keyword_to_font_optical_sizing(css_style_value_to_keyword(value)) else trap("VERIFY: Optional::release_value()")