mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-06-21 08:35:24 +00:00
Parameter values are absolutized at style computation time (or are confirmed to be resolvable in the case of reification or DOMMatrix) so there is no reason this function should fail.
61 lines
2.4 KiB
C++
61 lines
2.4 KiB
C++
/*
|
|
* Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org>
|
|
* Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
|
|
* Copyright (c) 2021-2025, Sam Atkins <sam@ladybird.org>
|
|
* Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibGfx/Matrix4x4.h>
|
|
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
|
#include <LibWeb/CSS/TransformFunctions.h>
|
|
|
|
namespace Web::CSS {
|
|
|
|
class TransformationStyleValue final : public StyleValueWithDefaultOperators<TransformationStyleValue> {
|
|
public:
|
|
static ValueComparingNonnullRefPtr<TransformationStyleValue const> create(PropertyID property, TransformFunction transform_function, StyleValueVector&& values)
|
|
{
|
|
return adopt_ref(*new (nothrow) TransformationStyleValue(property, transform_function, move(values)));
|
|
}
|
|
virtual ~TransformationStyleValue() override = default;
|
|
|
|
static ValueComparingNonnullRefPtr<TransformationStyleValue const> identity_transformation(TransformFunction);
|
|
|
|
TransformFunction transform_function() const { return m_properties.transform_function; }
|
|
StyleValueVector const& values() const { return m_properties.values; }
|
|
|
|
bool can_be_converted_to_matrix_without_reference_box() const;
|
|
FloatMatrix4x4 to_matrix(Optional<Painting::PaintableBox const&>) const;
|
|
|
|
virtual void serialize(StringBuilder&, SerializationMode) const override;
|
|
GC::Ptr<CSSTransformComponent> reify_a_transform_function(JS::Realm&) const;
|
|
|
|
virtual ValueComparingNonnullRefPtr<StyleValue const> absolutized(ComputationContext const&) const override;
|
|
|
|
bool properties_equal(TransformationStyleValue const& other) const { return m_properties == other.m_properties; }
|
|
|
|
virtual bool is_computationally_independent() const override
|
|
{
|
|
return all_of(m_properties.values, [](auto& value) { return value->is_computationally_independent(); });
|
|
}
|
|
|
|
private:
|
|
TransformationStyleValue(PropertyID property, TransformFunction transform_function, StyleValueVector&& values)
|
|
: StyleValueWithDefaultOperators(Type::Transformation)
|
|
, m_properties { .property = property, .transform_function = transform_function, .values = move(values) }
|
|
{
|
|
}
|
|
|
|
struct Properties {
|
|
PropertyID property;
|
|
TransformFunction transform_function;
|
|
StyleValueVector values;
|
|
bool operator==(Properties const& other) const;
|
|
} m_properties;
|
|
};
|
|
|
|
}
|