IdentifierStyleValue.h 1.2 KB

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