Repository: LadybirdBrowser/ladybird
File: Libraries/LibWeb/CSS/StyleComputer.cpp (C++)

Code before:
NonnullRefPtr<StyleValue const> StyleComputer::compute_animation_name(NonnullRefPtr<StyleValue const> const& absolutized_value)
{
    // https://drafts.csswg.org/css-animations-1/#animation-name
    // list, each item either a case-sensitive css identifier or the keyword none

    return compute_style_value_list(absolutized_value, [](NonnullRefPtr<StyleValue const> const& entry) -> NonnullRefPtr<StyleValue const> {
        // none | <custom-ident>
        if (entry->to_keyword() == Keyword::None || entry->is_custom_ident())
            return entry;

        // <string>
        if (entry->is_string()) {
            auto const& string_value = entry->as_string().string_value();

            // AD-HOC: We shouldn't convert strings that aren't valid <custom-ident>s
            if (is_css_wide_keyword(string_value) || string_value.is_one_of_ignoring_ascii_case("default"sv, "none"sv))
                return entry;

            return CustomIdentStyleValue::create(entry->as_string().string_value());
        }

        VERIFY_NOT_REACHED();
    });
}

NonnullRefPtr<StyleValue const> StyleComputer::compute_font_variation_settings(NonnullRefPtr<StyleValue const> const& absolutized_value, ComputationContext const& computation_context)
{
    if (absolutized_value->is_keyword())
        return absolutized_value;

    // https://drafts.csswg.org/css-fonts-4/#font-variation-settings-def
    // If the same axis name appears more than once, the value associated with the last appearance supersedes any
    // previous value for that axis. This deduplication is observable by accessing the computed value of this property."
    // So, we deduplicate them here using a HashSet.
    auto const& value_list = absolutized_value->as_value_list();
    OrderedHashMap<FlyString, NonnullRefPtr<OpenTypeTaggedStyleValue const>> axis_tags_map;
    for (size_t i = 0; i < value_list.values().size(); i++) {
        auto const& axis_tag = value_list.values().at(i)->as_open_type_tagged();
        axis_tags_map.set(axis_tag.tag(), axis_tag);
    }

    StyleValueVector axis_tags;

    // The computed value contains the de-duplicated axis names, sorted in ascending order by code unit.
    for (auto const& [key, axis_tag] : axis_tags_map)
        axis_tags.append(axis_tag->absolutized(computation_context));

    quick_sort(axis_tags, [](auto& a, auto& b) {
        return a->as_open_type_tagged().tag() < b->as_open_type_tagged().tag();
    });


Review comment (suggestion):
Same thing about the `absolutized_value` name.

I think if you put
```c++
    auto const& absolutized_value = specified_value->absolutized(computation_context);
```
at the start of the method, it'll match the others a bit better, you won't have to call `absolutized()` on the individual axis_tags below, and it might catch other things that needs absolutizing.

Code after:
NonnullRefPtr<StyleValue const> StyleComputer::compute_animation_name(NonnullRefPtr<StyleValue const> const& absolutized_value)
{
    // https://drafts.csswg.org/css-animations-1/#animation-name
    // list, each item either a case-sensitive css identifier or the keyword none

    return compute_style_value_list(absolutized_value, [](NonnullRefPtr<StyleValue const> const& entry) -> NonnullRefPtr<StyleValue const> {
        // none | <custom-ident>
        if (entry->to_keyword() == Keyword::None || entry->is_custom_ident())
            return entry;

        // <string>
        if (entry->is_string()) {
            auto const& string_value = entry->as_string().string_value();

            // AD-HOC: We shouldn't convert strings that aren't valid <custom-ident>s
            if (is_css_wide_keyword(string_value) || string_value.is_one_of_ignoring_ascii_case("default"sv, "none"sv))
                return entry;

            return CustomIdentStyleValue::create(entry->as_string().string_value());
        }

        VERIFY_NOT_REACHED();
    });
}

NonnullRefPtr<StyleValue const> StyleComputer::compute_font_variation_settings(NonnullRefPtr<StyleValue const> const& specified_value, ComputationContext const& computation_context)
{
    auto const& absolutized_value = specified_value->absolutized(computation_context);

    if (absolutized_value->is_keyword())
        return absolutized_value;

    // https://drafts.csswg.org/css-fonts-4/#font-variation-settings-def
    // If the same axis name appears more than once, the value associated with the last appearance supersedes any
    // previous value for that axis. This deduplication is observable by accessing the computed value of this property."
    // So, we deduplicate them here using a HashSet.
    auto const& value_list = absolutized_value->as_value_list();
    OrderedHashMap<FlyString, NonnullRefPtr<OpenTypeTaggedStyleValue const>> axis_tags_map;
    for (size_t i = 0; i < value_list.values().size(); i++) {
        auto const& axis_tag = value_list.values().at(i)->as_open_type_tagged();
        axis_tags_map.set(axis_tag.tag(), axis_tag);
    }

    StyleValueVector axis_tags;

    // The computed value contains the de-duplicated axis names, sorted in ascending order by code unit.
    for (auto const& [key, axis_tag] : axis_tags_map)
        axis_tags.append(axis_tag);

    quick_sort(axis_tags, [](auto& a, auto& b) {
        return a->as_open_type_tagged().tag() < b->as_open_type_tagged().tag();