1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:07:35 +00:00

LibWeb: Rename StyleComponentValueRule -> ComponentValue

"Component value" is the term used in the spec, and it doesn't conflict
 with any other types, so let's use the shorter name. :^)

Also, this doesn't need to be friends with the Parser any more.
This commit is contained in:
Sam Atkins 2022-03-31 11:43:07 +01:00 committed by Andreas Kling
parent 17632c3d2d
commit 8b538b1578
11 changed files with 216 additions and 217 deletions

View file

@ -0,0 +1,44 @@
/*
* Copyright (c) 2020-2021, the SerenityOS developers.
* Copyright (c) 2021-2022, Sam Atkins <atkinssj@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/NonnullRefPtr.h>
#include <AK/RefPtr.h>
#include <LibWeb/CSS/Parser/Token.h>
namespace Web::CSS {
class StyleBlockRule;
class StyleFunctionRule;
// https://www.w3.org/TR/css-syntax-3/#component-value
class ComponentValue {
public:
ComponentValue(Token);
explicit ComponentValue(NonnullRefPtr<StyleFunctionRule>);
explicit ComponentValue(NonnullRefPtr<StyleBlockRule>);
~ComponentValue();
bool is_block() const { return m_value.has<NonnullRefPtr<StyleBlockRule>>(); }
StyleBlockRule const& block() const { return m_value.get<NonnullRefPtr<StyleBlockRule>>(); }
bool is_function() const { return m_value.has<NonnullRefPtr<StyleFunctionRule>>(); }
StyleFunctionRule const& function() const { return m_value.get<NonnullRefPtr<StyleFunctionRule>>(); }
bool is_token() const { return m_value.has<Token>(); }
bool is(Token::Type type) const { return is_token() && token().is(type); }
Token const& token() const { return m_value.get<Token>(); }
operator Token() const { return m_value.get<Token>(); }
String to_string() const;
String to_debug_string() const;
private:
Variant<Token, NonnullRefPtr<StyleFunctionRule>, NonnullRefPtr<StyleBlockRule>> m_value;
};
}