mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-01 15:18:06 +00:00
LibWeb: Add formatter for Web::CSS::ValueType
Currently unused but I found it useful for debugging
This commit is contained in:
parent
9bfd46ce31
commit
18d65b014f
Notes:
github-actions[bot]
2025-08-08 08:46:29 +00:00
Author: https://github.com/Calme1709
Commit: 18d65b014f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5773
Reviewed-by: https://github.com/AtkinsSJ ✅
Reviewed-by: https://github.com/tcl3
2 changed files with 72 additions and 0 deletions
|
@ -66,4 +66,66 @@ Optional<ValueType> value_type_from_string(StringView string)
|
||||||
return {};
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/Format.h>
|
||||||
#include <AK/Optional.h>
|
#include <AK/Optional.h>
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
|
|
||||||
|
@ -41,6 +42,15 @@ enum class ValueType : u8 {
|
||||||
Url,
|
Url,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
StringView value_type_to_string(ValueType);
|
||||||
Optional<ValueType> value_type_from_string(StringView);
|
Optional<ValueType> value_type_from_string(StringView);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct AK::Formatter<Web::CSS::ValueType> : Formatter<StringView> {
|
||||||
|
ErrorOr<void> format(FormatBuilder& builder, Web::CSS::ValueType type)
|
||||||
|
{
|
||||||
|
return Formatter<StringView>::format(builder, Web::CSS::value_type_to_string(type));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue