mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:48:12 +00:00
LibWeb: Remove unused BrowsingContext::create_a_new_browsing_context()
Became unused after introducing create_a_new_browsing_context_and_document() used in navigables.
This commit is contained in:
parent
24f97491bf
commit
4532584b3a
2 changed files with 0 additions and 143 deletions
|
@ -105,147 +105,6 @@ HTML::Origin determine_the_origin(AK::URL const& url, SandboxingFlagSet sandbox_
|
|||
return URL::url_origin(url);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/browsers.html#creating-a-new-browsing-context
|
||||
JS::NonnullGCPtr<BrowsingContext> BrowsingContext::create_a_new_browsing_context(Page& page, JS::GCPtr<DOM::Document> creator, JS::GCPtr<DOM::Element> embedder, BrowsingContextGroup&)
|
||||
{
|
||||
// 1. Let browsingContext be a new browsing context.
|
||||
NavigableContainer* container = (embedder && is<NavigableContainer>(*embedder)) ? static_cast<NavigableContainer*>(embedder.ptr()) : nullptr;
|
||||
auto browsing_context = Bindings::main_thread_vm().heap().allocate_without_realm<BrowsingContext>(page, container);
|
||||
|
||||
// 2. Let unsafeContextCreationTime be the unsafe shared current time.
|
||||
[[maybe_unused]] auto unsafe_context_creation_time = HighResolutionTime::unsafe_shared_current_time();
|
||||
|
||||
// 3. If creator is non-null, then set browsingContext's creator origin to return creator's origin,
|
||||
// browsingContext's creator URL to return creator's URL,
|
||||
// browsingContext's creator base URL to return creator's base URL,
|
||||
// FIXME: and browsingContext's virtual browsing context group ID to creator's top-level browsing context's virtual browsing context group ID.
|
||||
if (creator) {
|
||||
browsing_context->m_creator_origin = creator->origin();
|
||||
browsing_context->m_creator_url = creator->url();
|
||||
browsing_context->m_creator_base_url = creator->base_url();
|
||||
}
|
||||
|
||||
// FIXME: 4. Let sandboxFlags be the result of determining the creation sandboxing flags given browsingContext and embedded.
|
||||
SandboxingFlagSet sandbox_flags = {};
|
||||
|
||||
// 5. Let origin be the result of determining the origin given browsingContext, about:blank, sandboxFlags, and browsingContext's creator origin.
|
||||
auto origin = determine_the_origin(*browsing_context, AK::URL("about:blank"), sandbox_flags, browsing_context->m_creator_origin);
|
||||
|
||||
// FIXME: 6. Let permissionsPolicy be the result of creating a permissions policy given browsingContext and origin. [PERMISSIONSPOLICY]
|
||||
|
||||
// FIXME: 7. Let agent be the result of obtaining a similar-origin window agent given origin, group, and false.
|
||||
|
||||
JS::GCPtr<Window> window;
|
||||
|
||||
// 8. Let realm execution context be the result of creating a new JavaScript realm given agent and the following customizations:
|
||||
auto realm_execution_context = Bindings::create_a_new_javascript_realm(
|
||||
Bindings::main_thread_vm(),
|
||||
[&](JS::Realm& realm) -> JS::Object* {
|
||||
browsing_context->m_window_proxy = realm.heap().allocate<WindowProxy>(realm, realm);
|
||||
|
||||
// - For the global object, create a new Window object.
|
||||
window = HTML::Window::create(realm);
|
||||
return window.ptr();
|
||||
},
|
||||
[&](JS::Realm&) -> JS::Object* {
|
||||
// - For the global this binding, use browsingContext's WindowProxy object.
|
||||
return browsing_context->m_window_proxy;
|
||||
});
|
||||
|
||||
// 9. Let topLevelCreationURL be about:blank if embedder is null; otherwise embedder's relevant settings object's top-level creation URL.
|
||||
auto top_level_creation_url = !embedder ? AK::URL("about:blank") : relevant_settings_object(*embedder).top_level_creation_url;
|
||||
|
||||
// 10. Let topLevelOrigin be origin if embedder is null; otherwise embedder's relevant settings object's top-level origin.
|
||||
auto top_level_origin = !embedder ? origin : relevant_settings_object(*embedder).origin();
|
||||
|
||||
// 11. Set up a window environment settings object with about:blank, realm execution context, null, topLevelCreationURL, and topLevelOrigin.
|
||||
HTML::WindowEnvironmentSettingsObject::setup(
|
||||
AK::URL("about:blank"),
|
||||
move(realm_execution_context),
|
||||
{},
|
||||
top_level_creation_url,
|
||||
top_level_origin);
|
||||
|
||||
// 12. Let loadTimingInfo be a new document load timing info with its navigation start time set to the result of calling
|
||||
// coarsen time with unsafeContextCreationTime and the new environment settings object's cross-origin isolated capability.
|
||||
auto load_timing_info = DOM::DocumentLoadTimingInfo();
|
||||
load_timing_info.navigation_start_time = HighResolutionTime::coarsen_time(
|
||||
unsafe_context_creation_time,
|
||||
verify_cast<WindowEnvironmentSettingsObject>(Bindings::host_defined_environment_settings_object(window->realm())).cross_origin_isolated_capability() == CanUseCrossOriginIsolatedAPIs::Yes);
|
||||
|
||||
// 13. Let coop be a new cross-origin opener policy.
|
||||
auto coop = CrossOriginOpenerPolicy {};
|
||||
|
||||
// 14. If creator is non-null and creator's origin is same origin with creator's relevant settings object's top-level origin,
|
||||
// then set coop to creator's browsing context's top-level browsing context's active document's cross-origin opener policy.
|
||||
if (creator && creator->origin().is_same_origin(relevant_settings_object(*creator).top_level_origin)) {
|
||||
VERIFY(creator->browsing_context());
|
||||
auto* top_level_document = creator->browsing_context()->top_level_browsing_context().active_document();
|
||||
VERIFY(top_level_document);
|
||||
coop = top_level_document->cross_origin_opener_policy();
|
||||
}
|
||||
|
||||
// 15. Let document be a new Document, marked as an HTML document in quirks mode,
|
||||
// whose content type is "text/html",
|
||||
// origin is origin,
|
||||
// FIXME: active sandboxing flag set is sandboxFlags,
|
||||
// FIXME: permissions policy is permissionsPolicy,
|
||||
// cross-origin opener policy is coop,
|
||||
// load timing info is loadTimingInfo,
|
||||
// FIXME: navigation id is null,
|
||||
// and which is ready for post-load tasks.
|
||||
auto document = HTML::HTMLDocument::create(window->realm());
|
||||
|
||||
// Non-standard
|
||||
window->set_associated_document(*document);
|
||||
|
||||
document->set_quirks_mode(DOM::QuirksMode::Yes);
|
||||
document->set_content_type("text/html"_string);
|
||||
document->set_origin(origin);
|
||||
document->set_url(AK::URL("about:blank"));
|
||||
document->set_cross_origin_opener_policy(coop);
|
||||
document->set_load_timing_info(load_timing_info);
|
||||
document->set_ready_for_post_load_tasks(true);
|
||||
|
||||
// FIXME: 16. Assert: document's URL and document's relevant settings object's creation URL are about:blank.
|
||||
|
||||
// 17. Set document's is initial about:blank to true.
|
||||
document->set_is_initial_about_blank(true);
|
||||
|
||||
// 18. Ensure that document has a single child html node, which itself has two empty child nodes: a head element, and a body element.
|
||||
auto html_node = DOM::create_element(document, HTML::TagNames::html, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
|
||||
MUST(html_node->append_child(DOM::create_element(document, HTML::TagNames::head, Namespace::HTML).release_value_but_fixme_should_propagate_errors()));
|
||||
MUST(html_node->append_child(DOM::create_element(document, HTML::TagNames::body, Namespace::HTML).release_value_but_fixme_should_propagate_errors()));
|
||||
MUST(document->append_child(html_node));
|
||||
|
||||
// 19. Set the active document of browsingContext to document.
|
||||
browsing_context->set_active_document(*document);
|
||||
|
||||
// 20. If browsingContext's creator URL is non-null, then set document's referrer to the serialization of it.
|
||||
if (browsing_context->m_creator_url.has_value()) {
|
||||
document->set_referrer(browsing_context->m_creator_url->serialize());
|
||||
}
|
||||
|
||||
// FIXME: 21. If creator is non-null, then set document's policy container to a clone of creator's policy container.
|
||||
|
||||
// 22. Append a new session history entry to browsingContext's session history whose URL is about:blank and document is document.
|
||||
auto new_entry = browsing_context->heap().allocate_without_realm<SessionHistoryEntry>();
|
||||
new_entry->url = AK::URL("about:blank");
|
||||
new_entry->document_state = *browsing_context->heap().allocate_without_realm<DocumentState>();
|
||||
new_entry->document_state->set_document(document.ptr());
|
||||
new_entry->policy_container = {};
|
||||
new_entry->scroll_restoration_mode = {};
|
||||
new_entry->browsing_context_name = {};
|
||||
new_entry->original_source_browsing_context = {};
|
||||
browsing_context->m_session_history.append(*new_entry);
|
||||
|
||||
// 23. Completely finish loading document.
|
||||
document->completely_finish_loading();
|
||||
|
||||
// 24. Return browsingContext.
|
||||
return *browsing_context;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/document-sequences.html#creating-a-new-auxiliary-browsing-context
|
||||
WebIDL::ExceptionOr<BrowsingContext::BrowsingContextAndDocument> BrowsingContext::create_a_new_auxiliary_browsing_context_and_document(Page& page, JS::NonnullGCPtr<HTML::BrowsingContext> opener)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue