LibWeb/CSS: Remove Transformation in favor of TransformationStyleValue

The Transformation class wasn't really accomplishing anything. It still
had to store StyleValues, so it was basically the same as
TransformationStyleValue, with extra steps to convert from one to the
other. So... let's just use TransformationStyleValue instead!

Apart from moving code around, the behavior has changed a bit. We now
actually acknowledge unresolvable parameters and return an error when
we try to produce a matrix from them. Previously we just skipped over
them, which was pretty wrong. This gets us an extra pass in the
typed-om test.

We also get some slightly different results with our transform
serialization, because we're not converting to CSSPixels and back.
This commit is contained in:
Sam Atkins
2025-12-17 16:40:48 +00:00
committed by Jelle Raaijmakers
parent 6b5836644a
commit c446281844
Notes: github-actions[bot] 2025-12-19 13:53:02 +00:00
21 changed files with 344 additions and 397 deletions

View File

@@ -7,6 +7,7 @@
#include <LibGfx/ImmutableBitmap.h>
#include <LibJS/Runtime/Realm.h>
#include <LibWeb/CSS/CSSKeyframesRule.h>
#include <LibWeb/CSS/PropertyID.h>
#include <LibWeb/HTML/EventLoop/EventLoop.h>
#include <LibWeb/HTML/Navigable.h>
#include <LibWeb/HTML/Scripting/TemporaryExecutionContext.h>
@@ -302,7 +303,11 @@ ErrorOr<void> ViewTransition::capture_the_old_state()
// 6. Set captures old transform to a <transform-function> that would map elements border box from the
// snapshot containing block origin to its current visual position.
// FIXME: Actually compute the right transform here.
capture->old_transform = CSS::Transformation(CSS::TransformFunction::Translate, Vector<CSS::TransformValue>({ CSS::TransformValue(CSS::Length(0, CSS::LengthUnit::Px)), CSS::TransformValue(CSS::Length(0, CSS::LengthUnit::Px)) }));
capture->old_transform = CSS::TransformationStyleValue::create(CSS::PropertyID::Transform, CSS::TransformFunction::Translate,
CSS::StyleValueVector {
CSS::LengthStyleValue::create(CSS::Length(0, CSS::LengthUnit::Px)),
CSS::LengthStyleValue::create(CSS::Length(0, CSS::LengthUnit::Px)),
});
// 7. Set captures old writing-mode to the computed value of writing-mode on element.
capture->old_writing_mode = element.layout_node()->computed_values().writing_mode();
@@ -807,7 +812,7 @@ ErrorOr<void> ViewTransition::update_pseudo_element_styles()
// colorScheme be null.
Optional<CSSPixels> width = {};
Optional<CSSPixels> height = {};
Optional<CSS::Transformation> transform = {};
RefPtr<CSS::TransformationStyleValue const> transform = {};
Optional<CSS::WritingMode> writing_mode = {};
Optional<CSS::Direction> direction = {};
// FIXME: Implement this once we have text-orientation.
@@ -880,7 +885,11 @@ ErrorOr<void> ViewTransition::update_pseudo_element_styles()
// 5. Set transform to a transform that would map newRect from the snapshot containing block origin
// to its current visual position.
auto offset = new_rect.location() - captured_element->new_element->navigable()->snapshot_containing_block().location();
transform = CSS::Transformation(CSS::TransformFunction::Translate, Vector<CSS::TransformValue>({ CSS::TransformValue(CSS::Length::make_px(offset.x())), CSS::TransformValue(CSS::Length::make_px(offset.y())) }));
transform = CSS::TransformationStyleValue::create(CSS::PropertyID::Transform, CSS::TransformFunction::Translate,
CSS::StyleValueVector {
CSS::LengthStyleValue::create(CSS::Length::make_px(offset.x())),
CSS::LengthStyleValue::create(CSS::Length::make_px(offset.y())),
});
// 6. Set writingMode to the computed value of writing-mode on capturedElements new element.
writing_mode = captured_element->new_element->layout_node()->computed_values().writing_mode();