BackgroundSizeStyleValue.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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/Length.h>
  11. #include <LibWeb/CSS/Percentage.h>
  12. #include <LibWeb/CSS/StyleValue.h>
  13. namespace Web::CSS {
  14. // NOTE: This is not used for identifier sizes, like `cover` and `contain`.
  15. class BackgroundSizeStyleValue final : public StyleValueWithDefaultOperators<BackgroundSizeStyleValue> {
  16. public:
  17. static ValueComparingNonnullRefPtr<BackgroundSizeStyleValue> create(LengthPercentage size_x, LengthPercentage size_y)
  18. {
  19. return adopt_ref(*new BackgroundSizeStyleValue(size_x, size_y));
  20. }
  21. virtual ~BackgroundSizeStyleValue() override;
  22. LengthPercentage size_x() const { return m_properties.size_x; }
  23. LengthPercentage size_y() const { return m_properties.size_y; }
  24. virtual ErrorOr<String> to_string() const override;
  25. bool properties_equal(BackgroundSizeStyleValue const& other) const { return m_properties == other.m_properties; }
  26. private:
  27. BackgroundSizeStyleValue(LengthPercentage size_x, LengthPercentage size_y);
  28. struct Properties {
  29. LengthPercentage size_x;
  30. LengthPercentage size_y;
  31. bool operator==(Properties const&) const = default;
  32. } m_properties;
  33. };
  34. }