1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-12 02:30:30 +09:00

LibWeb: Rename Bindings::HostDefined to Bindings::PrincipalHostDefined

With the introduction of shadow realms, there will be two different
possible host defined objects. For clarity, rename the existing host
defined object to PrincipalHostDefined.
This commit is contained in:
Shannon Booth 2024-10-26 21:02:28 +13:00 committed by Andrew Kaster
parent 16ab3c5f9d
commit 5154df020b
Notes: github-actions[bot] 2024-11-05 18:00:05 +00:00
25 changed files with 81 additions and 89 deletions

View file

@ -1,46 +0,0 @@
/*
* Copyright (c) 2022, Andrew Kaster <akaster@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/TypeCasts.h>
#include <LibJS/Heap/GCPtr.h>
#include <LibJS/Runtime/Realm.h>
#include <LibWeb/Forward.h>
namespace Web::Bindings {
struct HostDefined : public JS::Realm::HostDefined {
HostDefined(JS::NonnullGCPtr<HTML::EnvironmentSettingsObject> eso, JS::NonnullGCPtr<Intrinsics> intrinsics, JS::NonnullGCPtr<Page> page)
: environment_settings_object(eso)
, intrinsics(intrinsics)
, page(page)
{
}
virtual ~HostDefined() override = default;
virtual void visit_edges(JS::Cell::Visitor& visitor) override;
JS::NonnullGCPtr<HTML::EnvironmentSettingsObject> environment_settings_object;
JS::NonnullGCPtr<Intrinsics> intrinsics;
JS::NonnullGCPtr<Page> page;
};
[[nodiscard]] inline HTML::EnvironmentSettingsObject& host_defined_environment_settings_object(JS::Realm& realm)
{
return *verify_cast<HostDefined>(realm.host_defined())->environment_settings_object;
}
[[nodiscard]] inline HTML::EnvironmentSettingsObject const& host_defined_environment_settings_object(JS::Realm const& realm)
{
return *verify_cast<HostDefined>(realm.host_defined())->environment_settings_object;
}
[[nodiscard]] inline Page& host_defined_page(JS::Realm& realm)
{
return *verify_cast<HostDefined>(realm.host_defined())->page;
}
}

View file

@ -13,7 +13,7 @@
#include <LibJS/Heap/Cell.h> #include <LibJS/Heap/Cell.h>
#include <LibJS/Heap/Heap.h> #include <LibJS/Heap/Heap.h>
#include <LibJS/Runtime/VM.h> #include <LibJS/Runtime/VM.h>
#include <LibWeb/Bindings/HostDefined.h> #include <LibWeb/Bindings/PrincipalHostDefined.h>
#define WEB_SET_PROTOTYPE_FOR_INTERFACE_WITH_CUSTOM_NAME(interface_class, interface_name) \ #define WEB_SET_PROTOTYPE_FOR_INTERFACE_WITH_CUSTOM_NAME(interface_class, interface_name) \
do { \ do { \
@ -84,7 +84,7 @@ private:
[[nodiscard]] inline Intrinsics& host_defined_intrinsics(JS::Realm& realm) [[nodiscard]] inline Intrinsics& host_defined_intrinsics(JS::Realm& realm)
{ {
return *verify_cast<HostDefined>(realm.host_defined())->intrinsics; return *verify_cast<PrincipalHostDefined>(realm.host_defined())->intrinsics;
} }
template<typename T> template<typename T>

View file

@ -6,14 +6,14 @@
#include <LibJS/Heap/Cell.h> #include <LibJS/Heap/Cell.h>
#include <LibJS/Runtime/Realm.h> #include <LibJS/Runtime/Realm.h>
#include <LibWeb/Bindings/HostDefined.h>
#include <LibWeb/Bindings/Intrinsics.h> #include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Bindings/PrincipalHostDefined.h>
#include <LibWeb/HTML/Scripting/Environments.h> #include <LibWeb/HTML/Scripting/Environments.h>
#include <LibWeb/Page/Page.h> #include <LibWeb/Page/Page.h>
namespace Web::Bindings { namespace Web::Bindings {
void HostDefined::visit_edges(JS::Cell::Visitor& visitor) void PrincipalHostDefined::visit_edges(JS::Cell::Visitor& visitor)
{ {
JS::Realm::HostDefined::visit_edges(visitor); JS::Realm::HostDefined::visit_edges(visitor);
visitor.visit(environment_settings_object); visitor.visit(environment_settings_object);

View file

@ -0,0 +1,46 @@
/*
* Copyright (c) 2022, Andrew Kaster <akaster@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/TypeCasts.h>
#include <LibJS/Heap/GCPtr.h>
#include <LibJS/Runtime/Realm.h>
#include <LibWeb/Forward.h>
namespace Web::Bindings {
struct PrincipalHostDefined : public JS::Realm::HostDefined {
PrincipalHostDefined(JS::NonnullGCPtr<HTML::EnvironmentSettingsObject> eso, JS::NonnullGCPtr<Intrinsics> intrinsics, JS::NonnullGCPtr<Page> page)
: environment_settings_object(eso)
, intrinsics(intrinsics)
, page(page)
{
}
virtual ~PrincipalHostDefined() override = default;
virtual void visit_edges(JS::Cell::Visitor& visitor) override;
JS::NonnullGCPtr<HTML::EnvironmentSettingsObject> environment_settings_object;
JS::NonnullGCPtr<Intrinsics> intrinsics;
JS::NonnullGCPtr<Page> page;
};
[[nodiscard]] inline HTML::EnvironmentSettingsObject& principal_host_defined_environment_settings_object(JS::Realm& realm)
{
return *verify_cast<PrincipalHostDefined>(realm.host_defined())->environment_settings_object;
}
[[nodiscard]] inline HTML::EnvironmentSettingsObject const& principal_host_defined_environment_settings_object(JS::Realm const& realm)
{
return *verify_cast<PrincipalHostDefined>(realm.host_defined())->environment_settings_object;
}
[[nodiscard]] inline Page& principal_host_defined_page(JS::Realm& realm)
{
return *verify_cast<PrincipalHostDefined>(realm.host_defined())->page;
}
}

View file

@ -16,13 +16,13 @@ set(SOURCES
ARIA/RoleType.cpp ARIA/RoleType.cpp
ARIA/StateAndProperties.cpp ARIA/StateAndProperties.cpp
Bindings/AudioConstructor.cpp Bindings/AudioConstructor.cpp
Bindings/HostDefined.cpp
Bindings/ImageConstructor.cpp Bindings/ImageConstructor.cpp
Bindings/Intrinsics.cpp Bindings/Intrinsics.cpp
Bindings/LocationConstructor.cpp Bindings/LocationConstructor.cpp
Bindings/MainThreadVM.cpp Bindings/MainThreadVM.cpp
Bindings/OptionConstructor.cpp Bindings/OptionConstructor.cpp
Bindings/PlatformObject.cpp Bindings/PlatformObject.cpp
Bindings/PrincipalHostDefined.cpp
Clipboard/Clipboard.cpp Clipboard/Clipboard.cpp
Clipboard/ClipboardEvent.cpp Clipboard/ClipboardEvent.cpp
Crypto/Crypto.cpp Crypto/Crypto.cpp

View file

@ -7,7 +7,6 @@
#include <LibJS/Runtime/Realm.h> #include <LibJS/Runtime/Realm.h>
#include <LibTextCodec/Decoder.h> #include <LibTextCodec/Decoder.h>
#include <LibWeb/Bindings/ClipboardPrototype.h> #include <LibWeb/Bindings/ClipboardPrototype.h>
#include <LibWeb/Bindings/HostDefined.h>
#include <LibWeb/Clipboard/Clipboard.h> #include <LibWeb/Clipboard/Clipboard.h>
#include <LibWeb/FileAPI/Blob.h> #include <LibWeb/FileAPI/Blob.h>
#include <LibWeb/HTML/Scripting/Environments.h> #include <LibWeb/HTML/Scripting/Environments.h>

View file

@ -383,7 +383,7 @@ JS::NonnullGCPtr<Document> Document::create_for_fragment_parsing(JS::Realm& real
Document::Document(JS::Realm& realm, const URL::URL& url, TemporaryDocumentForFragmentParsing temporary_document_for_fragment_parsing) Document::Document(JS::Realm& realm, const URL::URL& url, TemporaryDocumentForFragmentParsing temporary_document_for_fragment_parsing)
: ParentNode(realm, *this, NodeType::DOCUMENT_NODE) : ParentNode(realm, *this, NodeType::DOCUMENT_NODE)
, m_page(Bindings::host_defined_page(realm)) , m_page(Bindings::principal_host_defined_page(realm))
, m_style_computer(make<CSS::StyleComputer>(*this)) , m_style_computer(make<CSS::StyleComputer>(*this))
, m_url(url) , m_url(url)
, m_temporary_document_for_fragment_parsing(temporary_document_for_fragment_parsing) , m_temporary_document_for_fragment_parsing(temporary_document_for_fragment_parsing)
@ -1649,7 +1649,7 @@ Color Document::visited_link_color() const
HTML::EnvironmentSettingsObject& Document::relevant_settings_object() const HTML::EnvironmentSettingsObject& Document::relevant_settings_object() const
{ {
// Then, the relevant settings object for a platform object o is the environment settings object of the relevant Realm for o. // Then, the relevant settings object for a platform object o is the environment settings object of the relevant Realm for o.
return Bindings::host_defined_environment_settings_object(realm()); return Bindings::principal_host_defined_environment_settings_object(realm());
} }
// https://dom.spec.whatwg.org/#dom-document-createelement // https://dom.spec.whatwg.org/#dom-document-createelement
@ -4171,7 +4171,7 @@ void Document::start_intersection_observing_a_lazy_loading_element(Element& elem
// Spec Note: This allows for fetching the image during scrolling, when it does not yet — but is about to — intersect the viewport. // Spec Note: This allows for fetching the image during scrolling, when it does not yet — but is about to — intersect the viewport.
auto options = IntersectionObserver::IntersectionObserverInit {}; auto options = IntersectionObserver::IntersectionObserverInit {};
auto wrapped_callback = realm.heap().allocate_without_realm<WebIDL::CallbackType>(callback, Bindings::host_defined_environment_settings_object(realm)); auto wrapped_callback = realm.heap().allocate_without_realm<WebIDL::CallbackType>(callback, Bindings::principal_host_defined_environment_settings_object(realm));
m_lazy_load_intersection_observer = IntersectionObserver::IntersectionObserver::construct_impl(realm, wrapped_callback, options).release_value_but_fixme_should_propagate_errors(); m_lazy_load_intersection_observer = IntersectionObserver::IntersectionObserver::construct_impl(realm, wrapped_callback, options).release_value_but_fixme_should_propagate_errors();
} }

View file

@ -590,7 +590,7 @@ void EventTarget::activate_event_handler(FlyString const& name, HTML::EventHandl
0, "", &realm); 0, "", &realm);
// NOTE: As per the spec, the callback context is arbitrary. // NOTE: As per the spec, the callback context is arbitrary.
auto callback = realm.heap().allocate_without_realm<WebIDL::CallbackType>(*callback_function, Bindings::host_defined_environment_settings_object(realm)); auto callback = realm.heap().allocate_without_realm<WebIDL::CallbackType>(*callback_function, Bindings::principal_host_defined_environment_settings_object(realm));
// 5. Let listener be a new event listener whose type is the event handler event type corresponding to eventHandler and callback is callback. // 5. Let listener be a new event listener whose type is the event handler event type corresponding to eventHandler and callback is callback.
auto listener = realm.heap().allocate_without_realm<DOMEventListener>(); auto listener = realm.heap().allocate_without_realm<DOMEventListener>();

View file

@ -13,7 +13,6 @@
#include <LibJS/Runtime/TypedArray.h> #include <LibJS/Runtime/TypedArray.h>
#include <LibTextCodec/Decoder.h> #include <LibTextCodec/Decoder.h>
#include <LibWeb/Bindings/ExceptionOrUtils.h> #include <LibWeb/Bindings/ExceptionOrUtils.h>
#include <LibWeb/Bindings/HostDefined.h>
#include <LibWeb/Bindings/MainThreadVM.h> #include <LibWeb/Bindings/MainThreadVM.h>
#include <LibWeb/DOMURL/URLSearchParams.h> #include <LibWeb/DOMURL/URLSearchParams.h>
#include <LibWeb/Fetch/Body.h> #include <LibWeb/Fetch/Body.h>

View file

@ -8,7 +8,6 @@
#include <AK/TypeCasts.h> #include <AK/TypeCasts.h>
#include <LibJS/Runtime/PromiseCapability.h> #include <LibJS/Runtime/PromiseCapability.h>
#include <LibWeb/Bindings/ExceptionOrUtils.h> #include <LibWeb/Bindings/ExceptionOrUtils.h>
#include <LibWeb/Bindings/HostDefined.h>
#include <LibWeb/DOM/AbortSignal.h> #include <LibWeb/DOM/AbortSignal.h>
#include <LibWeb/Fetch/FetchMethod.h> #include <LibWeb/Fetch/FetchMethod.h>
#include <LibWeb/Fetch/Fetching/Fetching.h> #include <LibWeb/Fetch/Fetching/Fetching.h>

View file

@ -6,7 +6,6 @@
#include <LibJS/Heap/HeapFunction.h> #include <LibJS/Heap/HeapFunction.h>
#include <LibWeb/Bindings/ExceptionOrUtils.h> #include <LibWeb/Bindings/ExceptionOrUtils.h>
#include <LibWeb/Bindings/HostDefined.h>
#include <LibWeb/Fetch/Fetching/FetchedDataReceiver.h> #include <LibWeb/Fetch/Fetching/FetchedDataReceiver.h>
#include <LibWeb/Fetch/Infrastructure/FetchParams.h> #include <LibWeb/Fetch/Infrastructure/FetchParams.h>
#include <LibWeb/Fetch/Infrastructure/Task.h> #include <LibWeb/Fetch/Infrastructure/Task.h>

View file

@ -1833,7 +1833,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_network_or_cache_fet
// with the user agents cookie store and httpRequests current URL. // with the user agents cookie store and httpRequests current URL.
auto cookies = ([&] { auto cookies = ([&] {
// FIXME: Getting to the page client reliably is way too complicated, and going via the document won't work in workers. // FIXME: Getting to the page client reliably is way too complicated, and going via the document won't work in workers.
auto document = Bindings::host_defined_environment_settings_object(realm).responsible_document(); auto document = Bindings::principal_host_defined_environment_settings_object(realm).responsible_document();
if (!document) if (!document)
return String {}; return String {};
return document->page().client().page_did_request_cookie(http_request->current_url(), Cookie::Source::Http); return document->page().client().page_did_request_cookie(http_request->current_url(), Cookie::Source::Http);
@ -2193,7 +2193,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> nonstandard_resource_load
auto request = fetch_params.request(); auto request = fetch_params.request();
auto& page = Bindings::host_defined_page(realm); auto& page = Bindings::principal_host_defined_page(realm);
// NOTE: Using LoadRequest::create_for_url_on_page here will unconditionally add cookies as long as there's a page available. // NOTE: Using LoadRequest::create_for_url_on_page here will unconditionally add cookies as long as there's a page available.
// However, it is up to http_network_or_cache_fetch to determine if cookies should be added to the request. // However, it is up to http_network_or_cache_fetch to determine if cookies should be added to the request.

View file

@ -5,7 +5,6 @@
*/ */
#include <LibJS/Runtime/TypedArray.h> #include <LibJS/Runtime/TypedArray.h>
#include <LibWeb/Bindings/HostDefined.h>
#include <LibWeb/Fetch/Infrastructure/IncrementalReadLoopReadRequest.h> #include <LibWeb/Fetch/Infrastructure/IncrementalReadLoopReadRequest.h>
#include <LibWeb/HTML/Scripting/TemporaryExecutionContext.h> #include <LibWeb/HTML/Scripting/TemporaryExecutionContext.h>

View file

@ -341,7 +341,7 @@ JS::NonnullGCPtr<Streams::ReadableStream> Blob::get_stream()
// onto the realm's VM, and we need an incumbent realm which is pushed onto the incumbent realm stack // onto the realm's VM, and we need an incumbent realm which is pushed onto the incumbent realm stack
// by HTML::prepare_to_run_callback(). // by HTML::prepare_to_run_callback().
auto& realm = stream->realm(); auto& realm = stream->realm();
auto& environment_settings = Bindings::host_defined_environment_settings_object(realm); auto& environment_settings = Bindings::principal_host_defined_environment_settings_object(realm);
realm.vm().push_execution_context(environment_settings.realm_execution_context()); realm.vm().push_execution_context(environment_settings.realm_execution_context());
HTML::prepare_to_run_callback(realm); HTML::prepare_to_run_callback(realm);
ScopeGuard const guard = [&realm] { ScopeGuard const guard = [&realm] {

View file

@ -210,7 +210,7 @@ WebIDL::ExceptionOr<BrowsingContext::BrowsingContextAndDocument> BrowsingContext
auto load_timing_info = DOM::DocumentLoadTimingInfo(); auto load_timing_info = DOM::DocumentLoadTimingInfo();
load_timing_info.navigation_start_time = HighResolutionTime::coarsen_time( load_timing_info.navigation_start_time = HighResolutionTime::coarsen_time(
unsafe_context_creation_time, unsafe_context_creation_time,
verify_cast<WindowEnvironmentSettingsObject>(Bindings::host_defined_environment_settings_object(window->realm())).cross_origin_isolated_capability() == CanUseCrossOriginIsolatedAPIs::Yes); verify_cast<WindowEnvironmentSettingsObject>(Bindings::principal_host_defined_environment_settings_object(window->realm())).cross_origin_isolated_capability() == CanUseCrossOriginIsolatedAPIs::Yes);
// 15. Let document be a new Document, with: // 15. Let document be a new Document, with:
auto document = HTML::HTMLDocument::create(window->realm()); auto document = HTML::HTMLDocument::create(window->realm());

View file

@ -124,7 +124,7 @@ WebIDL::ExceptionOr<void> HTMLDialogElement::show_modal()
return JS::js_undefined(); return JS::js_undefined();
}, },
0, "", &realm()); 0, "", &realm());
auto cancel_callback = realm().heap().allocate_without_realm<WebIDL::CallbackType>(*cancel_callback_function, Bindings::host_defined_environment_settings_object(realm())); auto cancel_callback = realm().heap().allocate_without_realm<WebIDL::CallbackType>(*cancel_callback_function, Bindings::principal_host_defined_environment_settings_object(realm()));
m_close_watcher->add_event_listener_without_options(HTML::EventNames::cancel, DOM::IDLEventListener::create(realm(), cancel_callback)); m_close_watcher->add_event_listener_without_options(HTML::EventNames::cancel, DOM::IDLEventListener::create(realm(), cancel_callback));
// - closeAction being to close the dialog given this and null. // - closeAction being to close the dialog given this and null.
auto close_callback_function = JS::NativeFunction::create( auto close_callback_function = JS::NativeFunction::create(
@ -134,7 +134,7 @@ WebIDL::ExceptionOr<void> HTMLDialogElement::show_modal()
return JS::js_undefined(); return JS::js_undefined();
}, },
0, "", &realm()); 0, "", &realm());
auto close_callback = realm().heap().allocate_without_realm<WebIDL::CallbackType>(*close_callback_function, Bindings::host_defined_environment_settings_object(realm())); auto close_callback = realm().heap().allocate_without_realm<WebIDL::CallbackType>(*close_callback_function, Bindings::principal_host_defined_environment_settings_object(realm()));
m_close_watcher->add_event_listener_without_options(HTML::EventNames::close, DOM::IDLEventListener::create(realm(), close_callback)); m_close_watcher->add_event_listener_without_options(HTML::EventNames::close, DOM::IDLEventListener::create(realm(), close_callback));
// FIXME: 11. Set this's previously focused element to the focused element. // FIXME: 11. Set this's previously focused element to the focused element.

View file

@ -896,7 +896,7 @@ void HTMLInputElement::create_text_input_shadow_tree()
return JS::js_undefined(); return JS::js_undefined();
}, },
0, "", &realm()); 0, "", &realm());
auto mouseup_callback = realm().heap().allocate_without_realm<WebIDL::CallbackType>(*mouseup_callback_function, Bindings::host_defined_environment_settings_object(realm())); auto mouseup_callback = realm().heap().allocate_without_realm<WebIDL::CallbackType>(*mouseup_callback_function, Bindings::principal_host_defined_environment_settings_object(realm()));
DOM::AddEventListenerOptions mouseup_listener_options; DOM::AddEventListenerOptions mouseup_listener_options;
mouseup_listener_options.once = true; mouseup_listener_options.once = true;
@ -909,7 +909,7 @@ void HTMLInputElement::create_text_input_shadow_tree()
return JS::js_undefined(); return JS::js_undefined();
}, },
0, "", &realm()); 0, "", &realm());
auto step_up_callback = realm().heap().allocate_without_realm<WebIDL::CallbackType>(*up_callback_function, Bindings::host_defined_environment_settings_object(realm())); auto step_up_callback = realm().heap().allocate_without_realm<WebIDL::CallbackType>(*up_callback_function, Bindings::principal_host_defined_environment_settings_object(realm()));
up_button->add_event_listener_without_options(UIEvents::EventNames::mousedown, DOM::IDLEventListener::create(realm(), step_up_callback)); up_button->add_event_listener_without_options(UIEvents::EventNames::mousedown, DOM::IDLEventListener::create(realm(), step_up_callback));
up_button->add_event_listener_without_options(UIEvents::EventNames::mouseup, DOM::IDLEventListener::create(realm(), mouseup_callback)); up_button->add_event_listener_without_options(UIEvents::EventNames::mouseup, DOM::IDLEventListener::create(realm(), mouseup_callback));
@ -931,7 +931,7 @@ void HTMLInputElement::create_text_input_shadow_tree()
return JS::js_undefined(); return JS::js_undefined();
}, },
0, "", &realm()); 0, "", &realm());
auto step_down_callback = realm().heap().allocate_without_realm<WebIDL::CallbackType>(*down_callback_function, Bindings::host_defined_environment_settings_object(realm())); auto step_down_callback = realm().heap().allocate_without_realm<WebIDL::CallbackType>(*down_callback_function, Bindings::principal_host_defined_environment_settings_object(realm()));
down_button->add_event_listener_without_options(UIEvents::EventNames::mousedown, DOM::IDLEventListener::create(realm(), step_down_callback)); down_button->add_event_listener_without_options(UIEvents::EventNames::mousedown, DOM::IDLEventListener::create(realm(), step_down_callback));
down_button->add_event_listener_without_options(UIEvents::EventNames::mouseup, DOM::IDLEventListener::create(realm(), mouseup_callback)); down_button->add_event_listener_without_options(UIEvents::EventNames::mouseup, DOM::IDLEventListener::create(realm(), mouseup_callback));
} }
@ -990,7 +990,7 @@ void HTMLInputElement::create_file_input_shadow_tree()
}; };
auto on_button_click_function = JS::NativeFunction::create(realm, move(on_button_click), 0, "", &realm); auto on_button_click_function = JS::NativeFunction::create(realm, move(on_button_click), 0, "", &realm);
auto on_button_click_callback = realm.heap().allocate_without_realm<WebIDL::CallbackType>(on_button_click_function, Bindings::host_defined_environment_settings_object(realm)); auto on_button_click_callback = realm.heap().allocate_without_realm<WebIDL::CallbackType>(on_button_click_function, Bindings::principal_host_defined_environment_settings_object(realm));
m_file_button->add_event_listener_without_options(UIEvents::EventNames::click, DOM::IDLEventListener::create(realm, on_button_click_callback)); m_file_button->add_event_listener_without_options(UIEvents::EventNames::click, DOM::IDLEventListener::create(realm, on_button_click_callback));
update_file_input_shadow_tree(); update_file_input_shadow_tree();
@ -1062,7 +1062,7 @@ void HTMLInputElement::create_range_input_shadow_tree()
return JS::js_undefined(); return JS::js_undefined();
}, },
0, "", &realm()); 0, "", &realm());
auto keydown_callback = realm().heap().allocate_without_realm<WebIDL::CallbackType>(*keydown_callback_function, Bindings::host_defined_environment_settings_object(realm())); auto keydown_callback = realm().heap().allocate_without_realm<WebIDL::CallbackType>(*keydown_callback_function, Bindings::principal_host_defined_environment_settings_object(realm()));
add_event_listener_without_options(UIEvents::EventNames::keydown, DOM::IDLEventListener::create(realm(), keydown_callback)); add_event_listener_without_options(UIEvents::EventNames::keydown, DOM::IDLEventListener::create(realm(), keydown_callback));
auto wheel_callback_function = JS::NativeFunction::create( auto wheel_callback_function = JS::NativeFunction::create(
@ -1077,7 +1077,7 @@ void HTMLInputElement::create_range_input_shadow_tree()
return JS::js_undefined(); return JS::js_undefined();
}, },
0, "", &realm()); 0, "", &realm());
auto wheel_callback = realm().heap().allocate_without_realm<WebIDL::CallbackType>(*wheel_callback_function, Bindings::host_defined_environment_settings_object(realm())); auto wheel_callback = realm().heap().allocate_without_realm<WebIDL::CallbackType>(*wheel_callback_function, Bindings::principal_host_defined_environment_settings_object(realm()));
add_event_listener_without_options(UIEvents::EventNames::wheel, DOM::IDLEventListener::create(realm(), wheel_callback)); add_event_listener_without_options(UIEvents::EventNames::wheel, DOM::IDLEventListener::create(realm(), wheel_callback));
auto update_slider_by_mouse = [this](JS::VM& vm) { auto update_slider_by_mouse = [this](JS::VM& vm) {
@ -1100,7 +1100,7 @@ void HTMLInputElement::create_range_input_shadow_tree()
return JS::js_undefined(); return JS::js_undefined();
}, },
0, "", &realm()); 0, "", &realm());
auto mousemove_callback = realm().heap().allocate_without_realm<WebIDL::CallbackType>(*mousemove_callback_function, Bindings::host_defined_environment_settings_object(realm())); auto mousemove_callback = realm().heap().allocate_without_realm<WebIDL::CallbackType>(*mousemove_callback_function, Bindings::principal_host_defined_environment_settings_object(realm()));
auto mousemove_listener = DOM::IDLEventListener::create(realm(), mousemove_callback); auto mousemove_listener = DOM::IDLEventListener::create(realm(), mousemove_callback);
auto& window = static_cast<HTML::Window&>(relevant_global_object(*this)); auto& window = static_cast<HTML::Window&>(relevant_global_object(*this));
window.add_event_listener_without_options(UIEvents::EventNames::mousemove, mousemove_listener); window.add_event_listener_without_options(UIEvents::EventNames::mousemove, mousemove_listener);
@ -1112,7 +1112,7 @@ void HTMLInputElement::create_range_input_shadow_tree()
return JS::js_undefined(); return JS::js_undefined();
}, },
0, "", &realm()); 0, "", &realm());
auto mouseup_callback = realm().heap().allocate_without_realm<WebIDL::CallbackType>(*mouseup_callback_function, Bindings::host_defined_environment_settings_object(realm())); auto mouseup_callback = realm().heap().allocate_without_realm<WebIDL::CallbackType>(*mouseup_callback_function, Bindings::principal_host_defined_environment_settings_object(realm()));
DOM::AddEventListenerOptions mouseup_listener_options; DOM::AddEventListenerOptions mouseup_listener_options;
mouseup_listener_options.once = true; mouseup_listener_options.once = true;
window.add_event_listener(UIEvents::EventNames::mouseup, DOM::IDLEventListener::create(realm(), mouseup_callback), mouseup_listener_options); window.add_event_listener(UIEvents::EventNames::mouseup, DOM::IDLEventListener::create(realm(), mouseup_callback), mouseup_listener_options);
@ -1120,7 +1120,7 @@ void HTMLInputElement::create_range_input_shadow_tree()
return JS::js_undefined(); return JS::js_undefined();
}, },
0, "", &realm()); 0, "", &realm());
auto mousedown_callback = realm().heap().allocate_without_realm<WebIDL::CallbackType>(*mousedown_callback_function, Bindings::host_defined_environment_settings_object(realm())); auto mousedown_callback = realm().heap().allocate_without_realm<WebIDL::CallbackType>(*mousedown_callback_function, Bindings::principal_host_defined_environment_settings_object(realm()));
add_event_listener_without_options(UIEvents::EventNames::mousedown, DOM::IDLEventListener::create(realm(), mousedown_callback)); add_event_listener_without_options(UIEvents::EventNames::mousedown, DOM::IDLEventListener::create(realm(), mousedown_callback));
} }

View file

@ -140,7 +140,7 @@ JS::ExecutionContext const& execution_context_of_realm(JS::Realm const& realm)
// FIXME: 1. If realm is a principal realm, then return the realm execution context of the environment settings object of realm. // FIXME: 1. If realm is a principal realm, then return the realm execution context of the environment settings object of realm.
// FIXME: 2. Assert: realm is a synthetic realm. // FIXME: 2. Assert: realm is a synthetic realm.
// FIXME: 3. Return the execution context of the synthetic realm settings object of realm. // FIXME: 3. Return the execution context of the synthetic realm settings object of realm.
return Bindings::host_defined_environment_settings_object(realm).realm_execution_context(); return Bindings::principal_host_defined_environment_settings_object(realm).realm_execution_context();
} }
// https://html.spec.whatwg.org/multipage/webappapis.html#clean-up-after-running-script // https://html.spec.whatwg.org/multipage/webappapis.html#clean-up-after-running-script
@ -327,7 +327,7 @@ JS::Realm& incumbent_realm()
EnvironmentSettingsObject& incumbent_settings_object() EnvironmentSettingsObject& incumbent_settings_object()
{ {
// FIXME: Then, the incumbent settings object is the incumbent realm's principal realm settings object. // FIXME: Then, the incumbent settings object is the incumbent realm's principal realm settings object.
return Bindings::host_defined_environment_settings_object(incumbent_realm()); return Bindings::principal_host_defined_environment_settings_object(incumbent_realm());
} }
// https://html.spec.whatwg.org/multipage/webappapis.html#concept-incumbent-global // https://html.spec.whatwg.org/multipage/webappapis.html#concept-incumbent-global
@ -362,7 +362,7 @@ JS::Realm& principal_realm(JS::Realm& realm)
EnvironmentSettingsObject& principal_realm_settings_object(JS::Realm& realm) EnvironmentSettingsObject& principal_realm_settings_object(JS::Realm& realm)
{ {
// A principal realm has a [[HostDefined]] field, which contains the principal realm's settings object. // A principal realm has a [[HostDefined]] field, which contains the principal realm's settings object.
return Bindings::host_defined_environment_settings_object(realm); return Bindings::principal_host_defined_environment_settings_object(realm);
} }
// https://html.spec.whatwg.org/multipage/webappapis.html#current-settings-object // https://html.spec.whatwg.org/multipage/webappapis.html#current-settings-object
@ -392,7 +392,7 @@ JS::Realm& relevant_realm(JS::Object const& object)
EnvironmentSettingsObject& relevant_settings_object(JS::Object const& object) EnvironmentSettingsObject& relevant_settings_object(JS::Object const& object)
{ {
// Then, the relevant settings object for a platform object o is the environment settings object of the relevant Realm for o. // Then, the relevant settings object for a platform object o is the environment settings object of the relevant Realm for o.
return Bindings::host_defined_environment_settings_object(relevant_realm(object)); return Bindings::principal_host_defined_environment_settings_object(relevant_realm(object));
} }
EnvironmentSettingsObject& relevant_settings_object(DOM::Node const& node) EnvironmentSettingsObject& relevant_settings_object(DOM::Node const& node)
@ -424,7 +424,7 @@ JS::Realm& entry_realm()
EnvironmentSettingsObject& entry_settings_object() EnvironmentSettingsObject& entry_settings_object()
{ {
// Then, the entry settings object is the environment settings object of the entry realm. // Then, the entry settings object is the environment settings object of the entry realm.
return Bindings::host_defined_environment_settings_object(entry_realm()); return Bindings::principal_host_defined_environment_settings_object(entry_realm());
} }
// https://html.spec.whatwg.org/multipage/webappapis.html#entry-global-object // https://html.spec.whatwg.org/multipage/webappapis.html#entry-global-object

View file

@ -6,7 +6,6 @@
#include <LibJS/Console.h> #include <LibJS/Console.h>
#include <LibJS/Runtime/ConsoleObject.h> #include <LibJS/Runtime/ConsoleObject.h>
#include <LibWeb/Bindings/HostDefined.h>
#include <LibWeb/DOMURL/DOMURL.h> #include <LibWeb/DOMURL/DOMURL.h>
#include <LibWeb/HTML/Scripting/Fetching.h> #include <LibWeb/HTML/Scripting/Fetching.h>
#include <LibWeb/HTML/Scripting/ImportMap.h> #include <LibWeb/HTML/Scripting/ImportMap.h>

View file

@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
*/ */
#include <LibWeb/Bindings/HostDefined.h>
#include <LibWeb/Bindings/Intrinsics.h> #include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Bindings/PrincipalHostDefined.h>
#include <LibWeb/DOM/Document.h> #include <LibWeb/DOM/Document.h>
#include <LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.h> #include <LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.h>
#include <LibWeb/HTML/Window.h> #include <LibWeb/HTML/Window.h>
@ -74,7 +74,7 @@ void WindowEnvironmentSettingsObject::setup(Page& page, URL::URL const& creation
// 7. Set realm's [[HostDefined]] field to settings object. // 7. Set realm's [[HostDefined]] field to settings object.
// Non-Standard: We store the ESO next to the web intrinsics in a custom HostDefined object // Non-Standard: We store the ESO next to the web intrinsics in a custom HostDefined object
auto intrinsics = realm->heap().allocate<Bindings::Intrinsics>(*realm, *realm); auto intrinsics = realm->heap().allocate<Bindings::Intrinsics>(*realm, *realm);
auto host_defined = make<Bindings::HostDefined>(settings_object, intrinsics, page); auto host_defined = make<Bindings::PrincipalHostDefined>(settings_object, intrinsics, page);
realm->set_host_defined(move(host_defined)); realm->set_host_defined(move(host_defined));
// Non-Standard: We cannot fully initialize window object until *after* the we set up // Non-Standard: We cannot fully initialize window object until *after* the we set up

View file

@ -44,7 +44,7 @@ JS::NonnullGCPtr<WorkerEnvironmentSettingsObject> WorkerEnvironmentSettingsObjec
// 8. Set realm's [[HostDefined]] field to settings object. // 8. Set realm's [[HostDefined]] field to settings object.
auto intrinsics = realm->heap().allocate<Bindings::Intrinsics>(*realm, *realm); auto intrinsics = realm->heap().allocate<Bindings::Intrinsics>(*realm, *realm);
auto host_defined = make<Bindings::HostDefined>(settings_object, intrinsics, page); auto host_defined = make<Bindings::PrincipalHostDefined>(settings_object, intrinsics, page);
realm->set_host_defined(move(host_defined)); realm->set_host_defined(move(host_defined));
// Non-Standard: We cannot fully initialize worker object until *after* the we set up // Non-Standard: We cannot fully initialize worker object until *after* the we set up

View file

@ -24,7 +24,7 @@ JS_DEFINE_ALLOCATOR(SharedResourceRequest);
JS::NonnullGCPtr<SharedResourceRequest> SharedResourceRequest::get_or_create(JS::Realm& realm, JS::NonnullGCPtr<Page> page, URL::URL const& url) JS::NonnullGCPtr<SharedResourceRequest> SharedResourceRequest::get_or_create(JS::Realm& realm, JS::NonnullGCPtr<Page> page, URL::URL const& url)
{ {
auto document = Bindings::host_defined_environment_settings_object(realm).responsible_document(); auto document = Bindings::principal_host_defined_environment_settings_object(realm).responsible_document();
VERIFY(document); VERIFY(document);
auto& shared_resource_requests = document->shared_resource_requests(); auto& shared_resource_requests = document->shared_resource_requests();
if (auto it = shared_resource_requests.find(url); it != shared_resource_requests.end()) if (auto it = shared_resource_requests.find(url); it != shared_resource_requests.end())

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
*/ */
#include <LibWeb/Bindings/HostDefined.h> #include <LibWeb/Bindings/PrincipalHostDefined.h>
#include <LibWeb/HTML/MessagePort.h> #include <LibWeb/HTML/MessagePort.h>
#include <LibWeb/HTML/WorkerAgent.h> #include <LibWeb/HTML/WorkerAgent.h>
#include <LibWeb/Page/Page.h> #include <LibWeb/Page/Page.h>
@ -34,7 +34,7 @@ void WorkerAgent::initialize(JS::Realm& realm)
// NOTE: This blocking IPC call may launch another process. // NOTE: This blocking IPC call may launch another process.
// If spinning the event loop for this can cause other javascript to execute, we're in trouble. // If spinning the event loop for this can cause other javascript to execute, we're in trouble.
auto worker_socket_file = Bindings::host_defined_page(realm).client().request_worker_agent(); auto worker_socket_file = Bindings::principal_host_defined_page(realm).client().request_worker_agent();
auto worker_socket = MUST(Core::LocalSocket::adopt_fd(worker_socket_file.take_fd())); auto worker_socket = MUST(Core::LocalSocket::adopt_fd(worker_socket_file.take_fd()));
MUST(worker_socket->set_blocking(true)); MUST(worker_socket->set_blocking(true));

View file

@ -12,7 +12,6 @@
#include <LibJS/Forward.h> #include <LibJS/Forward.h>
#include <LibJS/Runtime/AbstractOperations.h> #include <LibJS/Runtime/AbstractOperations.h>
#include <LibJS/Runtime/FunctionObject.h> #include <LibJS/Runtime/FunctionObject.h>
#include <LibWeb/Bindings/HostDefined.h>
#include <LibWeb/HTML/Scripting/Environments.h> #include <LibWeb/HTML/Scripting/Environments.h>
#include <LibWeb/WebIDL/CallbackType.h> #include <LibWeb/WebIDL/CallbackType.h>

View file

@ -11,7 +11,6 @@
#include <LibJS/Runtime/PromiseConstructor.h> #include <LibJS/Runtime/PromiseConstructor.h>
#include <LibJS/Runtime/Realm.h> #include <LibJS/Runtime/Realm.h>
#include <LibWeb/Bindings/ExceptionOrUtils.h> #include <LibWeb/Bindings/ExceptionOrUtils.h>
#include <LibWeb/Bindings/HostDefined.h>
#include <LibWeb/HTML/Scripting/ExceptionReporter.h> #include <LibWeb/HTML/Scripting/ExceptionReporter.h>
#include <LibWeb/WebIDL/Promise.h> #include <LibWeb/WebIDL/Promise.h>