Ladybird: Implement WebDriver's navigation and window control endpoints

This commit is contained in:
Timothy Flynn 2022-11-14 11:24:06 -05:00 committed by Andrew Kaster
parent 4031630b49
commit 54321f49ad
Notes: sideshowbarker 2024-07-17 02:39:20 +09:00
3 changed files with 47 additions and 7 deletions

View file

@ -112,6 +112,33 @@ Tab::Tab(BrowserWindow* window, int webdriver_fd_passing_socket)
text_edit->show();
});
QObject::connect(m_view, &WebContentView::navigate_back, this, &Tab::back);
QObject::connect(m_view, &WebContentView::navigate_forward, this, &Tab::forward);
QObject::connect(m_view, &WebContentView::refresh, this, &Tab::reload);
QObject::connect(m_view, &WebContentView::restore_window, this, [this]() {
m_window->showNormal();
});
QObject::connect(m_view, &WebContentView::reposition_window, this, [this](auto const& position) {
m_window->move(position.x(), position.y());
return Gfx::IntPoint { m_window->x(), m_window->y() };
});
QObject::connect(m_view, &WebContentView::resize_window, this, [this](auto const& size) {
m_window->resize(size.width(), size.height());
return Gfx::IntSize { m_window->width(), m_window->height() };
});
QObject::connect(m_view, &WebContentView::maximize_window, this, [this]() {
m_window->showMaximized();
return Gfx::IntRect { m_window->x(), m_window->y(), m_window->width(), m_window->height() };
});
QObject::connect(m_view, &WebContentView::minimize_window, this, [this]() {
m_window->showMinimized();
return Gfx::IntRect { m_window->x(), m_window->y(), m_window->width(), m_window->height() };
});
QObject::connect(m_view, &WebContentView::fullscreen_window, this, [this]() {
m_window->showFullScreen();
return Gfx::IntRect { m_window->x(), m_window->y(), m_window->width(), m_window->height() };
});
// FIXME: This is a hack to make the JS console usable in new windows.
// Something else should ensure that there's an initial about:blank document loaded in the view.
// We set m_is_history_navigation = true so that the initial about:blank doesn't get added to the history.

View file

@ -810,14 +810,17 @@ void WebContentView::notify_server_did_finish_loading(Badge<WebContentClient>, A
void WebContentView::notify_server_did_request_navigate_back(Badge<WebContentClient>)
{
emit navigate_back();
}
void WebContentView::notify_server_did_request_navigate_forward(Badge<WebContentClient>)
{
emit navigate_forward();
}
void WebContentView::notify_server_did_request_refresh(Badge<WebContentClient>)
{
emit refresh();
}
void WebContentView::notify_server_did_request_context_menu(Badge<WebContentClient>, Gfx::IntPoint const& content_position)
@ -942,31 +945,32 @@ void WebContentView::notify_server_did_update_resource_count(i32 count_waiting)
void WebContentView::notify_server_did_request_restore_window()
{
emit restore_window();
}
Gfx::IntPoint WebContentView::notify_server_did_request_reposition_window(Gfx::IntPoint const&)
Gfx::IntPoint WebContentView::notify_server_did_request_reposition_window(Gfx::IntPoint const& position)
{
return {};
return emit reposition_window(position);
}
Gfx::IntSize WebContentView::notify_server_did_request_resize_window(Gfx::IntSize const&)
Gfx::IntSize WebContentView::notify_server_did_request_resize_window(Gfx::IntSize const& size)
{
return {};
return emit resize_window(size);
}
Gfx::IntRect WebContentView::notify_server_did_request_maximize_window()
{
return {};
return emit maximize_window();
}
Gfx::IntRect WebContentView::notify_server_did_request_minimize_window()
{
return {};
return emit minimize_window();
}
Gfx::IntRect WebContentView::notify_server_did_request_fullscreen_window()
{
return {};
return emit fullscreen_window();
}
void WebContentView::notify_server_did_request_file(Badge<WebContentClient>, String const& path, i32 request_id)

View file

@ -160,6 +160,15 @@ signals:
void title_changed(QString);
void favicon_changed(QIcon);
void got_source(URL, QString);
void navigate_back();
void navigate_forward();
void refresh();
void restore_window();
Gfx::IntPoint reposition_window(Gfx::IntPoint const&);
Gfx::IntSize resize_window(Gfx::IntSize const&);
Gfx::IntRect maximize_window();
Gfx::IntRect minimize_window();
Gfx::IntRect fullscreen_window();
private:
void request_repaint();