Skip to content

Commit a5923db

Browse files
committed
LibWeb: Rename current_settings_object to current_principal_...
This aligns with the lastest version of the PR implementing the javascript shadow realm proposal: whatwg/html#9893 This commit simply performs the rename before implementing the behaviour change.
1 parent 97ca603 commit a5923db

16 files changed

+35
-35
lines changed

Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ ErrorOr<void> initialize_main_thread_vm(HTML::EventLoop::Type type)
145145
}
146146

147147
// 3. Let settings object be the current settings object.
148-
// 4. If script is not null, then set settings object to script's settings object.
149-
auto& settings_object = script ? script->settings_object() : HTML::current_settings_object();
148+
// 4. If script is not null, then set settings object to script's principal settings object.
149+
auto& settings_object = script ? script->settings_object() : HTML::current_principal_settings_object();
150150

151151
switch (operation) {
152152
case JS::Promise::RejectionOperation::Reject:
@@ -414,8 +414,8 @@ ErrorOr<void> initialize_main_thread_vm(HTML::EventLoop::Type type)
414414
auto& vm = *s_main_thread_vm;
415415
auto& realm = *vm.current_realm();
416416

417-
// 1. Let settingsObject be the current settings object.
418-
Optional<HTML::EnvironmentSettingsObject&> settings_object = HTML::current_settings_object();
417+
// 1. Let settingsObject be the current principal settings object.
418+
Optional<HTML::EnvironmentSettingsObject&> settings_object = HTML::current_principal_settings_object();
419419

420420
// FIXME: 2. If settingsObject's global object implements WorkletGlobalScope or ServiceWorkerGlobalScope and loadState is undefined, then:
421421

Userland/Libraries/LibWeb/DOMURL/DOMURL.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ WebIDL::ExceptionOr<void> DOMURL::revoke_object_url(JS::VM& vm, StringView url)
144144
auto origin = url_record.origin();
145145

146146
// 4. Let settings be the current settings object.
147-
auto& settings = HTML::current_settings_object();
147+
auto& settings = HTML::current_principal_settings_object();
148148

149149
// 5. If origin is not same origin with settings’s origin, return.
150150
if (!origin.is_same_origin(settings.origin()))

Userland/Libraries/LibWeb/Fetch/Response.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Response>> Response::redirect(JS::VM& vm, S
167167
{
168168
auto& realm = *vm.current_realm();
169169

170-
// 1. Let parsedURL be the result of parsing url with current settings object’s API base URL.
171-
auto api_base_url = HTML::current_settings_object().api_base_url();
170+
// 1. Let parsedURL be the result of parsing url with current principal settings object’s API base URL.
171+
auto api_base_url = HTML::current_principal_settings_object().api_base_url();
172172
auto parsed_url = DOMURL::parse(url, api_base_url);
173173

174174
// 2. If parsedURL is failure, then throw a TypeError.

Userland/Libraries/LibWeb/FileAPI/BlobURLStore.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ ErrorOr<String> generate_new_blob_url()
3333
TRY(result.try_append("blob:"sv));
3434

3535
// 3. Let settings be the current settings object
36-
auto& settings = HTML::current_settings_object();
36+
auto& settings = HTML::current_principal_settings_object();
3737

3838
// 4. Let origin be settings’s origin.
3939
auto origin = settings.origin();
@@ -69,7 +69,7 @@ ErrorOr<String> add_entry_to_blob_url_store(JS::NonnullGCPtr<Blob> object)
6969
auto url = TRY(generate_new_blob_url());
7070

7171
// 3. Let entry be a new blob URL entry consisting of object and the current settings object.
72-
BlobURLEntry entry { object, HTML::current_settings_object() };
72+
BlobURLEntry entry { object, HTML::current_principal_settings_object() };
7373

7474
// 4. Set store[url] to entry.
7575
TRY(store.try_set(url, move(entry)));

Userland/Libraries/LibWeb/HTML/CrossOrigin/AbstractOperations.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ JS::ThrowCompletionOr<JS::PropertyDescriptor> cross_origin_property_fallback(JS:
8484
// 7.2.3.3 IsPlatformObjectSameOrigin ( O ), https://html.spec.whatwg.org/multipage/browsers.html#isplatformobjectsameorigin-(-o-)
8585
bool is_platform_object_same_origin(JS::Object const& object)
8686
{
87-
// 1. Return true if the current settings object's origin is same origin-domain with O's relevant settings object's origin, and false otherwise.
88-
return HTML::current_settings_object().origin().is_same_origin_domain(HTML::relevant_settings_object(object).origin());
87+
// 1. Return true if the current principal settings object's origin is same origin-domain with O's relevant settings object's origin, and false otherwise.
88+
return HTML::current_principal_settings_object().origin().is_same_origin_domain(HTML::relevant_settings_object(object).origin());
8989
}
9090

9191
// 7.2.3.4 CrossOriginGetOwnPropertyHelper ( O, P ), https://html.spec.whatwg.org/multipage/browsers.html#crossorigingetownpropertyhelper-(-o,-p-)
@@ -95,9 +95,9 @@ Optional<JS::PropertyDescriptor> cross_origin_get_own_property_helper(Variant<HT
9595
auto const* object_ptr = object.visit([](auto* o) { return static_cast<JS::Object const*>(o); });
9696
auto const object_const_variant = object.visit([](auto* o) { return Variant<HTML::Location const*, HTML::Window const*> { o }; });
9797

98-
// 1. Let crossOriginKey be a tuple consisting of the current settings object, O's relevant settings object, and P.
98+
// 1. Let crossOriginKey be a tuple consisting of the current principal settings object, O's relevant settings object, and P.
9999
auto cross_origin_key = CrossOriginKey {
100-
.current_settings_object = (FlatPtr)&HTML::current_settings_object(),
100+
.current_principal_settings_object = (FlatPtr)&HTML::current_principal_settings_object(),
101101
.relevant_settings_object = (FlatPtr)&HTML::relevant_settings_object(*object_ptr),
102102
.property_key = property_key,
103103
};

Userland/Libraries/LibWeb/HTML/CrossOrigin/CrossOriginPropertyDescriptorMap.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct CrossOriginProperty {
2222
};
2323

2424
struct CrossOriginKey {
25-
FlatPtr current_settings_object;
25+
FlatPtr current_principal_settings_object;
2626
FlatPtr relevant_settings_object;
2727
JS::PropertyKey property_key;
2828
};
@@ -39,12 +39,12 @@ struct Traits<Web::HTML::CrossOriginKey> : public DefaultTraits<Web::HTML::Cross
3939
{
4040
return pair_int_hash(
4141
Traits<JS::PropertyKey>::hash(key.property_key),
42-
pair_int_hash(ptr_hash(key.current_settings_object), ptr_hash(key.relevant_settings_object)));
42+
pair_int_hash(ptr_hash(key.current_principal_settings_object), ptr_hash(key.relevant_settings_object)));
4343
}
4444

4545
static bool equals(Web::HTML::CrossOriginKey const& a, Web::HTML::CrossOriginKey const& b)
4646
{
47-
return a.current_settings_object == b.current_settings_object
47+
return a.current_principal_settings_object == b.current_principal_settings_object
4848
&& a.relevant_settings_object == b.relevant_settings_object
4949
&& Traits<JS::PropertyKey>::equals(a.property_key, b.property_key);
5050
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ JS::Object& incumbent_global_object()
385385
}
386386

387387
// https://html.spec.whatwg.org/multipage/webappapis.html#current-settings-object
388-
EnvironmentSettingsObject& current_settings_object()
388+
EnvironmentSettingsObject& current_principal_settings_object()
389389
{
390390
auto& event_loop = HTML::main_thread_event_loop();
391391
auto& vm = event_loop.vm();

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ struct EnvironmentSettingsObject : public Environment {
161161
EnvironmentSettingsObject& incumbent_settings_object();
162162
JS::Realm& incumbent_realm();
163163
JS::Object& incumbent_global_object();
164-
EnvironmentSettingsObject& current_settings_object();
164+
EnvironmentSettingsObject& current_principal_settings_object();
165165
JS::Object& current_global_object();
166166
JS::Realm& relevant_realm(JS::Object const&);
167167
EnvironmentSettingsObject& relevant_settings_object(JS::Object const&);

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ WebIDL::ExceptionOr<URL::URL> resolve_module_specifier(Optional<Script&> referri
9797
}
9898
// 3. Otherwise:
9999
else {
100-
// 1. Assert: there is a current settings object.
101-
// NOTE: This is handled by the current_settings_object() accessor.
100+
// 1. Assert: there is a current principal settings object.
101+
// NOTE: This is handled by the current_principal_settings_object() accessor.
102102

103103
// 2. Set settingsObject to the current settings object.
104-
settings_object = current_settings_object();
104+
settings_object = current_principal_settings_object();
105105

106106
// 3. Set baseURL to settingsObject's API base URL.
107107
base_url = settings_object->api_base_url();

Userland/Libraries/LibWeb/HTML/StructuredSerialize.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -565,10 +565,10 @@ WebIDL::ExceptionOr<void> serialize_array_buffer(JS::VM& vm, Vector<u32>& vector
565565

566566
// FIXME: 1. If IsSharedArrayBuffer(value) is true, then:
567567
if (false) {
568-
// 1. If the current settings object's cross-origin isolated capability is false, then throw a "DataCloneError" DOMException.
568+
// 1. If the current principal settings object's cross-origin isolated capability is false, then throw a "DataCloneError" DOMException.
569569
// NOTE: This check is only needed when serializing (and not when deserializing) as the cross-origin isolated capability cannot change
570570
// over time and a SharedArrayBuffer cannot leave an agent cluster.
571-
if (current_settings_object().cross_origin_isolated_capability() == CanUseCrossOriginIsolatedAPIs::No)
571+
if (current_principal_settings_object().cross_origin_isolated_capability() == CanUseCrossOriginIsolatedAPIs::No)
572572
return WebIDL::DataCloneError::create(*vm.current_realm(), "Cannot serialize SharedArrayBuffer when cross-origin isolated"_string);
573573

574574
// 2. If forStorage is true, then throw a "DataCloneError" DOMException.

Userland/Libraries/LibWeb/HTML/Window.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1005,8 +1005,8 @@ JS::GCPtr<DOM::Element const> Window::frame_element() const
10051005
if (!container)
10061006
return {};
10071007

1008-
// 5. If container's node document's origin is not same origin-domain with the current settings object's origin, then return null.
1009-
if (!container->document().origin().is_same_origin_domain(current_settings_object().origin()))
1008+
// 5. If container's node document's origin is not same origin-domain with the current principal settings object's origin, then return null.
1009+
if (!container->document().origin().is_same_origin_domain(current_principal_settings_object().origin()))
10101010
return {};
10111011

10121012
// 6. Return container.

Userland/Libraries/LibWeb/HTML/WindowProxy.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ JS::ThrowCompletionOr<JS::Value> WindowProxy::internal_get(JS::PropertyKey const
159159

160160
// 1. Let W be the value of the [[Window]] internal slot of this.
161161

162-
// 2. Check if an access between two browsing contexts should be reported, given the current global object's browsing context, W's browsing context, P, and the current settings object.
163-
check_if_access_between_two_browsing_contexts_should_be_reported(*verify_cast<Window>(current_global_object()).browsing_context(), m_window->browsing_context(), property_key, current_settings_object());
162+
// 2. Check if an access between two browsing contexts should be reported, given the current global object's browsing context, W's browsing context, P, and the current principal settings object.
163+
check_if_access_between_two_browsing_contexts_should_be_reported(*verify_cast<Window>(current_global_object()).browsing_context(), m_window->browsing_context(), property_key, current_principal_settings_object());
164164

165165
// 3. If IsPlatformObjectSameOrigin(W) is true, then return ? OrdinaryGet(this, P, Receiver).
166166
// NOTE: this is passed rather than W as OrdinaryGet and CrossOriginGet will invoke the [[GetOwnProperty]] internal method.
@@ -179,8 +179,8 @@ JS::ThrowCompletionOr<bool> WindowProxy::internal_set(JS::PropertyKey const& pro
179179

180180
// 1. Let W be the value of the [[Window]] internal slot of this.
181181

182-
// 2. Check if an access between two browsing contexts should be reported, given the current global object's browsing context, W's browsing context, P, and the current settings object.
183-
check_if_access_between_two_browsing_contexts_should_be_reported(*verify_cast<Window>(current_global_object()).browsing_context(), m_window->browsing_context(), property_key, current_settings_object());
182+
// 2. Check if an access between two browsing contexts should be reported, given the current global object's browsing context, W's browsing context, P, and the current principal settings object.
183+
check_if_access_between_two_browsing_contexts_should_be_reported(*verify_cast<Window>(current_global_object()).browsing_context(), m_window->browsing_context(), property_key, current_principal_settings_object());
184184

185185
// 3. If IsPlatformObjectSameOrigin(W) is true, then:
186186
if (is_platform_object_same_origin(*m_window)) {

Userland/Libraries/LibWeb/HTML/Worker.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Worker>> Worker::create(String const& scrip
5555
// a policy decision (e.g. if the user agent is configured to not allow the page to start dedicated workers).
5656
// Technically not a fixme if our policy is not to throw errors :^)
5757

58-
// 2. Let outside settings be the current settings object.
59-
auto& outside_settings = current_settings_object();
58+
// 2. Let outside settings be the current principal settings object.
59+
auto& outside_settings = current_principal_settings_object();
6060

6161
// 3. Parse the scriptURL argument relative to outside settings.
6262
auto url = document.parse_url(script_url);

Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ WebIDL::ExceptionOr<void> WorkerGlobalScope::import_scripts(Vector<String> const
8787

8888
// FIXME: 1. If worker global scope's type is "module", throw a TypeError exception.
8989

90-
// 2. Let settings object be the current settings object.
91-
auto& settings_object = HTML::current_settings_object();
90+
// 2. Let settings object be the current principal settings object.
91+
auto& settings_object = HTML::current_principal_settings_object();
9292

9393
// 3. If urls is empty, return.
9494
if (urls.is_empty())

Userland/Libraries/LibWeb/Page/Page.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ JS::NonnullGCPtr<HTML::TraversableNavigable> Page::top_level_traversable() const
256256
template<typename ResponseType>
257257
static ResponseType spin_event_loop_until_dialog_closed(PageClient& client, Optional<ResponseType>& response, SourceLocation location = SourceLocation::current())
258258
{
259-
auto& event_loop = Web::HTML::current_settings_object().responsible_event_loop();
259+
auto& event_loop = Web::HTML::current_principal_settings_object().responsible_event_loop();
260260

261261
ScopeGuard guard { [&] { event_loop.set_execution_paused(false); } };
262262
event_loop.set_execution_paused(true);

Userland/Libraries/LibWeb/WebAudio/BaseAudioContext.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ WebIDL::ExceptionOr<void> BaseAudioContext::verify_audio_options_inside_nominal_
123123

124124
void BaseAudioContext::queue_a_media_element_task(JS::NonnullGCPtr<JS::HeapFunction<void()>> steps)
125125
{
126-
auto task = HTML::Task::create(vm(), m_media_element_event_task_source.source, HTML::current_settings_object().responsible_document(), steps);
126+
auto task = HTML::Task::create(vm(), m_media_element_event_task_source.source, HTML::current_principal_settings_object().responsible_document(), steps);
127127
HTML::main_thread_event_loop().task_queue().add(task);
128128
}
129129

0 commit comments

Comments
 (0)