mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:27:45 +00:00
LibWeb: Port CSS::Parser::Rule to new Strings
`Rule::to_deprecated_string()` and `DeclarationOrAtRule::to_deprecated_string()` are not used anywhere, so we can just delete them.
This commit is contained in:
parent
bee32b6cd2
commit
41c4cc95e4
5 changed files with 10 additions and 49 deletions
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2020-2021, the SerenityOS developers.
|
||||
* Copyright (c) 2021-2022, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -24,20 +24,4 @@ DeclarationOrAtRule::DeclarationOrAtRule(Declaration declaration)
|
|||
|
||||
DeclarationOrAtRule::~DeclarationOrAtRule() = default;
|
||||
|
||||
DeprecatedString DeclarationOrAtRule::to_deprecated_string() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
switch (m_type) {
|
||||
default:
|
||||
case DeclarationType::At:
|
||||
builder.append(m_at->to_deprecated_string());
|
||||
break;
|
||||
case DeclarationType::Declaration:
|
||||
builder.append(m_declaration->to_string().release_value_but_fixme_should_propagate_errors());
|
||||
break;
|
||||
}
|
||||
|
||||
return builder.to_deprecated_string();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2020-2021, the SerenityOS developers.
|
||||
* Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -37,8 +38,6 @@ public:
|
|||
return *m_declaration;
|
||||
}
|
||||
|
||||
DeprecatedString to_deprecated_string() const;
|
||||
|
||||
private:
|
||||
DeclarationType m_type;
|
||||
RefPtr<Rule> m_at;
|
||||
|
|
|
@ -1518,7 +1518,7 @@ NonnullRefPtr<Rule> Parser::consume_an_at_rule(TokenStream<T>& tokens)
|
|||
|
||||
// Create a new at-rule with its name set to the value of the current input token, its prelude initially set to an empty list, and its value initially set to nothing.
|
||||
// NOTE: We create the Rule fully initialized when we return it instead.
|
||||
DeprecatedFlyString at_rule_name = ((Token)name_ident).at_keyword();
|
||||
auto at_rule_name = FlyString::from_utf8(((Token)name_ident).at_keyword()).release_value_but_fixme_should_propagate_errors();
|
||||
Vector<ComponentValue> prelude;
|
||||
RefPtr<Block> block;
|
||||
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2020-2021, the SerenityOS developers.
|
||||
* Copyright (c) 2021-2022, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/CSS/Parser/Rule.h>
|
||||
#include <LibWeb/CSS/Serialize.h>
|
||||
|
||||
namespace Web::CSS::Parser {
|
||||
|
||||
Rule::Rule(Rule::Type type, DeprecatedFlyString name, Vector<ComponentValue> prelude, RefPtr<Block> block)
|
||||
Rule::Rule(Rule::Type type, FlyString name, Vector<ComponentValue> prelude, RefPtr<Block> block)
|
||||
: m_type(type)
|
||||
, m_at_rule_name(move(name))
|
||||
, m_prelude(move(prelude))
|
||||
|
@ -20,23 +19,4 @@ Rule::Rule(Rule::Type type, DeprecatedFlyString name, Vector<ComponentValue> pre
|
|||
|
||||
Rule::~Rule() = default;
|
||||
|
||||
DeprecatedString Rule::to_deprecated_string() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
|
||||
if (is_at_rule()) {
|
||||
builder.append('@');
|
||||
serialize_an_identifier(builder, m_at_rule_name);
|
||||
}
|
||||
|
||||
builder.join(' ', m_prelude);
|
||||
|
||||
if (m_block)
|
||||
builder.append(m_block->to_string().release_value_but_fixme_should_propagate_errors());
|
||||
else
|
||||
builder.append(';');
|
||||
|
||||
return builder.to_deprecated_string();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
/*
|
||||
* Copyright (c) 2020-2021, the SerenityOS developers.
|
||||
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedFlyString.h>
|
||||
#include <AK/FlyString.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibWeb/CSS/Parser/Block.h>
|
||||
|
@ -22,7 +22,7 @@ public:
|
|||
Qualified,
|
||||
};
|
||||
|
||||
static NonnullRefPtr<Rule> make_at_rule(DeprecatedFlyString name, Vector<ComponentValue> prelude, RefPtr<Block> block)
|
||||
static NonnullRefPtr<Rule> make_at_rule(FlyString name, Vector<ComponentValue> prelude, RefPtr<Block> block)
|
||||
{
|
||||
return adopt_ref(*new Rule(Type::At, move(name), move(prelude), move(block)));
|
||||
}
|
||||
|
@ -41,13 +41,11 @@ public:
|
|||
RefPtr<Block const> block() const { return m_block; }
|
||||
StringView at_rule_name() const { return m_at_rule_name; }
|
||||
|
||||
DeprecatedString to_deprecated_string() const;
|
||||
|
||||
private:
|
||||
Rule(Type, DeprecatedFlyString name, Vector<ComponentValue> prelude, RefPtr<Block>);
|
||||
Rule(Type, FlyString name, Vector<ComponentValue> prelude, RefPtr<Block>);
|
||||
|
||||
Type const m_type;
|
||||
DeprecatedFlyString m_at_rule_name;
|
||||
FlyString m_at_rule_name;
|
||||
Vector<ComponentValue> m_prelude;
|
||||
RefPtr<Block> m_block;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue