summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorAliaksandr Kalenik <kalenik.aliaksandr@gmail.com>2022-10-28 02:46:27 +0300
committerSam Atkins <atkinssj@gmail.com>2022-11-02 11:04:23 +0000
commite4db71c88b5c90f64a0a23c44a6b7abf78d68e01 (patch)
tree80b99173639e5459eefe77b8b9f0d49a8130492f /Userland/Libraries
parentf099e2aa12dde9fcbf6cd0bdd734824cd77e06f3 (diff)
downloadserenity-e4db71c88b5c90f64a0a23c44a6b7abf78d68e01.zip
LibWeb: Support translate3d
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp15
-rw-r--r--Userland/Libraries/LibWeb/CSS/TransformFunctions.json7
-rw-r--r--Userland/Libraries/LibWeb/Painting/StackingContext.cpp12
3 files changed, 33 insertions, 1 deletions
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<StyleValue> Parser::parse_transform_value(Vector<ComponentValue> 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": "<length-percentage>", "required": false }
]
},
+ "translate3d": {
+ "parameters": [
+ { "type": "<length-percentage>", "required": true },
+ { "type": "<length-percentage>", "required": true },
+ { "type": "<length>", "required": true }
+ ]
+ },
"translateX": {
"parameters": [{ "type": "<length-percentage>", "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<CSS::Length const&> 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<float>(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),