2023-03-24 15:04:24 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
* Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
|
|
|
|
|
* Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
|
|
|
|
|
* Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <LibWeb/CSS/StyleValue.h>
|
|
|
|
|
#include <LibWeb/CSS/ValueID.h>
|
|
|
|
|
|
|
|
|
|
namespace Web::CSS {
|
|
|
|
|
|
|
|
|
|
class IdentifierStyleValue final : public StyleValueWithDefaultOperators<IdentifierStyleValue> {
|
|
|
|
|
public:
|
2023-08-19 14:00:10 +01:00
|
|
|
static ValueComparingNonnullRefPtr<IdentifierStyleValue> create(ValueID id)
|
2023-03-24 15:04:24 +00:00
|
|
|
{
|
2023-08-19 14:00:10 +01:00
|
|
|
return adopt_ref(*new (nothrow) IdentifierStyleValue(id));
|
2023-03-24 15:04:24 +00:00
|
|
|
}
|
|
|
|
|
virtual ~IdentifierStyleValue() override = default;
|
|
|
|
|
|
|
|
|
|
ValueID id() const { return m_id; }
|
|
|
|
|
|
2023-08-23 15:40:17 +01:00
|
|
|
static bool is_color(ValueID);
|
2023-03-24 15:04:24 +00:00
|
|
|
virtual bool has_color() const override;
|
2023-04-19 18:31:00 +01:00
|
|
|
virtual Color to_color(Optional<Layout::NodeWithStyle const&> node) const override;
|
2023-08-22 14:08:15 +01:00
|
|
|
virtual String to_string() const override;
|
2023-03-24 15:04:24 +00:00
|
|
|
|
|
|
|
|
bool properties_equal(IdentifierStyleValue const& other) const { return m_id == other.m_id; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
explicit IdentifierStyleValue(ValueID id)
|
|
|
|
|
: StyleValueWithDefaultOperators(Type::Identifier)
|
|
|
|
|
, m_id(id)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ValueID m_id { ValueID::Invalid };
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|