Skip to content

Commit 36456bc

Browse files
shannonboothkalenikaliaksandr
authored andcommitted
LibWeb: Remove always true "should report session history updates"
While this was all added together, as far as I can tell this always resolves to true for every test harness we use.
1 parent 7e4c2ac commit 36456bc

12 files changed

Lines changed: 23 additions & 66 deletions

File tree

Libraries/LibWeb/HTML/History.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,8 @@ WebIDL::ExceptionOr<void> History::set_scroll_restoration(Bindings::ScrollRestor
269269
break;
270270
}
271271

272-
if (this_relevant_global_object.associated_document().page().client().should_report_session_history_updates()) {
273-
auto navigable = this_relevant_global_object.navigable();
274-
this_relevant_global_object.associated_document().page().client().page_did_update_session_history_entry_scroll_restoration_mode(navigable->id(), active_session_history_entry->navigation_api_key(), active_session_history_entry->scroll_restoration_mode());
275-
}
272+
auto navigable = this_relevant_global_object.navigable();
273+
this_relevant_global_object.associated_document().page().client().page_did_update_session_history_entry_scroll_restoration_mode(navigable->id(), active_session_history_entry->navigation_api_key(), active_session_history_entry->scroll_restoration_mode());
276274

277275
return {};
278276
}

Libraries/LibWeb/HTML/LocalNavigable.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3202,10 +3202,8 @@ void LocalNavigable::reload(Optional<StorageSerializationRecord> navigation_api_
32023202

32033203
// AD-HOC: Report the reload-pending document state to the UI process before the reload history step finishes,
32043204
// so the UI-owned session history mirror remains synchronized during an in-flight reload.
3205-
if (traversable->page().client().should_report_session_history_updates()) {
3206-
auto session_history_snapshot = traversable->create_session_history_snapshot();
3207-
traversable->page().client().page_did_update_session_history(session_history_snapshot.top_level_session_history_entries, session_history_snapshot.used_session_history_steps, session_history_snapshot.current_used_step_index);
3208-
}
3205+
auto session_history_snapshot = traversable->create_session_history_snapshot();
3206+
traversable->page().client().page_did_update_session_history(session_history_snapshot.top_level_session_history_entries, session_history_snapshot.used_session_history_steps, session_history_snapshot.current_used_step_index);
32093207

32103208
// 4. Append the following session history traversal steps to traversable:
32113209
traversable->append_session_history_traversal_steps(GC::create_function(heap(), [traversable, user_involvement](NonnullRefPtr<Core::Promise<Empty>> signal) {

Libraries/LibWeb/HTML/LocalTraversableNavigable.cpp

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -504,10 +504,8 @@ void LocalTraversableNavigable::reset_session_history_for_testing(GC::Ref<GC::Fu
504504
auto entries_for_navigation_api = get_session_history_entries_for_the_navigation_api(*this, m_current_session_history_step);
505505
active_window()->navigation()->initialize_the_navigation_api_entries_for_reconstructed_session_history(entries_for_navigation_api, active_entry);
506506

507-
if (page().client().should_report_session_history_updates()) {
508-
auto session_history_snapshot = create_session_history_snapshot();
509-
page().client().page_did_update_session_history(session_history_snapshot.top_level_session_history_entries, session_history_snapshot.used_session_history_steps, session_history_snapshot.current_used_step_index);
510-
}
507+
auto session_history_snapshot = create_session_history_snapshot();
508+
page().client().page_did_update_session_history(session_history_snapshot.top_level_session_history_entries, session_history_snapshot.used_session_history_steps, session_history_snapshot.current_used_step_index);
511509

512510
signal->resolve({});
513511
on_complete->function()();
@@ -1548,21 +1546,19 @@ void ApplyHistoryStepState::complete()
15481546
m_traversable->m_current_session_history_step = used_target_step;
15491547

15501548
// AD-HOC: Report the updated session history descriptors to the UI-process mirror.
1551-
if (m_traversable->page().client().should_report_session_history_updates()) {
1552-
auto save_active_entry_persisted_state = LocalTraversableNavigable::SaveActiveEntryPersistedState::Yes;
1553-
// NB: During history traversal, the active entry can point at the target
1554-
// entry before the active document's queued history-step update has
1555-
// restored the target entry's persisted state. Do not overwrite that
1556-
// target entry with the document's pre-restoration viewport offset.
1557-
if (m_navigation_type == Bindings::NavigationType::Traverse) {
1558-
auto document = m_traversable->active_document();
1559-
auto active_entry = m_traversable->active_session_history_entry();
1560-
if (document && active_entry && document->latest_entry() != active_entry)
1561-
save_active_entry_persisted_state = LocalTraversableNavigable::SaveActiveEntryPersistedState::No;
1562-
}
1563-
auto session_history_snapshot = m_traversable->create_session_history_snapshot(save_active_entry_persisted_state);
1564-
m_traversable->page().client().page_did_update_session_history(session_history_snapshot.top_level_session_history_entries, session_history_snapshot.used_session_history_steps, session_history_snapshot.current_used_step_index);
1549+
auto save_active_entry_persisted_state = LocalTraversableNavigable::SaveActiveEntryPersistedState::Yes;
1550+
// NB: During history traversal, the active entry can point at the target
1551+
// entry before the active document's queued history-step update has
1552+
// restored the target entry's persisted state. Do not overwrite that
1553+
// target entry with the document's pre-restoration viewport offset.
1554+
if (m_navigation_type == Bindings::NavigationType::Traverse) {
1555+
auto document = m_traversable->active_document();
1556+
auto active_entry = m_traversable->active_session_history_entry();
1557+
if (document && active_entry && document->latest_entry() != active_entry)
1558+
save_active_entry_persisted_state = LocalTraversableNavigable::SaveActiveEntryPersistedState::No;
15651559
}
1560+
auto session_history_snapshot = m_traversable->create_session_history_snapshot(save_active_entry_persisted_state);
1561+
m_traversable->page().client().page_did_update_session_history(session_history_snapshot.top_level_session_history_entries, session_history_snapshot.used_session_history_steps, session_history_snapshot.current_used_step_index);
15661562

15671563
VERIFY(m_traversable->m_session_history_entries.size() > 0);
15681564
m_traversable->page().client().page_did_change_url(m_traversable->current_session_history_entry()->url());
@@ -2333,10 +2329,8 @@ void LocalTraversableNavigable::apply_the_reload_history_step(UserNavigationInvo
23332329
if (auto current_entry = current_session_history_entry(); current_entry && current_entry->document_state()->reload_pending()) {
23342330
current_entry->document_state()->set_reload_pending(false);
23352331

2336-
if (page().client().should_report_session_history_updates()) {
2337-
auto session_history_snapshot = create_session_history_snapshot();
2338-
page().client().page_did_update_session_history(session_history_snapshot.top_level_session_history_entries, session_history_snapshot.used_session_history_steps, session_history_snapshot.current_used_step_index);
2339-
}
2332+
auto session_history_snapshot = create_session_history_snapshot();
2333+
page().client().page_did_update_session_history(session_history_snapshot.top_level_session_history_entries, session_history_snapshot.used_session_history_steps, session_history_snapshot.current_used_step_index);
23402334
}
23412335
}
23422336
on_complete->function()(result);
@@ -2451,10 +2445,8 @@ bool LocalTraversableNavigable::try_to_synchronously_commit_same_document_naviga
24512445
}
24522446
}
24532447

2454-
if (page().client().should_report_session_history_updates()) {
2455-
auto session_history_snapshot = create_session_history_snapshot(SaveActiveEntryPersistedState::Yes);
2456-
page().client().page_did_update_session_history(session_history_snapshot.top_level_session_history_entries, session_history_snapshot.used_session_history_steps, session_history_snapshot.current_used_step_index);
2457-
}
2448+
auto session_history_snapshot = create_session_history_snapshot(SaveActiveEntryPersistedState::Yes);
2449+
page().client().page_did_update_session_history(session_history_snapshot.top_level_session_history_entries, session_history_snapshot.used_session_history_steps, session_history_snapshot.current_used_step_index);
24582450

24592451
VERIFY(session_history_entries().size() > 0);
24602452
page().client().page_did_change_url(current_session_history_entry()->url());

Libraries/LibWeb/HTML/Navigation.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ static void report_navigation_api_state_update(DOM::Document& document, SessionH
4545
return;
4646

4747
auto traversable = navigable->traversable_navigable();
48-
if (!traversable->page().client().should_report_session_history_updates())
49-
return;
50-
5148
traversable->page().client().page_did_update_session_history_entry_navigation_api_state(navigable->id(), entry.navigation_api_key(), entry.navigation_api_state());
5249
}
5350

Libraries/LibWeb/Internals/Internals.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -805,8 +805,7 @@ Utf16String Internals::dump_ui_process_session_history()
805805
{
806806
auto& document = window().associated_document();
807807
if (auto navigable = document.navigable()) {
808-
if (auto traversable = navigable->traversable_navigable();
809-
traversable && document.page().client().should_report_session_history_updates()) {
808+
if (auto traversable = navigable->traversable_navigable(); traversable) {
810809
auto session_history_snapshot = traversable->create_session_history_snapshot();
811810
return dump_string_to_utf16(document.page().client().page_did_update_session_history_and_request_ui_process_session_history_for_testing(
812811
session_history_snapshot.top_level_session_history_entries,

Libraries/LibWeb/Page/Page.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,6 @@ class PageClient : public JS::Cell {
582582
virtual NewWebViewResult page_did_request_new_web_view(HTML::ActivateTab, HTML::WebViewHints, HTML::TokenizedFeature::NoOpener) { return {}; }
583583
virtual void page_did_request_activate_tab() { }
584584
virtual void page_did_close_top_level_traversable() { }
585-
virtual bool should_report_session_history_updates() const { return true; }
586585
virtual void page_did_update_session_history([[maybe_unused]] Vector<HTML::SessionHistoryEntryDescriptor> const& entries, [[maybe_unused]] Vector<i32> const& used_steps, [[maybe_unused]] size_t current_used_step_index) { }
587586
virtual void page_did_update_session_history_entry_navigation_api_state([[maybe_unused]] HTML::CrossProcessId navigable_id, [[maybe_unused]] Utf16String const& navigation_api_key, [[maybe_unused]] HTML::StorageSerializationRecord const& navigation_api_state) { }
588587
virtual void page_did_update_session_history_entry_scroll_restoration_mode([[maybe_unused]] HTML::CrossProcessId navigable_id, [[maybe_unused]] Utf16String const& navigation_api_key, [[maybe_unused]] HTML::ScrollRestorationMode scroll_restoration_mode) { }

Libraries/LibWebView/HelperProcess.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ ErrorOr<NonnullRefPtr<WebView::WebContentClient>> launch_web_content_process(IsP
123123
arguments.append("--disable-async-scrolling"sv);
124124
if (web_content_options.file_scheme_urls_have_tuple_origins == FileSchemeUrlsHaveTupleOrigins::Yes)
125125
arguments.append("--tuple-file-origins"sv);
126-
if (web_content_options.report_session_history_updates_in_test_mode == ReportSessionHistoryUpdatesInTestMode::Yes)
127-
arguments.append("--report-session-history-updates-in-test-mode"sv);
128126
if (browser_options.disable_sandbox == DisableSandbox::Yes)
129127
arguments.append("--disable-sandbox"sv);
130128

Libraries/LibWebView/Options.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,6 @@ enum class FileSchemeUrlsHaveTupleOrigins {
170170
Yes,
171171
};
172172

173-
enum class ReportSessionHistoryUpdatesInTestMode {
174-
No,
175-
Yes,
176-
};
177-
178173
struct WebContentOptions {
179174
Optional<ByteString> config_path {};
180175
Optional<ByteString> cache_path {};
@@ -194,7 +189,6 @@ struct WebContentOptions {
194189
PaintViewportScrollbars paint_viewport_scrollbars { PaintViewportScrollbars::Yes };
195190
EnableAsyncScrolling enable_async_scrolling { EnableAsyncScrolling::Yes };
196191
FileSchemeUrlsHaveTupleOrigins file_scheme_urls_have_tuple_origins { FileSchemeUrlsHaveTupleOrigins::No };
197-
ReportSessionHistoryUpdatesInTestMode report_session_history_updates_in_test_mode { ReportSessionHistoryUpdatesInTestMode::No };
198192
Optional<StringView> default_time_zone {};
199193
Optional<u64> style_invalidation_counter_dump_interval {};
200194
};

Services/WebContent/PageClient.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ namespace WebContent {
6464

6565
static bool s_is_headless { false };
6666
static bool s_async_scrolling_enabled { false };
67-
static bool s_should_report_session_history_updates_in_test_mode { false };
6867
static constexpr size_t s_max_download_data_ipc_chunk_size = 16 * MiB;
6968

7069
GC_DEFINE_ALLOCATOR(PageClient);
@@ -94,11 +93,6 @@ void PageClient::set_async_scrolling_enabled(bool enabled)
9493
s_async_scrolling_enabled = enabled;
9594
}
9695

97-
void PageClient::set_should_report_session_history_updates_in_test_mode(bool should_report)
98-
{
99-
s_should_report_session_history_updates_in_test_mode = should_report;
100-
}
101-
10296
GC::Ref<PageClient> PageClient::create(JS::VM& vm, PageHost& page_host, u64 id, Optional<Web::HTML::CrossProcessId> pending_root_navigable_id)
10397
{
10498
return vm.heap().allocate<PageClient>(page_host, id, pending_root_navigable_id);
@@ -1085,11 +1079,6 @@ void PageClient::send_current_needs_beforeunload_check()
10851079
client().async_did_change_needs_beforeunload_check(m_id, page().needs_beforeunload_check());
10861080
}
10871081

1088-
bool PageClient::should_report_session_history_updates() const
1089-
{
1090-
return !Web::HTML::Window::in_test_mode() || s_should_report_session_history_updates_in_test_mode;
1091-
}
1092-
10931082
void PageClient::page_did_update_session_history(Vector<Web::HTML::SessionHistoryEntryDescriptor> const& entries, Vector<i32> const& used_steps, size_t current_used_step_index)
10941083
{
10951084
client().async_did_update_session_history(m_id, entries, used_steps, current_used_step_index);

Services/WebContent/PageClient.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class PageClient final : public Web::PageClient {
4646
static void set_is_headless(bool);
4747

4848
static void set_async_scrolling_enabled(bool);
49-
static void set_should_report_session_history_updates_in_test_mode(bool);
5049

5150
virtual Web::Page& page() override { return *m_page; }
5251
virtual Web::Page const& page() const override { return *m_page; }
@@ -242,7 +241,6 @@ class PageClient final : public Web::PageClient {
242241
virtual void page_did_request_activate_tab() override;
243242
virtual void page_did_close_top_level_traversable() override;
244243
virtual void page_did_change_needs_beforeunload_check(bool needs_beforeunload_check) override;
245-
virtual bool should_report_session_history_updates() const override;
246244
virtual void page_did_update_session_history(Vector<Web::HTML::SessionHistoryEntryDescriptor> const&, Vector<i32> const& used_steps, size_t current_used_step_index) override;
247245
virtual void page_did_update_session_history_entry_navigation_api_state(Web::HTML::CrossProcessId navigable_id, Utf16String const& navigation_api_key, Web::HTML::StorageSerializationRecord const& navigation_api_state) override;
248246
virtual void page_did_update_session_history_entry_scroll_restoration_mode(Web::HTML::CrossProcessId navigable_id, Utf16String const& navigation_api_key, Web::HTML::ScrollRestorationMode scroll_restoration_mode) override;

0 commit comments

Comments
 (0)