PositionStyleValue.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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/Enums.h>
  11. #include <LibWeb/CSS/PercentageOr.h>
  12. #include <LibWeb/CSS/StyleValue.h>
  13. #include <LibWeb/CSS/StyleValues/EdgeStyleValue.h>
  14. namespace Web::CSS {
  15. class PositionStyleValue final : public StyleValueWithDefaultOperators<PositionStyleValue> {
  16. public:
  17. static ValueComparingNonnullRefPtr<PositionStyleValue> create(ValueComparingNonnullRefPtr<EdgeStyleValue> edge_x, ValueComparingNonnullRefPtr<EdgeStyleValue> edge_y)
  18. {
  19. return adopt_ref(*new (nothrow) PositionStyleValue(move(edge_x), move(edge_y)));
  20. }
  21. virtual ~PositionStyleValue() override = default;
  22. ValueComparingNonnullRefPtr<EdgeStyleValue> edge_x() const { return m_properties.edge_x; }
  23. ValueComparingNonnullRefPtr<EdgeStyleValue> edge_y() const { return m_properties.edge_y; }
  24. virtual String to_string() const override;
  25. bool properties_equal(PositionStyleValue const& other) const { return m_properties == other.m_properties; }
  26. private:
  27. PositionStyleValue(ValueComparingNonnullRefPtr<EdgeStyleValue> edge_x, ValueComparingNonnullRefPtr<EdgeStyleValue> edge_y)
  28. : StyleValueWithDefaultOperators(Type::Position)
  29. , m_properties { .edge_x = edge_x, .edge_y = edge_y }
  30. {
  31. }
  32. struct Properties {
  33. ValueComparingNonnullRefPtr<EdgeStyleValue> edge_x;
  34. ValueComparingNonnullRefPtr<EdgeStyleValue> edge_y;
  35. bool operator==(Properties const&) const = default;
  36. } m_properties;
  37. };
  38. }