TransformationStyleValue.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. * Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
  4. * Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
  5. * Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
  6. *
  7. * SPDX-License-Identifier: BSD-2-Clause
  8. */
  9. #pragma once
  10. #include <LibWeb/CSS/StyleValue.h>
  11. #include <LibWeb/CSS/TransformFunctions.h>
  12. namespace Web::CSS {
  13. class TransformationStyleValue final : public StyleValueWithDefaultOperators<TransformationStyleValue> {
  14. public:
  15. static ValueComparingNonnullRefPtr<TransformationStyleValue> create(CSS::TransformFunction transform_function, StyleValueVector&& values)
  16. {
  17. return adopt_ref(*new TransformationStyleValue(transform_function, move(values)));
  18. }
  19. virtual ~TransformationStyleValue() override = default;
  20. CSS::TransformFunction transform_function() const { return m_properties.transform_function; }
  21. StyleValueVector values() const { return m_properties.values; }
  22. virtual ErrorOr<String> to_string() const override;
  23. bool properties_equal(TransformationStyleValue const& other) const { return m_properties == other.m_properties; }
  24. private:
  25. TransformationStyleValue(CSS::TransformFunction transform_function, StyleValueVector&& values)
  26. : StyleValueWithDefaultOperators(Type::Transformation)
  27. , m_properties { .transform_function = transform_function, .values = move(values) }
  28. {
  29. }
  30. struct Properties {
  31. CSS::TransformFunction transform_function;
  32. StyleValueVector values;
  33. bool operator==(Properties const& other) const;
  34. } m_properties;
  35. };
  36. }