ScaleStyleValue.h 1.2 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 ScaleStyleValue : public StyleValueWithDefaultOperators<ScaleStyleValue> {
  11. public:
  12. static ValueComparingNonnullRefPtr<ScaleStyleValue> create(NumberPercentage x, NumberPercentage y)
  13. {
  14. return adopt_ref(*new (nothrow) ScaleStyleValue(move(x), move(y)));
  15. }
  16. virtual ~ScaleStyleValue() override = default;
  17. NumberPercentage const& x() const { return m_properties.x; }
  18. NumberPercentage const& y() const { return m_properties.y; }
  19. virtual String to_string(SerializationMode) const override;
  20. bool properties_equal(ScaleStyleValue const& other) const { return m_properties == other.m_properties; }
  21. private:
  22. explicit ScaleStyleValue(
  23. NumberPercentage x,
  24. NumberPercentage y)
  25. : StyleValueWithDefaultOperators(Type::Scale)
  26. , m_properties {
  27. .x = move(x),
  28. .y = move(y),
  29. }
  30. {
  31. }
  32. struct Properties {
  33. NumberPercentage x;
  34. NumberPercentage y;
  35. bool operator==(Properties const&) const = default;
  36. } m_properties;
  37. };
  38. }