EdgeStyleValue.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (c) 2023, MacDue <macdue@dueutil.tech>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/CSS/Enums.h>
  8. #include <LibWeb/CSS/PercentageOr.h>
  9. #include <LibWeb/CSS/StyleValue.h>
  10. namespace Web::CSS {
  11. class EdgeStyleValue final : public StyleValueWithDefaultOperators<EdgeStyleValue> {
  12. public:
  13. static ValueComparingNonnullRefPtr<EdgeStyleValue> create(PositionEdge edge, LengthPercentage const& offset)
  14. {
  15. return adopt_ref(*new (nothrow) EdgeStyleValue(edge, offset));
  16. }
  17. virtual ~EdgeStyleValue() override = default;
  18. PositionEdge edge() const { return m_properties.edge; }
  19. LengthPercentage const& offset() const { return m_properties.offset; }
  20. virtual String to_string() const override;
  21. bool properties_equal(EdgeStyleValue const& other) const { return m_properties == other.m_properties; }
  22. private:
  23. EdgeStyleValue(PositionEdge edge, LengthPercentage const& offset)
  24. : StyleValueWithDefaultOperators(Type::Edge)
  25. , m_properties { .edge = edge, .offset = offset }
  26. {
  27. }
  28. struct Properties {
  29. PositionEdge edge;
  30. LengthPercentage offset;
  31. bool operator==(Properties const&) const = default;
  32. } m_properties;
  33. };
  34. }