2023-03-24 14:59:33 -03:00
|
|
|
/*
|
2024-10-04 08:19:50 -03:00
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org>
|
2023-03-24 14:59:33 -03:00
|
|
|
* Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
|
2025-01-15 11:53:18 -03:00
|
|
|
* Copyright (c) 2021-2025, Sam Atkins <sam@ladybird.org>
|
2023-03-24 14:59:33 -03:00
|
|
|
* Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2025-12-17 13:40:48 -03:00
|
|
|
#include <LibGfx/Matrix4x4.h>
|
2025-08-08 06:11:51 -03:00
|
|
|
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
2023-03-24 14:59:33 -03:00
|
|
|
#include <LibWeb/CSS/TransformFunctions.h>
|
|
|
|
|
|
|
|
|
|
namespace Web::CSS {
|
|
|
|
|
|
|
|
|
|
class TransformationStyleValue final : public StyleValueWithDefaultOperators<TransformationStyleValue> {
|
|
|
|
|
public:
|
2025-04-15 18:18:27 -03:00
|
|
|
static ValueComparingNonnullRefPtr<TransformationStyleValue const> create(PropertyID property, TransformFunction transform_function, StyleValueVector&& values)
|
2023-03-24 14:59:33 -03:00
|
|
|
{
|
2025-01-15 11:58:23 -03:00
|
|
|
return adopt_ref(*new (nothrow) TransformationStyleValue(property, transform_function, move(values)));
|
2023-03-24 14:59:33 -03:00
|
|
|
}
|
|
|
|
|
virtual ~TransformationStyleValue() override = default;
|
|
|
|
|
|
2025-11-14 09:41:32 -03:00
|
|
|
static ValueComparingNonnullRefPtr<TransformationStyleValue const> identity_transformation(TransformFunction);
|
|
|
|
|
|
2025-01-15 11:53:18 -03:00
|
|
|
TransformFunction transform_function() const { return m_properties.transform_function; }
|
|
|
|
|
StyleValueVector const& values() const { return m_properties.values; }
|
2023-03-24 14:59:33 -03:00
|
|
|
|
2025-12-17 13:40:48 -03:00
|
|
|
ErrorOr<FloatMatrix4x4> to_matrix(Optional<Painting::PaintableBox const&>) const;
|
2025-01-15 13:03:06 -03:00
|
|
|
|
2026-01-08 09:02:18 -03:00
|
|
|
virtual void serialize(StringBuilder&, SerializationMode) const override;
|
2025-12-17 11:43:22 -03:00
|
|
|
ErrorOr<GC::Ref<CSSTransformComponent>> reify_a_transform_function(JS::Realm&) const;
|
2023-03-24 14:59:33 -03:00
|
|
|
|
2025-10-21 08:48:32 -03:00
|
|
|
virtual ValueComparingNonnullRefPtr<StyleValue const> absolutized(ComputationContext const&) const override;
|
2025-10-01 01:57:35 -03:00
|
|
|
|
2023-03-24 14:59:33 -03:00
|
|
|
bool properties_equal(TransformationStyleValue const& other) const { return m_properties == other.m_properties; }
|
|
|
|
|
|
2026-03-08 00:19:00 -03:00
|
|
|
virtual bool is_computationally_independent() const override
|
|
|
|
|
{
|
|
|
|
|
return all_of(m_properties.values, [](auto& value) { return value->is_computationally_independent(); });
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-24 14:59:33 -03:00
|
|
|
private:
|
2025-01-15 11:58:23 -03:00
|
|
|
TransformationStyleValue(PropertyID property, TransformFunction transform_function, StyleValueVector&& values)
|
2023-03-24 14:59:33 -03:00
|
|
|
: StyleValueWithDefaultOperators(Type::Transformation)
|
2025-01-15 11:58:23 -03:00
|
|
|
, m_properties { .property = property, .transform_function = transform_function, .values = move(values) }
|
2023-03-24 14:59:33 -03:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct Properties {
|
2025-01-15 11:58:23 -03:00
|
|
|
PropertyID property;
|
|
|
|
|
TransformFunction transform_function;
|
2023-03-24 14:59:33 -03:00
|
|
|
StyleValueVector values;
|
|
|
|
|
bool operator==(Properties const& other) const;
|
|
|
|
|
} m_properties;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|