diff --git a/Libraries/LibWeb/CSS/ValueType.cpp b/Libraries/LibWeb/CSS/ValueType.cpp index b2125bf71bb..9cfe79c1e60 100644 --- a/Libraries/LibWeb/CSS/ValueType.cpp +++ b/Libraries/LibWeb/CSS/ValueType.cpp @@ -66,4 +66,66 @@ Optional value_type_from_string(StringView string) return {}; } +StringView value_type_to_string(ValueType value_type) +{ + switch (value_type) { + case Web::CSS::ValueType::Anchor: + return "Anchor"sv; + case Web::CSS::ValueType::AnchorSize: + return "AnchorSize"sv; + case Web::CSS::ValueType::Angle: + return "Angle"sv; + case Web::CSS::ValueType::BackgroundPosition: + return "BackgroundPosition"sv; + case Web::CSS::ValueType::BasicShape: + return "BasicShape"sv; + case Web::CSS::ValueType::Color: + return "Color"sv; + case Web::CSS::ValueType::Counter: + return "Counter"sv; + case Web::CSS::ValueType::CustomIdent: + return "CustomIdent"sv; + case Web::CSS::ValueType::EasingFunction: + return "EasingFunction"sv; + case Web::CSS::ValueType::FilterValueList: + return "FilterValueList"sv; + case Web::CSS::ValueType::FitContent: + return "FitContent"sv; + case Web::CSS::ValueType::Flex: + return "Flex"sv; + case Web::CSS::ValueType::Frequency: + return "Frequency"sv; + case Web::CSS::ValueType::Image: + return "Image"sv; + case Web::CSS::ValueType::Integer: + return "Integer"sv; + case Web::CSS::ValueType::Length: + return "Length"sv; + case Web::CSS::ValueType::Number: + return "Number"sv; + case Web::CSS::ValueType::OpenTypeTag: + return "OpenTypeTag"sv; + case Web::CSS::ValueType::Paint: + return "Paint"sv; + case Web::CSS::ValueType::Percentage: + return "Percentage"sv; + case Web::CSS::ValueType::Position: + return "Position"sv; + case Web::CSS::ValueType::Ratio: + return "Ratio"sv; + case Web::CSS::ValueType::Rect: + return "Rect"sv; + case Web::CSS::ValueType::Resolution: + return "Resolution"sv; + case Web::CSS::ValueType::String: + return "String"sv; + case Web::CSS::ValueType::Time: + return "Time"sv; + case Web::CSS::ValueType::Url: + return "Url"sv; + } + + VERIFY_NOT_REACHED(); +} + } diff --git a/Libraries/LibWeb/CSS/ValueType.h b/Libraries/LibWeb/CSS/ValueType.h index 93c1078aa2d..4a2078bfb61 100644 --- a/Libraries/LibWeb/CSS/ValueType.h +++ b/Libraries/LibWeb/CSS/ValueType.h @@ -6,6 +6,7 @@ #pragma once +#include #include #include @@ -41,6 +42,15 @@ enum class ValueType : u8 { Url, }; +StringView value_type_to_string(ValueType); Optional value_type_from_string(StringView); } + +template<> +struct AK::Formatter : Formatter { + ErrorOr format(FormatBuilder& builder, Web::CSS::ValueType type) + { + return Formatter::format(builder, Web::CSS::value_type_to_string(type)); + } +};