LibWeb/HTML: Pass user_involvement through navigables code

This corresponds to part of https://github.com/whatwg/html/pull/10818
This commit is contained in:
Sam Atkins 2025-01-07 14:58:48 +00:00 committed by Andreas Kling
commit c6a18f795d
Notes: github-actions[bot] 2025-01-11 10:11:59 +00:00
7 changed files with 110 additions and 94 deletions

View file

@ -460,15 +460,16 @@ GC::Ptr<DOM::Document> load_document(HTML::NavigationParams const& navigation_pa
if (type.essence() == "application/pdf"_string
|| type.essence() == "text/pdf"_string) {
// FIXME: If the user agent's PDF viewer supported is true, return the result of creating a document for inline
// content that doesn't have a DOM given navigationParams's navigable.
// content that doesn't have a DOM given navigationParams's navigable, navigationParams's id,
// navigationParams's navigation timing type, and navigationParams's user involvement.
}
// Otherwise, proceed onward.
// 3. If, given type, the new resource is to be handled by displaying some sort of inline content, e.g., a
// FIXME: 3. If, given type, the new resource is to be handled by displaying some sort of inline content, e.g., a
// native rendering of the content or an error message because the specified type is not supported, then
// return the result of creating a document for inline content that doesn't have a DOM given navigationParams's
// navigable, navigationParams's id, and navigationParams's navigation timing type.
// navigable, navigationParams's id, navigationParams's navigation timing type, and navigationParams's user involvement.
// FIXME: 4. Otherwise, the document's type is such that the resource will not affect navigationParams's navigable,
// e.g., because the resource is to be handed to an external application or because it is an unknown type

View file

@ -18,7 +18,7 @@ bool can_load_document_with_type(MimeSniff::MimeType const&);
// https://html.spec.whatwg.org/multipage/document-lifecycle.html#read-ua-inline
template<typename MutateDocument>
GC::Ref<DOM::Document> create_document_for_inline_content(GC::Ptr<HTML::Navigable> navigable, Optional<String> navigation_id, MutateDocument mutate_document)
GC::Ref<DOM::Document> create_document_for_inline_content(GC::Ptr<HTML::Navigable> navigable, Optional<String> navigation_id, HTML::UserNavigationInvolvement user_involvement, MutateDocument mutate_document)
{
auto& vm = navigable->vm();
@ -53,6 +53,7 @@ GC::Ref<DOM::Document> create_document_for_inline_content(GC::Ptr<HTML::Navigabl
// opener policy: coop
// FIXME: navigation timing type: navTimingType
// about base URL: null
// user involvement: userInvolvement
auto response = Fetch::Infrastructure::Response::create(vm);
response->url_list().append(URL::URL("about:error")); // AD-HOC: https://github.com/whatwg/html/issues/9122
auto navigation_params = vm.heap().allocate<HTML::NavigationParams>();
@ -69,6 +70,7 @@ GC::Ref<DOM::Document> create_document_for_inline_content(GC::Ptr<HTML::Navigabl
navigation_params->final_sandboxing_flag_set = HTML::SandboxingFlagSet {};
navigation_params->opener_policy = move(coop);
navigation_params->about_base_url = {};
navigation_params->user_involvement = user_involvement;
// 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();