LibWeb+LibWebView+UI: Migrate to LibWebView's language settings

This commit is contained in:
Timothy Flynn 2025-04-03 13:53:02 -04:00 committed by Jelle Raaijmakers
commit a3ea4881e7
Notes: github-actions[bot] 2025-04-04 08:17:32 +00:00
13 changed files with 14 additions and 148 deletions

View file

@ -252,11 +252,6 @@ void ViewImplementation::set_preferred_motion(Web::CSS::PreferredMotion motion)
client().async_set_preferred_motion(page_id(), motion);
}
void ViewImplementation::set_preferred_languages(ReadonlySpan<String> preferred_languages)
{
client().async_set_preferred_languages(page_id(), preferred_languages);
}
ByteString ViewImplementation::selected_text()
{
return client().get_selected_text(page_id());
@ -599,6 +594,7 @@ void ViewImplementation::initialize_client(CreateNewClient create_new_client)
if (auto const& user_agent_preset = Application::web_content_options().user_agent_preset; user_agent_preset.has_value())
client().async_debug_request(m_client_state.page_index, "spoof-user-agent"sv, *user_agents.get(*user_agent_preset));
languages_changed();
autoplay_settings_changed();
do_not_track_changed();
}
@ -648,6 +644,12 @@ void ViewImplementation::handle_web_content_process_crash(LoadErrorPage load_err
}
}
void ViewImplementation::languages_changed()
{
auto const& languages = Application::settings().languages();
client().async_set_preferred_languages(page_id(), languages);
}
void ViewImplementation::autoplay_settings_changed()
{
auto const& autoplay_settings = Application::settings().autoplay_settings();

View file

@ -80,8 +80,6 @@ public:
void set_preferred_contrast(Web::CSS::PreferredContrast);
void set_preferred_motion(Web::CSS::PreferredMotion);
void set_preferred_languages(ReadonlySpan<String>);
ByteString selected_text();
Optional<String> selected_text_with_whitespace_collapsed();
void select_all();
@ -262,6 +260,7 @@ protected:
};
void handle_web_content_process_crash(LoadErrorPage = LoadErrorPage::Yes);
virtual void languages_changed() override;
virtual void autoplay_settings_changed() override;
virtual void do_not_track_changed() override;