ContentStyleValue.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 ContentStyleValue final : public StyleValueWithDefaultOperators<ContentStyleValue> {
  13. public:
  14. static ValueComparingNonnullRefPtr<ContentStyleValue> create(ValueComparingNonnullRefPtr<StyleValueList> content, ValueComparingRefPtr<StyleValueList> alt_text)
  15. {
  16. return adopt_ref(*new ContentStyleValue(move(content), move(alt_text)));
  17. }
  18. virtual ~ContentStyleValue() override = default;
  19. StyleValueList const& content() const { return *m_properties.content; }
  20. bool has_alt_text() const { return !m_properties.alt_text.is_null(); }
  21. StyleValueList const* alt_text() const { return m_properties.alt_text; }
  22. virtual ErrorOr<String> to_string() const override;
  23. bool properties_equal(ContentStyleValue const& other) const { return m_properties == other.m_properties; };
  24. private:
  25. ContentStyleValue(ValueComparingNonnullRefPtr<StyleValueList> content, ValueComparingRefPtr<StyleValueList> alt_text)
  26. : StyleValueWithDefaultOperators(Type::Content)
  27. , m_properties { .content = move(content), .alt_text = move(alt_text) }
  28. {
  29. }
  30. struct Properties {
  31. ValueComparingNonnullRefPtr<StyleValueList> content;
  32. ValueComparingRefPtr<StyleValueList> alt_text;
  33. bool operator==(Properties const&) const;
  34. } m_properties;
  35. };
  36. }