TranslationStyleValue.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright (c) 2024, Andreas Kling <andreas@ladybird.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/CSS/CSSStyleValue.h>
  8. #include <LibWeb/CSS/PercentageOr.h>
  9. namespace Web::CSS {
  10. class TranslationStyleValue : public StyleValueWithDefaultOperators<TranslationStyleValue> {
  11. public:
  12. static ValueComparingNonnullRefPtr<TranslationStyleValue> create(LengthPercentage x, LengthPercentage y)
  13. {
  14. return adopt_ref(*new (nothrow) TranslationStyleValue(move(x), move(y)));
  15. }
  16. virtual ~TranslationStyleValue() override = default;
  17. LengthPercentage const& x() const { return m_properties.x; }
  18. LengthPercentage const& y() const { return m_properties.y; }
  19. virtual String to_string() const override;
  20. bool properties_equal(TranslationStyleValue const& other) const { return m_properties == other.m_properties; }
  21. private:
  22. explicit TranslationStyleValue(
  23. LengthPercentage x,
  24. LengthPercentage y)
  25. : StyleValueWithDefaultOperators(Type::Translation)
  26. , m_properties {
  27. .x = move(x),
  28. .y = move(y),
  29. }
  30. {
  31. }
  32. struct Properties {
  33. LengthPercentage x;
  34. LengthPercentage y;
  35. bool operator==(Properties const&) const = default;
  36. } m_properties;
  37. };
  38. }