IdentifierStyleValue.h 1.4 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. #include <LibWeb/CSS/ValueID.h>
  12. namespace Web::CSS {
  13. class IdentifierStyleValue final : public StyleValueWithDefaultOperators<IdentifierStyleValue> {
  14. public:
  15. static ValueComparingNonnullRefPtr<IdentifierStyleValue> create(ValueID id)
  16. {
  17. return adopt_ref(*new IdentifierStyleValue(id));
  18. }
  19. virtual ~IdentifierStyleValue() override = default;
  20. ValueID id() const { return m_id; }
  21. virtual bool has_auto() const override { return m_id == ValueID::Auto; }
  22. virtual bool has_identifier() const override { return true; }
  23. virtual ValueID to_identifier() const override { return m_id; }
  24. virtual bool has_color() const override;
  25. virtual Color to_color(Layout::NodeWithStyle const& node) const override;
  26. virtual ErrorOr<String> to_string() const override;
  27. bool properties_equal(IdentifierStyleValue const& other) const { return m_id == other.m_id; }
  28. private:
  29. explicit IdentifierStyleValue(ValueID id)
  30. : StyleValueWithDefaultOperators(Type::Identifier)
  31. , m_id(id)
  32. {
  33. }
  34. ValueID m_id { ValueID::Invalid };
  35. };
  36. }