RectStyleValue.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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/StyleValue.h>
  11. namespace Web::CSS {
  12. class RectStyleValue : public StyleValueWithDefaultOperators<RectStyleValue> {
  13. public:
  14. static ValueComparingNonnullRefPtr<RectStyleValue> create(EdgeRect rect);
  15. virtual ~RectStyleValue() override = default;
  16. EdgeRect rect() const { return m_rect; }
  17. virtual ErrorOr<String> to_string() const override;
  18. virtual bool has_rect() const override { return true; }
  19. virtual EdgeRect to_rect() const override { return m_rect; }
  20. bool properties_equal(RectStyleValue const& other) const { return m_rect == other.m_rect; }
  21. private:
  22. explicit RectStyleValue(EdgeRect rect)
  23. : StyleValueWithDefaultOperators(Type::Rect)
  24. , m_rect(rect)
  25. {
  26. }
  27. EdgeRect m_rect;
  28. };
  29. }