1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:38:11 +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

@ -16,7 +16,7 @@
namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/webappapis.html#creating-a-classic-script
JS::NonnullGCPtr<ClassicScript> ClassicScript::create(String filename, StringView source, EnvironmentSettingsObject& environment_settings_object, AK::URL base_url, size_t source_line_number, MutedErrors muted_errors)
JS::NonnullGCPtr<ClassicScript> ClassicScript::create(DeprecatedString filename, StringView source, EnvironmentSettingsObject& environment_settings_object, AK::URL base_url, size_t source_line_number, MutedErrors muted_errors)
{
auto& vm = environment_settings_object.realm().vm();
@ -148,7 +148,7 @@ JS::Completion ClassicScript::run(RethrowErrors rethrow_errors)
// Return Completion { [[Type]]: throw, [[Value]]: a new "QuotaExceededError" DOMException, [[Target]]: empty }.
}
ClassicScript::ClassicScript(AK::URL base_url, String filename, EnvironmentSettingsObject& environment_settings_object)
ClassicScript::ClassicScript(AK::URL base_url, DeprecatedString filename, EnvironmentSettingsObject& environment_settings_object)
: Script(move(base_url), move(filename), environment_settings_object)
{
}

View file

@ -23,7 +23,7 @@ public:
No,
Yes,
};
static JS::NonnullGCPtr<ClassicScript> create(String filename, StringView source, EnvironmentSettingsObject&, AK::URL base_url, size_t source_line_number = 1, MutedErrors = MutedErrors::No);
static JS::NonnullGCPtr<ClassicScript> create(DeprecatedString filename, StringView source, EnvironmentSettingsObject&, AK::URL base_url, size_t source_line_number = 1, MutedErrors = MutedErrors::No);
JS::Script* script_record() { return m_script_record; }
JS::Script const* script_record() const { return m_script_record; }
@ -37,7 +37,7 @@ public:
MutedErrors muted_errors() const { return m_muted_errors; }
private:
ClassicScript(AK::URL base_url, String filename, EnvironmentSettingsObject& environment_settings_object);
ClassicScript(AK::URL base_url, DeprecatedString filename, EnvironmentSettingsObject& environment_settings_object);
virtual void visit_edges(Cell::Visitor&) override;

View file

@ -301,7 +301,7 @@ bool EnvironmentSettingsObject::is_scripting_disabled() const
}
// https://html.spec.whatwg.org/multipage/webappapis.html#module-type-allowed
bool EnvironmentSettingsObject::module_type_allowed(AK::String const& module_type) const
bool EnvironmentSettingsObject::module_type_allowed(AK::DeprecatedString const& module_type) const
{
// 1. If moduleType is not "javascript", "css", or "json", then return false.
if (module_type != "javascript"sv && module_type != "css"sv && module_type != "json"sv)

View file

@ -23,7 +23,7 @@ struct Environment {
virtual ~Environment() = default;
// An id https://html.spec.whatwg.org/multipage/webappapis.html#concept-environment-id
String id;
DeprecatedString id;
// https://html.spec.whatwg.org/multipage/webappapis.html#concept-environment-creation-url
AK::URL creation_url;
@ -71,7 +71,7 @@ struct EnvironmentSettingsObject
virtual JS::GCPtr<DOM::Document> responsible_document() = 0;
// https://html.spec.whatwg.org/multipage/webappapis.html#api-url-character-encoding
virtual String api_url_character_encoding() = 0;
virtual DeprecatedString api_url_character_encoding() = 0;
// https://html.spec.whatwg.org/multipage/webappapis.html#api-base-url
virtual AK::URL api_base_url() = 0;
@ -113,7 +113,7 @@ struct EnvironmentSettingsObject
bool is_scripting_enabled() const;
bool is_scripting_disabled() const;
bool module_type_allowed(String const& module_type) const;
bool module_type_allowed(DeprecatedString const& module_type) const;
void disallow_further_import_maps();

View file

@ -18,10 +18,10 @@
namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/webappapis.html#module-type-from-module-request
String module_type_from_module_request(JS::ModuleRequest const& module_request)
DeprecatedString module_type_from_module_request(JS::ModuleRequest const& module_request)
{
// 1. Let moduleType be "javascript".
String module_type = "javascript"sv;
DeprecatedString module_type = "javascript"sv;
// 2. If moduleRequest.[[Assertions]] has a Record entry such that entry.[[Key]] is "type", then:
for (auto const& entry : module_request.assertions) {
@ -41,7 +41,7 @@ String module_type_from_module_request(JS::ModuleRequest const& module_request)
}
// https://html.spec.whatwg.org/multipage/webappapis.html#resolve-a-module-specifier
WebIDL::ExceptionOr<AK::URL> resolve_module_specifier(Optional<Script&> referring_script, String const& specifier)
WebIDL::ExceptionOr<AK::URL> resolve_module_specifier(Optional<Script&> referring_script, DeprecatedString const& specifier)
{
// 1. Let settingsObject and baseURL be null.
Optional<EnvironmentSettingsObject&> settings_object;
@ -113,11 +113,11 @@ WebIDL::ExceptionOr<AK::URL> resolve_module_specifier(Optional<Script&> referrin
return as_url.release_value();
// 13. Throw a TypeError indicating that specifier was a bare specifier, but was not remapped to anything by importMap.
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, String::formatted("Failed to resolve non relative module specifier '{}' from an import map.", specifier) };
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, DeprecatedString::formatted("Failed to resolve non relative module specifier '{}' from an import map.", specifier) };
}
// https://html.spec.whatwg.org/multipage/webappapis.html#resolving-an-imports-match
WebIDL::ExceptionOr<Optional<AK::URL>> resolve_imports_match(String const& normalized_specifier, Optional<AK::URL> as_url, ModuleSpecifierMap const& specifier_map)
WebIDL::ExceptionOr<Optional<AK::URL>> resolve_imports_match(DeprecatedString const& normalized_specifier, Optional<AK::URL> as_url, ModuleSpecifierMap const& specifier_map)
{
// 1. For each specifierKey → resolutionResult of specifierMap:
for (auto const& [specifier_key, resolution_result] : specifier_map) {
@ -125,7 +125,7 @@ WebIDL::ExceptionOr<Optional<AK::URL>> resolve_imports_match(String const& norma
if (specifier_key == normalized_specifier) {
// 1. If resolutionResult is null, then throw a TypeError indicating that resolution of specifierKey was blocked by a null entry.
if (!resolution_result.has_value())
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, String::formatted("Import resolution of '{}' was blocked by a null entry.", specifier_key) };
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, DeprecatedString::formatted("Import resolution of '{}' was blocked by a null entry.", specifier_key) };
// 2. Assert: resolutionResult is a URL.
VERIFY(resolution_result->is_valid());
@ -146,7 +146,7 @@ WebIDL::ExceptionOr<Optional<AK::URL>> resolve_imports_match(String const& norma
) {
// 1. If resolutionResult is null, then throw a TypeError indicating that the resolution of specifierKey was blocked by a null entry.
if (!resolution_result.has_value())
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, String::formatted("Import resolution of '{}' was blocked by a null entry.", specifier_key) };
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, DeprecatedString::formatted("Import resolution of '{}' was blocked by a null entry.", specifier_key) };
// 2. Assert: resolutionResult is a URL.
VERIFY(resolution_result->is_valid());
@ -164,7 +164,7 @@ WebIDL::ExceptionOr<Optional<AK::URL>> resolve_imports_match(String const& norma
// 6. If url is failure, then throw a TypeError indicating that resolution of normalizedSpecifier was blocked since the afterPrefix portion
// could not be URL-parsed relative to the resolutionResult mapped to by the specifierKey prefix.
if (!url.is_valid())
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, String::formatted("Could not resolve '{}' as the after prefix portion could not be URL-parsed.", normalized_specifier) };
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, DeprecatedString::formatted("Could not resolve '{}' as the after prefix portion could not be URL-parsed.", normalized_specifier) };
// 7. Assert: url is a URL.
VERIFY(url.is_valid());
@ -172,7 +172,7 @@ WebIDL::ExceptionOr<Optional<AK::URL>> resolve_imports_match(String const& norma
// 8. If the serialization of resolutionResult is not a code unit prefix of the serialization of url, then throw a TypeError indicating
// that the resolution of normalizedSpecifier was blocked due to it backtracking above its prefix specifierKey.
if (!Infra::is_code_unit_prefix(resolution_result->serialize(), url.serialize()))
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, String::formatted("Could not resolve '{}' as it backtracks above its prefix specifierKey.", normalized_specifier) };
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, DeprecatedString::formatted("Could not resolve '{}' as it backtracks above its prefix specifierKey.", normalized_specifier) };
// 9. Return url.
return url;
@ -184,7 +184,7 @@ WebIDL::ExceptionOr<Optional<AK::URL>> resolve_imports_match(String const& norma
}
// https://html.spec.whatwg.org/multipage/webappapis.html#resolving-a-url-like-module-specifier
Optional<AK::URL> resolve_url_like_module_specifier(String const& specifier, AK::URL const& base_url)
Optional<AK::URL> resolve_url_like_module_specifier(DeprecatedString const& specifier, AK::URL const& base_url)
{
// 1. If specifier starts with "/", "./", or "../", then:
if (specifier.starts_with("/"sv) || specifier.starts_with("./"sv) || specifier.starts_with("../"sv)) {
@ -339,7 +339,7 @@ void fetch_descendants_of_a_module_script(JavaScriptModuleScript& module_script,
void fetch_single_module_script(AK::URL const& url, EnvironmentSettingsObject&, StringView, EnvironmentSettingsObject& module_map_settings_object, AK::URL const&, Optional<JS::ModuleRequest> const& module_request, TopLevelModule, ModuleCallback on_complete)
{
// 1. Let moduleType be "javascript".
String module_type = "javascript"sv;
DeprecatedString module_type = "javascript"sv;
// 2. If moduleRequest was given, then set moduleType to the result of running the module type from module request steps given moduleRequest.
if (module_request.has_value())
@ -442,7 +442,7 @@ void fetch_external_module_script_graph(AK::URL const& url, EnvironmentSettingsO
}
// https://html.spec.whatwg.org/multipage/webappapis.html#fetch-an-inline-module-script-graph
void fetch_inline_module_script_graph(String const& filename, String const& source_text, AK::URL const& base_url, EnvironmentSettingsObject& settings_object, ModuleCallback on_complete)
void fetch_inline_module_script_graph(DeprecatedString const& filename, DeprecatedString const& source_text, AK::URL const& base_url, EnvironmentSettingsObject& settings_object, ModuleCallback on_complete)
{
// 1. Disallow further import maps given settings object.
settings_object.disallow_further_import_maps();

View file

@ -38,14 +38,14 @@ private:
ModuleCallback m_on_complete;
};
String module_type_from_module_request(JS::ModuleRequest const&);
WebIDL::ExceptionOr<AK::URL> resolve_module_specifier(Optional<Script&> referring_script, String const& specifier);
WebIDL::ExceptionOr<Optional<AK::URL>> resolve_imports_match(String const& normalized_specifier, Optional<AK::URL> as_url, ModuleSpecifierMap const&);
Optional<AK::URL> resolve_url_like_module_specifier(String const& specifier, AK::URL const& base_url);
DeprecatedString module_type_from_module_request(JS::ModuleRequest const&);
WebIDL::ExceptionOr<AK::URL> resolve_module_specifier(Optional<Script&> referring_script, DeprecatedString const& specifier);
WebIDL::ExceptionOr<Optional<AK::URL>> resolve_imports_match(DeprecatedString const& normalized_specifier, Optional<AK::URL> as_url, ModuleSpecifierMap const&);
Optional<AK::URL> resolve_url_like_module_specifier(DeprecatedString const& specifier, AK::URL const& base_url);
void fetch_internal_module_script_graph(JS::ModuleRequest const& module_request, EnvironmentSettingsObject& fetch_client_settings_object, StringView destination, Script& referring_script, HashTable<ModuleLocationTuple> const& visited_set, ModuleCallback on_complete);
void fetch_external_module_script_graph(AK::URL const&, EnvironmentSettingsObject& settings_object, ModuleCallback on_complete);
void fetch_inline_module_script_graph(String const& filename, String const& source_text, AK::URL const& base_url, EnvironmentSettingsObject& settings_object, ModuleCallback on_complete);
void fetch_inline_module_script_graph(DeprecatedString const& filename, DeprecatedString const& source_text, AK::URL const& base_url, EnvironmentSettingsObject& settings_object, ModuleCallback on_complete);
void fetch_descendants_of_a_module_script(JavaScriptModuleScript& module_script, EnvironmentSettingsObject& fetch_client_settings_object, StringView destination, HashTable<ModuleLocationTuple> visited_set, ModuleCallback callback);
void fetch_descendants_of_and_link_a_module_script(JavaScriptModuleScript& module_script, EnvironmentSettingsObject& fetch_client_settings_object, StringView destination, HashTable<ModuleLocationTuple> const& visited_set, ModuleCallback on_complete);

View file

@ -10,7 +10,7 @@
namespace Web::HTML {
using ModuleSpecifierMap = HashMap<String, Optional<AK::URL>>;
using ModuleSpecifierMap = HashMap<DeprecatedString, Optional<AK::URL>>;
// https://html.spec.whatwg.org/multipage/webappapis.html#import-map
class ImportMap {

View file

@ -8,17 +8,17 @@
namespace Web::HTML {
bool ModuleMap::is_fetching(AK::URL const& url, String const& type) const
bool ModuleMap::is_fetching(AK::URL const& url, DeprecatedString const& type) const
{
return is(url, type, EntryType::Fetching);
}
bool ModuleMap::is_failed(AK::URL const& url, String const& type) const
bool ModuleMap::is_failed(AK::URL const& url, DeprecatedString const& type) const
{
return is(url, type, EntryType::Failed);
}
bool ModuleMap::is(AK::URL const& url, String const& type, EntryType entry_type) const
bool ModuleMap::is(AK::URL const& url, DeprecatedString const& type, EntryType entry_type) const
{
auto value = m_values.get({ url, type });
if (!value.has_value())
@ -27,12 +27,12 @@ bool ModuleMap::is(AK::URL const& url, String const& type, EntryType entry_type)
return value->type == entry_type;
}
Optional<ModuleMap::Entry> ModuleMap::get(AK::URL const& url, String const& type) const
Optional<ModuleMap::Entry> ModuleMap::get(AK::URL const& url, DeprecatedString const& type) const
{
return m_values.get({ url, type });
}
AK::HashSetResult ModuleMap::set(AK::URL const& url, String const& type, Entry entry)
AK::HashSetResult ModuleMap::set(AK::URL const& url, DeprecatedString const& type, Entry entry)
{
auto callbacks = m_callbacks.get({ url, type });
if (callbacks.has_value())
@ -42,7 +42,7 @@ AK::HashSetResult ModuleMap::set(AK::URL const& url, String const& type, Entry e
return m_values.set({ url, type }, entry);
}
void ModuleMap::wait_for_change(AK::URL const& url, String const& type, Function<void(Entry)> callback)
void ModuleMap::wait_for_change(AK::URL const& url, DeprecatedString const& type, Function<void(Entry)> callback)
{
m_callbacks.ensure({ url, type }).append(move(callback));
}

View file

@ -12,14 +12,14 @@ namespace Web::HTML {
class ModuleLocationTuple {
public:
ModuleLocationTuple(AK::URL url, String type)
ModuleLocationTuple(AK::URL url, DeprecatedString type)
: m_url(move(url))
, m_type(move(type))
{
}
AK::URL const& url() const { return m_url; };
String const& type() const { return m_type; }
DeprecatedString const& type() const { return m_type; }
bool operator==(ModuleLocationTuple const& other) const
{
@ -28,7 +28,7 @@ public:
private:
AK::URL m_url;
String m_type;
DeprecatedString m_type;
};
// https://html.spec.whatwg.org/multipage/webappapis.html#module-map
@ -50,16 +50,16 @@ public:
JavaScriptModuleScript* module_script;
};
bool is_fetching(AK::URL const& url, String const& type) const;
bool is_failed(AK::URL const& url, String const& type) const;
bool is_fetching(AK::URL const& url, DeprecatedString const& type) const;
bool is_failed(AK::URL const& url, DeprecatedString const& type) const;
bool is(AK::URL const& url, String const& type, EntryType) const;
bool is(AK::URL const& url, DeprecatedString const& type, EntryType) const;
Optional<Entry> get(AK::URL const& url, String const& type) const;
Optional<Entry> get(AK::URL const& url, DeprecatedString const& type) const;
AK::HashSetResult set(AK::URL const& url, String const& type, Entry);
AK::HashSetResult set(AK::URL const& url, DeprecatedString const& type, Entry);
void wait_for_change(AK::URL const& url, String const& type, Function<void(Entry)> callback);
void wait_for_change(AK::URL const& url, DeprecatedString const& type, Function<void(Entry)> callback);
private:
HashMap<ModuleLocationTuple, Entry> m_values;

View file

@ -16,20 +16,20 @@ namespace Web::HTML {
ModuleScript::~ModuleScript() = default;
ModuleScript::ModuleScript(AK::URL base_url, String filename, EnvironmentSettingsObject& environment_settings_object)
ModuleScript::ModuleScript(AK::URL base_url, DeprecatedString filename, EnvironmentSettingsObject& environment_settings_object)
: Script(move(base_url), move(filename), environment_settings_object)
{
}
JavaScriptModuleScript::~JavaScriptModuleScript() = default;
JavaScriptModuleScript::JavaScriptModuleScript(AK::URL base_url, String filename, EnvironmentSettingsObject& environment_settings_object)
JavaScriptModuleScript::JavaScriptModuleScript(AK::URL base_url, DeprecatedString filename, EnvironmentSettingsObject& environment_settings_object)
: ModuleScript(move(base_url), move(filename), environment_settings_object)
{
}
// https://html.spec.whatwg.org/multipage/webappapis.html#creating-a-javascript-module-script
JS::GCPtr<JavaScriptModuleScript> JavaScriptModuleScript::create(String const& filename, StringView source, EnvironmentSettingsObject& settings_object, AK::URL base_url)
JS::GCPtr<JavaScriptModuleScript> JavaScriptModuleScript::create(DeprecatedString const& filename, StringView source, EnvironmentSettingsObject& settings_object, AK::URL base_url)
{
// 1. If scripting is disabled for settings, then set source to the empty string.
if (settings_object.is_scripting_disabled())

View file

@ -20,7 +20,7 @@ public:
virtual ~ModuleScript() override;
protected:
ModuleScript(AK::URL base_url, String filename, EnvironmentSettingsObject& environment_settings_object);
ModuleScript(AK::URL base_url, DeprecatedString filename, EnvironmentSettingsObject& environment_settings_object);
};
class JavaScriptModuleScript final : public ModuleScript {
@ -29,7 +29,7 @@ class JavaScriptModuleScript final : public ModuleScript {
public:
virtual ~JavaScriptModuleScript() override;
static JS::GCPtr<JavaScriptModuleScript> create(String const& filename, StringView source, EnvironmentSettingsObject&, AK::URL base_url);
static JS::GCPtr<JavaScriptModuleScript> create(DeprecatedString const& filename, StringView source, EnvironmentSettingsObject&, AK::URL base_url);
enum class PreventErrorReporting {
Yes,
@ -42,7 +42,7 @@ public:
JS::SourceTextModule* record() { return m_record.ptr(); };
protected:
JavaScriptModuleScript(AK::URL base_url, String filename, EnvironmentSettingsObject& environment_settings_object);
JavaScriptModuleScript(AK::URL base_url, DeprecatedString filename, EnvironmentSettingsObject& environment_settings_object);
private:
virtual void visit_edges(JS::Cell::Visitor&) override;

View file

@ -8,7 +8,7 @@
namespace Web::HTML {
Script::Script(AK::URL base_url, String filename, EnvironmentSettingsObject& environment_settings_object)
Script::Script(AK::URL base_url, DeprecatedString filename, EnvironmentSettingsObject& environment_settings_object)
: m_base_url(move(base_url))
, m_filename(move(filename))
, m_settings_object(environment_settings_object)

View file

@ -23,18 +23,18 @@ public:
virtual ~Script() override;
AK::URL const& base_url() const { return m_base_url; }
String const& filename() const { return m_filename; }
DeprecatedString const& filename() const { return m_filename; }
EnvironmentSettingsObject& settings_object() { return m_settings_object; }
protected:
Script(AK::URL base_url, String filename, EnvironmentSettingsObject& environment_settings_object);
Script(AK::URL base_url, DeprecatedString filename, EnvironmentSettingsObject& environment_settings_object);
private:
virtual void visit_host_defined_self(JS::Cell::Visitor&) override;
AK::URL m_base_url;
String m_filename;
DeprecatedString m_filename;
EnvironmentSettingsObject& m_settings_object;
};

View file

@ -49,7 +49,7 @@ void WindowEnvironmentSettingsObject::setup(AK::URL const& creation_url, Nonnull
settings_object->target_browsing_context = reserved_environment->target_browsing_context;
// 2. Set reservedEnvironment's id to the empty string.
reserved_environment->id = String::empty();
reserved_environment->id = DeprecatedString::empty();
}
// 5. Otherwise, ...
@ -58,7 +58,7 @@ void WindowEnvironmentSettingsObject::setup(AK::URL const& creation_url, Nonnull
// settings object's target browsing context to null,
// and settings object's active service worker to null.
static i64 next_id = 1;
settings_object->id = String::number(next_id++);
settings_object->id = DeprecatedString::number(next_id++);
settings_object->target_browsing_context = nullptr;
}
@ -88,7 +88,7 @@ JS::GCPtr<DOM::Document> WindowEnvironmentSettingsObject::responsible_document()
}
// https://html.spec.whatwg.org/multipage/window-object.html#script-settings-for-window-objects:api-url-character-encoding
String WindowEnvironmentSettingsObject::api_url_character_encoding()
DeprecatedString WindowEnvironmentSettingsObject::api_url_character_encoding()
{
// Return the current character encoding of window's associated Document.
return m_window->associated_document().encoding_or_default();

View file

@ -20,7 +20,7 @@ public:
virtual ~WindowEnvironmentSettingsObject() override;
virtual JS::GCPtr<DOM::Document> responsible_document() override;
virtual String api_url_character_encoding() override;
virtual DeprecatedString api_url_character_encoding() override;
virtual AK::URL api_base_url() override;
virtual Origin origin() override;
virtual PolicyContainer policy_container() override;

View file

@ -43,14 +43,14 @@ public:
virtual ~WorkerEnvironmentSettingsObject() override = default;
JS::GCPtr<DOM::Document> responsible_document() override { return nullptr; }
String api_url_character_encoding() override { return m_api_url_character_encoding; }
DeprecatedString api_url_character_encoding() override { return m_api_url_character_encoding; }
AK::URL api_base_url() override { return m_url; }
Origin origin() override { return m_origin; }
PolicyContainer policy_container() override { return m_policy_container; }
CanUseCrossOriginIsolatedAPIs cross_origin_isolated_capability() override { TODO(); }
private:
String m_api_url_character_encoding;
DeprecatedString m_api_url_character_encoding;
AK::URL m_url;
HTML::Origin m_origin;
HTML::PolicyContainer m_policy_container;