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>
|
2024-08-14 11:46:56 +01:00
|
|
|
* Copyright (c) 2021-2024, Sam Atkins <sam@ladybird.org>
|
2023-03-24 15:04:24 +00:00
|
|
|
* Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2024-08-14 11:10:54 +01:00
|
|
|
#include <LibWeb/CSS/CSSStyleValue.h>
|
2024-08-14 14:06:03 +01:00
|
|
|
#include <LibWeb/CSS/Keyword.h>
|
2023-03-24 15:04:24 +00:00
|
|
|
|
|
|
|
namespace Web::CSS {
|
|
|
|
|
2024-08-14 11:46:56 +01:00
|
|
|
// https://drafts.css-houdini.org/css-typed-om-1/#csskeywordvalue
|
|
|
|
class CSSKeywordValue final : public StyleValueWithDefaultOperators<CSSKeywordValue> {
|
2023-03-24 15:04:24 +00:00
|
|
|
public:
|
2024-08-14 14:06:03 +01:00
|
|
|
static ValueComparingNonnullRefPtr<CSSKeywordValue> create(Keyword keyword)
|
2023-03-24 15:04:24 +00:00
|
|
|
{
|
2024-08-14 14:06:03 +01:00
|
|
|
return adopt_ref(*new (nothrow) CSSKeywordValue(keyword));
|
2023-03-24 15:04:24 +00:00
|
|
|
}
|
2024-08-14 11:46:56 +01:00
|
|
|
virtual ~CSSKeywordValue() override = default;
|
2023-03-24 15:04:24 +00:00
|
|
|
|
2024-08-14 14:06:03 +01:00
|
|
|
Keyword keyword() const { return m_keyword; }
|
2023-03-24 15:04:24 +00:00
|
|
|
|
2024-08-14 14:06:03 +01:00
|
|
|
static bool is_color(Keyword);
|
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
|
|
|
|
2024-08-14 14:06:03 +01:00
|
|
|
bool properties_equal(CSSKeywordValue const& other) const { return m_keyword == other.m_keyword; }
|
2023-03-24 15:04:24 +00:00
|
|
|
|
|
|
|
private:
|
2024-08-14 14:06:03 +01:00
|
|
|
explicit CSSKeywordValue(Keyword keyword)
|
2024-08-14 11:46:56 +01:00
|
|
|
: StyleValueWithDefaultOperators(Type::Keyword)
|
2024-08-14 14:06:03 +01:00
|
|
|
, m_keyword(keyword)
|
2023-03-24 15:04:24 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-08-14 14:06:03 +01:00
|
|
|
Keyword m_keyword { Keyword::Invalid };
|
2023-03-24 15:04:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|