From 9ebfafafbe275910f161b6c2bc401994031a2d31 Mon Sep 17 00:00:00 2001 From: Tobias Christiansen Date: Sat, 18 Sep 2021 17:20:00 +0200 Subject: LibWeb: Add transform property to the system This patch adds parsing support as well as all the needed stuctures all over LibWeb to pass Transformations around. --- Userland/Libraries/LibWeb/CSS/StyleProperties.cpp | 38 +++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'Userland/Libraries/LibWeb/CSS/StyleProperties.cpp') diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp index e51111fd85..6fc9bc461b 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp @@ -424,6 +424,44 @@ Optional StyleProperties::justify_content() const } } +Vector StyleProperties::transformations() const +{ + auto value = property(CSS::PropertyID::Transform); + if (!value.has_value()) + return {}; + + if (value.value()->is_identifier() && value.value()->to_identifier() == CSS::ValueID::None) + return {}; + + if (!value.value()->is_value_list()) + return {}; + + auto& list = static_cast(*value.value()); + + Vector transformations; + + for (auto& it : list.values()) { + if (!it.is_transformation()) + return {}; + auto& transformation_style_value = static_cast(it); + CSS::Transformation transformation; + transformation.function = transformation_style_value.transform_function(); + Vector> values; + for (auto& transformation_value : transformation_style_value.values()) { + if (transformation_value.is_length()) { + values.append({ transformation_value.to_length() }); + } else if (transformation_value.is_numeric()) { + values.append({ static_cast(transformation_value).value() }); + } else { + dbgln("FIXME: Unsupported value in transform!"); + } + } + transformation.values = move(values); + transformations.append(move(transformation)); + } + return transformations; +} + Optional StyleProperties::align_items() const { auto value = property(CSS::PropertyID::AlignItems); -- cgit v1.2.3