Skip to content

Commit c6a18f7

Browse files
AtkinsSJawesomekling
authored andcommitted
LibWeb/HTML: Pass user_involvement through navigables code
This corresponds to part of whatwg/html#10818
1 parent 8b5e9c2 commit c6a18f7

File tree

7 files changed

+110
-94
lines changed

7 files changed

+110
-94
lines changed

Libraries/LibWeb/DOM/DocumentLoading.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,15 +460,16 @@ GC::Ptr<DOM::Document> load_document(HTML::NavigationParams const& navigation_pa
460460
if (type.essence() == "application/pdf"_string
461461
|| type.essence() == "text/pdf"_string) {
462462
// FIXME: If the user agent's PDF viewer supported is true, return the result of creating a document for inline
463-
// content that doesn't have a DOM given navigationParams's navigable.
463+
// content that doesn't have a DOM given navigationParams's navigable, navigationParams's id,
464+
// navigationParams's navigation timing type, and navigationParams's user involvement.
464465
}
465466

466467
// Otherwise, proceed onward.
467468

468-
// 3. If, given type, the new resource is to be handled by displaying some sort of inline content, e.g., a
469+
// FIXME: 3. If, given type, the new resource is to be handled by displaying some sort of inline content, e.g., a
469470
// native rendering of the content or an error message because the specified type is not supported, then
470471
// return the result of creating a document for inline content that doesn't have a DOM given navigationParams's
471-
// navigable, navigationParams's id, and navigationParams's navigation timing type.
472+
// navigable, navigationParams's id, navigationParams's navigation timing type, and navigationParams's user involvement.
472473

473474
// FIXME: 4. Otherwise, the document's type is such that the resource will not affect navigationParams's navigable,
474475
// e.g., because the resource is to be handed to an external application or because it is an unknown type

Libraries/LibWeb/DOM/DocumentLoading.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ bool can_load_document_with_type(MimeSniff::MimeType const&);
1818

1919
// https://html.spec.whatwg.org/multipage/document-lifecycle.html#read-ua-inline
2020
template<typename MutateDocument>
21-
GC::Ref<DOM::Document> create_document_for_inline_content(GC::Ptr<HTML::Navigable> navigable, Optional<String> navigation_id, MutateDocument mutate_document)
21+
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)
2222
{
2323
auto& vm = navigable->vm();
2424

@@ -53,6 +53,7 @@ GC::Ref<DOM::Document> create_document_for_inline_content(GC::Ptr<HTML::Navigabl
5353
// opener policy: coop
5454
// FIXME: navigation timing type: navTimingType
5555
// about base URL: null
56+
// user involvement: userInvolvement
5657
auto response = Fetch::Infrastructure::Response::create(vm);
5758
response->url_list().append(URL::URL("about:error")); // AD-HOC: https://github.com/whatwg/html/issues/9122
5859
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
6970
navigation_params->final_sandboxing_flag_set = HTML::SandboxingFlagSet {};
7071
navigation_params->opener_policy = move(coop);
7172
navigation_params->about_base_url = {};
73+
navigation_params->user_involvement = user_involvement;
7274

7375
// 5. Let document be the result of creating and initializing a Document object given "html", "text/html", and navigationParams.
7476
auto document = DOM::Document::create_and_initialize(DOM::Document::Type::HTML, "text/html"_string, navigation_params).release_value_but_fixme_should_propagate_errors();

Libraries/LibWeb/HTML/Navigable.cpp

Lines changed: 52 additions & 42 deletions
Large diffs are not rendered by default.

Libraries/LibWeb/HTML/Navigable.h

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,6 @@ enum class CSPNavigationType {
3434
FormSubmission,
3535
};
3636

37-
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#user-navigation-involvement
38-
enum class UserNavigationInvolvement {
39-
BrowserUI,
40-
Activation,
41-
None,
42-
};
43-
4437
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#target-snapshot-params
4538
struct TargetSnapshotParams {
4639
SandboxingFlagSet sandboxing_flags {};
@@ -133,6 +126,7 @@ class Navigable : public JS::Cell {
133126
GC::Ptr<SessionHistoryEntry> entry,
134127
SourceSnapshotParams const& source_snapshot_params,
135128
TargetSnapshotParams const& target_snapshot_params,
129+
UserNavigationInvolvement user_involvement,
136130
Optional<String> navigation_id = {},
137131
NavigationParamsVariant navigation_params = Navigable::NullOrError {},
138132
CSPNavigationType csp_navigation_type = CSPNavigationType::Other,
@@ -156,12 +150,12 @@ class Navigable : public JS::Cell {
156150

157151
WebIDL::ExceptionOr<void> navigate_to_a_fragment(URL::URL const&, HistoryHandlingBehavior, UserNavigationInvolvement, Optional<SerializationRecord> navigation_api_state, String navigation_id);
158152

159-
GC::Ptr<DOM::Document> evaluate_javascript_url(URL::URL const&, URL::Origin const& new_document_origin, String navigation_id);
160-
void navigate_to_a_javascript_url(URL::URL const&, HistoryHandlingBehavior, URL::Origin const& initiator_origin, CSPNavigationType csp_navigation_type, String navigation_id);
153+
GC::Ptr<DOM::Document> evaluate_javascript_url(URL::URL const&, URL::Origin const& new_document_origin, UserNavigationInvolvement, String navigation_id);
154+
void navigate_to_a_javascript_url(URL::URL const&, HistoryHandlingBehavior, URL::Origin const& initiator_origin, UserNavigationInvolvement, CSPNavigationType csp_navigation_type, String navigation_id);
161155

162156
bool allowed_by_sandboxing_to_navigate(Navigable const& target, SourceSnapshotParams const&);
163157

164-
void reload();
158+
void reload(UserNavigationInvolvement = UserNavigationInvolvement::None);
165159

166160
// https://github.com/whatwg/html/issues/9690
167161
[[nodiscard]] bool has_been_destroyed() const { return m_has_been_destroyed; }
@@ -245,7 +239,7 @@ class Navigable : public JS::Cell {
245239
HashTable<Navigable*>& all_navigables();
246240

247241
bool navigation_must_be_a_replace(URL::URL const& url, DOM::Document const& document);
248-
void finalize_a_cross_document_navigation(GC::Ref<Navigable>, HistoryHandlingBehavior, GC::Ref<SessionHistoryEntry>);
242+
void finalize_a_cross_document_navigation(GC::Ref<Navigable>, HistoryHandlingBehavior, UserNavigationInvolvement, GC::Ref<SessionHistoryEntry>);
249243
void perform_url_and_history_update_steps(DOM::Document& document, URL::URL new_url, Optional<SerializationRecord> = {}, HistoryHandlingBehavior history_handling = HistoryHandlingBehavior::Replace);
250244
UserNavigationInvolvement user_navigation_involvement(DOM::Event const&);
251245

Libraries/LibWeb/HTML/NavigationParams.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020

2121
namespace Web::HTML {
2222

23+
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#user-navigation-involvement
24+
enum class UserNavigationInvolvement {
25+
BrowserUI,
26+
Activation,
27+
None,
28+
};
29+
2330
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigation-params
2431
struct NavigationParams : JS::Cell {
2532
GC_CELL(NavigationParams, JS::Cell);
@@ -66,6 +73,9 @@ struct NavigationParams : JS::Cell {
6673
// a URL or null used to populate the new Document's about base URL
6774
Optional<URL::URL> about_base_url;
6875

76+
// a user navigation involvement used when obtaining a browsing context for the new Document
77+
UserNavigationInvolvement user_involvement;
78+
6979
void visit_edges(Visitor& visitor) override;
7080
};
7181

@@ -94,6 +104,9 @@ struct NonFetchSchemeNavigationParams : JS::Cell {
94104

95105
// FIXME: a NavigationTimingType used for creating the navigation timing entry for the new Document
96106

107+
// a user navigation involvement used when obtaining a browsing context for the new Document (if one is created)
108+
UserNavigationInvolvement user_involvement;
109+
97110
void visit_edges(Visitor& visitor) override;
98111
};
99112

0 commit comments

Comments
 (0)