mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 04:39:06 +00:00
LibWeb: Give NavigationParams a constructor
This allows for NavigationParams to hold non-default constructable types.
This commit is contained in:
parent
766cbf4937
commit
0d905b1846
Notes:
github-actions[bot]
2025-06-17 18:55:41 +00:00
Author: https://github.com/shannonbooth
Commit: 0d905b1846
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5094
Reviewed-by: https://github.com/gmta ✅
4 changed files with 107 additions and 66 deletions
|
@ -57,21 +57,21 @@ GC::Ref<DOM::Document> create_document_for_inline_content(GC::Ptr<HTML::Navigabl
|
||||||
// user involvement: userInvolvement
|
// user involvement: userInvolvement
|
||||||
auto response = Fetch::Infrastructure::Response::create(vm);
|
auto response = Fetch::Infrastructure::Response::create(vm);
|
||||||
response->url_list().append(URL::about_error()); // AD-HOC: https://github.com/whatwg/html/issues/9122
|
response->url_list().append(URL::about_error()); // AD-HOC: https://github.com/whatwg/html/issues/9122
|
||||||
auto navigation_params = vm.heap().allocate<HTML::NavigationParams>();
|
auto navigation_params = vm.heap().allocate<HTML::NavigationParams>(
|
||||||
navigation_params->id = move(navigation_id);
|
move(navigation_id),
|
||||||
navigation_params->navigable = navigable;
|
navigable,
|
||||||
navigation_params->request = nullptr;
|
nullptr,
|
||||||
navigation_params->response = response;
|
response,
|
||||||
navigation_params->fetch_controller = nullptr;
|
nullptr,
|
||||||
navigation_params->commit_early_hints = nullptr;
|
nullptr,
|
||||||
navigation_params->coop_enforcement_result = move(coop_enforcement_result);
|
move(coop_enforcement_result),
|
||||||
navigation_params->reserved_environment = {};
|
nullptr,
|
||||||
navigation_params->origin = move(origin);
|
move(origin),
|
||||||
navigation_params->policy_container = vm.heap().allocate<HTML::PolicyContainer>(vm.heap());
|
vm.heap().allocate<HTML::PolicyContainer>(vm.heap()),
|
||||||
navigation_params->final_sandboxing_flag_set = HTML::SandboxingFlagSet {};
|
HTML::SandboxingFlagSet {},
|
||||||
navigation_params->opener_policy = move(coop);
|
move(coop),
|
||||||
navigation_params->about_base_url = {};
|
OptionalNone {},
|
||||||
navigation_params->user_involvement = user_involvement;
|
user_involvement);
|
||||||
|
|
||||||
// 5. Let document be the result of creating and initializing a Document object given "html", "text/html", and navigationParams.
|
// 5. Let document be the result of creating and initializing a Document object given "html", "text/html", and navigationParams.
|
||||||
auto document = DOM::Document::create_and_initialize(DOM::Document::Type::HTML, "text/html"_string, navigation_params).release_value_but_fixme_should_propagate_errors();
|
auto document = DOM::Document::create_and_initialize(DOM::Document::Type::HTML, "text/html"_string, navigation_params).release_value_but_fixme_should_propagate_errors();
|
||||||
|
|
|
@ -751,19 +751,21 @@ static GC::Ref<NavigationParams> create_navigation_params_from_a_srcdoc_resource
|
||||||
// FIXME: navigation timing type: navTimingType
|
// FIXME: navigation timing type: navTimingType
|
||||||
// about base URL: entry's document state's about base URL
|
// about base URL: entry's document state's about base URL
|
||||||
// user involvement: userInvolvement
|
// user involvement: userInvolvement
|
||||||
auto navigation_params = vm.heap().allocate<NavigationParams>();
|
return vm.heap().allocate<NavigationParams>(
|
||||||
navigation_params->id = move(navigation_id);
|
move(navigation_id),
|
||||||
navigation_params->navigable = navigable;
|
navigable,
|
||||||
navigation_params->response = response;
|
nullptr,
|
||||||
navigation_params->coop_enforcement_result = move(coop_enforcement_result);
|
response,
|
||||||
navigation_params->origin = move(response_origin);
|
nullptr,
|
||||||
navigation_params->policy_container = *policy_container;
|
nullptr,
|
||||||
navigation_params->final_sandboxing_flag_set = target_snapshot_params.sandboxing_flags;
|
move(coop_enforcement_result),
|
||||||
navigation_params->opener_policy = move(coop);
|
nullptr,
|
||||||
navigation_params->about_base_url = entry->document_state()->about_base_url();
|
move(response_origin),
|
||||||
navigation_params->user_involvement = user_involvement;
|
*policy_container,
|
||||||
|
target_snapshot_params.sandboxing_flags,
|
||||||
return navigation_params;
|
move(coop),
|
||||||
|
entry->document_state()->about_base_url(),
|
||||||
|
user_involvement);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#create-navigation-params-by-fetching
|
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#create-navigation-params-by-fetching
|
||||||
|
@ -1165,22 +1167,21 @@ static WebIDL::ExceptionOr<Navigable::NavigationParamsVariant> create_navigation
|
||||||
// FIXME: navigation timing type: navTimingType
|
// FIXME: navigation timing type: navTimingType
|
||||||
// about base URL: entry's document state's about base URL
|
// about base URL: entry's document state's about base URL
|
||||||
// user involvement: userInvolvement
|
// user involvement: userInvolvement
|
||||||
auto navigation_params = vm.heap().allocate<NavigationParams>();
|
return vm.heap().allocate<NavigationParams>(
|
||||||
navigation_params->id = navigation_id;
|
navigation_id,
|
||||||
navigation_params->navigable = navigable;
|
navigable,
|
||||||
navigation_params->request = request;
|
request,
|
||||||
navigation_params->response = *response_holder->response();
|
*response_holder->response(),
|
||||||
navigation_params->fetch_controller = fetch_controller;
|
fetch_controller,
|
||||||
navigation_params->commit_early_hints = move(commit_early_hints);
|
move(commit_early_hints),
|
||||||
navigation_params->coop_enforcement_result = coop_enforcement_result;
|
coop_enforcement_result,
|
||||||
navigation_params->reserved_environment = request->reserved_client();
|
request->reserved_client(),
|
||||||
navigation_params->origin = *response_origin;
|
*response_origin,
|
||||||
navigation_params->policy_container = result_policy_container;
|
result_policy_container,
|
||||||
navigation_params->final_sandboxing_flag_set = final_sandbox_flags;
|
final_sandbox_flags,
|
||||||
navigation_params->opener_policy = response_coop;
|
response_coop,
|
||||||
navigation_params->about_base_url = entry->document_state()->about_base_url();
|
entry->document_state()->about_base_url(),
|
||||||
navigation_params->user_involvement = user_involvement;
|
user_involvement);
|
||||||
return navigation_params;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#attempt-to-populate-the-history-entry's-document
|
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#attempt-to-populate-the-history-entry's-document
|
||||||
|
@ -1891,21 +1892,21 @@ GC::Ptr<DOM::Document> Navigable::evaluate_javascript_url(URL::URL const& url, U
|
||||||
// FIXME: navigation timing type: "navigate"
|
// FIXME: navigation timing type: "navigate"
|
||||||
// about base URL: targetNavigable's active document's about base URL
|
// about base URL: targetNavigable's active document's about base URL
|
||||||
// user involvement: userInvolvement
|
// user involvement: userInvolvement
|
||||||
auto navigation_params = vm.heap().allocate<NavigationParams>();
|
auto navigation_params = vm.heap().allocate<NavigationParams>(
|
||||||
navigation_params->id = navigation_id;
|
navigation_id,
|
||||||
navigation_params->navigable = this;
|
this,
|
||||||
navigation_params->request = {};
|
nullptr,
|
||||||
navigation_params->response = response;
|
response,
|
||||||
navigation_params->fetch_controller = nullptr;
|
nullptr,
|
||||||
navigation_params->commit_early_hints = nullptr;
|
nullptr,
|
||||||
navigation_params->coop_enforcement_result = move(coop_enforcement_result);
|
move(coop_enforcement_result),
|
||||||
navigation_params->reserved_environment = {};
|
nullptr,
|
||||||
navigation_params->origin = new_document_origin;
|
new_document_origin,
|
||||||
navigation_params->policy_container = policy_container;
|
policy_container,
|
||||||
navigation_params->final_sandboxing_flag_set = final_sandbox_flags;
|
final_sandbox_flags,
|
||||||
navigation_params->opener_policy = coop;
|
coop,
|
||||||
navigation_params->about_base_url = active_document()->about_base_url();
|
active_document()->about_base_url(),
|
||||||
navigation_params->user_involvement = user_involvement;
|
user_involvement);
|
||||||
|
|
||||||
// 17. Return the result of loading an HTML document given navigationParams.
|
// 17. Return the result of loading an HTML document given navigationParams.
|
||||||
return load_document(navigation_params);
|
return load_document(navigation_params);
|
||||||
|
|
|
@ -76,7 +76,40 @@ struct NavigationParams : GC::Cell {
|
||||||
// a user navigation involvement used when obtaining a browsing context for the new Document
|
// a user navigation involvement used when obtaining a browsing context for the new Document
|
||||||
UserNavigationInvolvement user_involvement;
|
UserNavigationInvolvement user_involvement;
|
||||||
|
|
||||||
|
protected:
|
||||||
void visit_edges(Visitor& visitor) override;
|
void visit_edges(Visitor& visitor) override;
|
||||||
|
|
||||||
|
NavigationParams(
|
||||||
|
Optional<String> id,
|
||||||
|
GC::Ptr<Navigable> navigable,
|
||||||
|
GC::Ptr<Fetch::Infrastructure::Request> request,
|
||||||
|
GC::Ptr<Fetch::Infrastructure::Response> response,
|
||||||
|
GC::Ptr<Fetch::Infrastructure::FetchController> fetch_controller,
|
||||||
|
Function<void(DOM::Document&)> commit_early_hints,
|
||||||
|
OpenerPolicyEnforcementResult coop_enforcement_result,
|
||||||
|
Fetch::Infrastructure::Request::ReservedClientType reserved_environment,
|
||||||
|
URL::Origin origin,
|
||||||
|
GC::Ptr<PolicyContainer> policy_container,
|
||||||
|
SandboxingFlagSet final_sandboxing_flag_set,
|
||||||
|
OpenerPolicy opener_policy,
|
||||||
|
Optional<URL::URL> about_base_url,
|
||||||
|
UserNavigationInvolvement user_involvement)
|
||||||
|
: id(move(id))
|
||||||
|
, navigable(navigable)
|
||||||
|
, request(request)
|
||||||
|
, response(response)
|
||||||
|
, fetch_controller(fetch_controller)
|
||||||
|
, commit_early_hints(move(commit_early_hints))
|
||||||
|
, coop_enforcement_result(move(coop_enforcement_result))
|
||||||
|
, reserved_environment(reserved_environment)
|
||||||
|
, origin(move(origin))
|
||||||
|
, policy_container(policy_container)
|
||||||
|
, final_sandboxing_flag_set(final_sandboxing_flag_set)
|
||||||
|
, opener_policy(opener_policy)
|
||||||
|
, about_base_url(move(about_base_url))
|
||||||
|
, user_involvement(user_involvement)
|
||||||
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#non-fetch-scheme-navigation-params
|
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#non-fetch-scheme-navigation-params
|
||||||
|
|
|
@ -37,13 +37,20 @@ ErrorOr<GC::Ref<SVGDecodedImageData>> SVGDecodedImageData::create(JS::Realm& rea
|
||||||
GC::Ref<HTML::Navigable> navigable = page->top_level_traversable();
|
GC::Ref<HTML::Navigable> navigable = page->top_level_traversable();
|
||||||
auto response = Fetch::Infrastructure::Response::create(navigable->vm());
|
auto response = Fetch::Infrastructure::Response::create(navigable->vm());
|
||||||
response->url_list().append(url);
|
response->url_list().append(url);
|
||||||
auto navigation_params = navigable->heap().allocate<HTML::NavigationParams>();
|
auto navigation_params = navigable->heap().allocate<HTML::NavigationParams>(OptionalNone {},
|
||||||
navigation_params->navigable = navigable;
|
navigable,
|
||||||
navigation_params->response = response;
|
nullptr,
|
||||||
navigation_params->origin = URL::Origin {};
|
response,
|
||||||
navigation_params->policy_container = navigable->heap().allocate<HTML::PolicyContainer>(realm.heap());
|
nullptr,
|
||||||
navigation_params->final_sandboxing_flag_set = HTML::SandboxingFlagSet {};
|
nullptr,
|
||||||
navigation_params->opener_policy = HTML::OpenerPolicy {};
|
HTML::OpenerPolicyEnforcementResult {},
|
||||||
|
nullptr,
|
||||||
|
URL::Origin {},
|
||||||
|
navigable->heap().allocate<HTML::PolicyContainer>(realm.heap()),
|
||||||
|
HTML::SandboxingFlagSet {},
|
||||||
|
HTML::OpenerPolicy {},
|
||||||
|
OptionalNone {},
|
||||||
|
HTML::UserNavigationInvolvement::None);
|
||||||
|
|
||||||
// FIXME: Use Navigable::navigate() instead of manually replacing the navigable's document.
|
// FIXME: Use Navigable::navigate() instead of manually replacing the navigable's document.
|
||||||
auto document = MUST(DOM::Document::create_and_initialize(DOM::Document::Type::HTML, "text/html"_string, navigation_params));
|
auto document = MUST(DOM::Document::create_and_initialize(DOM::Document::Type::HTML, "text/html"_string, navigation_params));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue