From e4db71c88b5c90f64a0a23c44a6b7abf78d68e01 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Fri, 28 Oct 2022 02:46:27 +0300 Subject: LibWeb: Support translate3d --- Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp | 15 +++++++++++++++ Userland/Libraries/LibWeb/CSS/TransformFunctions.json | 7 +++++++ Userland/Libraries/LibWeb/Painting/StackingContext.cpp | 12 +++++++++++- 3 files changed, 33 insertions(+), 1 deletion(-) (limited to 'Userland/Libraries') diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index 6441f64180..cf996e4c59 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -5563,6 +5563,21 @@ RefPtr Parser::parse_transform_value(Vector const& c } break; } + case TransformFunctionParameterType::Length: { + if (maybe_calc_value && maybe_calc_value->resolves_to_length()) { + values.append(LengthStyleValue::create(Length::make_calculated(maybe_calc_value.release_nonnull()))); + } else { + auto dimension_value = parse_dimension_value(value); + if (!dimension_value) + return nullptr; + + if (dimension_value->is_length()) + values.append(dimension_value.release_nonnull()); + else + return nullptr; + } + break; + } case TransformFunctionParameterType::LengthPercentage: { if (maybe_calc_value && maybe_calc_value->resolves_to_length()) { values.append(LengthStyleValue::create(Length::make_calculated(maybe_calc_value.release_nonnull()))); diff --git a/Userland/Libraries/LibWeb/CSS/TransformFunctions.json b/Userland/Libraries/LibWeb/CSS/TransformFunctions.json index bca5b145bb..08f1b5e17f 100644 --- a/Userland/Libraries/LibWeb/CSS/TransformFunctions.json +++ b/Userland/Libraries/LibWeb/CSS/TransformFunctions.json @@ -35,6 +35,13 @@ { "type": "", "required": false } ] }, + "translate3d": { + "parameters": [ + { "type": "", "required": true }, + { "type": "", "required": true }, + { "type": "", "required": true } + ] + }, "translateX": { "parameters": [{ "type": "", "required": true }] }, diff --git a/Userland/Libraries/LibWeb/Painting/StackingContext.cpp b/Userland/Libraries/LibWeb/Painting/StackingContext.cpp index ec2d848983..df9b1ca068 100644 --- a/Userland/Libraries/LibWeb/Painting/StackingContext.cpp +++ b/Userland/Libraries/LibWeb/Painting/StackingContext.cpp @@ -209,7 +209,11 @@ Gfx::FloatMatrix4x4 StackingContext::get_transformation_matrix(CSS::Transformati auto value = [this, transformation](size_t index, Optional reference_length = {}) -> float { return transformation.values[index].visit( [this, reference_length](CSS::LengthPercentage const& value) { - return value.resolved(m_box, reference_length.value()).to_px(m_box); + if (reference_length.has_value()) { + return value.resolved(m_box, reference_length.value()).to_px(m_box); + } + + return value.length().to_px(m_box); }, [](CSS::Angle const& value) { return value.to_degrees() * static_cast(M_DEG2RAD); @@ -250,6 +254,12 @@ Gfx::FloatMatrix4x4 StackingContext::get_transformation_matrix(CSS::Transformati 0, 0, 1, 0, 0, 0, 0, 1); break; + case CSS::TransformFunction::Translate3d: + return Gfx::FloatMatrix4x4(1, 0, 0, value(0, width), + 0, 1, 0, value(1, height), + 0, 0, 1, value(2), + 0, 0, 0, 1); + break; case CSS::TransformFunction::TranslateX: if (count == 1) return Gfx::FloatMatrix4x4(1, 0, 0, value(0, width), -- cgit v1.2.3