Luce packages
LuceLuce BaseLuciaOS

dymokomi/luce-browser-engine

Source of release 0.6.0

0.6.0 / src / web / css / preferred_contrast.lucb

#==============================================================================================
#
#   preferred_contrast - CSS::PreferredContrast: the user's contrast preference as a string
#
#   DESCRIPTION:
#       Port of LibWeb/CSS/PreferredContrast.cpp (lines 1-37).
#
#       Copyright (c) 2024, the Ladybird developers.
#       SPDX-License-Identifier: BSD-2-Clause
#
#==============================================================================================

## Ported from Libraries/LibWeb/CSS/PreferredContrast.cpp:11 Web::CSS::preferred_contrast_from_string.
pub func css_preferred_contrast_from_string(value: ak.StringView) -> CssPreferredContrast:
    if ak.string_view_equals_ignoring_ascii_case(&value, ak.sv("less")):
        return CssPreferredContrast.less
    if ak.string_view_equals_ignoring_ascii_case(&value, ak.sv("more")):
        return CssPreferredContrast.more
    if ak.string_view_equals_ignoring_ascii_case(&value, ak.sv("no-preference")):
        return CssPreferredContrast.no_preference
    return CssPreferredContrast.auto

## Ported from Libraries/LibWeb/CSS/PreferredContrast.cpp:22 Web::CSS::preferred_contrast_to_string.
pub func css_preferred_contrast_to_string(value: CssPreferredContrast) -> ak.StringView:
    match value:
        .auto: return ak.sv("auto")
        .less: return ak.sv("less")
        .more: return ak.sv("more")
        .no_preference: return ak.sv("no-preference")
        _: trap("VERIFY_NOT_REACHED")