diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2022-04-17 15:52:30 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-04-18 14:16:28 +0200 |
commit | 61ad39b110626e70404b24cc75b5ddd2bdefb816 (patch) | |
tree | 649bcf66d7fe58ab78dc29ccb48cf07750c7f160 | |
parent | 872ad98ebac2a5dae9deb195921291e16d86e1c3 (diff) | |
download | serenity-61ad39b110626e70404b24cc75b5ddd2bdefb816.zip |
LibWeb: Use generated TransformFunction enum and functions
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp | 29 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/StyleValue.cpp | 40 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/StyleValue.h | 15 |
3 files changed, 3 insertions, 81 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index ba316883f6..88e5131182 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -4769,33 +4769,6 @@ RefPtr<StyleValue> Parser::parse_text_decoration_line_value(TokenStream<Componen return StyleValueList::create(move(style_values), StyleValueList::Separator::Space); } -static Optional<CSS::TransformFunction> parse_transform_function_name(StringView name) -{ - if (name == "matrix") - return CSS::TransformFunction::Matrix; - if (name == "translate") - return CSS::TransformFunction::Translate; - if (name == "translateX") - return CSS::TransformFunction::TranslateX; - if (name == "translateY") - return CSS::TransformFunction::TranslateY; - if (name == "scale") - return CSS::TransformFunction::Scale; - if (name == "scaleX") - return CSS::TransformFunction::ScaleX; - if (name == "scaleY") - return CSS::TransformFunction::ScaleY; - if (name == "rotate") - return CSS::TransformFunction::Rotate; - if (name == "skew") - return CSS::TransformFunction::Skew; - if (name == "skewX") - return CSS::TransformFunction::SkewX; - if (name == "skewY") - return CSS::TransformFunction::SkewY; - return {}; -} - RefPtr<StyleValue> Parser::parse_transform_value(Vector<ComponentValue> const& component_values) { NonnullRefPtrVector<StyleValue> transformations; @@ -4811,7 +4784,7 @@ RefPtr<StyleValue> Parser::parse_transform_value(Vector<ComponentValue> const& c if (!part.is_function()) return nullptr; - auto maybe_function = parse_transform_function_name(part.function().name()); + auto maybe_function = transform_function_from_string(part.function().name()); if (!maybe_function.has_value()) return nullptr; diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp index 824e0acb2b..5c6961ccd0 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp @@ -1315,45 +1315,7 @@ String TextDecorationStyleValue::to_string() const String TransformationStyleValue::to_string() const { StringBuilder builder; - - switch (m_transform_function) { - case TransformFunction::Matrix: - builder.append("matrix"); - break; - case TransformFunction::Translate: - builder.append("translate"); - break; - case TransformFunction::TranslateX: - builder.append("translateX"); - break; - case TransformFunction::TranslateY: - builder.append("translateY"); - break; - case TransformFunction::Scale: - builder.append("scale"); - break; - case TransformFunction::ScaleX: - builder.append("scaleX"); - break; - case TransformFunction::ScaleY: - builder.append("scaleY"); - break; - case TransformFunction::Rotate: - builder.append("rotate"); - break; - case TransformFunction::Skew: - builder.append("skew"); - break; - case TransformFunction::SkewX: - builder.append("skewX"); - break; - case TransformFunction::SkewY: - builder.append("skewY"); - break; - default: - VERIFY_NOT_REACHED(); - } - + builder.append(CSS::to_string(m_transform_function)); builder.append('('); builder.join(", ", m_values); builder.append(')'); diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValue.h index 3d53927150..4909996fd5 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.h @@ -34,6 +34,7 @@ #include <LibWeb/CSS/PropertyID.h> #include <LibWeb/CSS/Resolution.h> #include <LibWeb/CSS/Time.h> +#include <LibWeb/CSS/TransformFunctions.h> #include <LibWeb/CSS/ValueID.h> #include <LibWeb/Forward.h> #include <LibWeb/Loader/ImageResource.h> @@ -72,20 +73,6 @@ inline Gfx::Painter::ScalingMode to_gfx_scaling_mode(CSS::ImageRendering css_val VERIFY_NOT_REACHED(); } -enum class TransformFunction { - Matrix, - Translate, - TranslateX, - TranslateY, - Scale, - ScaleX, - ScaleY, - Rotate, - Skew, - SkewX, - SkewY, -}; - class StyleValue : public RefCounted<StyleValue> { public: virtual ~StyleValue() = default; |