summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/CSS
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2023-02-15 11:28:23 +0000
committerTim Flynn <trflynn89@pm.me>2023-02-15 12:48:26 -0500
commitbee32b6cd23e8cfb4cc4f2ad1c691f457d7f4e45 (patch)
treec270a0d7fa885898b5406420ca6ae3c6462e5046 /Userland/Libraries/LibWeb/CSS
parenta168cda4a789b32d4d627daf344e081db6d1848f (diff)
downloadserenity-bee32b6cd23e8cfb4cc4f2ad1c691f457d7f4e45.zip
LibWeb: Port CSS::Parser::Declaration to new Strings
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS')
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/Declaration.cpp14
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/Declaration.h9
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/DeclarationOrAtRule.cpp2
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp4
4 files changed, 15 insertions, 14 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Declaration.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Declaration.cpp
index e38aa497fa..1ae3732321 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Declaration.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Declaration.cpp
@@ -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
*/
@@ -10,7 +10,7 @@
namespace Web::CSS::Parser {
-Declaration::Declaration(DeprecatedFlyString name, Vector<ComponentValue> values, Important important)
+Declaration::Declaration(FlyString name, Vector<ComponentValue> values, Important important)
: m_name(move(name))
, m_values(move(values))
, m_important(move(important))
@@ -19,18 +19,18 @@ Declaration::Declaration(DeprecatedFlyString name, Vector<ComponentValue> values
Declaration::~Declaration() = default;
-DeprecatedString Declaration::to_deprecated_string() const
+ErrorOr<String> Declaration::to_string() const
{
StringBuilder builder;
serialize_an_identifier(builder, m_name);
- builder.append(": "sv);
- builder.join(' ', m_values);
+ TRY(builder.try_append(": "sv));
+ TRY(builder.try_join(' ', m_values));
if (m_important == Important::Yes)
- builder.append(" !important"sv);
+ TRY(builder.try_append(" !important"sv));
- return builder.to_deprecated_string();
+ return builder.to_string();
}
}
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Declaration.h b/Userland/Libraries/LibWeb/CSS/Parser/Declaration.h
index 35f0dc1a6c..a8da2664e2 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Declaration.h
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Declaration.h
@@ -1,12 +1,13 @@
/*
* Copyright (c) 2020-2021, the SerenityOS developers.
+ * Copyright (c) 2022-2023, Sam Atkins <atkinssj@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
-#include <AK/DeprecatedString.h>
+#include <AK/FlyString.h>
#include <AK/Vector.h>
#include <LibWeb/CSS/CSSStyleDeclaration.h>
#include <LibWeb/CSS/Parser/ComponentValue.h>
@@ -15,17 +16,17 @@ namespace Web::CSS::Parser {
class Declaration {
public:
- Declaration(DeprecatedFlyString name, Vector<ComponentValue> values, Important);
+ Declaration(FlyString name, Vector<ComponentValue> values, Important);
~Declaration();
StringView name() const { return m_name; }
Vector<ComponentValue> const& values() const { return m_values; }
Important importance() const { return m_important; }
- DeprecatedString to_deprecated_string() const;
+ ErrorOr<String> to_string() const;
private:
- DeprecatedFlyString m_name;
+ FlyString m_name;
Vector<ComponentValue> m_values;
Important m_important { Important::No };
};
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/DeclarationOrAtRule.cpp b/Userland/Libraries/LibWeb/CSS/Parser/DeclarationOrAtRule.cpp
index e26ee5ec28..cee9589a9e 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/DeclarationOrAtRule.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Parser/DeclarationOrAtRule.cpp
@@ -33,7 +33,7 @@ DeprecatedString DeclarationOrAtRule::to_deprecated_string() const
builder.append(m_at->to_deprecated_string());
break;
case DeclarationType::Declaration:
- builder.append(m_declaration->to_deprecated_string());
+ builder.append(m_declaration->to_string().release_value_but_fixme_should_propagate_errors());
break;
}
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
index 2b12a82016..ebcee80605 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
@@ -1395,7 +1395,7 @@ Optional<Supports::Feature> Parser::parse_supports_feature(TokenStream<Component
if (auto declaration = consume_a_declaration(block_tokens); declaration.has_value()) {
transaction.commit();
return Supports::Feature {
- Supports::Declaration { declaration->to_deprecated_string() }
+ Supports::Declaration { declaration->to_string().release_value_but_fixme_should_propagate_errors().to_deprecated_string() }
};
}
}
@@ -1856,7 +1856,7 @@ Optional<Declaration> Parser::consume_a_declaration(TokenStream<T>& tokens)
// Create a new declaration with its name set to the value of the current input token
// and its value initially set to the empty list.
// NOTE: We create a fully-initialized Declaration just before returning it instead.
- DeprecatedFlyString declaration_name = ((Token)token).ident();
+ auto declaration_name = FlyString::from_utf8(((Token)token).ident()).release_value_but_fixme_should_propagate_errors();
Vector<ComponentValue> declaration_values;
Important declaration_important = Important::No;