dymokomi/luce-browser-engine
Source of release 0.6.1
0.6.1 / src / web / css / parser / value_parsing_12.lucb
#==============================================================================================
#
# value_parsing_12 - parsing CSS values: <opacity-value>, <opentype-tag>, <font-src>,
# substitution, transforms and parse_value
#
# DESCRIPTION:
# Port of LibWeb/CSS/Parser/ValueParsing.cpp (lines 5335-5818): <opacity-value>,
# <opentype-tag>, @font-face's <font-src>, both resolve_unresolved_style_value overloads
# (replacing the substitution functions in a property's value), <transform-function>,
# <transform-list> and parse_value, the dispatcher from a ValueType to its parser.
#
# Copyright (c) 2018-2024, Andreas Kling <andreas@ladybird.org>
# Copyright (c) 2021-2025, Sam Atkins <sam@ladybird.org>
# (the full list of ValueParsing.cpp's copyright holders is in value_parsing_1)
# SPDX-License-Identifier: BSD-2-Clause
#
#==============================================================================================
# mark: <opacity-value> and <opentype-tag> ======================================================
## Ported from Libraries/LibWeb/CSS/Parser/ValueParsing.cpp:5336 Web::CSS::Parser::Parser::parse_opacity_value_value.
# https://drafts.csswg.org/css-color-4/#typedef-opacity-opacity-value
pub func css_parser_parse_opacity_value_value(this: CssParser*, tokens: css_syntax.TokenStream[css_syntax.ComponentValue]*) -> CssStyleValue*?:
# <opacity-value> = <number> | <percentage>
if let value = css_parser_parse_number_percentage_value(this, tokens, css_infinite_range, css_infinite_range):
return css_opacity_value_style_value_create(value).css_style_value()
return none
## Ported from Libraries/LibWeb/CSS/Parser/ValueParsing.cpp:5346 Web::CSS::Parser::Parser::parse_opentype_tag_value.
# https://drafts.csswg.org/css-fonts/#typedef-opentype-tag
pub func css_parser_parse_opentype_tag_value(this: CssParser*, tokens: css_syntax.TokenStream[css_syntax.ComponentValue]*) -> CssStringStyleValue*?:
# <opentype-tag> = <string>
# The <opentype-tag> is a case-sensitive OpenType feature tag.
# As specified in the OpenType specification [OPENTYPE], feature tags contain four ASCII characters.
# Tag strings longer or shorter than four characters, or containing characters outside the U+20–7E codepoint range are invalid.
var transaction = css_syntax.token_stream_begin_transaction(tokens)
defer css_syntax.state_transaction_destroy(&transaction)
let string_value = css_parser_parse_string_value(this, tokens) else return none
let string_fly_string = css_string_style_value_string_value(string_value)
let string = ak.fly_string_bytes_as_string_view(&string_fly_string)
if ak.string_view_length(&string) != 4:
return none
for c in ak.string_view_bytes(&string):
if c < 0x20 or c > 0x7E:
return none
css_syntax.state_transaction_commit(&transaction)
return string_value
# mark: <font-src> ==============================================================================
## `ErrorReporter::the().report(InvalidValueError { .value_type = "<font-src>"_fly_string, ... })`.
func css_report_invalid_font_src(value_string: ak.String, description: ak.String):
css_error_reporter_report(css_error_reporter_the(), CssParsingError.css_invalid_value_error(CssInvalidValueError(
value_type = ak.fly_string_from_str("<font-src>"),
value_string = value_string,
description = description,
)))
## The format names of parse_font_source_value's `format("<string>")`: the format, and whether the string adds
## `tech(variations)`; none for a string outside the set.
func css_font_format_from_string(name_string: const ak.FlyString*) -> (ak.FlyString, bool)?:
# There's a fixed set of strings allowed here, which we'll assume are case-insensitive:
# format("woff2") -> format(woff2)
# format("woff") -> format(woff)
# format("truetype") -> format(truetype)
# format("opentype") -> format(opentype)
# format("collection") -> format(collection)
# format("woff2-variations") -> format(woff2) tech(variations)
# format("woff-variations") -> format(woff) tech(variations)
# format("truetype-variations") -> format(truetype) tech(variations)
# format("opentype-variations") -> format(opentype) tech(variations)
if ak.fly_string_equals_ignoring_ascii_case_string_view(name_string, ak.sv("woff2")):
return (ak.fly_string_from_str("woff2"), false)
if ak.fly_string_equals_ignoring_ascii_case_string_view(name_string, ak.sv("woff")):
return (ak.fly_string_from_str("woff"), false)
if ak.fly_string_equals_ignoring_ascii_case_string_view(name_string, ak.sv("truetype")):
return (ak.fly_string_from_str("truetype"), false)
if ak.fly_string_equals_ignoring_ascii_case_string_view(name_string, ak.sv("opentype")):
return (ak.fly_string_from_str("opentype"), false)
if ak.fly_string_equals_ignoring_ascii_case_string_view(name_string, ak.sv("collection")):
return (ak.fly_string_from_str("collection"), false)
if ak.fly_string_equals_ignoring_ascii_case_string_view(name_string, ak.sv("woff2-variations")):
return (ak.fly_string_from_str("woff2"), true)
if ak.fly_string_equals_ignoring_ascii_case_string_view(name_string, ak.sv("woff-variations")):
return (ak.fly_string_from_str("woff"), true)
if ak.fly_string_equals_ignoring_ascii_case_string_view(name_string, ak.sv("truetype-variations")):
return (ak.fly_string_from_str("truetype"), true)
if ak.fly_string_equals_ignoring_ascii_case_string_view(name_string, ak.sv("opentype-variations")):
return (ak.fly_string_from_str("opentype"), true)
return none
## The `tech(<font-tech>#)` item `ident_token`'s FontTech, when it names a supported one.
func css_supported_font_tech(font_tech_name: const ak.FlyString*) -> css_data.FontTech?:
if let keyword = css_data.keyword_from_string(ak.fly_string_bytes_as_string_view(font_tech_name)):
if let font_tech = css_data.keyword_to_font_tech(keyword):
if css_font_tech_is_supported_font_tech(font_tech):
return font_tech
return none
## Ported from Libraries/LibWeb/CSS/Parser/ValueParsing.cpp:5371 Web::CSS::Parser::Parser::parse_font_source_value.
# https://drafts.csswg.org/css-fonts/#font-face-src-parsing
pub func css_parser_parse_font_source_value(this: CssParser*, tokens: css_syntax.TokenStream[css_syntax.ComponentValue]*) -> CssFontSourceStyleValue*?:
# <font-src> = <url> [ format(<font-format>)]? [ tech( <font-tech>#)]? | local(<family-name>)
var transaction = css_syntax.token_stream_begin_transaction(tokens)
defer css_syntax.state_transaction_destroy(&transaction)
css_syntax.token_stream_discard_whitespace(tokens)
# local(<family-name>)
if css_next_token_is_function(tokens, "local"):
let local_token = css_syntax.token_stream_consume_a_token(tokens)
let function = css_syntax.component_value_function(&local_token)
var function_tokens = css_syntax.token_stream_create(function.value)
if let family_name = css_parser_parse_family_name_value(this, &function_tokens):
css_syntax.state_transaction_commit(&transaction)
return css_font_source_style_value_create(CssFontSourceStyleValueSource.css_font_source_style_value_local(CssFontSourceStyleValueLocal(name = family_name)), none, ak.Vector[css_data.FontTech]())
return none
# <url> [ format(<font-format>)]? [ tech( <font-tech>#)]?
# <url>
let url = css_parser_parse_url_function(this, tokens) else return none
var format_: ak.FlyString? = none
var tech = ak.Vector[css_data.FontTech]()
css_syntax.token_stream_discard_whitespace(tokens)
# [ format(<font-format>)]?
if css_next_token_is_function(tokens, "format"):
let format_token = css_syntax.token_stream_consume_a_token(tokens)
let function = css_syntax.component_value_function(&format_token)
css_parser_push_temporary_value_parsing_context(this, css_function_context_of(&function))
defer css_parser_pop_temporary_value_parsing_context(this)
var format_tokens = css_syntax.token_stream_create(function.value)
css_syntax.token_stream_discard_whitespace(&format_tokens)
let format_name_token = css_syntax.token_stream_consume_a_token(&format_tokens)
var format_name = ak.fly_string_new()
if css_syntax.component_value_is(&format_name_token, .ident):
format_name = css_component_value_ident(&format_name_token)
elif css_syntax.component_value_is(&format_name_token, .string):
let string_token = css_syntax.component_value_token(&format_name_token)
let name_string = css_syntax.token_string(&string_token)
if let format_and_variations = css_font_format_from_string(&name_string):
format_name = format_and_variations.0
if format_and_variations.1:
ak.vector_append_t(&tech, css_data.FontTech.variations)
else:
css_report_invalid_font_src(css_syntax.token_stream_dump_string(tokens), css_string_formatted("format() parameter \"{}\" is not in the set of valid strings.", [css_arg_fly_string(&name_string)]))
return none
else:
let debug_string = css_syntax.component_value_to_debug_string(&format_name_token)
css_report_invalid_font_src(css_syntax.token_stream_dump_string(tokens), css_string_formatted("format() parameter is not an ident or string; is: {}", [css_arg_string(&debug_string)]))
return none
if not css_font_format_is_supported(format_name):
css_report_invalid_font_src(css_syntax.token_stream_dump_string(tokens), css_string_formatted("format({}) is not supported.", [css_arg_fly_string(&format_name)]))
return none
css_syntax.token_stream_discard_whitespace(&format_tokens)
if css_syntax.token_stream_has_next_token(&format_tokens):
css_report_invalid_font_src(css_syntax.token_stream_dump_string(tokens), ak.string_from_str("format() has trailing tokens."))
return none
format_ = format_name
css_syntax.token_stream_discard_whitespace(tokens)
# [ tech( <font-tech>#)]?
if css_next_token_is_function(tokens, "tech"):
let tech_token = css_syntax.token_stream_consume_a_token(tokens)
let function = css_syntax.component_value_function(&tech_token)
css_parser_push_temporary_value_parsing_context(this, css_function_context_of(&function))
defer css_parser_pop_temporary_value_parsing_context(this)
var function_tokens = css_syntax.token_stream_create(function.value)
let tech_items = css_parser_parse_a_comma_separated_list_of_component_values(this, &function_tokens)
if ak.vector_is_empty(&tech_items):
css_report_invalid_font_src(css_syntax.token_stream_dump_string(tokens), ak.string_from_str("tech() has no arguments."))
return none
for tech_item in ak.vector_span_const(&tech_items):
var tech_tokens = css_syntax.token_stream_create(tech_item)
css_syntax.token_stream_discard_whitespace(&tech_tokens)
let ident_token = css_syntax.token_stream_consume_a_token(&tech_tokens)
if not css_syntax.component_value_is(&ident_token, .ident):
let debug_string = css_syntax.component_value_to_debug_string(&ident_token)
css_report_invalid_font_src(css_syntax.token_stream_dump_string(tokens), css_string_formatted("tech() parameters must be idents, got: {}", [css_arg_string(&debug_string)]))
return none
css_syntax.token_stream_discard_whitespace(&tech_tokens)
if css_syntax.token_stream_has_next_token(&tech_tokens):
css_report_invalid_font_src(css_syntax.token_stream_dump_string(tokens), ak.string_from_str("tech() has trailing tokens."))
return none
let font_tech_name = css_component_value_ident(&ident_token)
if let font_tech = css_supported_font_tech(&font_tech_name):
ak.vector_append_t(&tech, font_tech)
continue
css_report_invalid_font_src(css_syntax.token_stream_dump_string(tokens), css_string_formatted("tech({}) is not supported.", [css_arg_fly_string(&font_tech_name)]))
return none
css_syntax.state_transaction_commit(&transaction)
return css_font_source_style_value_create(CssFontSourceStyleValueSource.css_url(url), format_, tech)
# mark: Substitution ============================================================================
## Ported from Libraries/LibWeb/CSS/Parser/ValueParsing.cpp:5548 Web::CSS::Parser::Parser::resolve_unresolved_style_value.
pub func css_parser_resolve_unresolved_style_value_css_parsing_params(context: CssParsingParams, abstract_element: DomAbstractElement, property: CssPropertyNameAndId, unresolved: CssUnresolvedStyleValue*, existing_guarded_contexts: CssGuardedSubstitutionContexts*? = none) -> CssStyleValue*:
var parser = css_parser_create(context, ak.sv(""))
if let guarded = existing_guarded_contexts:
return css_parser_resolve_unresolved_style_value_dom_abstract_element(&parser, abstract_element, guarded, property, unresolved)
var guarded_contexts = CssGuardedSubstitutionContexts()
return css_parser_resolve_unresolved_style_value_dom_abstract_element(&parser, abstract_element, &guarded_contexts, property, unresolved)
## Ported from Libraries/LibWeb/CSS/Parser/ValueParsing.cpp:5558 Web::CSS::Parser::Parser::resolve_unresolved_style_value.
# https://drafts.csswg.org/css-values-5/#property-replacement
pub func css_parser_resolve_unresolved_style_value_dom_abstract_element(this: CssParser*, element: DomAbstractElement, guarded_contexts: CssGuardedSubstitutionContexts*, property: CssPropertyNameAndId, unresolved: CssUnresolvedStyleValue*) -> CssStyleValue*:
var abstract_element = element
# AD-HOC: Report that we might rely on custom properties.
if css_unresolved_style_value_includes_attr_function(unresolved):
dom_element_set_style_uses_attr_css_function(dom_abstract_element_element(&abstract_element))
if css_unresolved_style_value_includes_if_function(unresolved):
dom_element_set_style_uses_if_css_function(dom_abstract_element_element(&abstract_element))
if css_unresolved_style_value_includes_inherit_function(unresolved):
dom_element_set_style_uses_inherit_css_function(dom_abstract_element_element(&abstract_element))
if css_unresolved_style_value_includes_var_function(unresolved):
dom_element_set_style_uses_var_css_function(dom_abstract_element_element(&abstract_element))
# To replace substitution functions in a property prop:
# 1. Substitute arbitrary substitution functions in prop’s value, given «"property", prop’s name» as the
# substitution context. Let result be the returned component value sequence.
let property_name = css_property_name_and_id_name(&property)
let result = css_substitute_arbitrary_substitution_functions(&abstract_element, guarded_contexts, css_unresolved_style_value_values(unresolved), CssSubstitutionContext(dependency_type = CssSubstitutionContextDependencyType.property, first = ak.fly_string_to_string_const(&property_name)))
# 2. If result contains the guaranteed-invalid value, prop is invalid at computed-value time; return.
if css_contains_guaranteed_invalid_value(result):
return css_guaranteed_invalid_style_value_create().css_style_value()
# 3. Parse result according to prop’s grammar. If this returns failure, prop is invalid at computed-value time; return.
# NB: Custom properties have no grammar as such, so we skip this step for them.
# FIXME: Parse according to @property syntax once we support that.
if css_property_name_and_id_is_custom_property(&property):
return css_unresolved_style_value_create(result, css_syntax.SubstitutionFunctionsPresence()).css_style_value()
var expanded_value_tokens = css_syntax.token_stream_create(result)
let parsed_value = css_parser_parse_css_value(this, css_property_name_and_id_id(&property), &expanded_value_tokens) catch:
return css_guaranteed_invalid_style_value_create().css_style_value()
# 4. Otherwise, replace prop’s value with the parsed result.
return parsed_value
# mark: Transforms ==============================================================================
## `ErrorReporter::the().report(InvalidValueError { .value_type = "<transform-function>"_fly_string, ... })`.
func css_report_invalid_transform_function(value_string: ak.String, description: ak.String):
css_error_reporter_report(css_error_reporter_the(), CssParsingError.css_invalid_value_error(CssInvalidValueError(
value_type = ak.fly_string_from_str("<transform-function>"),
value_string = value_string,
description = description,
)))
## The value of one transform-function argument of the given parameter type (the switch of
## parse_transform_function_value); none when it does not parse as that type.
func css_parser_parse_transform_function_argument(this: CssParser*, argument_tokens: css_syntax.TokenStream[css_syntax.ComponentValue]*, parameter_type: css_data.TransformFunctionParameterType) -> CssStyleValue*?:
match parameter_type:
.angle:
# These are `<angle> | <zero>` in the spec, so we have to check for both kinds.
if let angle_value = css_parser_parse_angle_value(this, argument_tokens, css_infinite_range):
return angle_value
let next = css_syntax.token_stream_next_token(argument_tokens)
if css_syntax.component_value_is(&next, .number):
let number_token = css_syntax.component_value_token(&next)
if css_syntax.token_number_value(&number_token) == 0.0:
css_syntax.token_stream_discard_a_token(argument_tokens) # 0
return css_angle_style_value_create(css_angle_make_degrees(0.0)).css_style_value()
return none
.length, .length_none:
if let length_value = css_parser_parse_length_value(this, argument_tokens, css_infinite_range):
return length_value
if parameter_type == css_data.TransformFunctionParameterType.length_none and css_next_token_is_ident(argument_tokens, "none"):
css_syntax.token_stream_discard_a_token(argument_tokens) # none
return css_keyword_style_value_create(css_data.Keyword.none_).css_style_value()
return none
.length_percentage:
return css_parser_parse_length_percentage_value(this, argument_tokens, css_infinite_range, css_infinite_range)
.number:
return css_parser_parse_number_value(this, argument_tokens, css_infinite_range)
.number_percentage:
return css_parser_parse_number_percentage_value(this, argument_tokens, css_infinite_range, css_infinite_range)
_:
trap("VERIFY_NOT_REACHED")
## Ported from Libraries/LibWeb/CSS/Parser/ValueParsing.cpp:5596 Web::CSS::Parser::Parser::parse_transform_function_value.
# https://drafts.csswg.org/css-transforms-1/#typedef-transform-function
pub func css_parser_parse_transform_function_value(this: CssParser*, tokens: css_syntax.TokenStream[css_syntax.ComponentValue]*) -> CssStyleValue*?:
var transaction = css_syntax.token_stream_begin_transaction(tokens)
defer css_syntax.state_transaction_destroy(&transaction)
css_syntax.token_stream_discard_whitespace(tokens)
let part = css_syntax.token_stream_consume_a_token(tokens)
if not css_syntax.component_value_is_function(&part):
return none
let part_function = css_syntax.component_value_function(&part)
let function = css_data.transform_function_from_string(ak.fly_string_bytes_as_string_view(&part_function.name)) else return none
css_parser_push_temporary_value_parsing_context(this, css_function_context_of(&part_function))
defer css_parser_pop_temporary_value_parsing_context(this)
let function_metadata = css_data.transform_function_metadata(function)
let parameter_count = ak.vector_size(&function_metadata.parameters)
var function_tokens = css_syntax.token_stream_create(part_function.value)
let arguments = css_parser_parse_a_comma_separated_list_of_component_values(this, &function_tokens)
if ak.vector_size(&arguments) > parameter_count:
css_report_invalid_transform_function(css_syntax.function_original_source_text(&part_function),
css_string_formatted("Too many arguments to {}. max: {}", [css_arg_fly_string(&part_function.name), ak.arg_u64((u64)parameter_count)]))
return none
if ak.vector_size(&arguments) < parameter_count and ak.vector_at_const(&function_metadata.parameters, ak.vector_size(&arguments)).required:
css_report_invalid_transform_function(css_syntax.function_original_source_text(&part_function),
css_string_formatted("Required parameter at position {} is missing", [ak.arg_u64((u64)ak.vector_size(&arguments))]))
return none
var values = ak.Vector[CssStyleValue*]()
for argument_index in 0..<ak.vector_size(&arguments):
var argument_tokens = css_syntax.token_stream_create(*ak.vector_at_const(&arguments, argument_index))
css_syntax.token_stream_discard_whitespace(&argument_tokens)
let parameter_type = ak.vector_at_const(&function_metadata.parameters, argument_index).type_
let value = css_parser_parse_transform_function_argument(this, &argument_tokens, parameter_type) else return none
ak.vector_append_t(&values, value)
css_syntax.token_stream_discard_whitespace(&argument_tokens)
if css_syntax.token_stream_has_next_token(&argument_tokens):
return none
css_syntax.state_transaction_commit(&transaction)
return css_transformation_style_value_create(css_data.PropertyId.transform, function, values).css_style_value()
## Ported from Libraries/LibWeb/CSS/Parser/ValueParsing.cpp:5700 Web::CSS::Parser::Parser::parse_transform_list_value.
# https://drafts.csswg.org/css-transforms-1/#typedef-transform-list
pub func css_parser_parse_transform_list_value(this: CssParser*, tokens: css_syntax.TokenStream[css_syntax.ComponentValue]*) -> CssStyleValue*?:
# <transform-list> = <transform-function>+
# https://www.w3.org/TR/css-transforms-1/#transform-property
var transformations = ak.Vector[CssStyleValue*]()
var transaction = css_syntax.token_stream_begin_transaction(tokens)
defer css_syntax.state_transaction_destroy(&transaction)
while css_syntax.token_stream_has_next_token(tokens):
if let maybe_function = css_parser_parse_transform_function_value(this, tokens):
ak.vector_append_t(&transformations, maybe_function)
css_syntax.token_stream_discard_whitespace(tokens)
continue
break
if ak.vector_is_empty(&transformations):
return none
css_syntax.state_transaction_commit(&transaction)
return css_style_value_list_create(transformations, CssStyleValueListSeparator.space).css_style_value()
# mark: parse_value =============================================================================
## Ported from Libraries/LibWeb/CSS/Parser/ValueParsing.cpp:5720 Web::CSS::Parser::Parser::parse_value.
pub func css_parser_parse_value(this: CssParser*, value_type: CssValueType, tokens: css_syntax.TokenStream[css_syntax.ComponentValue]*) -> CssStyleValue*?:
var no_blacklist: const ak.StringView[]
match value_type:
.anchor: return css_parser_parse_anchor(this, tokens)
.anchor_size: return css_parser_parse_anchor_size(this, tokens)
.angle: return css_parser_parse_angle_value(this, tokens, css_infinite_range)
.angle_percentage: return css_parser_parse_angle_percentage_value(this, tokens, css_infinite_range, css_infinite_range)
.background_position: return css_style_value_of_position(css_parser_parse_position_value(this, tokens, CssParserPositionParsingMode.background_position))
.basic_shape: return css_parser_parse_basic_shape_value(this, tokens)
.color: return css_parser_parse_color_value(this, tokens)
.corner_shape: return css_parser_parse_corner_shape_value(this, tokens)
.counter: return css_parser_parse_counter_value(this, tokens)
.counter_style: return css_parser_parse_counter_style_value(this, tokens)
.custom_ident:
# FIXME: Figure out how to pass the blacklist here
if let custom_ident = css_parser_parse_custom_ident_value(this, tokens, no_blacklist):
return custom_ident.css_style_value()
return none
.dashed_ident:
if let dashed_ident = css_parser_parse_dashed_ident_value(this, tokens):
return dashed_ident.css_style_value()
return none
.easing_function: return css_parser_parse_easing_value(this, tokens)
.filter_value_list: return css_parser_parse_filter_value_list_value(this, tokens)
.fit_content: return css_parser_parse_fit_content_value(this, tokens)
.flex: return css_parser_parse_flex_value(this, tokens, css_infinite_range)
.font_style: return css_parser_parse_font_style_value(this, tokens)
.font_variant_alternates: return css_parser_parse_font_variant_alternates_value(this, tokens)
.font_variant_east_asian: return css_parser_parse_font_variant_east_asian_value(this, tokens)
.font_variant_ligatures: return css_parser_parse_font_variant_ligatures_value(this, tokens)
.font_variant_numeric: return css_parser_parse_font_variant_numeric_value(this, tokens)
.frequency: return css_parser_parse_frequency_value(this, tokens, css_infinite_range)
.frequency_percentage: return css_parser_parse_frequency_percentage_value(this, tokens, css_infinite_range, css_infinite_range)
.image:
if let image = css_parser_parse_image_value(this, tokens):
return image.css_style_value()
return none
.integer: return css_parser_parse_integer_value(this, tokens, css_infinite_integer_range)
.length: return css_parser_parse_length_value(this, tokens, css_infinite_range)
.length_percentage: return css_parser_parse_length_percentage_value(this, tokens, css_infinite_range, css_infinite_range)
.number: return css_parser_parse_number_value(this, tokens, css_infinite_range)
.opacity_value: return css_parser_parse_opacity_value_value(this, tokens)
.opentype_tag:
if let tag = css_parser_parse_opentype_tag_value(this, tokens):
return tag.css_style_value()
return none
.paint: return css_parser_parse_paint_value(this, tokens)
.percentage: return css_parser_parse_percentage_value(this, tokens, css_infinite_range)
.position: return css_style_value_of_position(css_parser_parse_position_value(this, tokens))
.ratio: return css_parser_parse_ratio_value(this, tokens)
.rect: return css_parser_parse_rect_value(this, tokens)
.resolution: return css_parser_parse_resolution_value(this, tokens, css_infinite_range)
.scroll_function:
if let function = css_parser_parse_scroll_function_value(this, tokens):
return function.css_style_value()
return none
.string:
if let string = css_parser_parse_string_value(this, tokens):
return string.css_style_value()
return none
.time: return css_parser_parse_time_value(this, tokens, css_infinite_range)
.time_percentage: return css_parser_parse_time_percentage_value(this, tokens, css_infinite_range, css_infinite_range)
.transform_function: return css_parser_parse_transform_function_value(this, tokens)
.transform_list: return css_parser_parse_transform_list_value(this, tokens)
.url:
if let url = css_parser_parse_url_value(this, tokens):
return url.css_style_value()
return none
.view_function:
if let function = css_parser_parse_view_function_value(this, tokens):
return function.css_style_value()
return none
.view_timeline_inset: return css_parser_parse_view_timeline_inset_value(this, tokens)
_: trap("VERIFY_NOT_REACHED")
## A `RefPtr<PositionStyleValue const>` returned as a `RefPtr<StyleValue const>`.
func css_style_value_of_position(position: CssPositionStyleValue*?) -> CssStyleValue*?:
if let value = position:
return value.css_style_value()
return none