1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 23:17:46 +00:00

AK+Everywhere: Rename String to DeprecatedString

We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
This commit is contained in:
Linus Groh 2022-12-04 18:02:33 +00:00 committed by Andreas Kling
parent f74251606d
commit 6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions

View file

@ -103,7 +103,7 @@ static ErrorOr<JsonObject, Error> validate_capabilities(JsonValue const& capabil
else if (name.is_one_of("browserName"sv, "browser_version"sv, "platformName"sv)) {
// If value is not a string return an error with error code invalid argument. Otherwise, let deserialized be set to value.
if (!value.is_string())
return Error::from_code(ErrorCode::InvalidArgument, String::formatted("Capability {} must be a string", name));
return Error::from_code(ErrorCode::InvalidArgument, DeprecatedString::formatted("Capability {} must be a string", name));
deserialized = value;
}
@ -149,7 +149,7 @@ static ErrorOr<JsonObject, Error> validate_capabilities(JsonValue const& capabil
// -> The remote end is an endpoint node
else {
// Return an error with error code invalid argument.
return Error::from_code(ErrorCode::InvalidArgument, String::formatted("Unrecognized capability: {}", name));
return Error::from_code(ErrorCode::InvalidArgument, DeprecatedString::formatted("Unrecognized capability: {}", name));
}
// d. If deserialized is not null, set a property on result with name name and value deserialized.
@ -192,7 +192,7 @@ static ErrorOr<JsonObject, Error> merge_capabilities(JsonObject const& primary,
// d. If primary value is not undefined, return an error with error code invalid argument.
if (primary_value != nullptr)
return Error::from_code(ErrorCode::InvalidArgument, String::formatted("Unable to merge capability {}", name));
return Error::from_code(ErrorCode::InvalidArgument, DeprecatedString::formatted("Unable to merge capability {}", name));
// e. Set a property on result with name name and value value.
result.set(name, value);

View file

@ -8,9 +8,9 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/Error.h>
#include <AK/NonnullOwnPtrVector.h>
#include <AK/String.h>
#include <AK/Variant.h>
#include <LibCore/Object.h>
#include <LibCore/Stream.h>

View file

@ -12,7 +12,7 @@ namespace Web::WebDriver {
struct ErrorCodeData {
ErrorCode error_code;
unsigned http_status;
String json_error_code;
DeprecatedString json_error_code;
};
// https://w3c.github.io/webdriver/#dfn-error-code
@ -47,7 +47,7 @@ static Vector<ErrorCodeData> const s_error_code_data = {
{ ErrorCode::UnsupportedOperation, 500, "unsupported operation" },
};
Error Error::from_code(ErrorCode code, String message, Optional<JsonValue> data)
Error Error::from_code(ErrorCode code, DeprecatedString message, Optional<JsonValue> data)
{
auto const& error_code_data = s_error_code_data[to_underlying(code)];
return {

View file

@ -7,8 +7,8 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/JsonValue.h>
#include <AK/String.h>
namespace Web::WebDriver {
@ -47,11 +47,11 @@ enum class ErrorCode {
// https://w3c.github.io/webdriver/#errors
struct Error {
unsigned http_status;
String error;
String message;
DeprecatedString error;
DeprecatedString message;
Optional<JsonValue> data;
static Error from_code(ErrorCode, String message, Optional<JsonValue> data = {});
static Error from_code(ErrorCode, DeprecatedString message, Optional<JsonValue> data = {});
};
}
@ -60,6 +60,6 @@ template<>
struct AK::Formatter<Web::WebDriver::Error> : Formatter<StringView> {
ErrorOr<void> format(FormatBuilder& builder, Web::WebDriver::Error const& error)
{
return Formatter<StringView>::format(builder, String::formatted("Error {}, {}: {}", error.http_status, error.error, error.message));
return Formatter<StringView>::format(builder, DeprecatedString::formatted("Error {}, {}: {}", error.http_status, error.error, error.message));
}
};

View file

@ -204,7 +204,7 @@ static ErrorOr<JsonValue, ExecuteScriptResultType> clone_an_object(JS::Realm& re
}
// https://w3c.github.io/webdriver/#dfn-execute-a-function-body
static JS::ThrowCompletionOr<JS::Value> execute_a_function_body(Web::Page& page, String const& body, JS::MarkedVector<JS::Value> parameters)
static JS::ThrowCompletionOr<JS::Value> execute_a_function_body(Web::Page& page, DeprecatedString const& body, JS::MarkedVector<JS::Value> parameters)
{
// FIXME: If at any point during the algorithm a user prompt appears, immediately return Completion { [[Type]]: normal, [[Value]]: null, [[Target]]: empty }, but continue to run the other steps of this algorithm in parallel.
@ -221,7 +221,7 @@ static JS::ThrowCompletionOr<JS::Value> execute_a_function_body(Web::Page& page,
auto& realm = window.realm();
bool contains_direct_call_to_eval = false;
auto source_text = String::formatted("function() {{ {} }}", body);
auto source_text = DeprecatedString::formatted("function() {{ {} }}", body);
auto parser = JS::Parser { JS::Lexer { source_text } };
auto function_expression = parser.parse_function_node<JS::FunctionExpression>();
@ -266,7 +266,7 @@ static JS::ThrowCompletionOr<JS::Value> execute_a_function_body(Web::Page& page,
return completion;
}
ExecuteScriptResultSerialized execute_script(Web::Page& page, String const& body, JS::MarkedVector<JS::Value> arguments, Optional<u64> const& timeout)
ExecuteScriptResultSerialized execute_script(Web::Page& page, DeprecatedString const& body, JS::MarkedVector<JS::Value> arguments, Optional<u64> const& timeout)
{
// FIXME: Use timeout.
(void)timeout;
@ -307,7 +307,7 @@ ExecuteScriptResultSerialized execute_script(Web::Page& page, String const& body
return { result.type, json_value_or_error.release_value() };
}
ExecuteScriptResultSerialized execute_async_script(Web::Page& page, String const& body, JS::MarkedVector<JS::Value> arguments, Optional<u64> const& timeout)
ExecuteScriptResultSerialized execute_async_script(Web::Page& page, DeprecatedString const& body, JS::MarkedVector<JS::Value> arguments, Optional<u64> const& timeout)
{
auto* window = page.top_level_browsing_context().active_window();
auto& realm = window->realm();

View file

@ -31,7 +31,7 @@ struct ExecuteScriptResultSerialized {
JsonValue value;
};
ExecuteScriptResultSerialized execute_script(Page& page, String const& body, JS::MarkedVector<JS::Value> arguments, Optional<u64> const& timeout);
ExecuteScriptResultSerialized execute_async_script(Page& page, String const& body, JS::MarkedVector<JS::Value> arguments, Optional<u64> const& timeout);
ExecuteScriptResultSerialized execute_script(Page& page, DeprecatedString const& body, JS::MarkedVector<JS::Value> arguments, Optional<u64> const& timeout);
ExecuteScriptResultSerialized execute_async_script(Page& page, DeprecatedString const& body, JS::MarkedVector<JS::Value> arguments, Optional<u64> const& timeout);
}