BorderStyleValue.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 BorderStyleValue final : public StyleValueWithDefaultOperators<BorderStyleValue> {
  13. public:
  14. static ValueComparingNonnullRefPtr<BorderStyleValue> create(
  15. ValueComparingNonnullRefPtr<StyleValue> border_width,
  16. ValueComparingNonnullRefPtr<StyleValue> border_style,
  17. ValueComparingNonnullRefPtr<StyleValue> border_color)
  18. {
  19. return adopt_ref(*new BorderStyleValue(move(border_width), move(border_style), move(border_color)));
  20. }
  21. virtual ~BorderStyleValue() override;
  22. ValueComparingNonnullRefPtr<StyleValue> border_width() const { return m_properties.border_width; }
  23. ValueComparingNonnullRefPtr<StyleValue> border_style() const { return m_properties.border_style; }
  24. ValueComparingNonnullRefPtr<StyleValue> border_color() const { return m_properties.border_color; }
  25. virtual ErrorOr<String> to_string() const override;
  26. bool properties_equal(BorderStyleValue const& other) const { return m_properties == other.m_properties; }
  27. private:
  28. BorderStyleValue(
  29. ValueComparingNonnullRefPtr<StyleValue> border_width,
  30. ValueComparingNonnullRefPtr<StyleValue> border_style,
  31. ValueComparingNonnullRefPtr<StyleValue> border_color);
  32. struct Properties {
  33. ValueComparingNonnullRefPtr<StyleValue> border_width;
  34. ValueComparingNonnullRefPtr<StyleValue> border_style;
  35. ValueComparingNonnullRefPtr<StyleValue> border_color;
  36. bool operator==(Properties const&) const = default;
  37. } m_properties;
  38. };
  39. }