IdentifierStyleValue.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 ErrorOr<ValueComparingNonnullRefPtr<IdentifierStyleValue>> create(ValueID id)
  16. {
  17. return adopt_nonnull_ref_or_enomem(new (nothrow) IdentifierStyleValue(id));
  18. }
  19. virtual ~IdentifierStyleValue() override = default;
  20. ValueID id() const { return m_id; }
  21. virtual bool has_color() const override;
  22. virtual Color to_color(Optional<Layout::NodeWithStyle const&> node) const override;
  23. virtual ErrorOr<String> to_string() const override;
  24. bool properties_equal(IdentifierStyleValue const& other) const { return m_id == other.m_id; }
  25. private:
  26. explicit IdentifierStyleValue(ValueID id)
  27. : StyleValueWithDefaultOperators(Type::Identifier)
  28. , m_id(id)
  29. {
  30. }
  31. ValueID m_id { ValueID::Invalid };
  32. };
  33. }