2023-03-24 17:48:42 +00:00
|
|
|
/*
|
2024-07-17 12:42:12 +01:00
|
|
|
* Copyright (c) 2022-2024, Sam Atkins <atkinssj@serenityos.org>
|
2023-03-24 17:48:42 +00:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2024-07-17 12:42:12 +01:00
|
|
|
#include <AK/FlyString.h>
|
2025-09-09 13:37:30 +01:00
|
|
|
#include <LibWeb/CSS/Parser/ComponentValue.h>
|
2025-04-03 11:34:23 +01:00
|
|
|
#include <LibWeb/CSS/Serialize.h>
|
2025-08-08 10:11:51 +01:00
|
|
|
#include <LibWeb/CSS/StyleValues/StyleValue.h>
|
2023-03-24 17:48:42 +00:00
|
|
|
|
|
|
|
namespace Web::CSS {
|
|
|
|
|
|
|
|
class StringStyleValue : public StyleValueWithDefaultOperators<StringStyleValue> {
|
|
|
|
public:
|
2025-04-15 15:18:27 -06:00
|
|
|
static ValueComparingNonnullRefPtr<StringStyleValue const> create(FlyString const& string)
|
2023-03-24 17:48:42 +00:00
|
|
|
{
|
2023-08-19 14:00:10 +01:00
|
|
|
return adopt_ref(*new (nothrow) StringStyleValue(string));
|
2023-03-24 17:48:42 +00:00
|
|
|
}
|
|
|
|
virtual ~StringStyleValue() override = default;
|
|
|
|
|
2024-09-30 14:14:10 +01:00
|
|
|
FlyString const& string_value() const { return m_string; }
|
2024-12-07 00:59:49 +01:00
|
|
|
virtual String to_string(SerializationMode) const override { return serialize_a_string(m_string); }
|
2025-07-10 12:17:27 +01:00
|
|
|
virtual Vector<Parser::ComponentValue> tokenize() const override
|
|
|
|
{
|
|
|
|
return { Parser::Token::create_string(m_string) };
|
|
|
|
}
|
2023-03-24 17:48:42 +00:00
|
|
|
|
|
|
|
bool properties_equal(StringStyleValue const& other) const { return m_string == other.m_string; }
|
|
|
|
|
|
|
|
private:
|
2024-07-17 12:42:12 +01:00
|
|
|
explicit StringStyleValue(FlyString const& string)
|
2023-03-24 17:48:42 +00:00
|
|
|
: StyleValueWithDefaultOperators(Type::String)
|
|
|
|
, m_string(string)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-07-17 12:42:12 +01:00
|
|
|
FlyString m_string;
|
2023-03-24 17:48:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|