Skip to content

Commit c63d30c

Browse files
shannonboothawesomekling
authored andcommitted
LibWeb: Port HTML Environments from ByteString
1 parent 562e0d7 commit c63d30c

File tree

6 files changed

+14
-15
lines changed

6 files changed

+14
-15
lines changed

Userland/Libraries/LibWeb/HTML/Navigable.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,7 @@ static WebIDL::ExceptionOr<Variant<Empty, NavigationParams, NonFetchSchemeNaviga
674674
request->set_credentials_mode(Fetch::Infrastructure::Request::CredentialsMode::Include);
675675
request->set_use_url_credentials(true);
676676
request->set_redirect_mode(Fetch::Infrastructure::Request::RedirectMode::Manual);
677-
auto replaces_client_id = TRY_OR_THROW_OOM(vm, String::from_byte_string(active_document.relevant_settings_object().id));
678-
request->set_replaces_client_id(replaces_client_id);
677+
request->set_replaces_client_id(active_document.relevant_settings_object().id);
679678
request->set_mode(Fetch::Infrastructure::Request::Mode::Navigate);
680679
request->set_referrer(entry->document_state->request_referrer());
681680

Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ bool EnvironmentSettingsObject::is_scripting_disabled() const
308308
}
309309

310310
// https://html.spec.whatwg.org/multipage/webappapis.html#module-type-allowed
311-
bool EnvironmentSettingsObject::module_type_allowed(AK::ByteString const& module_type) const
311+
bool EnvironmentSettingsObject::module_type_allowed(StringView module_type) const
312312
{
313313
// 1. If moduleType is not "javascript", "css", or "json", then return false.
314314
if (module_type != "javascript"sv && module_type != "css"sv && module_type != "json"sv)

Userland/Libraries/LibWeb/HTML/Scripting/Environments.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct Environment {
2020
virtual ~Environment() = default;
2121

2222
// An id https://html.spec.whatwg.org/multipage/webappapis.html#concept-environment-id
23-
ByteString id;
23+
String id;
2424

2525
// https://html.spec.whatwg.org/multipage/webappapis.html#concept-environment-creation-url
2626
AK::URL creation_url;
@@ -69,7 +69,7 @@ struct EnvironmentSettingsObject
6969
virtual JS::GCPtr<DOM::Document> responsible_document() = 0;
7070

7171
// https://html.spec.whatwg.org/multipage/webappapis.html#api-url-character-encoding
72-
virtual ByteString api_url_character_encoding() = 0;
72+
virtual String api_url_character_encoding() = 0;
7373

7474
// https://html.spec.whatwg.org/multipage/webappapis.html#api-base-url
7575
virtual AK::URL api_base_url() = 0;
@@ -111,7 +111,7 @@ struct EnvironmentSettingsObject
111111
bool is_scripting_enabled() const;
112112
bool is_scripting_disabled() const;
113113

114-
bool module_type_allowed(ByteString const& module_type) const;
114+
bool module_type_allowed(StringView module_type) const;
115115

116116
void disallow_further_import_maps();
117117

Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void WindowEnvironmentSettingsObject::setup(Page& page, AK::URL const& creation_
5151
settings_object->target_browsing_context = reserved_environment->target_browsing_context;
5252

5353
// 2. Set reservedEnvironment's id to the empty string.
54-
reserved_environment->id = ByteString::empty();
54+
reserved_environment->id = String {};
5555
}
5656

5757
// 5. Otherwise, ...
@@ -60,16 +60,16 @@ void WindowEnvironmentSettingsObject::setup(Page& page, AK::URL const& creation_
6060
// settings object's target browsing context to null,
6161
// and settings object's active service worker to null.
6262
static i64 next_id = 1;
63-
settings_object->id = ByteString::number(next_id++);
63+
settings_object->id = MUST(String::number(next_id++));
6464
settings_object->target_browsing_context = nullptr;
6565
}
6666

6767
// 6. Set settings object's creation URL to creationURL,
6868
// settings object's top-level creation URL to topLevelCreationURL,
6969
// and settings object's top-level origin to topLevelOrigin.
7070
settings_object->creation_url = creation_url;
71-
settings_object->top_level_creation_url = top_level_creation_url;
72-
settings_object->top_level_origin = top_level_origin;
71+
settings_object->top_level_creation_url = move(top_level_creation_url);
72+
settings_object->top_level_origin = move(top_level_origin);
7373

7474
// 7. Set realm's [[HostDefined]] field to settings object.
7575
// Non-Standard: We store the ESO next to the web intrinsics in a custom HostDefined object
@@ -90,10 +90,10 @@ JS::GCPtr<DOM::Document> WindowEnvironmentSettingsObject::responsible_document()
9090
}
9191

9292
// https://html.spec.whatwg.org/multipage/window-object.html#script-settings-for-window-objects:api-url-character-encoding
93-
ByteString WindowEnvironmentSettingsObject::api_url_character_encoding()
93+
String WindowEnvironmentSettingsObject::api_url_character_encoding()
9494
{
9595
// Return the current character encoding of window's associated Document.
96-
return m_window->associated_document().encoding_or_default().to_byte_string();
96+
return m_window->associated_document().encoding_or_default();
9797
}
9898

9999
// https://html.spec.whatwg.org/multipage/window-object.html#script-settings-for-window-objects:api-base-url

Userland/Libraries/LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class WindowEnvironmentSettingsObject final : public EnvironmentSettingsObject {
2121
virtual ~WindowEnvironmentSettingsObject() override;
2222

2323
virtual JS::GCPtr<DOM::Document> responsible_document() override;
24-
virtual ByteString api_url_character_encoding() override;
24+
virtual String api_url_character_encoding() override;
2525
virtual AK::URL api_base_url() override;
2626
virtual Origin origin() override;
2727
virtual PolicyContainer policy_container() override;

Userland/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class WorkerEnvironmentSettingsObject final
2929
virtual ~WorkerEnvironmentSettingsObject() override = default;
3030

3131
JS::GCPtr<DOM::Document> responsible_document() override { return nullptr; }
32-
ByteString api_url_character_encoding() override { return m_api_url_character_encoding; }
32+
String api_url_character_encoding() override { return m_api_url_character_encoding; }
3333
AK::URL api_base_url() override { return m_url; }
3434
Origin origin() override { return m_origin; }
3535
PolicyContainer policy_container() override { return m_policy_container; }
@@ -38,7 +38,7 @@ class WorkerEnvironmentSettingsObject final
3838
private:
3939
virtual void visit_edges(JS::Cell::Visitor&) override;
4040

41-
ByteString m_api_url_character_encoding;
41+
String m_api_url_character_encoding;
4242
AK::URL m_url;
4343
HTML::Origin m_origin;
4444
HTML::PolicyContainer m_policy_container;

0 commit comments

Comments
 (0)