1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 09:57:36 +00:00

WebContent+Everywhere: Add a WebContent IPC to activate a tab

This commit is contained in:
Timothy Flynn 2023-03-20 19:52:00 -04:00 committed by Linus Groh
parent a77daf77bd
commit f8b6369c23
18 changed files with 50 additions and 0 deletions

View file

@ -401,6 +401,11 @@ Tab& BrowserWindow::new_tab(QString const& url, Web::HTML::ActivateTab activate_
return *tab_ptr;
}
void BrowserWindow::activate_tab(int index)
{
m_tabs_container->setCurrentIndex(index);
}
void BrowserWindow::close_tab(int index)
{
auto* tab = m_tabs_container->widget(index);

View file

@ -36,6 +36,7 @@ public slots:
void tab_title_changed(int index, QString const&);
void tab_favicon_changed(int index, QIcon icon);
Tab& new_tab(QString const&, Web::HTML::ActivateTab);
void activate_tab(int index);
void close_tab(int index);
void close_current_tab();
void open_next_tab();

View file

@ -64,6 +64,10 @@ Tab::Tab(BrowserWindow* window, StringView webdriver_content_ipc_path)
m_toolbar->addAction(m_home_action);
m_toolbar->addWidget(m_location_edit);
QObject::connect(m_view, &WebContentView::activate_tab, [this] {
m_window->activate_tab(tab_index());
});
QObject::connect(m_view, &WebContentView::close, [this] {
m_window->close_tab(tab_index());
});

View file

@ -988,6 +988,11 @@ String WebContentView::notify_server_did_request_new_tab(Badge<WebContentClient>
return {};
}
void WebContentView::notify_server_did_request_activate_tab(Badge<WebContentClient>)
{
emit activate_tab();
}
void WebContentView::notify_server_did_update_resource_count(i32 count_waiting)
{
// FIXME

View file

@ -148,6 +148,7 @@ public:
virtual void notify_server_did_set_cookie(Badge<WebContentClient>, const AK::URL& url, Web::Cookie::ParsedCookie const& cookie, Web::Cookie::Source source) override;
virtual void notify_server_did_update_cookie(Badge<WebContentClient>, Web::Cookie::Cookie const& cookie) override;
virtual String notify_server_did_request_new_tab(Badge<WebContentClient>, Web::HTML::ActivateTab activate_tab) override;
virtual void notify_server_did_request_activate_tab(Badge<WebContentClient>) override;
virtual void notify_server_did_close_browsing_context(Badge<WebContentClient>) override;
virtual void notify_server_did_update_resource_count(i32 count_waiting) override;
virtual void notify_server_did_request_restore_window() override;
@ -160,6 +161,7 @@ public:
virtual void notify_server_did_finish_handling_input_event(bool event_was_accepted) override;
signals:
void activate_tab();
void close();
void link_hovered(QString, int timeout = 0);
void link_unhovered();